Пример #1
0
 @Test
 public void testPorcessRequestAnswersErrorResponse() {
   SampleRequest request = new SampleRequest("testError");
   SampleExceptionHandler handler = new SampleExceptionHandler();
   controller.addHandler(request, handler);
   Response response = controller.processRequest(request);
   assertNotNull("Must not return a null response", response);
   assertEquals(ErrorResponse.class, response.getClass());
 }
Пример #2
0
 //  test 건너뛰
 @Test(timeout = 130)
 @Ignore(value = "Ignore for now until new decide a decent time - limit")
 public void testProcessMultipleRequestsTimeout() {
   Request request;
   Response response = new SampleResponse();
   RequestHandler handler = new SampleHandler();
   for (int i = 0; i < 99999; i++) {
     request = new SampleRequest(String.valueOf(i));
     controller.addHandler(request, handler);
     response = controller.processRequest(request);
     assertNotNull(response);
     assertNotSame(ErrorResponse.class, response.getClass());
   }
 }
Пример #3
0
 @Before
 public void instantiate() throws Exception {
   controller = new DefaultController();
   request = new SampleRequest();
   handler = new SampleHandler();
   controller.addHandler(request, handler);
 }
Пример #4
0
  @Test(expected = RuntimeException.class)
  public void testAddRequestDuplicateName() {
    SampleRequest request = new SampleRequest();
    SampleHandler handler = new SampleHandler();

    //  다음줄에서 RuntimeExceptiom을 발생시킬 것이다.
    controller.addHandler(request, handler);
  }
Пример #5
0
  @Test
  public void testAddHandler() {

    /*
     * instance initalize Request request = new SampleRequest();
     * RequestHandler handler = new SampleHandler();
     * controller.addHandler(request, handler);
     */
    RequestHandler handler2 = controller.getHandler(request);
    assertSame("Handler we set in controller should be the same handler we get", handler2, handler);
  }
Пример #6
0
  @Test
  public void testProcessRequest() {

    /*
     * instance init Request request = new SampleRequest(); RequestHandler
     * handler = new SampleHandler(); controller.addHandler(request,
     * handler);
     */
    Response response = controller.processRequest(request);
    assertNotNull("Muset not return a null response", response);
    assertEquals(
        "Response should be of type SampleResponse", SampleResponse.class, response.getClass());
    assertEquals("Response should be of type SampleResponse", new SampleResponse(), response);
  }
Пример #7
0
 @Test(expected = RuntimeException.class)
 public void testGetHandlerNotDefined() {
   SampleRequest request = new SampleRequest("testNotDefinded");
   //  다음줄에서 RuntimeExceptiom을 발생시킬 것이다.
   controller.getHandler(request);
 }