Package org.jogger.test

Examples of org.jogger.test.MockResponse


    when( cs.getPriority() ).thenReturn(1000);

    RoutingEngine routingEngine = getSpringContext().getBean(RoutingEngine.class);
    when(routingEngine.getConnections()).thenReturn( Collections.singletonList(cs) );

    MockResponse response = get("/connections").addCookie(new Cookie("access_token", "true")).run();

    Assert.assertEquals( response.getStatus(), Response.OK );

    JSONArray jsonResponse = new JSONArray( response.getOutputAsString() );
    Assert.assertNotNull( jsonResponse );
    Assert.assertEquals( jsonResponse.length(), 1 );

    JSONObject jsonConnection = jsonResponse.getJSONObject(0);
    Assert.assertNotNull( jsonConnection );
View Full Code Here


  @Test
  public void shouldListEmptyConnections() throws Exception {
    RoutingEngine routingEngine = getSpringContext().getBean(RoutingEngine.class);
    when(routingEngine.getConnections()).thenReturn( new ArrayList<ConnectorService>() );

    MockResponse response = get("/connections").addCookie(new Cookie("access_token", "true")).run();

    Assert.assertEquals( response.getStatus(), Response.OK );
    Assert.assertEquals( response.getOutputAsString() , "[]");
  }
View Full Code Here

    Assert.assertEquals( response.getOutputAsString() , "[]");
  }

  @Test
  public void shouldFailListConnectionsWithoutAccessToken() throws Exception {
    MockResponse response = get("/connections").run();
    Assert.assertEquals( response.getStatus(), Response.UNAUTHORIZED );
  }
View Full Code Here

    when( cs.getPriority() ).thenReturn(1000);

    RoutingEngine routingEngine = getSpringContext().getBean(RoutingEngine.class);
    when(routingEngine.getConnection("test-connection")).thenReturn(cs);

    MockResponse response = post("/connections/test-connection/stop")
        .addCookie(new Cookie("access_token", "true"))
        .run();

    Assert.assertEquals( response.getStatus(), Response.OK );
    verify(cs).stop();
    verify(cs, never()).start();
  }
View Full Code Here

    when( cs.getPriority() ).thenReturn(1000);

    RoutingEngine routingEngine = getSpringContext().getBean(RoutingEngine.class);
    Mockito.when(routingEngine.getApplications()).thenReturn( Collections.singletonList(cs) );

    MockResponse response = get("/applications").addCookie(new Cookie("access_token", "true")).run();

    Assert.assertEquals( response.getStatus(), Response.OK );

    JSONArray jsonResponse = new JSONArray( response.getOutputAsString() );
    Assert.assertNotNull( jsonResponse );
    Assert.assertEquals( jsonResponse.length(), 1 );

    JSONObject jsonConnection = jsonResponse.getJSONObject(0);
    Assert.assertNotNull( jsonConnection );
View Full Code Here

  @Test
  public void shouldListEmptyApplications() throws Exception {
    RoutingEngine routingEngine = getSpringContext().getBean(RoutingEngine.class);
    Mockito.when(routingEngine.getApplications()).thenReturn( new ArrayList<ConnectorService>() );

    MockResponse response = get("/applications").addCookie(new Cookie("access_token", "true")).run();

    Assert.assertEquals( response.getStatus(), Response.OK );
    Assert.assertEquals( response.getOutputAsString() , "[]");
  }
View Full Code Here

    Assert.assertEquals( response.getOutputAsString() , "[]");
  }

  @Test
  public void shouldFailListApplicationsWithoutAccessToken() throws Exception {
    MockResponse response = get("/applications").run();
    Assert.assertEquals( response.getStatus(), Response.UNAUTHORIZED );
  }
View Full Code Here

TOP

Related Classes of org.jogger.test.MockResponse

Copyright © 2018 www.massapicom. 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.