Search in sources :

Example 11 with SocketServerConnection

use of org.teiid.net.socket.SocketServerConnection in project teiid by teiid.

the class TestCommSockets method testConnectWithoutPooling.

@Test
public void testConnectWithoutPooling() throws Exception {
    Properties p = new Properties();
    // $NON-NLS-1$
    p.setProperty("org.teiid.sockets.maxCachedInstances", String.valueOf(0));
    SocketServerConnection conn = helpEstablishConnection(false, new SSLConfiguration(), p);
    SocketListenerStats stats = listener.getStats();
    // handshake response, logon,
    assertEquals(2, stats.objectsRead);
    assertEquals(1, stats.sockets);
    conn.close();
    stats = listener.getStats();
    assertEquals(1, stats.maxSockets);
    // handshake response, logon, logoff
    assertEquals(3, stats.objectsRead);
    if (stats.sockets > 0) {
        // there is a timing issue here, since the effect of shutdown on the
        // server side can be delayed
        Thread.sleep(500);
    }
    stats = listener.getStats();
    assertEquals(0, stats.sockets);
}
Also used : Properties(java.util.Properties) SocketServerConnection(org.teiid.net.socket.SocketServerConnection) Test(org.junit.Test)

Example 12 with SocketServerConnection

use of org.teiid.net.socket.SocketServerConnection in project teiid by teiid.

the class TestCommSockets method testSSLConnectWithNonSSLServer.

@Test
public void testSSLConnectWithNonSSLServer() throws Exception {
    // first make a non-ssl connection to ensure that it's not reused
    SocketServerConnection conn = helpEstablishConnection(false);
    conn.close();
    try {
        helpEstablishConnection(true);
        // $NON-NLS-1$
        fail("exception expected");
    } catch (CommunicationException e) {
    }
}
Also used : CommunicationException(org.teiid.net.CommunicationException) SocketServerConnection(org.teiid.net.socket.SocketServerConnection) Test(org.junit.Test)

Aggregations

SocketServerConnection (org.teiid.net.socket.SocketServerConnection)12 Test (org.junit.Test)10 Properties (java.util.Properties)6 CommunicationException (org.teiid.net.CommunicationException)4 FakeService (org.teiid.transport.TestSocketRemoting.FakeService)3 ResultsFuture (org.teiid.client.util.ResultsFuture)2 ConnectionException (org.teiid.net.ConnectionException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 StringReader (java.io.StringReader)1 InetSocketAddress (java.net.InetSocketAddress)1 UnknownHostException (java.net.UnknownHostException)1 ExecutionException (java.util.concurrent.ExecutionException)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 SSLContext (javax.net.ssl.SSLContext)1 DQP (org.teiid.client.DQP)1 ILogon (org.teiid.client.security.ILogon)1 InvalidSessionException (org.teiid.client.security.InvalidSessionException)1 LogonException (org.teiid.client.security.LogonException)1