@Override
  protected void setUp() throws Exception {
    super.setUp();

    setConf(new Properties());
    getConf().setProperty("mail.smtp.host", "localhost");
    getConf().setProperty("mail.smtp.port", "2345");
    getConf().setProperty("from", "*****@*****.**");
    getConf().setProperty("replyTo", "*****@*****.**");
    getConf().setProperty("defaultLanguage", "en-UK");

    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();
    System.out.println("Waiting for the JMS Task Server to come up");
    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();

    setWiser(new Wiser());
    getWiser().setHostname(getConf().getProperty("mail.smtp.host"));
    getWiser().setPort(Integer.parseInt(getConf().getProperty("mail.smtp.port")));
    getWiser().start();
  }
  /**
   * Creates a new client
   *
   * @return the created client.
   */
  protected AsyncTaskService createTaskClient() {
    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");
    AsyncTaskService client =
        new TaskClient(
            new JMSTaskClientConnector(
                "org.jbpm.process.workitem.wsht.WSThroughJMSHumanTaskHandler",
                new JMSTaskClientHandler(SystemEventListenerFactory.getSystemEventListener()),
                clientProperties,
                context));

    return client;
  }
  /** Starts the server */
  @Override
  protected void setUp() throws Exception {

    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);

    EntityManagerFactory localEntityManagerFactory =
        Persistence.createEntityManagerFactory("org.jbpm.task");
    TaskService localTaskService =
        new TaskService(
            localEntityManagerFactory, SystemEventListenerFactory.getSystemEventListener());
    TaskServiceSession localTaskServiceSession = localTaskService.createSession();
    for (int i = 0; i < 10; i++) {
      User user = new User("usr" + i);
      localTaskServiceSession.addUser(user);
    }
    for (int j = 0; j < 3; j++) {
      localTaskServiceSession.addGroup(new Group("grp" + j));
    }

    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");

    this.server = new JMSTaskServer(localTaskService, serverProperties, context);
    Thread thread = new Thread(this.server);
    thread.start();
    localTaskServiceSession.dispose();
  }