示例#1
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    ActiveMQConnectionFactory factory =
        new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");

    this.context = EasyMock.createMock(Context.class);
    EasyMock.expect(context.lookup("ConnectionFactory")).andReturn(factory).anyTimes();
    EasyMock.replay(context);

    Properties serverProperties = new Properties();
    serverProperties.setProperty("JMSTaskServer.connectionFactory", "ConnectionFactory");
    serverProperties.setProperty("JMSTaskServer.transacted", "true");
    serverProperties.setProperty("JMSTaskServer.acknowledgeMode", "AUTO_ACKNOWLEDGE");
    serverProperties.setProperty("JMSTaskServer.queueName", "tasksQueue");
    serverProperties.setProperty("JMSTaskServer.responseQueueName", "tasksResponseQueue");

    server = new JMSTaskServer(taskService, serverProperties, context);
    Thread thread = new Thread(server);
    thread.start();
    while (!server.isRunning()) {
      System.out.print(".");
      Thread.sleep(50);
    }

    Properties clientProperties = new Properties();
    clientProperties.setProperty("JMSTaskClient.connectionFactory", "ConnectionFactory");
    clientProperties.setProperty("JMSTaskClient.transactedQueue", "true");
    clientProperties.setProperty("JMSTaskClient.acknowledgeMode", "AUTO_ACKNOWLEDGE");
    clientProperties.setProperty("JMSTaskClient.queueName", "tasksQueue");
    clientProperties.setProperty("JMSTaskClient.responseQueueName", "tasksResponseQueue");

    client =
        new SyncTaskServiceWrapper(
            new TaskClient(
                new JMSTaskClientConnector(
                    "client 1",
                    new JMSTaskClientHandler(SystemEventListenerFactory.getSystemEventListener()),
                    clientProperties,
                    context)));
    client.connect();
  }
示例#2
0
 protected void tearDown() throws Exception {
   super.tearDown();
   client.disconnect();
   server.stop();
 }