Package com.meterware.httpunit

Examples of com.meterware.httpunit.WebResponse


        problem.setParameter(OAuth2.REDIRECT_URI,"https://client.example.com/cb");
        HttpServletResponse hsr = ic.getResponse();
        OAuth2Servlet.handleException(ic.getRequest(),hsr,problem,null,false,false);


        WebResponse response   = ic.getServletResponse();

        assertEquals("ErroeRedirectResponse Location chceck", "https://client.example.com/cb?error=unsupported_response_type", response.getHeaderField(OAuth2ProblemException.HTTP_LOCATION));
        assertEquals("ErrorRedirectResponse Code check", "302", new Integer(response.getResponseCode()).toString());


    }
View Full Code Here


      
            String label = testCase[0];
            //String realm = testCase[1];
            List<OAuth2.Parameter> parameters = decodeForm(testCase[1]);
            OAuth2Servlet.sendFormInJson(ic.getResponse(),parameters);
            WebResponse response   = ic.getServletResponse();
            String expectedGrantType = testCase[2];
            String expectedClientId = testCase[3];
            //String expectedSecret = testCase[5];
            String expectedCode = testCase[4];
            String expectedRedirectURI = testCase[5];
            assertEquals(label, "{"+toStringWithQuotation("grant_type")+":"+toStringWithQuotation(expectedGrantType)+","
                                  +toStringWithQuotation("client_id")+":"+toStringWithQuotation(expectedClientId)+","
                          //+toStringWithQuotation("client_secret")+":"+toStringWithQuotation(expectedSecret)+","
                              +toStringWithQuotation("code")+":"+toStringWithQuotation(expectedCode)+","
                                  +toStringWithQuotation("redirect_uri")+":"+toStringWithQuotation(expectedRedirectURI)+"}", response.getText());
           
        }
    }
View Full Code Here

   * @throws Exception
   */
  @BeforeClass//TODO add description here
  public static void beforeClass() throws Exception{
    WebRequest req = new GetMethodWebRequest(SERVER_URI+"/ResetGameEngine"); // need to change to what your local host is
    final WebResponse res = WEB_CONVERSATION.getResponse( req )
    assertEquals(
        "the result object should be of DefaultJsonContainer/JsonContainerAdapter",
        "JsonContainerAdapter",
        JsonFactory.fromJson(res.getText()).objectName
      );
   
  }
View Full Code Here

  public void testGetGames() throws MalformedURLException, IOException, SAXException
  {
   
    WebRequest req = new GetMethodWebRequest(SERVER_URI+"/AvailableGames"); // need to change to what your local host is

    final WebResponse res = WEB_CONVERSATION.getResponse( req );
    res.getResponseMessage();
    //final org.w3c.dom.Document xml = res.getDOM();
    final String response = res.getText();

    Gson gson = new Gson();
    GamesJsonContainer obj = gson.fromJson(response, GamesJsonContainer.class);

    assertEquals(
View Full Code Here

  public void testCreateGame() throws MalformedURLException, IOException, SAXException
  {
   
    WebRequest req = new GetMethodWebRequest(SERVER_URI+"/GamePlayers"); // need to change to what your local host is
   
    final WebResponse res = WEB_CONVERSATION.getResponse( req );
    res.getResponseMessage();
    final String response = res.getText().trim();
    jec = GSON.fromJson(response, ExceptionJsonContainer.class);
    assertEquals("is the user authenticated",
        "Game id can not be null",
        jec.message);
  }
View Full Code Here

  public void testLoginFailed() throws MalformedURLException, IOException, SAXException
  {
   
    WebRequest req = new GetMethodWebRequest(SERVER_URI+"/Login"); // need to change to what your local host is
   
    final WebResponse res = WEB_CONVERSATION.getResponse( req );
    res.getResponseMessage();
    final String response = res.getText().trim();
   
    jec = GSON.fromJson(response, ExceptionJsonContainer.class);   
   
    assertEquals("is the user authenticated",
        "email is not provided",
View Full Code Here

  {
   
    WebRequest req = new GetMethodWebRequest(SERVER_URI+"/Login"); // need to change to what your local host is
    req.setParameter("name", "o");
   
    final WebResponse res = WEB_CONVERSATION.getResponse( req );
    res.getResponseMessage();
    final String response = res.getText().trim();
   
    jec = GSON.fromJson(response, ExceptionJsonContainer.class);   
   
    assertEquals("is the user authenticated",
        "email is not provided",
View Full Code Here

        // --- Execution
        // process the response code later, not via an exception.
        HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );

        WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
        WebResponse response = getServletUnitClient().getResponse( request );

        // --- Verification

        switch ( expectation )
        {
            case EXPECT_MANAGED_CONTENTS:
                assertResponseOK( response );
                assertTrue( "Invalid Test Case: Can't expect managed contents with "
                                + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
                assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
                break;
            case EXPECT_REMOTE_CONTENTS:
                assertResponseOK( response );
                assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
                break;
            case EXPECT_NOT_FOUND:
                assertResponseNotFound( response );
                assertManagedFileNotExists( repoRootInternal, resourcePath );
                break;
View Full Code Here

        // --- Execution
        // process the response code later, not via an exception.
        HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );

        WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
        WebResponse response = getServletUnitClient().getResponse( request );

        // --- Verification
        assertResponseOK( response );
        assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
    }
View Full Code Here

        // --- Execution
        // process the response code later, not via an exception.
        HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );

        WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
        WebResponse response = getServletUnitClient().getResponse( request );

        // --- Verification

        switch ( expectation )
        {
            case EXPECT_MANAGED_CONTENTS:
                assertResponseOK( response );
                assertTrue( "Invalid Test Case: Can't expect managed contents with "
                                + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
                assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() );
                break;
            case EXPECT_REMOTE_CONTENTS:
                assertResponseOK( response );
                assertEquals( "Expected remote file contents", expectedRemoteContents, response.getText() );
                break;
            case EXPECT_NOT_FOUND:
                assertResponseNotFound( response );
                assertManagedFileNotExists( repoRootInternal, resourcePath );
                break;
View Full Code Here

TOP

Related Classes of com.meterware.httpunit.WebResponse

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.