### Question:
ZipUtils { public static ArrayByteSource zipInMemory(List<? extends BeanByteSource> sources) { long instantMillis = System.currentTimeMillis(); try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { try (ZipOutputStream out = new ZipOutputStream(baos)) { for (BeanByteSource source : sources) { ZipEntry entry = new ZipEntry( source.getFileName() .orElseThrow(() -> new IllegalArgumentException("ByteSource must have a name in order to be zipped"))); entry.setTime(instantMillis); out.putNextEntry(entry); source.copyTo(out); out.closeEntry(); } } return ArrayByteSource.ofUnsafe(baos.toByteArray()); } catch (IOException ex) { throw new UncheckedIOException(ex); } } private  ZipUtils(); static Set<String> unzipPathNames(BeanByteSource source); static Optional<ArrayByteSource> unzipPathNameInMemory(BeanByteSource source, String relativePathName); static void unzip(BeanByteSource source, Path path); static ArrayByteSource zipInMemory(List<? extends BeanByteSource> sources); static Map<String, ArrayByteSource> unpackInMemory(BeanByteSource source); static void unpackInMemory(BeanByteSource source, BiConsumer<String, ArrayByteSource> consumer); static Map<String, ArrayByteSource> unzipInMemory(BeanByteSource source); static void unzipInMemory(BeanByteSource source, BiConsumer<String, ArrayByteSource> consumer); static BeanByteSource decryptZip(BeanByteSource source, String password);  }### Answer:
@Test public void test_zipInMemory() throws Exception { ArrayByteSource source1 = ArrayByteSource.ofUtf8("Hello World").withFileName("TestFile1.txt"); ArrayByteSource source2 = ArrayByteSource.ofUtf8("Hello Planet").withFileName("TestFile2.txt"); ArrayByteSource zipped = ZipUtils.zipInMemory(ImmutableList.of(source1, source2)); try (ZipInputStream in = new ZipInputStream(zipped.openBufferedStream())) { ZipEntry entry1 = in.getNextEntry(); assertThat(entry1.getName()).isEqualTo("TestFile1.txt"); assertThat(entry1.getTime()).isCloseTo(System.currentTimeMillis(), within(2000L)); ArrayByteSource file1 = ArrayByteSource.from(in); assertThat(file1.readUtf8()).isEqualTo("Hello World"); ZipEntry entry2 = in.getNextEntry(); assertThat(entry2.getName()).isEqualTo("TestFile2.txt"); assertThat(entry2.getTime()).isEqualTo(entry1.getTime()); ArrayByteSource file2 = ArrayByteSource.from(in); assertThat(file2.readUtf8()).isEqualTo("Hello Planet"); assertThat(in.getNextEntry()).isNull(); } }