Package org.jboss.test.messaging.tools.jmx.rmi

Examples of org.jboss.test.messaging.tools.jmx.rmi.Server


      {
         // doesn't make any sense to run in remote mode, since we'll start our won external VM
         return;
      }

      Server localServer = null;
      File serialized = null;

      try
      {
         localServer = new LocalTestServer();

         localServer.start("all", true);
         localServer.deployQueue("Queue", null, false);

         // lookup the connection factory and the queue which we'll send to the client VM via a
         // serialized instances saved in file

         InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
         ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
         Queue queue = (Queue)ic.lookup("/queue/Queue");

         serialized = writeToFile(cf, queue);

         // spawn a JVM that creates a JMS client, which sends a test message

         Process p = spawnVM(serialized);

         // read the message from the queue

         Connection conn = cf.createConnection();
         conn.start();
         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageConsumer cons = sess.createConsumer(queue);
         TextMessage tm = (TextMessage)cons.receive(5000);

         assertNotNull(tm);
         assertEquals(MESSAGE_TEXT, tm.getText());

         // the client VM should exit by itself. If it doesn't, that means we have a problem
         // and the test will timeout
         log.info("waiting for the client VM to exit ...");
         p.waitFor();

         assertEquals(0, p.exitValue());

      }
      finally
      {
         // TODO delete the file
         if (serialized != null)
         {
            serialized.delete();
         }

         localServer.undeployDestination(true, "Queue");
         localServer.stopServerPeer();
         localServer.stop();
      }
   }
View Full Code Here


         {
            servers[i] = new ServerHolder(new LocalTestServer(i), false);
         }
         else
         {
            Server s = acquireRemote(2, i, true);

            if (s != null)
            {
               servers[i] = new ServerHolder(s, false);
            }
View Full Code Here

   public static synchronized void start(int i, String config,
                                         ServiceAttributeOverrides attrOverrides,
                                         boolean clearDatabase,
                                         boolean startMessagingServer) throws Exception
   {
      Server s = create(i);

      log.info("starting server " + i);

      s.start(config, attrOverrides, clearDatabase, startMessagingServer);

      log.info("server " + i + " started");
   }
View Full Code Here

    * perform System.exit after few milliseconds. We will use this method in places where we need
    * the server killed.
    */
   public static synchronized void killAndWait(int i) throws Exception
   {
      Server server = servers[i].getServer();
      kill(i);
      try
      {
         while(true)
         {
            server.ping();
            log.debug("server " + i + " still alive ...");
            Thread.sleep(10);
         }
      }
      catch (Throwable e)
View Full Code Here

      for(int i = 0; i < servers.length; i++)
      {
         if (servers[i] != null && servers[i].isSpawned())
         {
            Server s = servers[i].getServer();
            destroyed.add(new Integer(s.getServerID()));
            s.stop();
            s.kill();
            servers[i] = null;
         }
      }

      return destroyed;
View Full Code Here

      // put the invoking thread on wait until the server is actually up and running and bound
      // in the RMI registry

      long maxWaitTime = 30; // seconds
      long startTime = System.currentTimeMillis();
      Server s = null;

      log.info("spawned server " + i + ", waiting for it to come online");

      while(System.currentTimeMillis() - startTime < maxWaitTime * 1000)
      {
View Full Code Here

    *         server after use.
    */
   public static Server poisonTheServer(int serverIndex, int type) throws Exception
   {
      insureStarted(serverIndex);
      Server poisoned = servers[serverIndex].getServer();

      // TODO (ovidiu): this is prone to race conditions, as somebody from the client may try to
      //       use (and create) an new server that is being poisoned, while the poisoned server is
      //       still alive.

      servers[serverIndex] = null;
      poisoned.poisonTheServer(type);

      return poisoned;
   }
View Full Code Here

   {
      String name =
         "//localhost:" + RMITestServer.DEFAULT_REGISTRY_PORT + "/" +
         RMITestServer.RMI_SERVER_PREFIX + index;

      Server s = null;
      int retries = initialRetries;

      while (s == null && retries > 0)
      {
         int attempt = initialRetries - retries + 1;
View Full Code Here

TOP

Related Classes of org.jboss.test.messaging.tools.jmx.rmi.Server

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.