aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/android/ziputils/SplitZipTest.java
diff options
context:
space:
mode:
authorGravatar kmb <kmb@google.com>2017-10-31 17:49:07 -0400
committerGravatar John Cater <jcater@google.com>2017-11-01 09:58:57 -0400
commit85a32d2451526a83ebfdff2a0345006f678b8170 (patch)
tree0ac40317845dc8cb2512f30a88e2ce8873401513 /src/test/java/com/google/devtools/build/android/ziputils/SplitZipTest.java
parent2ad8c6978f786795b501dd4e6fa6b94cd910a485 (diff)
Force DexMapper (aka shuffle_jars) tool to partition large packages into multiple shards. Also fix some weirdnesses with how shard assignments were recorded.
RELNOTES: None. PiperOrigin-RevId: 174095450
Diffstat (limited to 'src/test/java/com/google/devtools/build/android/ziputils/SplitZipTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/android/ziputils/SplitZipTest.java101
1 files changed, 65 insertions, 36 deletions
diff --git a/src/test/java/com/google/devtools/build/android/ziputils/SplitZipTest.java b/src/test/java/com/google/devtools/build/android/ziputils/SplitZipTest.java
index 87cc5ce6d8..1794252a22 100644
--- a/src/test/java/com/google/devtools/build/android/ziputils/SplitZipTest.java
+++ b/src/test/java/com/google/devtools/build/android/ziputils/SplitZipTest.java
@@ -270,47 +270,76 @@ public class SplitZipTest {
}
@Test
- public void testSplitInTwo() {
- try {
- new ZipFileBuilder()
- .add("pkg1/test1.class", "hello world")
- .add("pkg2/test1.class", "hello world")
- .add("pkg1/test2.class", "how are you")
- .add("pkg2/test2.class", "how are you")
- .add("pkg1/test3.class", "bye bye")
- .add("pkg2/test3.class", "bye bye")
- .create("input.jar");
+ public void testSplitOnPackageBoundary() throws IOException {
+ new ZipFileBuilder()
+ .add("pkg1/test1.class", "hello world")
+ .add("pkg2/test1.class", "hello world")
+ .add("pkg1/test2.class", "how are you")
+ .add("pkg2/test2.class", "how are you")
+ // no third file in pkg1 to test splitting early on package boundary
+ .add("pkg2/test3.class", "bye bye")
+ .create("input.jar");
- new SplitZip()
- .addOutput(new ZipOut(fileSystem.getOutputChannel("out/shard1.jar", false),
- "out/shard1.jar"))
- .addOutput(new ZipOut(fileSystem.getOutputChannel("out/shard2.jar", false),
- "out/shard2.jar"))
- .setVerbose(true)
- .addInput(new ZipIn(fileSystem.getInputChannel("input.jar"), "input.jar"))
- .run()
- .close();
+ new SplitZip()
+ .addOutput(new ZipOut(fileSystem.getOutputChannel("out/shard1.jar", false),
+ "out/shard1.jar"))
+ .addOutput(new ZipOut(fileSystem.getOutputChannel("out/shard2.jar", false),
+ "out/shard2.jar"))
+ .setVerbose(true)
+ .addInput(new ZipIn(fileSystem.getInputChannel("input.jar"), "input.jar"))
+ .run()
+ .close();
- new ZipFileBuilder()
- .add("pkg1/test1.class", "hello world")
- .add("pkg1/test2.class", "how are you")
- .add("pkg1/test3.class", "bye bye")
- .create("expected/shard1.jar");
- new ZipFileBuilder()
- .add("pkg2/test1.class", "hello world")
- .add("pkg2/test2.class", "how are you")
- .add("pkg2/test3.class", "bye bye")
- .create("expected/shard2.jar");
+ new ZipFileBuilder()
+ .add("pkg1/test1.class", "hello world")
+ .add("pkg1/test2.class", "how are you")
+ .create("expected/shard1.jar");
+ new ZipFileBuilder()
+ .add("pkg2/test1.class", "hello world")
+ .add("pkg2/test2.class", "how are you")
+ .add("pkg2/test3.class", "bye bye")
+ .create("expected/shard2.jar");
- assertThat(fileSystem.toByteArray("out/shard1.jar"))
- .isEqualTo(fileSystem.toByteArray("expected/shard1.jar"));
+ assertThat(fileSystem.toByteArray("out/shard1.jar")).named("shard1")
+ .isEqualTo(fileSystem.toByteArray("expected/shard1.jar"));
- assertThat(fileSystem.toByteArray("out/shard2.jar"))
- .isEqualTo(fileSystem.toByteArray("expected/shard2.jar"));
+ assertThat(fileSystem.toByteArray("out/shard2.jar")).named("shard2")
+ .isEqualTo(fileSystem.toByteArray("expected/shard2.jar"));
+ }
- } catch (IOException e) {
- fail("Exception: " + e);
- }
+ @Test
+ public void testSplitSinglePackageInTwo() throws IOException {
+ new ZipFileBuilder()
+ .add("a.class", "hello world")
+ .add("b.class", "how are you")
+ .add("c.class", "bye bye")
+ .add("d.class", "good night")
+ .create("input.jar");
+
+ new SplitZip()
+ .addOutput(new ZipOut(fileSystem.getOutputChannel("out/shard1.jar", false),
+ "out/shard1.jar"))
+ .addOutput(new ZipOut(fileSystem.getOutputChannel("out/shard2.jar", false),
+ "out/shard2.jar"))
+ .setVerbose(true)
+ .addInput(new ZipIn(fileSystem.getInputChannel("input.jar"), "input.jar"))
+ .run()
+ .close();
+
+ new ZipFileBuilder()
+ .add("a.class", "hello world")
+ .add("b.class", "how are you")
+ .create("expected/shard1.jar");
+ new ZipFileBuilder()
+ .add("c.class", "bye bye")
+ .add("d.class", "good night")
+ .create("expected/shard2.jar");
+
+ assertThat(fileSystem.toByteArray("out/shard1.jar")).named("shard1")
+ .isEqualTo(fileSystem.toByteArray("expected/shard1.jar"));
+
+ assertThat(fileSystem.toByteArray("out/shard2.jar")).named("shard2")
+ .isEqualTo(fileSystem.toByteArray("expected/shard2.jar"));
}
@Test