Skip to content

Commit

Permalink
refactor(test): validator-core - remove usage of XML models in tests …
Browse files Browse the repository at this point in the history
…(refs #351)
  • Loading branch information
mborne committed Aug 8, 2024
1 parent ed23bdf commit e1458d7
Show file tree
Hide file tree
Showing 31 changed files with 35 additions and 1,850 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
package fr.ign.validator.io;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.net.MalformedURLException;
import java.net.URL;

import org.junit.Test;

import fr.ign.validator.exception.InvalidModelException;

public class ModelReaderFactoryTest {

@Test
public void testXml() throws MalformedURLException {
URL url = new URL("https://example.org/my-model.xml");
ModelReader reader = ModelReaderFactory.createModelReader(url);
assertTrue(reader instanceof XmlModelReader);
RuntimeException thrown = null;
try {
ModelReaderFactory.createModelReader(url);
}catch(RuntimeException e){
thrown = e;
}
assertNotNull(thrown);
assertTrue(thrown instanceof InvalidModelException);
assertEquals("Fail to load https://example.org/my-model.xml (XML model support has been removed, use JSON format)",thrown.getMessage());
}

@Test
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

import fr.ign.validator.Context;
import fr.ign.validator.data.Document;
import fr.ign.validator.io.JsonModelReader;
import fr.ign.validator.io.ModelReader;
import fr.ign.validator.io.XmlModelReader;
import fr.ign.validator.model.DocumentModel;
import fr.ign.validator.model.FeatureType;
import fr.ign.validator.model.FileModel;
Expand Down Expand Up @@ -42,8 +42,8 @@ public void setUp() throws Exception {
context.setProjection(Projection.CODE_CRS84);
context.setReportBuilder(reportBuilder);

File documentModelPath = ResourceHelper.getResourceFile(getClass(), "/config-xml/adresse/files.xml");
ModelReader modelLoader = new XmlModelReader();
File documentModelPath = ResourceHelper.getResourceFile(getClass(), "/config-json/adresse/files.json");
ModelReader modelLoader = new JsonModelReader();
DocumentModel documentModel = modelLoader.loadDocumentModel(documentModelPath);

File documentPath = ResourceHelper.getResourceFile(getClass(), "/documents/adresse-multiple");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ public class FileUtilsTest {

@Test
public void testListFilesAndDirs() {
File directory = ResourceHelper.getResourceFile(getClass(), "/config-xml/geofla");
File directory = ResourceHelper.getResourceFile(getClass(), "/documents/commune-sample");
String[] extensions = {
"xml"
};
Collection<File> files = FileUtils.listFilesAndDirs(directory, extensions);
assertEquals(4, files.size());
// 2 XML files and 1 sub-directory
assertEquals(3, files.size());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void setUp() throws Exception {

context = new Context();
context.setStringFixer(StringFixer.createFullStringFixer(StandardCharsets.ISO_8859_1));
File currentDirectory = ResourceHelper.getResourceFile(getClass(), "/config-xml/geofla");
File currentDirectory = ResourceHelper.getResourceFile(getClass(), "/documents/adresse-multiple");
context.setCurrentDirectory(currentDirectory);

report = new InMemoryReportBuilder();
Expand Down
Loading

0 comments on commit e1458d7

Please sign in to comment.