Package org.jboss.remoting

Examples of org.jboss.remoting.Client


      InvokerLocator clientLocator = new InvokerLocator(locatorURI);
      HashMap clientConfig = new HashMap();
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
      clientConfig.put(InvokerLocator.DATATYPE, "config");
      addExtraClientConfig(clientConfig);
      Client client = new Client(clientLocator, clientConfig);
      client.connect();
      log.info("client is connected");
     
      // Test connections.
      assertEquals("abc", client.invoke("abc"));
      log.info("connection is good");
     
      // Configure callbacks.
      TestCallbackHandler callbackHandler = new TestCallbackHandler();
      client.addListener(callbackHandler, new HashMap());
     
      // Do tests.
      assertTrue(ConfigTestMarshaller.ok(false, 4));
      assertTrue(ConfigTestUnmarshaller.ok(false, 0));
      assertTrue(LocatorTestMarshaller.ok());
      assertTrue(LocatorTestUnmarshaller.ok());
      assertEquals(1, callbackHandler.counter);
     
      client.disconnect();
      shutdownServer();
      log.info(getName() + " PASSES");
   }
View Full Code Here


      HashMap config = new HashMap();
      config.put(InvokerLocator.FORCE_REMOTE, "true");
      config.put(ServerInvoker.TIMEOUT, "60000");
      config.put(Client.ENABLE_LEASE, "true");
      addClientConfig(config);
      final Client client = new Client(locator, config);
      try
      {
         client.connect();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
      log.info("making first invocation");
      Object response = client.invoke("test");
      assertEquals("test", response);
      log.info("first invocation succeeds");
     
     
      new Thread()
      {
         public void run()
         {
            try
            {
               // Wait for the server to be disabled.
               Thread.sleep(10000);
              
               try
               {
               // This invocation may use up a listening connection,
               // depending on transport.
                  HashMap metadata = new HashMap();
                  metadata.put("timeout", shortTimeoutString());
                  log.info("making invocation");
                  client.invoke("test", metadata);
                  log.info("made invocation");
               }
               catch (Exception e)
               {
                  log.info("client.invoke(\"test\") failed (that's OK)");
               }
              
              
               // Set disconnectTimeout to 1 second.
               log.info("calling client.disconnect()");
               client.setDisconnectTimeout(shortTimeout());
               client.disconnect();
               log.info("returned from client.disconnect()");
            }
            catch (Throwable e)
            {
               log.info("error in client.disconnect()", e);
            }
         }
      }.start();
     
      // It should take the Client a little while for LeasePinger's attempts to contact
      // the server to time out.  Wait for about 4 seconds after the call to
      // Client.disconnect() and then verify that the Client has successfully
      // disconnected even though the server is disabled.
      Thread.sleep(16000);
      assertFalse(client.isConnected());
      log.info(getName() + " PASSES");
   }
View Full Code Here

      connector.addInvocationHandler("test", handler);
      connector.start();
     
      HashMap clientConfig = new HashMap();
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
      Client client = new Client(locator, clientConfig);
      client.connect();
     
      int INVOCATIONS = 1000;
      OnewayThread[] threads = new OnewayThread[INVOCATIONS];
     
      for (int i = 0; i < INVOCATIONS; i++)
      {
         threads[i] = new OnewayThread(client, i, false);
         threads[i].start();
      }
     
      go = true;
      poolCounter++;
      Thread.sleep(10000);
     
      // Verify INVOCATION invocations were received.
      assertEquals(INVOCATIONS, handler.startedCount);
     
      for (int i = 0; i < INVOCATIONS; i++)
      {
         assertTrue("failure in thread: " + i, threads[i].ok);
      }
     
      // Verify only one thread pool was created.
      Field field = ServerInvoker.class.getDeclaredField("onewayThreadPool");
      field.setAccessible(true);
      Object pool = field.get(connector.getServerInvoker());
      assertTrue(pool instanceof BasicThreadPool);
      BasicThreadPool basicThreadPool = (BasicThreadPool) pool;
      assertEquals(poolCounter, basicThreadPool.getPoolNumber());
     
      client.disconnect();
      connector.stop();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      HashMap clientConfig = new HashMap();
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
      clientConfig.put(InvokerLocator.DATATYPE, "config");
      clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false");
      addExtraClientConfig(clientConfig);
      Client client = new Client(clientLocator, clientConfig);
      client.connect();
      log.info("client is connected");
     
      // Test connections.
      assertEquals("abc", client.invoke("abc"));
      log.info("connection is good");
     
      // Configure callbacks.
      TestCallbackHandler callbackHandler = new TestCallbackHandler();
      client.addListener(callbackHandler, new HashMap());
     
      // Do tests.
      assertTrue(ConfigTestMarshaller.ok(false, 4));
      assertTrue(ConfigTestUnmarshaller.ok(false, 0));
      assertTrue(LocatorTestMarshaller.ok());
      assertTrue(LocatorTestUnmarshaller.ok());
      assertEquals(1, callbackHandler.counter);
     
      client.disconnect();
      shutdownServer();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      HashMap clientConfig = new HashMap();
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
      clientConfig.put(InvokerLocator.DATATYPE, "config");
      clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "true");
      addExtraClientConfig(clientConfig);
      Client client = new Client(clientLocator, clientConfig);
      client.connect();
      log.info("client is connected");
     
      // Test connections.
      assertEquals("abc", client.invoke("abc"));
      log.info("connection is good");
     
      // Configure callbacks.
      TestCallbackHandler callbackHandler = new TestCallbackHandler();
      client.addListener(callbackHandler, new HashMap());
     
      // Do tests.
      assertTrue(ConfigTestMarshaller.ok(true, 16));
      assertTrue(ConfigTestUnmarshaller.ok(true, 8));
      assertTrue(LocatorTestMarshaller.ok());
      assertTrue(LocatorTestUnmarshaller.ok());
      assertEquals(1, callbackHandler.counter);
     
      client.disconnect();
      shutdownServer();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      HashMap config = new HashMap();
      config.put(InvokerLocator.FORCE_REMOTE, "true");
      config.put(ServerInvoker.TIMEOUT, "60000");
      config.put(Client.ENABLE_LEASE, "true");
      addClientConfig(config);
      final Client client = new Client(locator, config);
      try
      {
         client.connect();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
      log.info("making first invocation");
      Object response = client.invoke("test");
      assertEquals("test", response);
      log.info("first invocation succeeds");
     
      Thread t = new Thread()
      {
         public void run()
         {
            try
            {
               // Wait for the server to be disabled.
               Thread.sleep(10000);
              
               try
               {
               // This invocation may use up a listening connection,
               // depending on transport.
                  HashMap metadata = new HashMap();
                  metadata.put("timeout", shortTimeoutString());
                  log.info("making invocation");
                  client.invoke("test", metadata);
                  log.info("made invocation");
               }
               catch (Exception e)
               {
                  log.info("client.invoke(\"test\") failed (that's OK)");
               }

               log.info("calling client.disconnect()");
               client.disconnect();
               log.info("returned from client.disconnect()");
            }
            catch (Throwable e)
            {
               log.info("error in client.disconnect()", e);
            }
         }
      };
     
      t.setDaemon(true);
      t.start();
     
      // Since no disconnectTimeout has been specified, timeout value specified
      // when the Client was created, 60 seconds, will apply.  The client should
      // not be disconnected after rougly 8 seconds.
      Thread.sleep(20000);
      assertTrue(client.isConnected());
      log.info(getName() + " PASSES");
   }
View Full Code Here

      HashMap clientConfig = new HashMap();
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
      clientConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName());
      clientConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName());
      addExtraClientConfig(clientConfig);
      Client client = new Client(clientLocator, clientConfig);
      client.connect();
      log.info("client is connected");
     
      // Test connections.
      assertEquals("abc", client.invoke("abc"));
      log.info("connection is good");
     
      // Do callback.
      // Configure callbacks.
      TestCallbackHandler callbackHandler = new TestCallbackHandler();
      client.addListener(callbackHandler, new HashMap());
     
      // Do tests.
      assertTrue(ConfigTestMarshaller.ok(false, 2));
      assertTrue(ConfigTestUnmarshaller.ok(false, 0));
      assertTrue(LocatorTestMarshaller.ok());
      assertTrue(LocatorTestUnmarshaller.ok());
      assertEquals(1, callbackHandler.counter);
     
      client.disconnect();
      shutdownServer();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      // Create client.
      InvokerLocator clientLocator = new InvokerLocator(locatorURI);
      HashMap clientConfig = new HashMap();
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
      addExtraClientConfig(clientConfig);
      Client client = new Client(clientLocator, clientConfig);
      client.connect();
      log.info("client is connected");
     
      // Test connections.
      try
      {
         Object response = client.invoke("abc");
         fail("expected CannotConnectException, got: " + response);
      }
      catch (CannotConnectException e)
      {
         String message = e.getMessage();
         assertTrue("expected CannotConnectException message to contain \"Invalid URI\"", message != null && message.indexOf("Invalid URI") > 0);
         log.info("got expected CannotConnectException");
      }
      catch (Throwable t)
      {
         fail("expected CannotConnectException, got: " + t);        
      }
     
      client.disconnect();
      shutdownServer();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
      clientConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName());
      clientConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName());
      clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false");
      addExtraClientConfig(clientConfig);
      Client client = new Client(clientLocator, clientConfig);
      client.connect();
      log.info("client is connected");
     
      // Test connections.
      assertEquals("abc", client.invoke("abc"));
      log.info("connection is good");
     
      // Do callback.
      // Configure callbacks.
      TestCallbackHandler callbackHandler = new TestCallbackHandler();
      client.addListener(callbackHandler, new HashMap());
     
      // Do tests.
      assertTrue(ConfigTestMarshaller.ok(false, 2));
      assertTrue(ConfigTestUnmarshaller.ok(false, 0));
      assertTrue(LocatorTestMarshaller.ok());
      assertTrue(LocatorTestUnmarshaller.ok());
      assertEquals(1, callbackHandler.counter);
     
      client.disconnect();
      shutdownServer();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      HashMap config = new HashMap();
      config.put(InvokerLocator.FORCE_REMOTE, "true");
      config.put(ServerInvoker.TIMEOUT, "60000");
      config.put(Client.ENABLE_LEASE, "true");
      addClientConfig(config);
      final Client client = new Client(locator, config);
      try
      {
         client.connect();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
      log.info("making first invocation");
      Object response = client.invoke("test");
      assertEquals("test", response);
      log.info("first invocation succeeds");
      final InvokerCallbackHandler callbackHandler = new TestCallbackHandler();
      client.addListener(callbackHandler, new HashMap(), null, true);
     
      final Holder removeListener = new Holder();
      new Thread()
      {
         public void run()
         {
            try
            {
               // Wait for the server to be disabled.
               Thread.sleep(10000);
              
               try
               {
               // This invocation may use up a listening connection,
               // depending on transport.
                  HashMap metadata = new HashMap();
                  metadata.put("timeout", shortTimeoutString());
                  log.info("making invocation");
                  client.invoke("test", metadata);
                  log.info("made invocation");
               }
               catch (Exception e)
               {
                  log.info("client.invoke(\"test\") failed (that's OK)");
               }
              
               // Set disconnectTimeout to 0.
               client.setDisconnectTimeout(0);
               client.removeListener(callbackHandler);
               removeListener.done = true;
               log.info("returned from client.removeListener()");
            }
            catch (Throwable e)
            {
View Full Code Here

TOP

Related Classes of org.jboss.remoting.Client

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.