Search in sources :

Example 1 with SocketServerConnection

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

the class TestCommSockets method testConnectWithoutClientEncryption.

@Test
public void testConnectWithoutClientEncryption() throws Exception {
    SSLConfiguration config = new SSLConfiguration();
    config.setMode(SSLConfiguration.DISABLED);
    SocketServerConnection conn = helpEstablishConnection(false, config, new Properties());
    assertTrue(conn.selectServerInstance(false).getCryptor() instanceof NullCryptor);
    conn.close();
}
Also used : Properties(java.util.Properties) SocketServerConnection(org.teiid.net.socket.SocketServerConnection) NullCryptor(org.teiid.core.crypto.NullCryptor) Test(org.junit.Test)

Example 2 with SocketServerConnection

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

the class TestCommSockets method testLobs.

@Test
public void testLobs() throws Exception {
    SocketServerConnection conn = helpEstablishConnection(false);
    FakeService fs = conn.getService(FakeService.class);
    assertEquals(150, fs.lobMethod(new ByteArrayInputStream(new byte[100]), new StringReader(new String(new char[50]))));
    assertEquals(2, storageManager.getCreated());
    assertEquals(2, storageManager.getRemoved());
    assertEquals(0, fs.lobMethod(new ByteArrayInputStream(new byte[0]), new StringReader(new String(new char[0]))));
    assertEquals(4, storageManager.getCreated());
    assertEquals(4, storageManager.getRemoved());
    assertEquals((1 << 17) + 50, fs.lobMethod(new ByteArrayInputStream(new byte[1 << 17]), new StringReader(new String(new char[50]))));
    assertEquals(6, storageManager.getCreated());
    assertEquals(6, storageManager.getRemoved());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) StringReader(java.io.StringReader) FakeService(org.teiid.transport.TestSocketRemoting.FakeService) SocketServerConnection(org.teiid.net.socket.SocketServerConnection) Test(org.junit.Test)

Example 3 with SocketServerConnection

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

the class TestCommSockets method testServerRemoteStreaming.

@Test
public void testServerRemoteStreaming() throws Exception {
    SocketServerConnection conn = helpEstablishConnection(false);
    FakeService fs = conn.getService(FakeService.class);
    assertEquals("hello world", ObjectConverterUtil.convertToString(fs.getReader()));
    assertTrue(Serializable.class.isAssignableFrom(fs.getReader().getClass()));
}
Also used : Serializable(java.io.Serializable) FakeService(org.teiid.transport.TestSocketRemoting.FakeService) SocketServerConnection(org.teiid.net.socket.SocketServerConnection) Test(org.junit.Test)

Example 4 with SocketServerConnection

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

the class TestCommSockets method helpTestNewInstance.

private void helpTestNewInstance(Properties p) throws CommunicationException, ConnectionException, SessionServiceException {
    SSLConfiguration config = new SSLConfiguration();
    SocketServerConnection conn = helpEstablishConnection(false, config, p);
    SocketListenerStats stats = listener.getStats();
    // handshake response, logon,
    assertEquals(2, stats.objectsRead);
    assertEquals(1, stats.sockets);
    conn.cleanUp();
    assertEquals(1, this.service.getActiveSessionsCount());
    ServerConnection conn2 = helpEstablishConnection(false, config, p);
    assertEquals(2, this.service.getActiveSessionsCount());
    conn.selectServerInstance(false);
    assertEquals(2, this.service.getActiveSessionsCount());
    assertTrue(conn.isOpen(10000));
    stats = listener.getStats();
    // (ping (pool test), assert identityx2, ping (isOpen))x2
    assertEquals(8, stats.objectsRead);
    assertEquals(2, stats.sockets);
    conn.close();
    conn2.close();
}
Also used : SocketServerConnection(org.teiid.net.socket.SocketServerConnection) ServerConnection(org.teiid.net.ServerConnection) SocketServerConnection(org.teiid.net.socket.SocketServerConnection)

Example 5 with SocketServerConnection

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

the class TestFailover method testFailover.

@Test
public void testFailover() throws Exception {
    SSLConfiguration config = new SSLConfiguration();
    Properties p = new Properties();
    SocketServerConnection conn = helpEstablishConnection(false, config, p);
    assertTrue(conn.isOpen(1000));
    assertEquals(1, logonAttempts);
    // restart the second instance now that we know the connection was made to the first
    listener1 = createListener(new InetSocketAddress(addr.getAddress(), listener1.getPort()), config);
    listener.stop().await();
    // there is a chance this call can fail
    conn.isOpen(1000);
    assertTrue(conn.isOpen(1000));
    assertEquals(2, logonAttempts);
    listener1.stop().await();
    // both instances are down
    assertFalse(conn.isOpen(1000));
    // bring the first back up
    listener = createListener(new InetSocketAddress(addr.getAddress(), listener.getPort()), config);
    assertTrue(conn.isOpen(1000));
    assertEquals(3, logonAttempts);
    conn.close();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Properties(java.util.Properties) 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