Пример #1
0
 public void run() {
   int i = 0;
   try {
     Thread.sleep(2000);
     MuleClient client = new MuleClient();
     MuleMessage result = null;
     for (i = 0; i < numberOfRequests; i++) {
       try {
         result = client.request("CustomerResponses", getDelay());
       } catch (MuleException e) {
         exListener.exceptionThrown(e);
         break;
       }
       // System.out.println("Received: " + i);
       assertNotNull("Result is null", result);
       assertFalse("Result is null", result.getPayload() instanceof NullPayload);
       assertTrue(
           "Result should be LoanQuote but is " + result.getPayload().getClass().getName(),
           result.getPayload() instanceof LoanQuote);
       LoanQuote quote = (LoanQuote) result.getPayload();
       assertTrue(quote.getInterestRate() > 0);
     }
   } catch (Throwable e) {
     // e.printStackTrace();
     System.out.println(StringMessageUtils.getBoilerPlate("Processed Messages=" + i));
     if (e instanceof Error) {
       // throw (Error)e;
       exListener.exceptionThrown(new Exception(e));
     } else {
       exListener.exceptionThrown((Exception) e);
     }
   } finally {
     latch.countDown();
   }
 }
Пример #2
0
 public void testTransactionQueueEventsFalse() throws Exception {
   success = true;
   MuleClient client = new MuleClient();
   client.dispatch("vm://int3?connector=vmOnFly", "TEST", null);
   MuleMessage message = client.request("vm://outt3?connector=vm", 10000);
   assertNotNull(message);
   assertTrue(success);
 }
Пример #3
0
 protected MuleMessage receiveMessage() throws Exception {
   MuleMessage result = client.request(DEFAULT_OUTPUT_MULE_QUEUE_NAME, TIMEOUT);
   assertNotNull(result);
   assertNotNull(result.getPayload());
   assertNull(result.getExceptionPayload());
   assertEquals(DEFAULT_OUTPUT_MESSAGE, result.getPayload());
   return result;
 }
Пример #4
0
 public void testDelegateClass() throws Exception {
   MuleClient client = new MuleClient();
   client.dispatch(INPUT_DC_QUEUE_NAME, "test", null);
   MuleMessage message = client.request(OUTPUT_DC_QUEUE_NAME, TIMEOUT);
   assertNotNull(message);
   assertEquals(message.getPayload(), DEFUALT_OUTPUT_MESSAGE);
   client.dispose();
 }
Пример #5
0
 public void testWithInjectedDelegate() throws Exception {
   MuleClient client = new MuleClient();
   client.dispatch(INPUT_DI_QUEUE_NAME, DEFAULT_INPUT_MESSAGE, null);
   MuleMessage reply = client.request(OUTPUT_DI_QUEUE_NAME, TIMEOUT);
   assertNotNull(reply);
   assertNull(reply.getExceptionPayload());
   // same as original input
   assertEquals(DEFAULT_INPUT_MESSAGE, reply.getPayload());
 }
Пример #6
0
  public void testMuleXaTopic() throws Exception {
    UMOMessage result = null;
    MuleClient client = new MuleClient();
    client.dispatch("vm://in", DEFAULT_INPUT_MESSAGE, null);
    result = client.request("vm://out", TIMEOUT);
    assertNotNull(result);
    result = client.request("vm://out", TIMEOUT);
    assertNotNull(result);
    result = client.request("vm://out", SMALL_TIMEOUT);
    assertNull(result);

    managementContext.getRegistry().lookupConnector(CONNECTOR1_NAME).stop();
    assertEquals(
        managementContext.getRegistry().lookupConnector(CONNECTOR1_NAME).isStarted(), false);
    logger.info(CONNECTOR1_NAME + " is stopped");
    client.dispatch("vm://in", DEFAULT_INPUT_MESSAGE, null);
    Thread.sleep(1000);
    managementContext.getRegistry().lookupConnector(CONNECTOR1_NAME).start();
    Thread.sleep(1000);
    logger.info(CONNECTOR1_NAME + " is started");
    result = client.request("vm://out", TIMEOUT);
    assertNotNull(result);
    result = client.request("vm://out", TIMEOUT);
    assertNotNull(result);
    result = client.request("vm://out", SMALL_TIMEOUT);
    assertNull(result);
  }
Пример #7
0
  public void testSingleLoanRequest() throws Exception {
    MuleClient client = new MuleClient();
    Customer c = new Customer("Ross Mason", 1234);
    CustomerQuoteRequest request = new CustomerQuoteRequest(c, 100000, 48);
    // Send asynchronous request
    client.dispatch("CustomerRequests", request, null);

    // Wait for asynchronous response
    MuleMessage result = client.request("CustomerResponses", getDelay());
    assertNotNull("Result is null", result);
    assertFalse("Result is null", result.getPayload() instanceof NullPayload);
    assertTrue(
        "Result should be LoanQuote but is " + result.getPayload().getClass().getName(),
        result.getPayload() instanceof LoanQuote);
    LoanQuote quote = (LoanQuote) result.getPayload();
    assertTrue(quote.getInterestRate() > 0);
  }
Пример #8
0
 public void runAsynchronousDispatching() throws Exception {
   dispatchMessage();
   receiveMessage();
   MuleMessage result = client.request(DEFAULT_OUTPUT_MULE_QUEUE_NAME, SMALL_TIMEOUT);
   assertNull(result);
 }