@Test public void testAnalyzeAll4() throws IOException { createClassfile("bin1", AnalyzerTest.class); final int count = analyzer.analyzeAll(folder.getRoot()); assertEquals(1, count); assertEquals(Collections.singleton("org/jacoco/core/analysis/AnalyzerTest"), classes); }
@Test(expected = IOException.class) public void testAnalyzeAll6() throws IOException { File file = new File(folder.getRoot(), "broken.zip"); OutputStream out = new FileOutputStream(file); ZipOutputStream zip = new ZipOutputStream(out); zip.putNextEntry(new ZipEntry("brokenentry.txt")); out.write(0x23); // Unexpected data here zip.close(); analyzer.analyzeAll(file); }
@Test public void testAnalyzeAll2() throws IOException { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); final ZipOutputStream zip = new ZipOutputStream(buffer); zip.putNextEntry(new ZipEntry("org/jacoco/core/analysis/AnalyzerTest.class")); zip.write(TargetLoader.getClassDataAsBytes(AnalyzerTest.class)); zip.finish(); final int count = analyzer.analyzeAll(new ByteArrayInputStream(buffer.toByteArray())); assertEquals(1, count); assertEquals(Collections.singleton("org/jacoco/core/analysis/AnalyzerTest"), classes); }
@Test public void testAnalyzeAll5() throws IOException { createClassfile("bin1", Analyzer.class); createClassfile("bin2", AnalyzerTest.class); String path = "bin1" + File.pathSeparator + "bin2"; final int count = analyzer.analyzeAll(path, folder.getRoot()); assertEquals(2, count); assertEquals( new HashSet<String>( Arrays.asList( "org/jacoco/core/analysis/Analyzer", "org/jacoco/core/analysis/AnalyzerTest")), classes); }
@Test public void testAnalyzeAll1() throws IOException { final int count = analyzer.analyzeAll(TargetLoader.getClassData(AnalyzerTest.class)); assertEquals(1, count); assertEquals(Collections.singleton("org/jacoco/core/analysis/AnalyzerTest"), classes); }
@Test public void testAnalyzeAll3() throws IOException { final int count = analyzer.analyzeAll(new ByteArrayInputStream(new byte[0])); assertEquals(0, count); assertEquals(Collections.emptySet(), classes); }