public DefaultMuleEventContext(MuleEvent event) { this.event = event; this.session = event.getSession(); this.muleContext = event.getMuleContext(); this.clientInterface = muleContext.getClient(); }
@Test public void testIncompleteLoanBrokerRequest() throws Exception { MuleClient client = muleContext.getClient(); @SuppressWarnings("unchecked") Map<String, Object> props = new SingletonMap("http.method", HttpConstants.METHOD_GET); MuleMessage result = client.send("http://localhost:11081?amount=1234", null, props); assertEquals("Error: incomplete request", result.getPayloadAsString()); }
@Test public void testWrongLoanBrokerRequest() throws Exception { MuleClient client = muleContext.getClient(); @SuppressWarnings("unchecked") Map<String, Object> props = new SingletonMap("http.method", HttpConstants.METHOD_GET); MuleMessage result = client.send("http://localhost:11081?name=Muley&term=48&ssn=1234&amount=abcd", null, props); assertEquals("Error processing loan request", result.getPayloadAsString()); } }
@Test public void testDefaultLoanBrokerRequest() throws Exception { MuleClient client = muleContext.getClient(); @SuppressWarnings("unchecked") Map<String, Object> props = new SingletonMap("http.method", HttpConstants.METHOD_GET); MuleMessage result = client.send("http://localhost:11081?name=Muley&amount=20000&term=48&ssn=1234", null, props); assertNotNull("Result is null", result); assertFalse("Result is null", result.getPayload() instanceof NullPayload); assertNull(result.getExceptionPayload()); assertTrue("Unexpected response string", result.getPayloadAsString().matches("Bank #\\d, rate: \\d\\.(\\d)*$")); }