Search in sources :

Example 6 with SocketConfiguration

use of org.teiid.transport.SocketConfiguration in project teiid by teiid.

the class TestInternalConnection method testInternalRemote.

@Test
public void testInternalRemote() throws Exception {
    SocketConfiguration s = new SocketConfiguration();
    InetSocketAddress addr = new InetSocketAddress(0);
    s.setBindAddress(addr.getHostName());
    s.setPortNumber(addr.getPort());
    s.setProtocol(WireProtocol.teiid);
    EmbeddedConfiguration config = new EmbeddedConfiguration();
    config.addTransport(s);
    config.setSecurityHelper(new ThreadLocalSecurityHelper());
    es.start(config);
    es.deployVDB(new ByteArrayInputStream(vdb.getBytes()));
    Connection conn = null;
    try {
        TeiidDriver driver = new TeiidDriver();
        Properties p = new Properties();
        p.setProperty("user", "me");
        conn = driver.connect("jdbc:teiid:test@mm://" + addr.getHostName() + ":" + es.getPort(0), p);
        ResultSet rs = conn.createStatement().executeQuery("select func(1)");
        rs.next();
        assertEquals("me@teiid-securityHELLO WORLD1", rs.getString(1));
    } finally {
        if (conn != null) {
            conn.close();
        }
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InetSocketAddress(java.net.InetSocketAddress) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) SocketConfiguration(org.teiid.transport.SocketConfiguration) EmbeddedConfiguration(org.teiid.runtime.EmbeddedConfiguration) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

SocketConfiguration (org.teiid.transport.SocketConfiguration)6 InetSocketAddress (java.net.InetSocketAddress)5 Test (org.junit.Test)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 SSLConfiguration (org.teiid.transport.SSLConfiguration)3 Properties (java.util.Properties)2 TeiidDriver (org.teiid.jdbc.TeiidDriver)2 EmbeddedConfiguration (org.teiid.runtime.EmbeddedConfiguration)2 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BeforeClass (org.junit.BeforeClass)1 Driver (org.postgresql.Driver)1 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)1 FakeServer (org.teiid.jdbc.FakeServer)1 QueryExpression (org.teiid.language.QueryExpression)1 HardCodedExecutionFactory (org.teiid.runtime.HardCodedExecutionFactory)1 SocketListener (org.teiid.transport.SocketListener)1