@@ -0,0 +1,1776 @@
+package org.sagebionetworks.repo.manager.file.preview;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.util.zip.ZipEntry;%0Aimport java.util.zip.ZipOutputStream;%0A%0Aimport org.apache.commons.io.output.ByteArrayOutputStream;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.sagebionetworks.repo.web.ServiceUnavailableException;%0A%0Apublic class ZipPreviewTest %7B%0A%09ZipPreviewGenerator zipPreviewGenerator;%0A%09%0A%09@Before%0A%09public void before() throws IOException, ServiceUnavailableException%7B%0A%09%09zipPreviewGenerator = new ZipPreviewGenerator();%0A%09%7D%0A%09%0A%09@Test%0A%09public void testGeneratePreview() throws IOException %7B%0A%09%09// create a zip file.%0A%09%09File f = File.createTempFile(%22ZipPreview%22, %22.zip%22);%0A%09%09try %7B%0A%09%09%09StringBuilder sb = new StringBuilder();%0A%09%09%09sb.append(%22Test String%22);%0A%0A%09%09%09final ZipOutputStream out = new ZipOutputStream(%0A%09%09%09%09%09new FileOutputStream(f));%0A%09%09%09for (int i = 0; i %3C 10; i++) %7B%0A%09%09%09%09// write 10 entries%0A%09%09%09%09ZipEntry e = new ZipEntry(%22textFile%22 + i + %22.txt%22);%0A%09%09%09%09out.putNextEntry(e);%0A%09%09%09%09byte%5B%5D data = sb.toString().getBytes();%0A%09%09%09%09out.write(data, 0, data.length);%0A%09%09%09%09out.closeEntry();%0A%09%09%09%7D%0A%09%09%09out.close();%0A%09%09%09ByteArrayOutputStream baos = new ByteArrayOutputStream();%0A%09%09%09InputStream from = new FileInputStream(f);%0A%09%09%09String type = zipPreviewGenerator.generatePreview(from, baos);%0A%09%09%09assertEquals(ZipPreviewGenerator.TEXT_CSV, type);%0A%09%09%09String actual = baos.toString();%0A%09%09%09String expected = %22textFile0.txt%5CntextFile1.txt%5CntextFile2.txt%5CntextFile3.txt%5CntextFile4.txt%5CntextFile5.txt%5CntextFile6.txt%5CntextFile7.txt%5CntextFile8.txt%5CntextFile9.txt%5Cn%22;%0A%09%09%09assertEquals(expected, actual);%0A%09%09%7D finally %7B%0A%09%09%09f.delete();%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

add zip preview test