Package org.jboss.remoting

Examples of org.jboss.remoting.Client$ConnectionValidatorKey


      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, "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");
     
      // Do callback.
      // Configure callbacks.
      TestCallbackHandler callbackHandler = new TestCallbackHandler();
      client.addListener(callbackHandler, new HashMap());
     
      // Do tests.
      assertTrue(ConfigTestMarshaller.ok(true, 8));
      assertTrue(ConfigTestUnmarshaller.ok(true, 4));
      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 1 second.
               client.setDisconnectTimeout(shortTimeout());
               log.info("calling client.removeListener()");
               client.removeListener(callbackHandler);
               removeListener.done = true;
               log.info("returned from client.removeListener()");
            }
            catch (Throwable e)
            {
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);
     
      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.
                  log.info("making invocation");
                  client.invoke("test");
                  log.info("made invocation");
               }
               catch (Exception e)
               {
                  log.info("client.invoke(\"test\") failed (that's OK)");
               }
              
               log.info("calling client.removeListener()");
               client.removeListener(callbackHandler);
               removeListener.done = true;
               log.info("returned from client.removeListener()");
            }
            catch (Throwable e)
            {
View Full Code Here

public class HTTPInvokerTestClient extends TestCase implements HTTPInvokerConstants
{
  
   public void testRawInvocation() throws Exception
   {
      Client remotingClient = null;

      try
      {
         InvokerLocator locator = new InvokerLocator(getLocatorURI());
         System.out.println("Calling remoting server with locator uri of: " + getLocatorURI());

         remotingClient = new Client(locator);
         remotingClient.connect();

         Map metadata = new HashMap();
         metadata.put(Client.RAW, Boolean.TRUE);
        
         Object response = remotingClient.invoke("Do something", metadata);
         System.out.println("Second response should be " + WebInvocationHandler.HTML_PAGE_RESPONSE + " and was: " + response);
         assertEquals(WebInvocationHandler.HTML_PAGE_RESPONSE, response);
      }
      catch (Throwable throwable)
      {
         throw new Exception(throwable);
      }
      finally
      {
         if (remotingClient != null)
         {
            remotingClient.disconnect();
         }
      }
   }
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");
     
      // Make invocation, creating unmarshaller with testClassLoader1, in separate thread.
      TestCallingThread t = new TestCallingThread(client);
      t.run();
      synchronized (t)
      {
         if (!t.done)
         {
            t.wait();
         }
      }
     
      // Make invocation in main thread with context classloader testClassLoader2.
      testClassLoader2.setClassLoader(mainContextClassLoader);
      Thread.currentThread().setContextClassLoader(testClassLoader2);
      log.info("main thread result: " + client.invoke("2"));
      assertTrue(testClassLoader1.counter > 0);
      assertTrue(testClassLoader2.counter == 0);
     
      client.disconnect();
      shutdownServer();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      }
   }
  
   public void testCookedInvocation() throws Exception
   {
      Client remotingClient = null;

      try
      {
         InvokerLocator locator = new InvokerLocator(getLocatorURI());
         System.out.println("Calling remoting server with locator uri of: " + getLocatorURI());

         remotingClient = new Client(locator);
         remotingClient.connect();

         Object response = remotingClient.invoke("Do something");
         System.out.println("Second response should be " + WebInvocationHandler.HTML_PAGE_RESPONSE + " and was: " + response);
         assertEquals(WebInvocationHandler.HTML_PAGE_RESPONSE, response);
      }
      catch (Throwable throwable)
      {
         throw new Exception(throwable);
      }
      finally
      {
         if (remotingClient != null)
         {
            remotingClient.disconnect();
         }
      }
   }
View Full Code Here

      InvokerLocator clientLocator = new InvokerLocator(locatorURI);
      HashMap clientConfig = new HashMap();
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
      clientConfig.put(Remoting.USE_CURRENT_THREAD_CLASS_LOADER, "false");
      addExtraClientConfig(clientConfig);
      Client client = new Client(clientLocator, clientConfig);
      client.connect();
      log.info("client is connected");
     
      // Make invocation, creating unmarshaller with testClassLoader1, in separate thread.
      TestCallingThread t = new TestCallingThread(client);
      t.run();
      synchronized (t)
      {
         if (!t.done)
         {
            t.wait();
         }
      }
     
      // Make invocation in main thread with context classloader testClassLoader2.
      testClassLoader2.setClassLoader(mainContextClassLoader);
      Thread.currentThread().setContextClassLoader(testClassLoader2);
      log.info("main thread result: " + client.invoke("2"));
      assertTrue(testClassLoader1.counter > 0);
      assertTrue(testClassLoader2.counter == 0);
     
      client.disconnect();
      shutdownServer();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      InvokerLocator clientLocator = new InvokerLocator(locatorURI);
      HashMap clientConfig = new HashMap();
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
      clientConfig.put(Remoting.USE_CURRENT_THREAD_CLASS_LOADER, "true");
      addExtraClientConfig(clientConfig);
      Client client = new Client(clientLocator, clientConfig);
      client.connect();
      log.info("client is connected");
     
      // Make invocation, creating unmarshaller with testClassLoader1, in separate thread.
      TestCallingThread t = new TestCallingThread(client);
      t.run();
      synchronized (t)
      {
         if (!t.done)
         {
            t.wait();
         }
      }
     
      // Make invocation in main thread with context classloader testClassLoader2.
      testClassLoader2.setClassLoader(mainContextClassLoader);
      Thread.currentThread().setContextClassLoader(testClassLoader2);
      log.info("main thread result: " + client.invoke("2"));
      assertTrue(testClassLoader1.counter > 0);
      assertTrue(testClassLoader2.counter > 0);
     
      client.disconnect();
      shutdownServer();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      log.info("entering " + getName());
     
      // Create client.
      HashMap clientConfig = new HashMap();
      addExtraClientConfig(clientConfig);
      Client client = new Client(serverLocator, clientConfig);
      client.connect();
      log.info("client is connected");
     
      // Test connection.
      assertEquals("abc", client.invoke("abc"));
     
      // Add connection listener.
      ConnectionListener listener = new TestConnectionListener();
      client.addConnectionListener(listener);
     
      // Test pingPeriod.
      Field field = Client.class.getDeclaredField("connectionValidator");
      field.setAccessible(true);
      ConnectionValidator validator = (ConnectionValidator) field.get(client);
      field = ConnectionValidator.class.getDeclaredField("pingPeriod");
      field.setAccessible(true);
      long pingPeriod = ((Long) field.get(validator)).longValue();
      assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod);
     
      // Test timeout.
      field = ConnectionValidator.class.getDeclaredField("clientInvoker");
      field.setAccessible(true);
      AbstractInvoker invoker = (AbstractInvoker) field.get(validator);
      field = AbstractInvoker.class.getDeclaredField("configuration");
      field.setAccessible(true);
      Map config = (Map) field.get(invoker);
      Object o = config.get(ServerInvoker.TIMEOUT);
      assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o);
     
      // Test ping retries.
      assertTrue(invoker instanceof MicroSocketClientInvoker);
      MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker;
      int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES);
      assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries());
        
      client.disconnect();
   }
View Full Code Here

      connector.create();
      connector.addInvocationHandler("MySubsystem", new ServerInvocationHandlerImpl());
      connector.start();


      Client client = new Client(targetServerLocator);
      client.connect();

      InvokerCallbackHandler callbackHandler1 = new InvokerCallbackHandlerImpl("ONE");
      InvokerCallbackHandler callbackHandler2 = new InvokerCallbackHandlerImpl("TWO");

      client.addListener(callbackHandler1, callbackServerLocator);

      client.invoke("call back " + value1);

      assertEquals(1, callbacks.size());
      callbacks.clear();

      client.addListener(callbackHandler2, callbackServerLocator);

      client.invoke("call back " + value2);

      assertEquals(2, callbacks.size());
      callbacks.clear();

      client.removeListener(callbackHandler1);

      client.invoke("call back " + value3);

      assertEquals(1, callbacks.size());
      callbacks.clear();

      client.removeListener(callbackHandler2);

      connector.stop();
      callbackConnector.stop();

      connector.destroy();
View Full Code Here

TOP

Related Classes of org.jboss.remoting.Client$ConnectionValidatorKey

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.