use of org.teiid.runtime.EmbeddedServer in project teiid by teiid.
the class TestODataIntegration method before.
@Before
public void before() throws Exception {
TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("UTC"));
teiid = new EmbeddedServer();
EmbeddedConfiguration config = new EmbeddedConfiguration();
config.setTransactionManager(new DummyBaseTransactionManager());
teiid.start(config);
ef = new LoopbackExecutionFactory() {
@Override
public boolean supportsRowOffset() {
return false;
}
};
teiid.addTranslator("loopback", ef);
createContext("/odata4", null);
deployVDB();
}
use of org.teiid.runtime.EmbeddedServer in project teiid by teiid.
the class TestASTQueries method setUp.
@BeforeClass
public static void setUp() throws Exception {
server = new EmbeddedServer();
server.start(new EmbeddedConfiguration());
LoopbackExecutionFactory loopy = new LoopbackExecutionFactory();
loopy.setRowCount(10);
loopy.start();
server.addTranslator("l", loopy);
String DDL = "CREATE FOREIGN TABLE G1 (e1 string, e2 integer);";
ModelMetaData model = new ModelMetaData();
model.setName("PM1");
model.setModelType(Model.Type.PHYSICAL);
model.setSchemaSourceType("DDL");
model.setSchemaText(DDL);
SourceMappingMetadata sm = new SourceMappingMetadata();
sm.setName("loopy");
sm.setTranslatorName("l");
model.addSourceMapping(sm);
server.deployVDB("test", model);
}
use of org.teiid.runtime.EmbeddedServer in project teiid by teiid.
the class TestMaterializationPerformance method setup.
@Before
public void setup() {
es = new EmbeddedServer();
es.start(new EmbeddedConfiguration());
}
use of org.teiid.runtime.EmbeddedServer in project teiid by teiid.
the class TestTeiidPlatform method init.
@BeforeClass
public static void init() throws VirtualDatabaseException, ConnectorManagerException, TranslatorException, FileNotFoundException, IOException, ResourceException, SQLException {
server = new EmbeddedServer();
FileExecutionFactory executionFactory = new FileExecutionFactory();
server.addTranslator("file", executionFactory);
FileManagedConnectionFactory fileManagedconnectionFactory = new FileManagedConnectionFactory();
fileManagedconnectionFactory.setParentDirectory(UnitTestUtil.getTestDataPath() + File.separator + "file");
ConnectionFactory connectionFactory = fileManagedconnectionFactory.createConnectionFactory();
ConnectionFactoryProvider<ConnectionFactory> connectionFactoryProvider = new EmbeddedServer.SimpleConnectionFactoryProvider<ConnectionFactory>(connectionFactory);
server.addConnectionFactoryProvider("java:/marketdata-file", connectionFactoryProvider);
EmbeddedConfiguration config = new EmbeddedConfiguration();
server.start(config);
DriverManager.registerDriver(server.getDriver());
server.deployVDB(new FileInputStream(UnitTestUtil.getTestDataFile("vdb" + File.separator + "marketdata-vdb.xml")));
factory = Persistence.createEntityManagerFactory("org.teiid.eclipselink.test");
}
use of org.teiid.runtime.EmbeddedServer in project teiid by teiid.
the class TestRowBasedSecurity method testSecurity.
@Test
public void testSecurity() throws Exception {
es = new EmbeddedServer();
EmbeddedConfiguration ec = new EmbeddedConfiguration();
final Vector<Principal> v = new Vector<Principal>();
v.add(new Identity("myrole") {
});
final Subject subject = new Subject();
Group g = Mockito.mock(Group.class);
Mockito.stub(g.getName()).toReturn("Roles");
Mockito.stub(g.members()).toReturn((Enumeration) v.elements());
subject.getPrincipals().add(g);
ec.setSecurityHelper(new DoNothingSecurityHelper() {
@Override
public Subject getSubjectInContext(String securityDomain) {
return subject;
}
@Override
public Subject getSubjectInContext(Object context) {
return subject;
}
});
es.start(ec);
HardCodedExecutionFactory hcef = new HardCodedExecutionFactory() {
@Override
public void getMetadata(MetadataFactory metadataFactory, Object conn) throws TranslatorException {
Table t = metadataFactory.addTable("x");
Column col = metadataFactory.addColumn("col", TypeFacility.RUNTIME_NAMES.STRING, t);
metadataFactory.addColumn("col2", TypeFacility.RUNTIME_NAMES.STRING, t);
metadataFactory.addPermission("y", t, null, null, Boolean.TRUE, null, null, null, "col = 'a'", null);
metadataFactory.addColumnPermission("y", col, null, null, null, null, "null", null);
t = metadataFactory.addTable("y");
col = metadataFactory.addColumn("col", TypeFacility.RUNTIME_NAMES.STRING, t);
metadataFactory.addColumn("col2", TypeFacility.RUNTIME_NAMES.STRING, t);
metadataFactory.addPermission("z", t, null, null, null, null, null, null, "col = 'e'", null);
Table v = metadataFactory.addTable("v");
metadataFactory.addPermission("y", v, null, null, Boolean.TRUE, null, null, null, null, null);
col = metadataFactory.addColumn("col", TypeFacility.RUNTIME_NAMES.STRING, v);
metadataFactory.addColumn("col2", TypeFacility.RUNTIME_NAMES.STRING, v);
v.setTableType(Type.View);
v.setVirtual(true);
v.setSelectTransformation("/*+ cache(scope:session) */ select col, col2 from y");
}
@Override
public boolean isSourceRequiredForMetadata() {
return false;
}
};
hcef.addData("SELECT x.col, x.col2 FROM x", Arrays.asList(Arrays.asList("a", "b"), Arrays.asList("c", "d")));
hcef.addData("SELECT y.col, y.col2 FROM y", Arrays.asList(Arrays.asList("e", "f"), Arrays.asList("h", "g")));
es.addTranslator("hc", hcef);
es.deployVDB(new FileInputStream(UnitTestUtil.getTestDataFile("roles-vdb.xml")));
Connection c = es.getDriver().connect("jdbc:teiid:z;PassthroughAuthentication=true", null);
Statement s = c.createStatement();
ResultSet rs = s.executeQuery("select * from x");
rs.next();
// masking
assertEquals(null, rs.getString(1));
assertEquals("b", rs.getString(2));
// row filter
assertFalse(rs.next());
rs.close();
s = c.createStatement();
rs = s.executeQuery("select lookup('myschema.x', 'col', 'col2', 'b')");
rs.next();
// global scoped
assertEquals(null, rs.getString(1));
s = c.createStatement();
rs = s.executeQuery("select count(col2) from v where col is not null");
rs.next();
assertEquals(1, rs.getInt(1));
// different session with different roles
v.clear();
c = es.getDriver().connect("jdbc:teiid:z;PassthroughAuthentication=true", null);
s = c.createStatement();
rs = s.executeQuery("select count(col2) from v where col is not null");
rs.next();
assertEquals(2, rs.getInt(1));
}
Aggregations