Package org.mokai.connector.http

Examples of org.mokai.connector.http.HttpConnector.process()


    message.setProperty("to", "3002175604");
    message.setProperty("from", "3542");
    message.setProperty("text", "test · script @áÁ");

    HttpConnector connector = new HttpConnector(configuration);
    connector.process(message);

    Assert.assertEquals(mockHandler.getReceivedMethod(), "GET");
    mockHandler.validateExpectedProperties("to=3002175604&from=3542&text=test · script @áÁ");
    Assert.assertTrue(message.getProperty("responseCode", Integer.class) == HttpStatus.SC_OK);
  }
View Full Code Here


    Message message = new Message();
    message.setProperty("from", "3542");

    HttpConnector connector = new HttpConnector(configuration);
    connector.process(message);

    mockHandler.validateExpectedProperties("to=3002175604&from=3542");
  }

  @Test(expectedExceptions=IllegalArgumentException.class)
View Full Code Here

    HttpConfiguration configuration = new HttpConfiguration();
    configuration.setUrl("htp://invalidscheme/");

    HttpConnector connector = new HttpConnector(configuration);
    connector.process(new Message());
  }

  @Test
  public void shouldProcessPostRequest() throws Exception {
    MockRequestHandler mockHandler = new MockRequestHandler(HttpStatus.SC_OK);
View Full Code Here

    message.setProperty("to", "3002175604");
    message.setProperty("from", "3542");
    message.setProperty("text", "test · script @áÁ");

    HttpConnector connector = new HttpConnector(configuration);
    connector.process(message);

    Assert.assertEquals(mockHandler.getReceivedMethod(), "POST");
    mockHandler.validateExpectedProperties("to=3002175604&from=3542&text=test · script @áÁ");
    Assert.assertTrue(message.getProperty("responseCode", Integer.class) == HttpStatus.SC_OK);
  }
View Full Code Here

    testServer.register("/", mockHandler);

    HttpConfiguration configuration = new HttpConfiguration();

    HttpConnector connector = new HttpConnector(configuration);
    connector.process(new Message());

  }

  @Test(expectedExceptions=IllegalArgumentException.class)
  public void shouldNotConfigureUnknownHttpMethod() throws Exception {
View Full Code Here

    HttpConfiguration configuration = new HttpConfiguration();
    configuration.setUrl("http://" + getHost() + ":" + getPort() + "/");
    configuration.setMethod("UNKNOWN");

    HttpConnector connector = new HttpConnector(configuration);
    connector.process(new Message());
  }

  @Test
  public void testBasicAuth() throws Exception {
    MockRequestHandler mockHandler = new MockRequestHandler(HttpStatus.SC_OK);
View Full Code Here

    configuration.setBasicAuth(true);
    configuration.setUsername("german");
    configuration.setPassword("password");

    HttpConnector connector = new HttpConnector(configuration);
    connector.process(new Message());

    Header header = mockHandler.getHeader("Authorization");
    Assert.assertNotNull(header);
    Assert.assertNotNull(header.getValue());
    Assert.assertEquals(header.getValue(), "Basic Z2VybWFuOnBhc3N3b3Jk");
View Full Code Here

    message.setProperty("to", "3002175604");
    message.setProperty("from", "3542");
    message.setProperty("text", "test");

    HttpConnector connector = new HttpConnector(configuration);
    connector.process(message);

    mockHandler.validateExpectedProperties("to1=3002175604&from1=3542&text1=test&account=german&password=escobar");
  }

  @Test
View Full Code Here

    HttpConfiguration configuration = new HttpConfiguration();
    configuration.setUrl("http://" + getHost() + ":" + getPort() + "/");
    configuration.setThrowExceptionOnFailure(false);

    HttpConnector connector = new HttpConnector(configuration);
    connector.process(new Message());
  }

  @Test(expectedExceptions=HttpOperationFailedException.class)
  public void shouldThrowExceptionOnFailure() throws Exception {
    MockRequestHandler mockHandler = new MockRequestHandler(HttpStatus.SC_BAD_REQUEST);
View Full Code Here

    HttpConfiguration configuration = new HttpConfiguration();
    configuration.setUrl("http://" + getHost() + ":" + getPort() + "/");

    HttpConnector connector = new HttpConnector(configuration);
    connector.process(new Message());

  }

  @Test(expectedExceptions=HttpOperationFailedException.class)
  public void shouldFailUrlNotFound() throws Exception {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.