Search in sources :

Example 1 with FakeService

use of org.teiid.transport.TestSocketRemoting.FakeService 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 2 with FakeService

use of org.teiid.transport.TestSocketRemoting.FakeService 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 3 with FakeService

use of org.teiid.transport.TestSocketRemoting.FakeService in project teiid by teiid.

the class TestCommSockets method testAutoFailoverPing.

@Test
public void testAutoFailoverPing() throws Exception {
    Properties p = new Properties();
    p.setProperty(TeiidURL.CONNECTION.AUTO_FAILOVER, "true");
    p.setProperty("org.teiid.sockets.synchronousttl", "20000");
    SocketServerConnection conn = helpEstablishConnection(false, new SSLConfiguration(), p);
    ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
    Future<?> future = exec.submit(new Runnable() {

        @Override
        public void run() {
            final FakeService fs = conn.getService(FakeService.class);
            ResultsFuture<Integer> f = fs.delayedAsynchResult();
            f.addCompletionListener(new CompletionListener<Integer>() {

                @Override
                public void onCompletion(ResultsFuture<Integer> future) {
                    // potentially recurrent;
                    fs.asynchResult();
                }
            });
            try {
                f.get();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    });
    future.get(19, TimeUnit.SECONDS);
}
Also used : ResultsFuture(org.teiid.client.util.ResultsFuture) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) CompletionListener(org.teiid.client.util.ResultsFuture.CompletionListener) FakeService(org.teiid.transport.TestSocketRemoting.FakeService) Properties(java.util.Properties) SocketServerConnection(org.teiid.net.socket.SocketServerConnection) SessionServiceException(org.teiid.dqp.service.SessionServiceException) CommunicationException(org.teiid.net.CommunicationException) ConnectionException(org.teiid.net.ConnectionException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 SocketServerConnection (org.teiid.net.socket.SocketServerConnection)3 FakeService (org.teiid.transport.TestSocketRemoting.FakeService)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Serializable (java.io.Serializable)1 StringReader (java.io.StringReader)1 Properties (java.util.Properties)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ResultsFuture (org.teiid.client.util.ResultsFuture)1 CompletionListener (org.teiid.client.util.ResultsFuture.CompletionListener)1 SessionServiceException (org.teiid.dqp.service.SessionServiceException)1 CommunicationException (org.teiid.net.CommunicationException)1 ConnectionException (org.teiid.net.ConnectionException)1