use of org.teiid.adminapi.Admin in project teiid by teiid.
the class TestDDLMetadataStore method testVDBExport.
@Test
public void testVDBExport() throws Exception {
EmbeddedConfiguration ec = new EmbeddedConfiguration();
ec.setUseDisk(false);
ec.setSecurityHelper(new ThreadLocalSecurityHelper());
es.addTranslator("y", new TestEmbeddedServer.FakeTranslator(false));
es.start(ec);
final AtomicInteger counter = new AtomicInteger();
ConnectionFactoryProvider<AtomicInteger> cfp = new EmbeddedServer.SimpleConnectionFactoryProvider<AtomicInteger>(counter);
es.addConnectionFactoryProvider("z", cfp);
es.addMetadataRepository("myrepo", Mockito.mock(MetadataRepository.class));
es.deployVDB(new FileInputStream(UnitTestUtil.getTestDataPath() + "/first-db.ddl"), true);
Admin admin = es.getAdmin();
VDBMetaData vdb = (VDBMetaData) admin.getVDB("empty", "2");
ByteArrayOutputStream out = new ByteArrayOutputStream();
VDBMetadataParser.marshell(vdb, out);
String expected = ObjectConverterUtil.convertFileToString(new File(UnitTestUtil.getTestDataPath() + "/" + "first-vdb.xml"));
assertEquals(expected, new String(out.toByteArray()));
String exportedDdl = admin.getSchema("empty", "2", null, null, null);
Assert.assertEquals(ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("first-vdb.ddl")), exportedDdl);
}
Aggregations