zipLibraryWriter.setCompilationErrorsIndex(expectedCompilationErrorsIndex);
zipLibraryWriter.write();
// Read data back from disk.
ZipLibrary zipLibrary = new ZipLibrary(zipFile.getPath());
CompilationUnit barCompilationUnit =
zipLibrary.getCompilationUnitByTypeSourceName(BAR.getTypeName());
CompilationUnit superFooCompilationUnit =
zipLibrary.getCompilationUnitByTypeSourceName(SUPER_FOO.getTypeName());
// Compare it.
assertEquals(expectedLibraryName, zipLibrary.getLibraryName());
assertEquals(expectedResourceContents,
Util.readStreamAsString(zipLibrary.getPublicResourceByPath("index.html").openContents()));
assertEquals(expectedDependencyLibraryNames, zipLibrary.getDependencyLibraryNames());
// CompilationUnit
List<JDeclaredType> barTypes = barCompilationUnit.getTypes();
assertEquals(1, barTypes.size());
assertEquals(BAR.getTypeName(), barTypes.get(0).getName());
assertEquals(BAR.getLocation(), barCompilationUnit.getResourceLocation());
assertEquals(BAR.getTypeName(), barCompilationUnit.getTypeName());
// SuperSourceCompilationUnit
List<JDeclaredType> superFoo = superFooCompilationUnit.getTypes();
assertEquals(1, superFoo.size());
assertEquals(SUPER_FOO.getTypeName(), superFoo.get(0).getName());
assertEquals(SUPER_FOO.getLocation(), superFooCompilationUnit.getResourceLocation());
assertEquals(SUPER_FOO.getTypeName(), superFooCompilationUnit.getTypeName());
// Can find inner classes by source name.
assertTrue(zipLibrary.getNestedSourceNamesByCompilationUnitName().get(
JdtCompilerTest.OUTER_INNER.getTypeName()).contains(
JdtCompilerTest.OUTER_INNER.getTypeName() + ".Inner"));