예제 #1
0
  @Test
  public void testDeployment() throws Exception {
    HornetQMixIn hqMixIn =
        new HornetQMixIn(false).setUser(ResourceDeployer.USER).setPassword(ResourceDeployer.PASSWD);
    hqMixIn.initialize();
    String[] orders = {"BREAD", "PIZZA", "JAM", "POTATO", "MILK", "JAM"};

    try {
      Session session = hqMixIn.getJMSSession();
      MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(ORDER_QUEUE));
      for (String order : orders) {
        BytesMessage message = session.createBytesMessage();
        message.writeBytes(order.getBytes());
        producer.send(message);
      }
      session = hqMixIn.createJMSSession();

      MessageConsumer consumer = session.createConsumer(HornetQMixIn.getJMSQueue(SHIPPING_QUEUE));
      List<String> expectedShippingOrders =
          new ArrayList<String>(Arrays.asList("BREAD", "JAM", "MILK", "JAM"));
      Message msg = null;
      while ((msg = consumer.receive(1000)) != null) {
        Assert.assertTrue(expectedShippingOrders.remove(hqMixIn.readStringFromJMSMessage(msg)));
      }
      Assert.assertEquals(0, expectedShippingOrders.size());

      consumer = session.createConsumer(HornetQMixIn.getJMSQueue(FILLING_STOCK_QUEUE));
      List<String> expectedFillingStockOrders =
          new ArrayList<String>(Arrays.asList("PIZZA", "POTATO"));
      while ((msg = consumer.receive(1000)) != null) {
        Assert.assertTrue(expectedFillingStockOrders.remove(hqMixIn.readStringFromJMSMessage(msg)));
      }
      Assert.assertEquals(0, expectedFillingStockOrders.size());
    } finally {
      hqMixIn.uninitialize();
      ResourceDeployer.removeQueue(ORDER_QUEUE);
      ResourceDeployer.removeQueue(SHIPPING_QUEUE);
      ResourceDeployer.removeQueue(FILLING_STOCK_QUEUE);
    }
  }
  @Test
  public void testDeployment() throws Exception {
    HornetQMixIn hqMixIn = new HornetQMixIn(false).setUser(USER).setPassword(PASSWD);
    hqMixIn.initialize();

    try {
      Session session = hqMixIn.getJMSSession();
      MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(QUEUE));
      Message message = hqMixIn.createJMSMessage("Tomo");
      producer.send(message);
    } finally {
      hqMixIn.uninitialize();
      ResourceDeployer.removeQueue(QUEUE);
    }
  }