public void testGetDatasourceProperties() throws Exception { Properties props = new Properties(); props.setProperty("connection-url", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"); props.setProperty("user-name", "sa"); props.setProperty("password", "sa"); props.setProperty("connection-properties", "foo=bar,blah=blah"); props.setProperty("max-pool-size", "4"); admin.createDataSource("Oracle11_PushDS", "h2", props); Properties p = admin.getDataSource("Oracle11_PushDS"); assertEquals("4", p.getProperty("max-pool-size")); assertEquals("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", p.getProperty("connection-url")); admin.deleteDataSource("Oracle11_PushDS"); p = new Properties(); p.setProperty("class-name", "org.teiid.resource.adapter.ws.WSManagedConnectionFactory"); p.setProperty("EndPoint", "{endpoint}"); props.setProperty("max-pool-size", "4"); admin.createDataSource("nowhere", "teiid-connector-ws.rar", p); assertEquals( "org.teiid.resource.adapter.ws.WSManagedConnectionFactory", p.getProperty("class-name")); assertEquals("4", p.getProperty("max-pool-size")); assertEquals("{endpoint}", p.getProperty("EndPoint")); admin.deleteDataSource("nowhere"); }
@Test public void testReadOdataMetadata() throws Exception { String vdb = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<vdb name=\"Loopy\" version=\"1\">\n" + " <model name=\"MarketData\">\n" + " <source name=\"text-connector2\" translator-name=\"loopback\" />\n" + " <metadata type=\"DDL\"><![CDATA[\n" + " CREATE FOREIGN TABLE G1 (e1 string[], e2 integer PRIMARY KEY);\n" + " CREATE FOREIGN TABLE G2 (e1 string, e2 integer PRIMARY KEY) OPTIONS (UPDATABLE 'true');\n" + " ]]> </metadata>\n" + " </model>\n" + "</vdb>"; admin.deploy( "loopy-vdb.xml", new ReaderInputStream(new StringReader(vdb), Charset.forName("UTF-8"))); assertTrue(AdminUtil.waitForVDBLoad(admin, "Loopy", 1, 3)); String vdb2 = "<?xml version='1.0' encoding='UTF-8'?>\n" + "<vdb name=\"TestOData\" version=\"1\">\n" + " <model name=\"TestOData\" type=\"PHYSICAL\" visible=\"true\">\n" + " <property name=\"importer.entityContainer\" value=\"MarketData\"/>\n" + " <property name=\"importer.schemaNamespace\" value=\"MarketData\"/>\n" + " <source name=\"TestOData\" translator-name=\"odata4\" connection-jndi-name=\"java:/TestOData4\"/>\n" + " </model>\n" + "</vdb>"; Properties p = new Properties(); p.setProperty("class-name", "org.teiid.resource.adapter.ws.WSManagedConnectionFactory"); p.setProperty("EndPoint", "http://*****:*****@mm://localhost:31000;user=user;password=user", null); execute("SELECT Name FROM Sys.Tables Where name='G1'"); // $NON-NLS-1$ assertResultsSetEquals("Name[string]\nG1"); execute("SELECT * from G1"); // $NON-NLS-1$ assertResultsSetEquals("e1[string[]] e2[integer]\n[ABCDEFGHIJ] 0"); admin.undeploy("loopy-vdb.xml"); admin.undeploy("test-vdb.xml"); }
@Test public void testCreateConnectionFactory() throws Exception { String deployedName = "wsOne"; assertFalse(admin.getDataSourceNames().contains(deployedName)); Properties p = new Properties(); p.setProperty("class-name", "org.teiid.resource.adapter.ws.WSManagedConnectionFactory"); p.setProperty("EndPoint", "{endpoint}"); admin.createDataSource(deployedName, "webservice", p); assertTrue(admin.getDataSourceNames().contains(deployedName)); admin.deleteDataSource(deployedName); assertFalse(admin.getDataSourceNames().contains(deployedName)); admin.createDataSource(deployedName, "webservice", p); assertTrue(admin.getDataSourceNames().contains(deployedName)); admin.deleteDataSource(deployedName); }
@Test public void testVDBDeployment() throws Exception { Collection<?> vdbs = admin.getVDBs(); assertTrue(vdbs.isEmpty()); Collection<String> dsNames = admin.getDataSourceNames(); if (dsNames.contains("Oracle11_PushDS")) { admin.deleteDataSource("Oracle11_PushDS"); } admin.deploy("bqt.vdb", new FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb"))); vdbs = admin.getVDBs(); assertFalse(vdbs.isEmpty()); VDB vdb = admin.getVDB("bqt", 1); assertFalse(vdb.isValid()); assertTrue(AdminUtil.waitForVDBLoad(admin, "bqt", 1, 3)); assertFalse(vdb.isValid()); Properties props = new Properties(); props.setProperty("connection-url", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"); props.setProperty("user-name", "sa"); props.setProperty("password", "sa"); props.setProperty("connection-properties", "foo=bar,blah=blah"); admin.createDataSource("Oracle11_PushDS", "h2", props); vdb = admin.getVDB("bqt", 1); assertTrue(vdb.isValid()); assertTrue(vdb.getStatus().equals(Status.ACTIVE)); dsNames = admin.getDataSourceNames(); assertTrue(dsNames.contains("Oracle11_PushDS")); admin.deleteDataSource("Oracle11_PushDS"); vdb = admin.getVDB("bqt", 1); assertFalse(vdb.isValid()); }