Skip to content

Commit

Permalink
Mark some tests that don't pass under Android as @AndroidIncompatible.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 444869256
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Apr 27, 2022
1 parent a24a894 commit 98c0a78
Show file tree
Hide file tree
Showing 20 changed files with 42 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* @author Martin Buchholz
* @author mike nonemacher
*/
@AndroidIncompatible // depends on details of gc

public class GcFinalizationTest extends TestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public Integer computeNext() {


@GwtIncompatible // weak references
@AndroidIncompatible // depends on details of GC
public void testFreesNextReference() {
Iterator<Object> itr =
new AbstractIterator<Object>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void testGetIfPresent_whenNoMatchingConstant() {


@GwtIncompatible // weak references
@AndroidIncompatible // depends on details of GC and classloading
public void testGetIfPresent_doesNotPreventClassUnloading() throws Exception {
WeakReference<?> shadowLoaderReference = doTestClassUnloading();
GcFinalization.awaitClear(shadowLoaderReference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
*
* @author Bob Lee
*/
// - depends on details of GC and classloading
// - .class files aren't available
// - possibly no real concept of separate ClassLoaders?
@AndroidIncompatible
public class FinalizableReferenceQueueTest extends TestCase {

private FinalizableReferenceQueue frq;
Expand Down Expand Up @@ -101,7 +105,6 @@ public void finalizeReferent() {
};
}

@AndroidIncompatible // no concept of separate ClassLoaders
public void testDecoupledLoader() {
FinalizableReferenceQueue.DecoupledLoader decoupledLoader =
new FinalizableReferenceQueue.DecoupledLoader() {
Expand Down Expand Up @@ -141,7 +144,6 @@ protected synchronized Class<?> loadClass(String name, boolean resolve)
}
}

@AndroidIncompatible // TODO(cpovirk): How significant is this failure?
public void testGetFinalizerUrl() {
assertNotNull(getClass().getResource("internal/Finalizer.class"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void testCopyChannel() throws IOException {
assertThat(out.toByteArray()).isEqualTo(expected);
}

@AndroidIncompatible // Android forbids much filesystem access. Maybe we could make it work?

public void testCopyFileChannel() throws IOException {
final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*
* @author Chris Nokleberg
*/
@AndroidIncompatible // Android forbids much filesystem access. Maybe we could make it work?
public class FileBackedOutputStreamTest extends IoTestCase {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* @author Jens Nyman
*/

@AndroidIncompatible // Android forbids much filesystem access. Maybe we could make it work?
public class FilesFileTraverserTest extends TestCase {

private File rootDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* @author Chris Nokleberg
*/

@AndroidIncompatible // Android forbids much filesystem access. Maybe we could make it work?
public class FilesTest extends IoTestCase {

public static TestSuite suite() {
Expand Down
11 changes: 6 additions & 5 deletions android/guava-tests/test/com/google/common/io/ResourcesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
import com.google.common.testing.NullPointerTester;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
Expand All @@ -42,6 +40,7 @@

public class ResourcesTest extends IoTestCase {

@AndroidIncompatible // wouldn't run anyway, but strip the source entirely because of b/230620681
public static TestSuite suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Expand All @@ -62,9 +61,9 @@ public void testToString() throws IOException {
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}

public void testToToByteArray() throws IOException {
byte[] data = Resources.toByteArray(classfile(Resources.class));
assertEquals(0xCAFEBABE, new DataInputStream(new ByteArrayInputStream(data)).readInt());
public void testToByteArray() throws IOException {
URL resource = getClass().getResource("testdata/i18n.txt");
assertThat(Resources.toByteArray(resource)).isEqualTo(I18N.getBytes(Charsets.UTF_8));
}

public void testReadLines() throws IOException {
Expand Down Expand Up @@ -134,6 +133,7 @@ public void testGetResource_relativePath() {
assertNotNull(Resources.getResource(getClass(), "testdata/i18n.txt"));
}

@AndroidIncompatible // Android prevents most access to files
public void testGetResource_contextClassLoader() throws IOException {
// Check that we can find a resource if it is visible to the context class
// loader, even if it is not visible to the loader of the Resources class.
Expand Down Expand Up @@ -181,6 +181,7 @@ public void testGetResource_contextClassLoaderNull() {
}
}

@AndroidIncompatible // .class files aren't available
public void testNulls() {
new NullPointerTester()
.setDefault(URL.class, classfile(ResourcesTest.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public void testJarFileWithSpaces() throws Exception {
assertThat(ClassPath.from(classloader).getTopLevelClasses()).isNotEmpty();
}

@AndroidIncompatible // ClassPath is documented as not supporting Android

public void testScan_classPathCycle() throws IOException {
File jarFile = File.createTempFile("with_circular_class_path", ".jar");
Expand All @@ -201,6 +202,7 @@ public void testScanFromFile_fileNotExists() throws IOException {
.isEmpty();
}

@AndroidIncompatible // ClassPath is documented as not supporting Android

public void testScanFromFile_notJarFile() throws IOException {
ClassLoader classLoader = ClassPathTest.class.getClassLoader();
Expand Down Expand Up @@ -399,6 +401,7 @@ public void testNulls() throws IOException {
.testAllPublicInstanceMethods(ClassPath.from(getClass().getClassLoader()));
}

@AndroidIncompatible // ClassPath is documented as not supporting Android

public void testLocationsFrom_idempotentScan() throws IOException {
ImmutableSet<ClassPath.LocationInfo> locations =
Expand Down Expand Up @@ -429,6 +432,7 @@ public void testLocationEquals() {
.testEquals();
}

@AndroidIncompatible // ClassPath is documented as not supporting Android

public void testScanAllResources() throws IOException {
assertThat(scanResourceNames(ClassLoader.getSystemClassLoader()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* @author Martin Buchholz
* @author mike nonemacher
*/
@AndroidIncompatible // depends on details of gc

public class GcFinalizationTest extends TestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public Integer computeNext() {


@GwtIncompatible // weak references
@AndroidIncompatible // depends on details of GC
public void testFreesNextReference() {
Iterator<Object> itr =
new AbstractIterator<Object>() {
Expand Down
1 change: 1 addition & 0 deletions guava-tests/test/com/google/common/base/EnumsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void testGetIfPresent_whenNoMatchingConstant() {


@GwtIncompatible // weak references
@AndroidIncompatible // depends on details of GC and classloading
public void testGetIfPresent_doesNotPreventClassUnloading() throws Exception {
WeakReference<?> shadowLoaderReference = doTestClassUnloading();
GcFinalization.awaitClear(shadowLoaderReference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
*
* @author Bob Lee
*/
// - depends on details of GC and classloading
// - .class files aren't available
// - possibly no real concept of separate ClassLoaders?
@AndroidIncompatible
public class FinalizableReferenceQueueTest extends TestCase {

private FinalizableReferenceQueue frq;
Expand Down Expand Up @@ -102,7 +106,6 @@ public void finalizeReferent() {
};
}

@AndroidIncompatible // no concept of separate ClassLoaders
public void testDecoupledLoader() {
FinalizableReferenceQueue.DecoupledLoader decoupledLoader =
new FinalizableReferenceQueue.DecoupledLoader() {
Expand Down Expand Up @@ -142,7 +145,6 @@ protected synchronized Class<?> loadClass(String name, boolean resolve)
}
}

@AndroidIncompatible // TODO(cpovirk): How significant is this failure?
public void testGetFinalizerUrl() {
assertNotNull(getClass().getResource("internal/Finalizer.class"));
}
Expand Down
1 change: 1 addition & 0 deletions guava-tests/test/com/google/common/io/ByteStreamsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void testCopyChannel() throws IOException {
assertThat(out.toByteArray()).isEqualTo(expected);
}

@AndroidIncompatible // Android forbids much filesystem access. Maybe we could make it work?

public void testCopyFileChannel() throws IOException {
final int chunkSize = 14407; // Random prime, unlikely to match any internal chunk size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*
* @author Chris Nokleberg
*/
@AndroidIncompatible // Android forbids much filesystem access. Maybe we could make it work?
public class FileBackedOutputStreamTest extends IoTestCase {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* @author Jens Nyman
*/

@AndroidIncompatible // Android forbids much filesystem access. Maybe we could make it work?
public class FilesFileTraverserTest extends TestCase {

private File rootDir;
Expand Down
1 change: 1 addition & 0 deletions guava-tests/test/com/google/common/io/FilesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* @author Chris Nokleberg
*/

@AndroidIncompatible // Android forbids much filesystem access. Maybe we could make it work?
public class FilesTest extends IoTestCase {

public static TestSuite suite() {
Expand Down
11 changes: 6 additions & 5 deletions guava-tests/test/com/google/common/io/ResourcesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
import com.google.common.testing.NullPointerTester;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
Expand All @@ -42,6 +40,7 @@

public class ResourcesTest extends IoTestCase {

@AndroidIncompatible // wouldn't run anyway, but strip the source entirely because of b/230620681
public static TestSuite suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Expand All @@ -62,9 +61,9 @@ public void testToString() throws IOException {
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}

public void testToToByteArray() throws IOException {
byte[] data = Resources.toByteArray(classfile(Resources.class));
assertEquals(0xCAFEBABE, new DataInputStream(new ByteArrayInputStream(data)).readInt());
public void testToByteArray() throws IOException {
URL resource = getClass().getResource("testdata/i18n.txt");
assertThat(Resources.toByteArray(resource)).isEqualTo(I18N.getBytes(Charsets.UTF_8));
}

public void testReadLines() throws IOException {
Expand Down Expand Up @@ -134,6 +133,7 @@ public void testGetResource_relativePath() {
assertNotNull(Resources.getResource(getClass(), "testdata/i18n.txt"));
}

@AndroidIncompatible // Android prevents most access to files
public void testGetResource_contextClassLoader() throws IOException {
// Check that we can find a resource if it is visible to the context class
// loader, even if it is not visible to the loader of the Resources class.
Expand Down Expand Up @@ -181,6 +181,7 @@ public void testGetResource_contextClassLoaderNull() {
}
}

@AndroidIncompatible // .class files aren't available
public void testNulls() {
new NullPointerTester()
.setDefault(URL.class, classfile(ResourcesTest.class))
Expand Down
4 changes: 4 additions & 0 deletions guava-tests/test/com/google/common/reflect/ClassPathTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public void testJarFileWithSpaces() throws Exception {
assertThat(ClassPath.from(classloader).getTopLevelClasses()).isNotEmpty();
}

@AndroidIncompatible // ClassPath is documented as not supporting Android

public void testScan_classPathCycle() throws IOException {
File jarFile = File.createTempFile("with_circular_class_path", ".jar");
Expand Down Expand Up @@ -260,6 +261,7 @@ public void testScanFromFile_fileNotExists() throws IOException {
.isEmpty();
}

@AndroidIncompatible // ClassPath is documented as not supporting Android

public void testScanFromFile_notJarFile() throws IOException {
ClassLoader classLoader = ClassPathTest.class.getClassLoader();
Expand Down Expand Up @@ -458,6 +460,7 @@ public void testNulls() throws IOException {
.testAllPublicInstanceMethods(ClassPath.from(getClass().getClassLoader()));
}

@AndroidIncompatible // ClassPath is documented as not supporting Android

public void testLocationsFrom_idempotentScan() throws IOException {
ImmutableSet<ClassPath.LocationInfo> locations =
Expand Down Expand Up @@ -488,6 +491,7 @@ public void testLocationEquals() {
.testEquals();
}

@AndroidIncompatible // ClassPath is documented as not supporting Android

public void testScanAllResources() throws IOException {
assertThat(scanResourceNames(ClassLoader.getSystemClassLoader()))
Expand Down

0 comments on commit 98c0a78

Please sign in to comment.