Fix Cronet extension build and test.

Recently added Java 8 features in the cronet extension and the linked native libs
require to enable Java 8 desugaring in gradle. Moreover, junit.assertThrows is not
available in our version and its usage has been replaced by the manual check.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172077967
This commit is contained in:
tonihei 2017-10-13 03:30:29 -07:00 committed by Oliver Woodman
parent 7038c8fb70
commit c9ed9366ce
2 changed files with 11 additions and 2 deletions

View File

@ -27,6 +27,11 @@ android {
sourceSets.main { sourceSets.main {
jniLibs.srcDirs = ['jniLibs'] jniLibs.srcDirs = ['jniLibs']
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
} }
dependencies { dependencies {

View File

@ -18,7 +18,6 @@ package com.google.android.exoplayer2.ext.cronet;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
@ -163,7 +162,12 @@ public final class CronetDataSourceTest {
public void testOpeningTwiceThrows() throws HttpDataSourceException { public void testOpeningTwiceThrows() throws HttpDataSourceException {
mockResponseStartSuccess(); mockResponseStartSuccess();
dataSourceUnderTest.open(testDataSpec); dataSourceUnderTest.open(testDataSpec);
assertThrows(IllegalStateException.class, () -> dataSourceUnderTest.open(testDataSpec)); try {
dataSourceUnderTest.open(testDataSpec);
fail("Expected IllegalStateException.");
} catch (IllegalStateException e) {
// Expected.
}
} }
@Test @Test