use of org.teiid.runtime.EmbeddedConfiguration 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);
}
use of org.teiid.runtime.EmbeddedConfiguration in project teiid by teiid.
the class TestDDLMetadataStore method testRoles.
@Test
public void testRoles() throws Exception {
EmbeddedConfiguration ec = new EmbeddedConfiguration();
ec.setUseDisk(false);
ec.setSecurityHelper(new ThreadLocalSecurityHelper());
es.addTranslator("y", new TestEmbeddedServer.FakeTranslator(false));
es.addTranslator("y2", new TestEmbeddedServer.FakeTranslator(false));
final AtomicInteger counter = new AtomicInteger();
ConnectionFactoryProvider<AtomicInteger> cfp = new EmbeddedServer.SimpleConnectionFactoryProvider<AtomicInteger>(counter);
es.addConnectionFactoryProvider("z", cfp);
es.start(ec);
es.addMetadataRepository("myrepo", Mockito.mock(MetadataRepository.class));
es.deployVDB(new FileInputStream(UnitTestUtil.getTestDataPath() + "/first-db.ddl"), true);
TeiidDriver td = es.getDriver();
Connection c = td.connect("jdbc:teiid:empty", null);
Statement s = c.createStatement();
ResultSet rs = s.executeQuery("select * from mytable");
assertFalse(rs.next());
assertEquals("my-column", rs.getMetaData().getColumnLabel(1));
s.execute("update mytable set \"my-column\" = 'a'");
assertEquals(2, s.getUpdateCount());
try {
s.execute("delete from mytable where \"my-column\" = 'a'");
fail("should have stopped by roles");
} catch (Exception e) {
// pass
}
}
use of org.teiid.runtime.EmbeddedConfiguration in project teiid by teiid.
the class TestDDLMetadataStore method testMultiSource.
@Test
public void testMultiSource() throws Exception {
EmbeddedConfiguration ec = new EmbeddedConfiguration();
ec.setUseDisk(false);
es.start(ec);
es.addTranslator(FileExecutionFactory.class);
es.deployVDB(new FileInputStream(UnitTestUtil.getTestDataPath() + "/" + "multisource-vdb.ddl"), true);
es.getAdmin().addSource("multisource", "1", "MarketData", "x", "file", "z");
Connection c = es.getDriver().connect("jdbc:teiid:multisource", null);
DatabaseMetaData dmd = c.getMetaData();
ResultSet rs = dmd.getProcedureColumns(null, null, "deleteFile", null);
int count = 0;
while (rs.next()) {
count++;
}
assertEquals(2, count);
}
use of org.teiid.runtime.EmbeddedConfiguration in project teiid by teiid.
the class TestJDBCSocketPerformance method oneTimeSetup.
@BeforeClass
public static void oneTimeSetup() throws Exception {
SocketConfiguration config = new SocketConfiguration();
config.setSSLConfiguration(new SSLConfiguration());
addr = new InetSocketAddress(0);
config.setBindAddress(addr.getHostName());
config.setPortNumber(0);
EmbeddedConfiguration dqpConfig = new EmbeddedConfiguration();
dqpConfig.setMaxActivePlans(2);
server = new FakeServer(false);
server.start(dqpConfig);
ModelMetaData mmd = new ModelMetaData();
mmd.setName("x");
mmd.setModelType(Type.PHYSICAL);
mmd.addSourceMapping("x", "hc", null);
mmd.setSchemaSourceType("ddl");
StringBuffer ddl = new StringBuffer("create foreign table x (col0 string");
for (int i = 1; i < 10; i++) {
ddl.append(",").append(" col").append(i).append(" string");
}
ddl.append(");");
mmd.setSchemaText(ddl.toString());
server.addTranslator("hc", new HardCodedExecutionFactory() {
@Override
protected List<? extends List<?>> getData(QueryExpression command) {
List<List<String>> result = new ArrayList<List<String>>();
int size = command.getProjectedQuery().getDerivedColumns().size();
for (int i = 0; i < 64; i++) {
List<String> row = new ArrayList<String>(size);
for (int j = 0; j < size; j++) {
row.add("abcdefghi" + j);
}
result.add(row);
}
return result;
}
});
server.deployVDB("x", mmd);
jdbcTransport = new SocketListener(addr, config, server.getClientServiceRegistry(), BufferManagerFactory.getStandaloneBufferManager());
}
use of org.teiid.runtime.EmbeddedConfiguration in project teiid by teiid.
the class TestMaterializationPerformance method setup.
@Before
public void setup() {
es = new EmbeddedServer();
es.start(new EmbeddedConfiguration());
}
Aggregations