use of org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog in project webtools.sourceediting by eclipse.
the class AbstractCatalogTest method initCatalogs.
public void initCatalogs() {
defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs();
for (int i = 0; i < nextCatalogs.length; i++) {
INextCatalog catalog = nextCatalogs[i];
ICatalog referencedCatalog = catalog.getReferencedCatalog();
if (referencedCatalog != null) {
if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) {
systemCatalog = referencedCatalog;
} else if (XMLCorePlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) {
userCatalog = referencedCatalog;
}
}
}
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog in project webtools.sourceediting by eclipse.
the class CatalogWriterTest method testReadAndWriteComplexCatalog.
/*
* Class under test for void read(ICatalog, String)
*/
public void testReadAndWriteComplexCatalog() throws Exception {
// read catalog
String catalogFile = "/data/delegateAndRewrite/catalog11.xml";
URL catalogUrl = TestPlugin.getDefault().getBundle().getEntry(catalogFile);
assertNotNull(catalogUrl);
URL base = FileLocator.resolve(catalogUrl);
Catalog catalog = (Catalog) getCatalog("catalog11", base.toString());
// CatalogReader.read(catalog, catalogFilePath);
assertNotNull(catalog);
// test main catalog - catalog1.xml
// assertEquals("cat1", catalog.getId());
assertEquals(13, catalog.getCatalogElements().length);
// write catalog so we can read it back in
URL resultsFolder = TestPlugin.getDefault().getBundle().getEntry("/");
IPath path = new Path(FileLocator.resolve(resultsFolder).getFile());
String resultCatalogFile = path.append("/catalog11-x.xml").toFile().toURI().toString();
catalog.setLocation(resultCatalogFile);
// write catalog
catalog.save();
// read catalog file from the saved location and test its content
catalog = (Catalog) getCatalog("catalog2", catalog.getLocation());
assertNotNull(catalog);
// test main catalog - catalog1.xml
// assertEquals("cat1", catalog.getId());
assertEquals(13, catalog.getCatalogElements().length);
// test public entries
assertEquals(2, CatalogTest.getCatalogEntries(catalog, ICatalogEntry.ENTRY_TYPE_PUBLIC).size());
// test system entries
assertEquals(2, CatalogTest.getCatalogEntries(catalog, ICatalogEntry.ENTRY_TYPE_SYSTEM).size());
// test uri entries
assertEquals(1, CatalogTest.getCatalogEntries(catalog, ICatalogEntry.ENTRY_TYPE_URI).size());
// test next catalog - catalog2.xml
INextCatalog[] nextCatalogEntries = catalog.getNextCatalogs();
assertEquals(1, nextCatalogEntries.length);
INextCatalog nextCatalogEntry = (INextCatalog) nextCatalogEntries[0];
assertNotNull(nextCatalogEntry);
assertEquals("catalog.xml", nextCatalogEntry.getCatalogLocation());
}
Aggregations