|
26 | 26 | import jeeves.server.ServiceConfig; |
27 | 27 |
|
28 | 28 | import org.fao.geonet.AbstractCoreIntegrationTest; |
| 29 | +import org.fao.geonet.constants.Geonet; |
| 30 | +import org.fao.geonet.exceptions.BadParameterEx; |
29 | 31 | import org.jdom.Element; |
30 | 32 | import org.junit.Test; |
31 | 33 | import org.springframework.beans.factory.annotation.Autowired; |
|
34 | 36 | import java.nio.file.Path; |
35 | 37 | import java.util.ArrayList; |
36 | 38 |
|
37 | | -import static org.junit.Assert.assertEquals; |
| 39 | +import static org.junit.Assert.*; |
38 | 40 |
|
39 | 41 | /** |
40 | 42 | * Abstract class for GeonetworkDataDirectory tests where the data directory layout is a default |
@@ -76,6 +78,29 @@ public void testInit() throws Exception { |
76 | 78 | assertSystemDirSubFolders(expectedDataDir); |
77 | 79 | } |
78 | 80 |
|
| 81 | + @Test |
| 82 | + public void testGetXsltConversion() { |
| 83 | + Path xsltConversion = dataDirectory.getXsltConversion("conversion"); |
| 84 | + assertEquals(dataDirectory.getWebappDir().resolve(Geonet.Path.IMPORT_STYLESHEETS).resolve("conversion.xsl"), xsltConversion); |
| 85 | + try { |
| 86 | + dataDirectory.getXsltConversion("../conversion"); |
| 87 | + } catch (BadParameterEx e) { |
| 88 | + assertEquals("../conversion is not a valid value for: Invalid character found in path.", e.getMessage()); |
| 89 | + } |
| 90 | + |
| 91 | + xsltConversion = dataDirectory.getXsltConversion("schema:iso19115-3.2018:convert/fromISO19115-3.2014"); |
| 92 | + assertNotNull(xsltConversion); |
| 93 | + try { |
| 94 | + dataDirectory.getXsltConversion("schema:notExistingSchema:convert/fromISO19115-3.2014"); |
| 95 | + } catch (BadParameterEx e) { |
| 96 | + assertEquals("Conversion not found. Schema 'notExistingSchema' is not registered in this catalog.", e.getMessage()); |
| 97 | + } |
| 98 | + try { |
| 99 | + dataDirectory.getXsltConversion("schema:iso19115-3.2018:../../custom/path"); |
| 100 | + } catch (BadParameterEx e) { |
| 101 | + assertEquals("../../custom/path is not a valid value for: Invalid character found in path.", e.getMessage()); |
| 102 | + } |
| 103 | + } |
79 | 104 | private void assertSystemDirSubFolders(Path expectedDataDir) { |
80 | 105 | final Path expectedConfigDir = expectedDataDir.resolve("config"); |
81 | 106 | assertEquals(expectedConfigDir, dataDirectory.getConfigDir()); |
|
0 commit comments