Package org.apache.wink.client

Examples of org.apache.wink.client.MockHttpServer$HttpProcessor


        InputStream input = new FileInputStream(inDir + "tsa_response.asn1");
        byte[] content = IOUtils.toByteArray(input);
        input.close();

        // mock TSA server (RFC 3161)
        MockHttpServer mockServer = new MockHttpServer(15371);
        mockServer.startServer();
        String tsaUrl = "http://localhost:" + mockServer.getServerPort() + "/";
        MockHttpServer.MockHttpServerResponse response = new MockHttpServer.MockHttpServerResponse();
        response.setMockResponseContent(content);
        response.setMockResponseContentType("application/timestamp-reply");
        response.setMockResponseCode(200);
        mockServer.setMockHttpServerResponses(response);

        // TSA client
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        TSAClient tsaClient = new TSAClient(new URL(tsaUrl), null, null, digest);
View Full Code Here


                                                    + "        <content type=\"text\">This is entity created by John Smith</content>\n"
                                                    + "    </entry>\n"
                                                    + "</feed>\n";

    public void testAtomFeedReadWrite() throws WebApplicationException, IOException {
        MockHttpServer server = new MockHttpServer(SERVER_PORT);
        server.setMockResponseCode(200);
        server.setMockResponseContentEchoRequest(true);
        server.setMockResponseContentType(MediaType.APPLICATION_ATOM_XML);
        server.startServer();
        try {
            RestClient client = new RestClient();
            Resource resource =
                client.resource(MessageFormat.format(SERVICE_URL, String.valueOf(server
                    .getServerPort())));

            AtomFeedProvider afp = new AtomFeedProvider();
            AtomFeed entryToPost =
                afp.readFrom(AtomFeed.class,
                             null,
                             null,
                             MediaType.APPLICATION_ATOM_XML_TYPE,
                             null,
                             new ByteArrayInputStream(FEED.getBytes()));
            AtomFeed responseEntity =
                resource.accept(MediaType.APPLICATION_ATOM_XML_TYPE)
                    .contentType(MediaType.APPLICATION_ATOM_XML_TYPE).post(AtomFeed.class,
                                                                           entryToPost);

            ByteArrayOutputStream os = new ByteArrayOutputStream();
            afp.writeTo(responseEntity,
                        AtomFeed.class,
                        null,
                        null,
                        MediaType.APPLICATION_ATOM_XML_TYPE,
                        null,
                        os);
            String actual = os.toString();

            assertEquals(FEED, actual);
        } finally {
            server.stopServer();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.wink.client.MockHttpServer$HttpProcessor

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.