use of org.teiid.core.util.ReaderInputStream in project teiid by teiid.
the class IntegrationTestOData4 method testCompositeKeyTimestamp.
// TEIID-3914 - test the olingo-patch work
@Test
public void testCompositeKeyTimestamp() throws Exception {
String vdb = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<vdb name=\"Loopy\" version=\"1\">\n" + " <model name=\"m\">\n" + " <source name=\"x1\" translator-name=\"loopback\" />\n" + " <metadata type=\"DDL\"><![CDATA[\n" + " CREATE FOREIGN TABLE x (a string, b timestamp, c integer, primary key (a, b)) 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));
WebClient client = WebClient.create("http://localhost:8080/odata4/Loopy/m/x(a='a',b=2011-09-11T00:00:00Z)");
// $NON-NLS-1$ //$NON-NLS-2$
client.header("Authorization", "Basic " + Base64.encodeBytes(("user:user").getBytes()));
Response response = client.invoke("GET", null);
assertEquals(200, response.getStatus());
client = WebClient.create("http://localhost:8080/odata4/Loopy/m/x");
// $NON-NLS-1$ //$NON-NLS-2$
client.header("Authorization", "Basic " + Base64.encodeBytes(("user:user").getBytes()));
client.header("Content-Type", "application/json");
response = client.post("{\"a\":\"b\", \"b\":\"2000-02-02T22:22:22Z\"}");
assertEquals(304, response.getStatus());
admin.undeploy("loopy-vdb.xml");
}
use of org.teiid.core.util.ReaderInputStream in project teiid by teiid.
the class IntegrationTestOData4 method testCORS.
@Test
public void testCORS() 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 G1 (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));
WebClient client = WebClient.create("http://localhost:8080/odata4/loopy.1/MarketData/$metadata");
Response response = client.invoke("OPTIONS", null);
int statusCode = response.getStatus();
assertEquals(400, statusCode);
/* setting of Origin header is blocked HttpUrlConnection
client = WebClient.create("http://localhost:8080/odata4/loopy.1/MarketData/$metadata");
client.header("Origin", "foo.bar"); //$NON-NLS-1$ //$NON-NLS-2$
response = client.invoke("OPTIONS", null);
assertEquals(204, response.getStatus());
assertEquals("GET,POST,PUT,PATCH,DELETE", response.getHeaderString("Access-Control-Allow-Methods"));
assertEquals("foo.bar", response.getHeaderString("Access-Control-Allow-Origin"));
assertEquals("true", response.getHeaderString("Access-Control-Allow-Credentials"));
assertEquals("Content-Type,Accept,Origin,Authorization", response.getHeaderString("Access-Control-Allow-Headers"));
*/
}
use of org.teiid.core.util.ReaderInputStream in project teiid by teiid.
the class IntegrationTestOData4 method testOdataMetadataError.
@Test
public void testOdataMetadataError() 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 G1 (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));
WebClient client = WebClient.create("http://localhost:8080/odata4/loopy.1/MarketData/$metadata");
// $NON-NLS-1$ //$NON-NLS-2$
client.header("Authorization", "Basic " + Base64.encodeBytes(("user:user").getBytes()));
Response response = client.invoke("GET", null);
int statusCode = response.getStatus();
assertEquals(404, statusCode);
}
use of org.teiid.core.util.ReaderInputStream in project teiid by teiid.
the class IntegrationTestOData4 method testReadOdataMetadata.
@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://localhost:8080/odata4/Loopy.1/MarketData");
p.setProperty("SecurityType", "HTTPBasic");
p.setProperty("AuthUserName", "user");
p.setProperty("AuthPassword", "user");
admin.createDataSource("TestOData4", "webservice", p);
admin.deploy("test-vdb.xml", new ReaderInputStream(new StringReader(vdb2), Charset.forName("UTF-8")));
assertTrue(AdminUtil.waitForVDBLoad(admin, "TestOData", 1, 30000));
this.internalConnection = TeiidDriver.getInstance().connect("jdbc:teiid:TestOData@mm://localhost:31000;user=user;password=user", null);
// $NON-NLS-1$
execute("SELECT Name FROM Sys.Tables Where name='G1'");
assertResultsSetEquals("Name[string]\nG1");
// $NON-NLS-1$
execute("SELECT * from G1");
assertResultsSetEquals("e1[string[]] e2[integer]\n[ABCDEFGHIJ] 0");
admin.undeploy("loopy-vdb.xml");
admin.undeploy("test-vdb.xml");
}
use of org.teiid.core.util.ReaderInputStream in project teiid by teiid.
the class IntegrationTestOData4 method testOdata.
@Test
public void testOdata() 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));
WebClient client = WebClient.create("http://localhost:8080/odata4/loopy.1/MarketData/$metadata");
// $NON-NLS-1$ //$NON-NLS-2$
client.header("Authorization", "Basic " + Base64.encodeBytes(("user:user").getBytes()));
Response response = client.invoke("GET", null);
int statusCode = response.getStatus();
assertEquals(200, statusCode);
Connection conn = TeiidDriver.getInstance().connect("jdbc:teiid:loopy@mm://localhost:31000;user=user;password=user", null);
PreparedStatement ps = conn.prepareCall("select t.* from xmltable('/*:Edmx/*:DataServices/*:Schema[@Alias=\"MarketData\"]' passing xmlparse(document cast(? as clob))) as t");
ps.setAsciiStream(1, (InputStream) response.getEntity());
ResultSet rs = ps.executeQuery();
rs.next();
assertEquals(ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("loopy-metadata4-results.txt")), rs.getString(1));
conn.close();
// try an invalid url
client = WebClient.create("http://localhost:8080/odata4/x/y$metadata");
// $NON-NLS-1$ //$NON-NLS-2$
client.header("Authorization", "Basic " + Base64.encodeBytes(("user:user").getBytes()));
response = client.invoke("GET", null);
assertEquals(404, response.getStatus());
admin.undeploy("loopy-vdb.xml");
}
Aggregations