diff options
author | Adrian Roos <roosa@google.com> | 2020-03-30 11:55:20 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-03-30 11:55:20 +0000 |
commit | 93fbec92595e2bc9b6a3e593a04aa73b53ddea73 (patch) | |
tree | 8107af79f333219cf2f043078e4e733974edc19c /javatests/com/google/turbine/binder/ClassPathBinderTest.java | |
parent | 61aa957f55fb065224ea3695460b4fc047945037 (diff) | |
parent | 0d6829d18aedcaf5dd02b6c5f51d721e2e01791f (diff) | |
download | turbine-93fbec92595e2bc9b6a3e593a04aa73b53ddea73.tar.gz |
Merge upstream into AOSP am: b3b9a496c8 am: 0d6829d18a
Change-Id: I1e12da2f674663fd498d62d653ceb4735130a082
Diffstat (limited to 'javatests/com/google/turbine/binder/ClassPathBinderTest.java')
-rw-r--r-- | javatests/com/google/turbine/binder/ClassPathBinderTest.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/javatests/com/google/turbine/binder/ClassPathBinderTest.java b/javatests/com/google/turbine/binder/ClassPathBinderTest.java index 3f41706..c11d814 100644 --- a/javatests/com/google/turbine/binder/ClassPathBinderTest.java +++ b/javatests/com/google/turbine/binder/ClassPathBinderTest.java @@ -44,7 +44,10 @@ import com.google.turbine.type.AnnoInfo; import com.google.turbine.type.Type.ClassTy; import java.io.IOError; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -161,4 +164,18 @@ public class ClassPathBinderTest { assertThat(e).hasMessageThat().contains("NOT_A_JAR"); } } + + @Test + public void resources() throws Exception { + Path path = temporaryFolder.newFile("tmp.jar").toPath(); + try (JarOutputStream jos = new JarOutputStream(Files.newOutputStream(path))) { + jos.putNextEntry(new JarEntry("foo/bar/hello.txt")); + jos.write("hello".getBytes(UTF_8)); + jos.putNextEntry(new JarEntry("foo/bar/Baz.class")); + jos.write("goodbye".getBytes(UTF_8)); + } + ClassPath classPath = ClassPathBinder.bindClasspath(ImmutableList.of(path)); + assertThat(new String(classPath.resource("foo/bar/hello.txt").get(), UTF_8)).isEqualTo("hello"); + assertThat(classPath.resource("foo/bar/Baz.class")).isNull(); + } } |