Examples of ServletUnitClient


Examples of com.meterware.servletunit.ServletUnitClient

    public void testGetRepositoryGroups()
        throws Exception
    {
        ServletRunner sr = new ServletRunner();
        ServletUnitClient sc = sr.newClient();

        Configuration configuration = createInitialConfiguration();

        archivaConfiguration.getConfiguration();
        archivaConfigurationControl.setReturnValue( configuration, 6 );
        archivaConfigurationControl.replay();

        action.setServletRequest( sc.newInvocation( "http://localhost/admin/repositoryGroups.action" ).getRequest() );
        action.prepare();
        String result = action.execute();
        assertEquals( Action.SUCCESS, result );

        assertEquals( "http://localhost:0/repository", action.getBaseUrl() );
View Full Code Here

Examples of com.meterware.servletunit.ServletUnitClient

    }
   
    @Test
    public void testGetServiceList() throws Exception {
       
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(false);

        //test the '/' context get service list
        WebResponse  res = client.getResponse(CONTEXT_URL + "/");
        WebLink[] links = res.getLinks();
        assertEquals("There should get two links for the services", 3, links.length);
       
        Set<String> links2 = new HashSet<String>();
        for (WebLink l : links) {
View Full Code Here

Examples of com.volantis.synergetics.testtools.servletunit.ServletUnitClient

        ServletRunner servletRunner = new ServletRunner(webXMLInputStream);
        servletRunner.registerServlet("MyServlet",
                "com.volantis.mcs.devices.ResolveDeviceServlet");

        final ServletUnitClient servletClient = servletRunner.newClient();

        final WebRequest request = new PostMethodWebRequest(
                "http://test.colantis.com/MyServlet");
        request.setHeaderField("User-Agent", "Mozilla/5.0 blah blah blah");
        request.setHeaderField("host", "www.volantis.com:8080");
        request.setHeaderField("Accept", "text/html");
        request.setHeaderField("HeaderName", "HeaderValue");

        ConfigValue cv = new ConfigValue();
        AppConfigurator ac = new MyAppConfigurator();
        ac.setUp(cv);
        try {
            ConfigFileBuilder configFileBuilder = new ConfigFileBuilder();
            configFileBuilder.buildConfigDocument(cv);
            servletRunner.setRealPath(configFileBuilder.getConfigFileDir());

            hypersonicManager.useCleanupWith(new Executor() {
                public void execute() throws Exception {
                    createRepository();

                    WebResponse response = servletClient.getResponse(request);
                    assertEquals("Response Not as expected.",
                            "Device is Wibble", response.getText());
                }
          });
        } finally {
View Full Code Here

Examples of com.volantis.testtools.servletunit.ServletUnitClient

     */
    public void testInstantiation() throws Exception {
        ServletRunner runner = new ServletRunner(createWebXML(
                createConfigFile(null, null, 10, false, null)));

        ServletUnitClient client = runner.newClient();

        WebRequest request = createPostRequest(VALID_TEST_XML, READER_TEST_URL);
        request.setHeaderField("User-Agent", "Mozilla/5.0 Firefox...");
        request.setHeaderField("Accept", "text/html");

        // Try with a invalid location specified in the config file
        try {
            client.getResponse(request);
            fail("Runtime exception because of invalid location expected");
        } catch (RuntimeException e) {
            // This is expected...
        }

        // Now try where the init() etc. should succeed
        runner = new ServletRunner(createDefaultWebXML());
        client = runner.newClient();

        request = createPostRequest(VALID_TEST_XML, READER_TEST_URL);
        request.setHeaderField("User-Agent", "Mozilla/5.0 Firefox...");
        request.setHeaderField("Accept", "text/html");
        client.getResponse(request);
    }
View Full Code Here

Examples of com.volantis.testtools.servletunit.ServletUnitClient

     * @throws Exception
     */
    public void testStore() throws Exception {

        ServletRunner runner = new ServletRunner(createDefaultWebXML());
        ServletUnitClient client = runner.newClient();

        WebRequest request = createPostRequest(VALID_TEST_XML, READER_TEST_URL);

        WebResponse response = client.getResponse(request);
        String id = response.getHeaderField(
                MessageStoreServlet.MESSAGE_RESPONSE_HEADER_NAME);

        // Check the ID has been returned OK
        assertNotNull("ID should exist in the headers", id);
View Full Code Here

Examples of com.volantis.testtools.servletunit.ServletUnitClient

                                 10,
                                 true,
                                 null)));

        // tets with valid XML
        ServletUnitClient client = runner.newClient();
        WebRequest request = createPostRequest(VALID_TEST_XML, READER_TEST_URL);
        WebResponse response = client.getResponse(request);
        String id = response.getHeaderField(
                MessageStoreServlet.MESSAGE_RESPONSE_HEADER_NAME);

        // Check the ID has been returned OK
        assertNotNull("ID should exist in the headers", id);
        // Look for the file
        File storedFile =
                new File(MessageStoreTestHelper.MESSAGE_STORE_LOCATION,
                         id + ".xml");
        assertTrue("Stored file should exist", storedFile.exists());


        // And using invalid XML
        request = createPostRequest(INVALID_TEST_XML, READER_TEST_URL);
        client = runner.newClient();
        try {
            response = client.getResponse(request);
            fail("This is invalid XML and should cause an exception");
        } catch (HttpException he) {
            // Test success
        }
View Full Code Here

Examples of com.volantis.testtools.servletunit.ServletUnitClient

     * @throws Exception
     */

    public void testNonExistentID() throws Exception {
        ServletRunner runner = new ServletRunner(createDefaultWebXML());
        ServletUnitClient client = runner.newClient();

        WebRequest request = createPostRequest(VALID_TEST_XML, READER_TEST_URL);
        WebResponse response = client.getResponse(request);
        String id = response.getHeaderField(
                MessageStoreServlet.MESSAGE_RESPONSE_HEADER_NAME);

        // Check the ID has been returned OK
        assertNotNull("ID should exist in the headers", id);

        // Use a fake servlet class to avoid the need to initialise and run
        // an entire MCS session.
        request = new GetMethodWebRequest(PARTIAL_TEST_URL);
        request.setHeaderField("User-Agent", "Mozilla/5.0 Firefox...");
        request.setParameter(MessageStoreServlet.MESSAGE_RETRIEVE_PARAM_NAME,
                             id);

        client = runner.newClient();
        response = client.getResponse(request);
        assertEquals("The response code should indicate success",
                     MessageStoreMessageEnumeration.SUCCESS.getValue(),
                     response.getResponseCode());

        // create invalid ID
        String invalidID = "123h23h29t";

        // get the invalid ID
        request = new GetMethodWebRequest(FULL_TEST_URL);
        request.setHeaderField("User-Agent", "Mozilla/5.0 Firefox...");
        request.setParameter(MessageStoreServlet.MESSAGE_RETRIEVE_PARAM_NAME,
                             invalidID);

        client = runner.newClient();

        try {
            client.getResponse(request);
            fail("Getting an invalid ID is not allowed and should throw a 404");
        } catch (HttpException he) {
            // exception should be thrown
            // check that the reponse code is correct.
            assertEquals("Reponse code is not correct",
View Full Code Here

Examples of com.volantis.testtools.servletunit.ServletUnitClient

     * @throws Exception
     */

    public void testGetStore() throws Exception {
        ServletRunner runner = new ServletRunner(createDefaultWebXML());
        ServletUnitClient client = runner.newClient();

        WebRequest getRequest = new GetMethodWebRequest(FULL_TEST_URL);
        getRequest.setParameter(MessageStoreServlet.MESSAGE_STORE_PARAM_NAME,
                             VALID_TEST_XML);

        try {
            client.getResponse(getRequest);
            fail("Storing a message is not allowed using the GET method");
        } catch (HttpException he) {
            // exception should be thrown
            // check that the reponse code is correct.
            assertEquals("Reponse code is not correct",
View Full Code Here

Examples of com.volantis.testtools.servletunit.ServletUnitClient

     * @throws Exception
     */

    public void testMixedRequest() throws Exception {
        ServletRunner runner = new ServletRunner(createDefaultWebXML());
        ServletUnitClient client = runner.newClient();

        WebRequest request = createPostRequest(VALID_TEST_XML, READER_TEST_URL);
        WebResponse response = client.getResponse(request);
        String id = response.getHeaderField(
                MessageStoreServlet.MESSAGE_RESPONSE_HEADER_NAME);

        // Check the ID has been returned OK
        assertNotNull("ID should exist in the headers", id);

        // try a POST with XML content and ID
        request = createPostRequest(VALID_TEST_XML, READER_TEST_URL);
        request.setHeaderField("User-Agent", "Mozilla/5.0 Firefox...");
        request.setParameter(MessageStoreServlet.MESSAGE_RETRIEVE_PARAM_NAME,
                             id);
        response = client.getResponse(request);
        assertEquals("The response code should indicate success",
                     MessageStoreMessageEnumeration.SUCCESS.getValue(),
                     response.getResponseCode());

    }
View Full Code Here

Examples of com.volantis.testtools.servletunit.ServletUnitClient

        // emtpy message
        final String emptyMsg = "";

        // create MSS
        ServletRunner runner = new ServletRunner(createDefaultWebXML());
        ServletUnitClient client = runner.newClient();

        WebRequest request = createPostRequest(emptyMsg, READER_TEST_URL);
        request.setHeaderField("User-Agent", "Mozilla/5.0 Firefox...");

        try {
            client.getResponse(request);
        } catch (HttpException he) {
            // exception should be thrown
            // check that the reponse code is correct.
            assertEquals("Reponse code is not correct",
                         HttpServletResponse.SC_BAD_REQUEST,
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.