@Test public void testTraslators() throws Exception { Collection<? extends Translator> translators = admin.getTranslators(); assertEquals(38, translators.size()); JavaArchive jar = getLoopyArchive(); try { admin.deploy("loopy.jar", jar.as(ZipExporter.class).exportAsInputStream()); VDBTranslatorMetaData t = (VDBTranslatorMetaData) admin.getTranslator("loopy"); assertNotNull(t); assertEquals("ANY", t.getPropertyValue("SupportedJoinCriteria")); assertEquals("true", t.getPropertyValue("supportsSelectDistinct")); } finally { admin.undeploy("loopy.jar"); } VDBTranslatorMetaData t = (VDBTranslatorMetaData) admin.getTranslator("orcl"); assertNull(t); }
@Test public void testGetRequests() throws Exception { JavaArchive jar = getLoopyArchive(); try { admin.deploy("loopy.jar", jar.as(ZipExporter.class).exportAsInputStream()); deployVdb(); Translator t = admin.getTranslator("loopy"); assertNotNull(t); admin.updateSource("bqt", 1, "Source", "loopy", "java:jboss/datasources/ExampleDS"); Connection conn = TeiidDriver.getInstance() .connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user", null); Collection<? extends Session> sessions = admin.getSessions(); assertEquals(1, sessions.size()); Session s = sessions.iterator().next(); Statement stmt = conn.createStatement(); Collection<? extends Request> requests = admin.getRequests(); assertEquals(0, requests.size()); stmt.execute("select * from source.smalla"); requests = admin.getRequests(); assertEquals(1, requests.size()); Request r = requests.iterator().next(); assertEquals("select * from source.smalla", r.getCommand()); assertNotNull(r.getExecutionId()); assertNotNull(r.getSessionId()); stmt.execute("select * from source.smalla"); Collection<? extends Request> requests2 = admin.getRequestsForSession(s.getSessionId()); assertEquals(1, requests2.size()); Request r2 = requests.iterator().next(); assertEquals("select * from source.smalla", r2.getCommand()); assertEquals(s.getSessionId(), r2.getSessionId()); stmt.close(); conn.close(); requests = admin.getRequests(); assertEquals(0, requests.size()); } finally { admin.undeploy("loopy.jar"); } }