Commit b4120e7a authored by Riegel's avatar Riegel
Browse files

Refactor: Remove deprecated implementation

2 merge requests!28Version 3.17.0 Release,!26Add ZIP-archive support
Showing with 15 additions and 13 deletions
+15 -13
...@@ -26,12 +26,6 @@ public class CityGmlZipArchive implements Serializable { ...@@ -26,12 +26,6 @@ public class CityGmlZipArchive implements Serializable {
private final Path archivePath; private final Path archivePath;
private final String archiveNameRE; private final String archiveNameRE;
public static CityGmlZipArchive fromZipFile(String zipFile, ParserConfiguration config) {
CityGmlZipArchive archive = CityGmlZipArchive.register(zipFile);
archive.mountArchive(config);
logger.info("Zip-archive successfully uncompressed, {} CityGml files detected", archive.getEntries().size());
return archive;
}
public static CityGmlZipArchive register(String zipFile) { public static CityGmlZipArchive register(String zipFile) {
ArrayList<CityGmlZipEntry> archiveEntries = new ArrayList<>(); ArrayList<CityGmlZipEntry> archiveEntries = new ArrayList<>();
......
...@@ -24,12 +24,13 @@ public class ZipTest { ...@@ -24,12 +24,13 @@ public class ZipTest {
@Test @Test
public void testUnzipping() { public void testUnzipping() {
CityGmlZipArchive cgmlArch = CityGmlZipArchive.fromZipFile("src/test/resources/zip/mock_archive.zip", config); CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/mock_archive.zip");
assertNotNull(cgmlArch);
cgmlArch.mountArchive(config);
checkMockArchive(cgmlArch); checkMockArchive(cgmlArch);
} }
private void checkMockArchive(CityGmlZipArchive cgmlArch){ private void checkMockArchive(CityGmlZipArchive cgmlArch){
assertNotNull(cgmlArch);
assertEquals(5,cgmlArch.getEntries().size()); assertEquals(5,cgmlArch.getEntries().size());
for (CityGmlZipEntry entry : cgmlArch.getEntries()) { for (CityGmlZipEntry entry : cgmlArch.getEntries()) {
assertNotNull(entry); assertNotNull(entry);
...@@ -42,14 +43,18 @@ public class ZipTest { ...@@ -42,14 +43,18 @@ public class ZipTest {
@Test @Test
public void testZipping() throws IOException { public void testZipping() throws IOException {
CityGmlZipArchive cgmlArch = CityGmlZipArchive.fromZipFile("src/test/resources/zip/mock_archive.zip", config); CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/mock_archive.zip");
assertNotNull(cgmlArch);
cgmlArch.mountArchive(config);
Path tmpDir = null; Path tmpDir = null;
try { try {
tmpDir = Files.createTempDirectory("testTmp"); tmpDir = Files.createTempDirectory("testTmp");
tmpDir.toFile().deleteOnExit(); tmpDir.toFile().deleteOnExit();
String expPath = tmpDir.toString() + "/export.zip"; String expPath = tmpDir.toString() + "/export.zip";
cgmlArch.exportToZipFile(expPath); cgmlArch.exportToZipFile(expPath);
CityGmlZipArchive cgmlExport = CityGmlZipArchive.fromZipFile(expPath, config); CityGmlZipArchive cgmlExport = CityGmlZipArchive.register(expPath);
assertNotNull(cgmlExport);
cgmlExport.mountArchive(config);
checkMockArchive(cgmlExport); checkMockArchive(cgmlExport);
} finally { } finally {
if (tmpDir != null) { if (tmpDir != null) {
...@@ -60,8 +65,9 @@ public class ZipTest { ...@@ -60,8 +65,9 @@ public class ZipTest {
@Test @Test
public void testEpsgParsing() { public void testEpsgParsing() {
CityGmlZipArchive cgmlArch = CityGmlZipArchive.fromZipFile("src/test/resources/zip/epsg.zip", config); CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/epsg.zip");
assertNotNull(cgmlArch); assertNotNull(cgmlArch);
cgmlArch.mountArchive(config);
List<String> epsgs = new ArrayList<>(2); List<String> epsgs = new ArrayList<>(2);
epsgs.add("25832"); epsgs.add("25832");
epsgs.add("7415"); epsgs.add("7415");
...@@ -76,16 +82,18 @@ public class ZipTest { ...@@ -76,16 +82,18 @@ public class ZipTest {
@Test @Test
public void testValidation(){ public void testValidation(){
ParserConfiguration valConfig = new ParserConfiguration(8,true); ParserConfiguration valConfig = new ParserConfiguration(8,true);
CityGmlZipArchive cgmlArch = CityGmlZipArchive.fromZipFile("src/test/resources/zip/validate.zip", valConfig); CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/validate.zip");
assertNotNull(cgmlArch); assertNotNull(cgmlArch);
cgmlArch.mountArchive(valConfig);
assertNull(cgmlArch.getEntry("valCorrect.gml").getErrorType()); assertNull(cgmlArch.getEntry("valCorrect.gml").getErrorType());
assertEquals(ZipEntryErrorType.INVALID_CITY_GML_FILE, cgmlArch.getEntry("valFaulty.gml").getErrorType()); assertEquals(ZipEntryErrorType.INVALID_CITY_GML_FILE, cgmlArch.getEntry("valFaulty.gml").getErrorType());
} }
@Test @Test
public void testImplicitParsing(){ public void testImplicitParsing(){
CityGmlZipArchive cgmlArch = CityGmlZipArchive.fromZipFile("src/test/resources/zip/implicit.zip", config); CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/implicit.zip");
assertNotNull(cgmlArch); assertNotNull(cgmlArch);
cgmlArch.mountArchive(config);
CityDoctorModel mainModel = cgmlArch.getEntry("Main_model.gml").getModel(); CityDoctorModel mainModel = cgmlArch.getEntry("Main_model.gml").getModel();
assertEquals(18, mainModel.getGenericCityObjects().size()); assertEquals(18, mainModel.getGenericCityObjects().size());
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment