Package org.teiid.net.socket

Examples of org.teiid.net.socket.SocketServerConnection


  }

  @Test public void testConnectWithoutPooling() throws Exception {
    Properties p = new Properties();
    p.setProperty("org.teiid.sockets.maxCachedInstances", String.valueOf(0)); //$NON-NLS-1$
    SocketServerConnection conn = helpEstablishConnection(false, new SSLConfiguration(), p);
    SocketListenerStats stats = listener.getStats();
    assertEquals(2, stats.objectsRead); // handshake response, logon,
    assertEquals(1, stats.sockets);
    conn.close();
    stats = listener.getStats();
    assertEquals(1, stats.maxSockets);
    assertEquals(3, stats.objectsRead); // handshake response, logon, logoff
    if (stats.sockets > 0) {
      // there is a timing issue here, since the effect of shutdown on the
View Full Code Here


    stats = listener.getStats();
    assertEquals(0, stats.sockets);
  }
 
  @Test public void testConnectWithPooling() throws Exception {
    SocketServerConnection conn = helpEstablishConnection(false);
    SocketListenerStats stats = listener.getStats();
    assertEquals(2, stats.objectsRead); // handshake response, logon,
    assertEquals(1, stats.sockets);
    conn.close();
    stats = listener.getStats();
    assertEquals(1, stats.maxSockets);
    assertEquals(3, stats.objectsRead); // handshake response, logon, logoff
    stats = listener.getStats();
    assertEquals(1, stats.sockets);
    conn = helpEstablishConnection(false);
    conn.close();
    stats = listener.getStats();
    assertEquals(1, stats.sockets);
    assertEquals(1, stats.maxSockets);
  }
View Full Code Here

    assertEquals(1, stats.sockets);
    assertEquals(1, stats.maxSockets);
  }

  @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());
View Full Code Here

    assertEquals(6, storageManager.getCreated());
    assertEquals(6, storageManager.getRemoved());
  }
 
  @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()));
  }
View Full Code Here

  }

  @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();
  }
View Full Code Here

    return sscf.getConnection(p);
  }

  @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);
      fail("exception expected"); //$NON-NLS-1$
    } catch (CommunicationException e) {
     
View Full Code Here

    config.setMode(SSLConfiguration.ENABLED);
    config.setAuthenticationMode(SSLConfiguration.ANONYMOUS);
    Properties p = new Properties();
    p.setProperty("org.teiid.sockets.soTimeout", "100");
    helpEstablishConnection(true, config, p);
    SocketServerConnection conn = helpEstablishConnection(true, config, p);
    conn.close();
   
    try {
      helpEstablishConnection(false, config, p);
    } catch (CommunicationException e) {
     
View Full Code Here

  }
 
  @Test public void testSelectNewInstance() throws Exception {
    SSLConfiguration config = new SSLConfiguration();
    Properties p = new Properties();
    SocketServerConnection conn = helpEstablishConnection(false, config, p);
    SocketListenerStats stats = listener.getStats();
    assertEquals(2, stats.objectsRead); // handshake response, logon,
    assertEquals(1, stats.sockets);
    conn.cleanUp();
    assertTrue(conn.isOpen(1000));
    stats = listener.getStats();
    assertEquals(5, stats.objectsRead); // ping (pool test), assert identity, ping (isOpen)
    assertEquals(1, stats.sockets);
    conn.close();
  }
View Full Code Here

        }

      }, "foo"); //$NON-NLS-1$
    csr.registerClientService(FakeService.class, new FakeServiceImpl(), "foo"); //$NON-NLS-1$
    final FakeClientServerInstance serverInstance = new FakeClientServerInstance(csr);
    SocketServerConnection connection = createFakeConnection(serverInstance);
    ILogon logon = connection.getService(ILogon.class);
    Future<?> result = logon.ping();
    assertNull(result.get(0, TimeUnit.MILLISECONDS));
    result = logon.logoff();
    try {
      result.get(0, TimeUnit.MICROSECONDS);
      fail("exception expected"); //$NON-NLS-1$
    } catch (ExecutionException e) {
      assertTrue(e.getCause() instanceof TeiidComponentException);
    }
    FakeService service = connection.getService(FakeService.class);
    Future<Integer> asynchInteger = service.asynchResult();
    assertEquals(new Integer(5), asynchInteger.get(0, TimeUnit.MILLISECONDS));
    try {
      service.exceptionMethod();
      fail("exception expected"); //$NON-NLS-1$
    } catch (TeiidProcessingException e) {
     
    }
    DQP dqp = connection.getService(DQP.class);
    try {
      ResultsFuture<?> future = dqp.begin();
      future.get();
      fail("exception expected"); //$NON-NLS-1$
    } catch (Exception e) {
View Full Code Here

  }

  private SocketServerConnection createFakeConnection(
      final FakeClientServerInstance serverInstance)
      throws CommunicationException, ConnectionException {
    SocketServerConnection connection = new SocketServerConnection(new SocketServerInstanceFactory() {
   
      @Override
      public SocketServerInstance getServerInstance(HostInfo info)
          throws CommunicationException, IOException {
        return serverInstance;
View Full Code Here

TOP

Related Classes of org.teiid.net.socket.SocketServerConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.