Merge "Improves HostUtils to allow JUnit3 tests"
diff --git a/test_framework/com/android/tradefed/targetprep/InstrumentationPreparer.java b/test_framework/com/android/tradefed/targetprep/InstrumentationPreparer.java
index dfe4f42..c1f8eeb 100644
--- a/test_framework/com/android/tradefed/targetprep/InstrumentationPreparer.java
+++ b/test_framework/com/android/tradefed/targetprep/InstrumentationPreparer.java
@@ -17,12 +17,12 @@
package com.android.tradefed.targetprep;
import com.android.ddmlib.testrunner.TestResult.TestStatus;
-import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.config.Option;
import com.android.tradefed.config.Option.Importance;
import com.android.tradefed.config.OptionClass;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.CollectingTestListener;
import com.android.tradefed.result.TestDescription;
@@ -94,16 +94,16 @@
private long mRetryDelayMs = 0L;
@Override
- public void setUp(ITestDevice device, IBuildInfo buildInfo) throws TargetSetupError, BuildError,
- DeviceNotAvailableException {
+ public void setUp(TestInformation testInfo)
+ throws TargetSetupError, BuildError, DeviceNotAvailableException {
if (isDisabled()) {
return;
}
-
+ ITestDevice device = testInfo.getDevice();
BuildError e = new BuildError("unknown error", device.getDeviceDescriptor());
for (int i = 0; i < mAttempts; i++) {
try {
- runInstrumentation(device);
+ runInstrumentation(testInfo);
return;
} catch (BuildError e1) {
e = e1;
@@ -116,8 +116,9 @@
throw e;
}
- private void runInstrumentation(ITestDevice device) throws DeviceNotAvailableException,
- BuildError {
+ private void runInstrumentation(TestInformation testInfo)
+ throws DeviceNotAvailableException, BuildError {
+ ITestDevice device = testInfo.getDevice();
final InstrumentationTest test = createInstrumentationTest();
test.setDevice(device);
test.setPackageName(mPackageName);
@@ -131,7 +132,7 @@
}
final CollectingTestListener listener = new CollectingTestListener();
- test.run(listener);
+ test.run(testInfo, listener);
if (listener.hasFailedTests()) {
String msg = String.format("Failed to run instrumentation %s on %s. failed tests = %s",
mPackageName, device.getSerialNumber(), getFailedTestNames(listener));
diff --git a/test_framework/com/android/tradefed/testtype/CodeCoverageTest.java b/test_framework/com/android/tradefed/testtype/CodeCoverageTest.java
index b53decb..f7dfd64 100644
--- a/test_framework/com/android/tradefed/testtype/CodeCoverageTest.java
+++ b/test_framework/com/android/tradefed/testtype/CodeCoverageTest.java
@@ -19,6 +19,7 @@
import com.android.tradefed.config.Option;
import com.android.tradefed.config.OptionClass;
import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.CollectingTestListener;
import com.android.tradefed.result.FileInputStreamSource;
@@ -49,7 +50,8 @@
public static final String COVERAGE_REMOTE_FILE_LABEL = "coverageFilePath";
@Override
- public void run(final ITestInvocationListener listener) throws DeviceNotAvailableException {
+ public void run(TestInformation testInfo, final ITestInvocationListener listener)
+ throws DeviceNotAvailableException {
// Disable rerun mode, we want to stop the tests as soon as we fail.
super.setRerunMode(false);
// Force generation of emma coverage file to true and set up coverage
@@ -62,7 +64,7 @@
CollectingTestListener testCoverageFile = new CollectingTestListener();
// Run instrumentation tests.
- super.run(new ResultForwarder(listener, testCoverageFile));
+ super.run(testInfo, new ResultForwarder(listener, testCoverageFile));
// If coverage file path was not set explicitly before test run, fetch
// it from the
diff --git a/test_framework/com/android/tradefed/testtype/IsolatedHostTest.java b/test_framework/com/android/tradefed/testtype/IsolatedHostTest.java
index 16b7deb..40b7ad0 100644
--- a/test_framework/com/android/tradefed/testtype/IsolatedHostTest.java
+++ b/test_framework/com/android/tradefed/testtype/IsolatedHostTest.java
@@ -21,6 +21,7 @@
import com.android.tradefed.config.Option.Importance;
import com.android.tradefed.config.OptionClass;
import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.isolation.FilterSpec;
import com.android.tradefed.isolation.JUnitEvent;
import com.android.tradefed.isolation.RunnerMessage;
@@ -131,7 +132,8 @@
/** {@inheritDoc} */
@Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
+ public void run(TestInformation testInfo, ITestInvocationListener listener)
+ throws DeviceNotAvailableException {
try {
mServer = new ServerSocket(0);
mServer.setSoTimeout(mSocketTimeout);
diff --git a/tests/src/com/android/tradefed/targetprep/BaseTargetPreparerTest.java b/tests/src/com/android/tradefed/targetprep/BaseTargetPreparerTest.java
index c76fb67..bae99a0 100644
--- a/tests/src/com/android/tradefed/targetprep/BaseTargetPreparerTest.java
+++ b/tests/src/com/android/tradefed/targetprep/BaseTargetPreparerTest.java
@@ -17,11 +17,10 @@
import static org.junit.Assert.assertTrue;
-import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.config.Configuration;
import com.android.tradefed.config.IConfiguration;
import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.util.FileUtil;
import org.junit.Test;
@@ -43,7 +42,7 @@
}
@Override
- public void setUp(ITestDevice device, IBuildInfo buildInfo)
+ public void setUp(TestInformation testInfo)
throws TargetSetupError, BuildError, DeviceNotAvailableException {
// Ignore
}
diff --git a/tests/src/com/android/tradefed/targetprep/InstallApexModuleTargetPreparerTest.java b/tests/src/com/android/tradefed/targetprep/InstallApexModuleTargetPreparerTest.java
index a396d64..60702a7 100644
--- a/tests/src/com/android/tradefed/targetprep/InstallApexModuleTargetPreparerTest.java
+++ b/tests/src/com/android/tradefed/targetprep/InstallApexModuleTargetPreparerTest.java
@@ -589,7 +589,6 @@
Set<ApexInfo> activatedApex = new HashSet<ApexInfo>();
activatedApex.add(new ApexInfo("com.android.FAKE_APEX_PACKAGE_NAME", 1));
EasyMock.expect(mMockDevice.getActiveApexes()).andReturn(activatedApex).times(2);
- ;
mMockDevice.reboot();
EasyMock.expectLastCall();
Set<String> installableModules = new HashSet<>();
diff --git a/tests/src/com/android/tradefed/targetprep/InstrumentationPreparerTest.java b/tests/src/com/android/tradefed/targetprep/InstrumentationPreparerTest.java
index b9ddcf6..ac6b032 100644
--- a/tests/src/com/android/tradefed/targetprep/InstrumentationPreparerTest.java
+++ b/tests/src/com/android/tradefed/targetprep/InstrumentationPreparerTest.java
@@ -16,52 +16,59 @@
package com.android.tradefed.targetprep;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import com.android.tradefed.build.DeviceBuildInfo;
import com.android.tradefed.build.IDeviceBuildInfo;
import com.android.tradefed.command.remote.DeviceDescriptor;
import com.android.tradefed.device.DeviceAllocationState;
import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.invoker.IInvocationContext;
+import com.android.tradefed.invoker.InvocationContext;
+import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.TestDescription;
import com.android.tradefed.testtype.InstrumentationTest;
-import junit.framework.TestCase;
-
import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import java.util.HashMap;
-/**
- * Unit tests for {@link InstrumentationPreparer}.
- */
-public class InstrumentationPreparerTest extends TestCase {
+/** Unit tests for {@link InstrumentationPreparer}. */
+@RunWith(JUnit4.class)
+public class InstrumentationPreparerTest {
private InstrumentationPreparer mInstrumentationPreparer;
private ITestDevice mMockDevice;
private IDeviceBuildInfo mMockBuildInfo;
private InstrumentationTest mMockITest;
+ private TestInformation mTestInfo;
- @Override
+ @Before
public void setUp() throws Exception {
- super.setUp();
mMockDevice = EasyMock.createMock(ITestDevice.class);
EasyMock.expect(mMockDevice.getSerialNumber()).andReturn("foo").anyTimes();
mMockBuildInfo = new DeviceBuildInfo("0","");
+ IInvocationContext context = new InvocationContext();
+ context.addAllocatedDevice("device", mMockDevice);
+ context.addDeviceBuildInfo("device", mMockBuildInfo);
+ mTestInfo = TestInformation.newBuilder().setInvocationContext(context).build();
}
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
+ @Test
public void testRun() throws Exception {
final String packageName = "packageName";
final TestDescription test = new TestDescription("FooTest", "testFoo");
mMockITest =
new InstrumentationTest() {
@Override
- public void run(ITestInvocationListener listener) {
+ public void run(TestInformation testInfo, ITestInvocationListener listener) {
listener.testRunStarted(packageName, 1);
listener.testStarted(test);
listener.testEnded(test, new HashMap<String, Metric>());
@@ -78,17 +85,18 @@
false, DeviceAllocationState.Available, "unknown", "unknown", "unknown", "unknown",
"unknown"));
EasyMock.replay(mMockDevice);
- mInstrumentationPreparer.setUp(mMockDevice, mMockBuildInfo);
+ mInstrumentationPreparer.setUp(mTestInfo);
EasyMock.verify(mMockDevice);
}
+ @Test
public void testRun_testFailed() throws Exception {
final String packageName = "packageName";
final TestDescription test = new TestDescription("FooTest", "testFoo");
mMockITest =
new InstrumentationTest() {
@Override
- public void run(ITestInvocationListener listener) {
+ public void run(TestInformation testInfo, ITestInvocationListener listener) {
listener.testRunStarted(packageName, 1);
listener.testStarted(test);
listener.testFailed(test, null);
@@ -107,7 +115,7 @@
"unknown", "unknown"));
EasyMock.replay(mMockDevice);
try {
- mInstrumentationPreparer.setUp(mMockDevice, mMockBuildInfo);
+ mInstrumentationPreparer.setUp(mTestInfo);
fail("BuildError not thrown");
} catch(final BuildError e) {
assertTrue("The exception message does not contain failed test names",
diff --git a/tests/src/com/android/tradefed/targetprep/SwitchUserTargetPreparerTest.java b/tests/src/com/android/tradefed/targetprep/SwitchUserTargetPreparerTest.java
index c5bbb06..6a195a0 100644
--- a/tests/src/com/android/tradefed/targetprep/SwitchUserTargetPreparerTest.java
+++ b/tests/src/com/android/tradefed/targetprep/SwitchUserTargetPreparerTest.java
@@ -42,7 +42,6 @@
/** Unit tests for {@link SwitchUserTargetPreparer}. */
@RunWith(JUnit4.class)
public class SwitchUserTargetPreparerTest {
- private static final int USER_SYSTEM = 0; // From the UserHandle class.
@Mock private ITestDevice mMockDevice;
@@ -218,14 +217,6 @@
}
}
- private void mockUsers(int primaryUserId, int currentUserId)
- throws DeviceNotAvailableException {
- when(mMockDevice.getCurrentUser()).thenReturn(currentUserId);
-
- when(mMockDevice.getPrimaryUserId()).thenReturn(primaryUserId);
- when(mMockDevice.switchUser(anyInt())).thenReturn(true);
- }
-
private void mockListUsersInfo(ITestDevice device, Integer[] userIds, Integer[] flags)
throws DeviceNotAvailableException {
Map<Integer, UserInfo> result = new HashMap<>();
diff --git a/tests/src/com/android/tradefed/targetprep/UserCleanerFuncTest.java b/tests/src/com/android/tradefed/targetprep/UserCleanerFuncTest.java
index e7d333e..58650fe 100644
--- a/tests/src/com/android/tradefed/targetprep/UserCleanerFuncTest.java
+++ b/tests/src/com/android/tradefed/targetprep/UserCleanerFuncTest.java
@@ -59,7 +59,7 @@
device.createUser(UUID.randomUUID().toString());
assertEquals("additional users created", 3, device.listUsers().size());
- mCleaner.tearDown(getDevice(), null, null);
+ mCleaner.tearDown(getTestInformation(), null);
assertEquals("additional users removed", 1, device.listUsers().size());
}
}
diff --git a/tests/src/com/android/tradefed/testtype/InstrumentationTestFuncTest.java b/tests/src/com/android/tradefed/testtype/InstrumentationTestFuncTest.java
index 000d0dd..e4ea348 100644
--- a/tests/src/com/android/tradefed/testtype/InstrumentationTestFuncTest.java
+++ b/tests/src/com/android/tradefed/testtype/InstrumentationTestFuncTest.java
@@ -28,6 +28,7 @@
import com.android.tradefed.device.DeviceUnresponsiveException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.device.ITestDevice.RecoveryMode;
+import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
import com.android.tradefed.result.CollectingTestListener;
import com.android.tradefed.result.ITestInvocationListener;
@@ -45,7 +46,7 @@
/** Functional tests for {@link InstrumentationTest}. */
@RunWith(DeviceJUnit4ClassRunner.class)
-public class InstrumentationTestFuncTest implements IDeviceTest {
+public class InstrumentationTestFuncTest implements IDeviceTest, ITestInformationReceiver {
private static final String LOG_TAG = "InstrumentationTestFuncTest";
private static final long SHELL_TIMEOUT = 2500;
@@ -53,6 +54,7 @@
private static final long WAIT_FOR_DEVICE_AVAILABLE = 5 * 60 * 1000;
private ITestDevice mDevice;
+ private TestInformation mTestInfo;
/** The {@link InstrumentationTest} under test */
private InstrumentationTest mInstrumentationTest;
@@ -60,6 +62,16 @@
private ITestInvocationListener mMockListener;
@Override
+ public void setTestInformation(TestInformation testInformation) {
+ mTestInfo = testInformation;
+ }
+
+ @Override
+ public TestInformation getTestInformation() {
+ return mTestInfo;
+ }
+
+ @Override
public void setDevice(ITestDevice device) {
mDevice = device;
}
@@ -96,11 +108,11 @@
mMockListener.testRunStarted(TestAppConstants.TESTAPP_PACKAGE, 1);
mMockListener.testStarted(EasyMock.eq(expectedTest));
mMockListener.testEnded(
- EasyMock.eq(expectedTest), (HashMap<String, Metric>) EasyMock.anyObject());
+ EasyMock.eq(expectedTest), EasyMock.<HashMap<String, Metric>>anyObject());
mMockListener.testRunEnded(
- EasyMock.anyLong(), (HashMap<String, Metric>) EasyMock.anyObject());
+ EasyMock.anyLong(), EasyMock.<HashMap<String, Metric>>anyObject());
EasyMock.replay(mMockListener);
- mInstrumentationTest.run(mMockListener);
+ mInstrumentationTest.run(getTestInformation(), mMockListener);
EasyMock.verify(mMockListener);
}
@@ -115,6 +127,7 @@
String[] error = new String[1];
error[0] = null;
mInstrumentationTest.run(
+ getTestInformation(),
new ITestInvocationListener() {
@Override
public void testFailed(TestDescription test, String trace) {
@@ -143,22 +156,22 @@
mMockListener.testFailed(
EasyMock.eq(expectedTest), EasyMock.contains("RuntimeException"));
mMockListener.testEnded(
- EasyMock.eq(expectedTest), (HashMap<String, Metric>) EasyMock.anyObject());
+ EasyMock.eq(expectedTest), EasyMock.<HashMap<String, Metric>>anyObject());
mMockListener.testRunFailed(
EasyMock.eq("Instrumentation run failed due to 'java.lang.RuntimeException'"));
} else {
mMockListener.testFailed(
EasyMock.eq(expectedTest), EasyMock.contains("Process crashed."));
mMockListener.testEnded(
- EasyMock.eq(expectedTest), (HashMap<String, Metric>) EasyMock.anyObject());
+ EasyMock.eq(expectedTest), EasyMock.<HashMap<String, Metric>>anyObject());
mMockListener.testRunFailed(
EasyMock.eq("Instrumentation run failed due to 'Process crashed.'"));
}
mMockListener.testRunEnded(
- EasyMock.anyLong(), (HashMap<String, Metric>) EasyMock.anyObject());
+ EasyMock.anyLong(), EasyMock.<HashMap<String, Metric>>anyObject());
try {
EasyMock.replay(mMockListener);
- mInstrumentationTest.run(mMockListener);
+ mInstrumentationTest.run(getTestInformation(), mMockListener);
EasyMock.verify(mMockListener);
} finally {
getDevice().waitForDeviceAvailable();
@@ -180,6 +193,7 @@
String[] error = new String[1];
error[0] = null;
mInstrumentationTest.run(
+ getTestInformation(),
new ITestInvocationListener() {
@Override
public void testFailed(TestDescription test, String trace) {
@@ -232,6 +246,7 @@
String[] error = new String[1];
error[0] = null;
mInstrumentationTest.run(
+ getTestInformation(),
new ITestInvocationListener() {
@Override
public void testRunFailed(String errorMessage) {
@@ -260,6 +275,7 @@
final String[] called = new String[1];
called[0] = null;
mInstrumentationTest.run(
+ getTestInformation(),
new ITestInvocationListener() {
@Override
public void testRunFailed(String errorMessage) {
@@ -313,6 +329,7 @@
String[] error = new String[1];
error[0] = null;
mInstrumentationTest.run(
+ getTestInformation(),
new ITestInvocationListener() {
@Override
public void testRunFailed(String errorMessage) {
@@ -349,7 +366,7 @@
mInstrumentationTest.setShellTimeout(SHELL_TIMEOUT);
mInstrumentationTest.setTestTimeout(TEST_TIMEOUT);
CollectingTestListener listener = new CollectingTestListener();
- mInstrumentationTest.run(listener);
+ mInstrumentationTest.run(getTestInformation(), listener);
assertEquals(TestAppConstants.TOTAL_TEST_CLASS_TESTS, listener.getNumTotalTests());
assertEquals(
TestAppConstants.TOTAL_TEST_CLASS_PASSED_TESTS,
@@ -373,7 +390,7 @@
mInstrumentationTest.setShellTimeout(SHELL_TIMEOUT);
mInstrumentationTest.setTestTimeout(TEST_TIMEOUT);
CollectingTestListener listener = new CollectingTestListener();
- mInstrumentationTest.run(listener);
+ mInstrumentationTest.run(getTestInformation(), listener);
assertEquals(0, listener.getNumTotalTests());
assertNotNull(listener.getCurrentRunResults());
assertEquals(TestAppConstants.TESTAPP_PACKAGE, listener.getCurrentRunResults().getName());
@@ -399,7 +416,7 @@
mInstrumentationTest.setShellTimeout(SHELL_TIMEOUT);
mInstrumentationTest.setTestTimeout(TEST_TIMEOUT);
CollectingTestListener listener = new CollectingTestListener();
- mInstrumentationTest.run(listener);
+ mInstrumentationTest.run(getTestInformation(), listener);
assertEquals(0, listener.getNumTotalTests());
assertEquals(
TestAppConstants.TESTAPP_PACKAGE, listener.getCurrentRunResults().getName());
diff --git a/tests/src/com/android/tradefed/testtype/suite/TestSuiteStub.java b/tests/src/com/android/tradefed/testtype/suite/TestSuiteStub.java
index 4e7aac2..db08d47 100644
--- a/tests/src/com/android/tradefed/testtype/suite/TestSuiteStub.java
+++ b/tests/src/com/android/tradefed/testtype/suite/TestSuiteStub.java
@@ -18,6 +18,7 @@
import com.android.tradefed.config.Option;
import com.android.tradefed.config.OptionCopier;
import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
import com.android.tradefed.result.ByteArrayInputStreamSource;
import com.android.tradefed.result.ITestInvocationListener;
@@ -142,7 +143,8 @@
/** {@inheritDoc} */
@Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
+ public void run(TestInformation testInfo, ITestInvocationListener listener)
+ throws DeviceNotAvailableException {
if (mReportTest) {
if (mShardedTestToRun == null) {
if (!mRetry) {
diff --git a/tests/src/com/android/tradefed/testtype/suite/module/MinApiLevelModuleControllerTest.java b/tests/src/com/android/tradefed/testtype/suite/module/MinApiLevelModuleControllerTest.java
index ddf1b94..a1c9aab 100644
--- a/tests/src/com/android/tradefed/testtype/suite/module/MinApiLevelModuleControllerTest.java
+++ b/tests/src/com/android/tradefed/testtype/suite/module/MinApiLevelModuleControllerTest.java
@@ -37,7 +37,6 @@
/** Unit tests for {@link MinApiLevelModuleController}. */
@RunWith(JUnit4.class)
public class MinApiLevelModuleControllerTest {
- private OptionSetter mOptionSetter;
private MinApiLevelModuleController mController;
private IInvocationContext mContext;
private ITestDevice mMockDevice;
diff --git a/tests/src/com/android/tradefed/testtype/suite/params/InstantAppHandlerTest.java b/tests/src/com/android/tradefed/testtype/suite/params/InstantAppHandlerTest.java
index 42970ec..ca704b1 100644
--- a/tests/src/com/android/tradefed/testtype/suite/params/InstantAppHandlerTest.java
+++ b/tests/src/com/android/tradefed/testtype/suite/params/InstantAppHandlerTest.java
@@ -22,6 +22,7 @@
import com.android.tradefed.config.Configuration;
import com.android.tradefed.config.IConfiguration;
import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.targetprep.suite.SuiteApkInstaller;
import com.android.tradefed.testtype.IRemoteTest;
@@ -93,7 +94,8 @@
}
@Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
+ public void run(TestInformation testInfo, ITestInvocationListener listener)
+ throws DeviceNotAvailableException {
// ignore
}
}
diff --git a/tests/src/com/android/tradefed/util/BundletoolUtilTest.java b/tests/src/com/android/tradefed/util/BundletoolUtilTest.java
index c61cc46..238b1df 100644
--- a/tests/src/com/android/tradefed/util/BundletoolUtilTest.java
+++ b/tests/src/com/android/tradefed/util/BundletoolUtilTest.java
@@ -17,14 +17,12 @@
package com.android.tradefed.util;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.device.ITestDevice;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Before;
@@ -33,7 +31,8 @@
import org.junit.runners.JUnit4;
import java.io.File;
-import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
/** Unit tests for {@link BundletoolUtil} */
@RunWith(JUnit4.class)
@@ -72,7 +71,7 @@
}
@After
- public void tearDown() throws IOException {
+ public void tearDown() {
FileUtil.deleteFile(mBundletoolJar);
}
diff --git a/tests/src/com/android/tradefed/util/LogcatEventParserTest.java b/tests/src/com/android/tradefed/util/LogcatEventParserTest.java
index e24a6cb..cd094fb 100644
--- a/tests/src/com/android/tradefed/util/LogcatEventParserTest.java
+++ b/tests/src/com/android/tradefed/util/LogcatEventParserTest.java
@@ -35,7 +35,7 @@
import java.util.concurrent.TimeUnit;
-/** Unit tests for {@link LogcatUpdaterEventParser}. */
+/** Unit tests for {@link LogcatEventParser}. */
@RunWith(JUnit4.class)
public class LogcatEventParserTest {
diff --git a/tests/src/com/android/tradefed/util/RemoteZipTest.java b/tests/src/com/android/tradefed/util/RemoteZipTest.java
index ac461c8..d1319ab 100644
--- a/tests/src/com/android/tradefed/util/RemoteZipTest.java
+++ b/tests/src/com/android/tradefed/util/RemoteZipTest.java
@@ -63,9 +63,8 @@
mDownloader = Mockito.mock(IFileDownloader.class);
Mockito.doAnswer(
- (Answer)
+ (Answer<?>)
invocation -> {
- String remoteFilePath = (String) invocation.getArgument(0);
File destFile = (File) invocation.getArgument(1);
long startOffset = (long) invocation.getArgument(2);
long size = (long) invocation.getArgument(3);
@@ -75,7 +74,7 @@
.when(mDownloader)
.downloadFile(
Mockito.eq(REMOTE_FILE),
- Mockito.anyObject(),
+ Mockito.any(),
Mockito.anyLong(),
Mockito.anyLong());
diff --git a/tests/src/com/android/tradefed/util/StreamUtilTest.java b/tests/src/com/android/tradefed/util/StreamUtilTest.java
index 312c45d..2c2385b 100644
--- a/tests/src/com/android/tradefed/util/StreamUtilTest.java
+++ b/tests/src/com/android/tradefed/util/StreamUtilTest.java
@@ -185,7 +185,7 @@
/**
* Verify that {@link com.android.tradefed.util.StreamUtil#copyStreams(InputStream,
- * OutputStream, int, int)} can copy partial content.
+ * OutputStream, long, long)} can copy partial content.
*/
public void testCopyStreams_partialSuccess() throws Exception {
String text = getLargeText();
@@ -205,8 +205,8 @@
/**
* Verify that {@link com.android.tradefed.util.StreamUtil#copyStreams(InputStream,
- * OutputStream, int, int)} cannot copy partial content if requested size is larger than what's
- * available.
+ * OutputStream, long, long)} cannot copy partial content if requested size is larger than
+ * what's available.
*/
public void testCopyStreams_partialFail() throws Exception {
ByteArrayInputStream bais = null;