I want to test my REST service using the RestEasy Client Framework. In my application, I use Basic Authentication. According to the RestEasy documentation, I use org.apache.http.impl.client.DefaultHttpClient to set credentials for authentication.
For the HTTP-GET Request, this works fine, I logged in and get the Response result that I wanted.
But what if I want to make an HTTP message / HTTP-Put with a Java object (in XML) in an HTTP request tag? Is there a way to automatically marshall Java Object in HTTP-Body when I use org.apache.http.impl.client.DefaultHttpClient ?
Here is my authentication code, can someone tell me how to do HTTP Post / HTTP Put without writing an XML String or using an InputStream?
@Test public void testClient() throws Exception { DefaultHttpClient client = new DefaultHttpClient(); client.getCredentialsProvider().setCredentials( new AuthScope(host, port), new UsernamePasswordCredentials(username, password)); ApacheHttpClient4Executor executer = new ApacheHttpClient4Executor( client); ClientRequest request = new ClientRequest(requestUrl, executer); request.accept("*/*").pathParameter("param", requestParam);
Is it possible to use the Mock platform on the server side and then marshall and send your object there?
source share