Example #1
0
  public static synchronized void start(String repository, String axis2xml) throws Exception {
    if (count == 0) {
      TestUtils.shutdownFailsafe(TESTING_PORT);
      ConfigurationContext er = getNewConfigurationContext(repository, axis2xml);

      receiver = new SimpleHttpServerExtension(er, TESTING_PORT);

      try {
        receiver.start();
        System.out.print("Server started on port " + TESTING_PORT + ".....");
      } catch (Exception e) {
        throw new AxisFault("Error while starting the server on port " + TESTING_PORT, e);
      }

      try {
        Thread.sleep(2000);
      } catch (InterruptedException e1) {
        throw new AxisFault("Thread interuptted", e1);
      }
    }

    waitForService();

    count++;
  }
Example #2
0
 public static void waitForService() throws AxisFault {
   System.out.println("waiting for server start on port " + TESTING_PORT);
   Socket sock = null;
   int count = 1;
   while (true) {
     try {
       sock = new Socket("localhost", TESTING_PORT);
       if (sock != null) {
         break;
       }
     } catch (IOException e) {
       try {
         count++;
         Thread.sleep(10000);
       } catch (InterruptedException e1) {
         throw new AxisFault("Thread interuptted", e1);
       }
     }
     if (count > 30) {
       System.out.println("Server start failed on port " + TESTING_PORT);
       throw new AxisFault("Server start failed on port " + TESTING_PORT);
     }
   }
   System.out.println("Server started on port " + TESTING_PORT);
 }
Example #3
0
  public static synchronized void start(String repository) throws Exception {
    if (count == 0) {
      TestUtils.shutdownFailsafe(TESTING_PORT);
      ConfigurationContext er = getNewConfigurationContext(repository);

      receiver = new SimpleHttpServerExtension(er, TESTING_PORT);

      try {
        receiver.start();
        ListenerManager listenerManager = er.getListenerManager();
        TransportInDescription trsIn = new TransportInDescription(Constants.TRANSPORT_HTTP);
        trsIn.setReceiver(receiver);
        if (listenerManager == null) {
          listenerManager = new ListenerManager();
          listenerManager.init(er);
        }
        listenerManager.addListener(trsIn, true);
        System.out.print("Server started on port " + TESTING_PORT + ".....");
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    try {
      Thread.sleep(2000);
    } catch (InterruptedException e1) {
      throw new AxisFault("Thread interuptted", e1);
    }

    waitForService();

    count++;
  }
Example #4
0
 public static synchronized void stop() throws AxisFault {
   if (count == 1) {
     receiver.stop();
     while (receiver.isRunning()) {
       try {
         Thread.sleep(1000);
       } catch (InterruptedException e1) {
         // nothing to do here
       }
     }
     count = 0;
     // tp.doStop();
     System.out.print("Server stopped .....");
   } else {
     count--;
   }
   receiver.getConfigurationContext().terminate();
 }