@Override public void loadDefaultCatalog(final String url) throws CatalogApiException { if (url != null) { defaultCatalog = loader.loadDefaultCatalog(url); } }
@VisibleForTesting void setDefaultCatalog() { try { // Provided in the classpath this.defaultCatalog = loader.loadDefaultCatalog("EmptyCatalog.xml"); } catch (final CatalogApiException e) { this.defaultCatalog = new DefaultVersionedCatalog(); logger.error("Exception loading EmptyCatalog - should never happen!", e); } } }
@Test(groups = "fast", expectedExceptions = CatalogApiException.class) public void testLoadCatalogFromClasspathResourceBadFolder() throws CatalogApiException { loader.loadDefaultCatalog("SpyCarCustom.xml"); }
@Test(groups = "fast", expectedExceptions = CatalogApiException.class) public void testLoadCatalogFromInsideResourceWithBadFolderName() throws CatalogApiException { loader.loadDefaultCatalog("com/acme2/SpyCarCustom.xml"); }
@Test(groups = "fast") public void testLoadCatalogFromExternalFile() throws CatalogApiException, IOException, URISyntaxException { final File originFile = new File(Resources.getResource("SpyCarBasic.xml").toURI()); final File destinationFile = new File(Files.createTempDir().toString() + "/SpyCarBasicRelocated.xml"); destinationFile.deleteOnExit(); Files.copy(originFile, destinationFile); final VersionedCatalog c = loader.loadDefaultCatalog(destinationFile.toURI().toString()); Assert.assertEquals(c.getCatalogName(), "SpyCarBasic"); } }
@Test(groups = "fast") public void testLoadCatalogFromClasspathResourceFolder() throws CatalogApiException { final VersionedCatalog c = loader.loadDefaultCatalog("SpyCarBasic.xml"); Assert.assertEquals(c.getVersions().size(), 1); final DateTime dt = new DateTime("2013-02-08T00:00:00+00:00"); Assert.assertEquals(c.getEffectiveDate(), dt.toDate()); Assert.assertEquals(c.getCatalogName(), "SpyCarBasic"); }
@Test(groups = "fast") public void testLoadCatalogFromInsideResourceFolder() throws CatalogApiException { final DefaultVersionedCatalog c = loader.loadDefaultCatalog("com/acme/SpyCarCustom.xml"); Assert.assertEquals(c.getVersions().size(), 1); final DateTime dt = new DateTime("2015-10-04T00:00:00+00:00"); Assert.assertEquals(c.getEffectiveDate(), dt.toDate()); Assert.assertEquals(c.getCatalogName(), "SpyCarCustom"); }
@BeforeClass(groups = "fast") public void beforeClass() throws Exception { if (hasFailed()) { return; } super.beforeClass(); vc = loader.loadDefaultCatalog("versionedCatalog"); }
@Test(groups = "fast") public void testLoad() throws CatalogApiException { final DefaultVersionedCatalog c = loader.loadDefaultCatalog(Resources.getResource("versionedCatalog").toString()); Assert.assertEquals(c.getVersions().size(), 4); DateTime dt = new DateTime("2011-01-01T00:00:00+00:00"); Assert.assertEquals(c.getVersions().get(0).getEffectiveDate(), dt.toDate()); dt = new DateTime("2011-02-02T00:00:00+00:00"); Assert.assertEquals(c.getVersions().get(1).getEffectiveDate(), dt.toDate()); dt = new DateTime("2011-02-03T00:00:00+00:00"); Assert.assertEquals(c.getVersions().get(2).getEffectiveDate(), dt.toDate()); dt = new DateTime("2011-03-03T00:00:00+00:00"); Assert.assertEquals(c.getVersions().get(3).getEffectiveDate(), dt.toDate()); }
@Override public void loadDefaultCatalog(final String url) throws CatalogApiException { if (url != null) { defaultCatalog = loader.loadDefaultCatalog(url); } }
@VisibleForTesting void setDefaultCatalog() { try { // Provided in the classpath this.defaultCatalog = loader.loadDefaultCatalog("EmptyCatalog.xml"); } catch (final CatalogApiException e) { this.defaultCatalog = new DefaultVersionedCatalog(); logger.error("Exception loading EmptyCatalog - should never happen!", e); } } }
@Test(groups = "fast", expectedExceptions = CatalogApiException.class) public void testLoadCatalogFromClasspathResourceBadFolder() throws CatalogApiException { loader.loadDefaultCatalog("SpyCarCustom.xml"); }
@Test(groups = "fast", expectedExceptions = CatalogApiException.class) public void testLoadCatalogFromInsideResourceWithBadFolderName() throws CatalogApiException { loader.loadDefaultCatalog("com/acme2/SpyCarCustom.xml"); }
@Test(groups = "fast") public void testLoadCatalogFromExternalFile() throws CatalogApiException, IOException, URISyntaxException { final File originFile = new File(Resources.getResource("SpyCarBasic.xml").toURI()); final File destinationFile = new File(Files.createTempDir().toString() + "/SpyCarBasicRelocated.xml"); destinationFile.deleteOnExit(); Files.copy(originFile, destinationFile); final VersionedCatalog c = loader.loadDefaultCatalog(destinationFile.toURI().toString()); Assert.assertEquals(c.getCatalogName(), "SpyCarBasic"); } }
@Test(groups = "fast") public void testLoadCatalogFromInsideResourceFolder() throws CatalogApiException { final DefaultVersionedCatalog c = loader.loadDefaultCatalog("com/acme/SpyCarCustom.xml"); Assert.assertEquals(c.getVersions().size(), 1); final DateTime dt = new DateTime("2015-10-04T00:00:00+00:00"); Assert.assertEquals(c.getEffectiveDate(), dt.toDate()); Assert.assertEquals(c.getCatalogName(), "SpyCarCustom"); }
@Test(groups = "fast") public void testLoadCatalogFromClasspathResourceFolder() throws CatalogApiException { final VersionedCatalog c = loader.loadDefaultCatalog("SpyCarBasic.xml"); Assert.assertEquals(c.getVersions().size(), 1); final DateTime dt = new DateTime("2013-02-08T00:00:00+00:00"); Assert.assertEquals(c.getEffectiveDate(), dt.toDate()); Assert.assertEquals(c.getCatalogName(), "SpyCarBasic"); }
@BeforeClass(groups = "fast") public void beforeClass() throws Exception { if (hasFailed()) { return; } super.beforeClass(); vc = loader.loadDefaultCatalog("versionedCatalog"); }
@Test(groups = "fast") public void testLoad() throws CatalogApiException { final DefaultVersionedCatalog c = loader.loadDefaultCatalog(Resources.getResource("versionedCatalog").toString()); Assert.assertEquals(c.getVersions().size(), 4); DateTime dt = new DateTime("2011-01-01T00:00:00+00:00"); Assert.assertEquals(c.getVersions().get(0).getEffectiveDate(), dt.toDate()); dt = new DateTime("2011-02-02T00:00:00+00:00"); Assert.assertEquals(c.getVersions().get(1).getEffectiveDate(), dt.toDate()); dt = new DateTime("2011-02-03T00:00:00+00:00"); Assert.assertEquals(c.getVersions().get(2).getEffectiveDate(), dt.toDate()); dt = new DateTime("2011-03-03T00:00:00+00:00"); Assert.assertEquals(c.getVersions().get(3).getEffectiveDate(), dt.toDate()); }