Package org.jboss.resteasy.cdi.test

Source Code of org.jboss.resteasy.cdi.test.AbstractTest

package org.jboss.resteasy.cdi.test;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
* Contains utility methods used heavily in tests.
* @author Jozef Hartinger
*
*/
public abstract class AbstractTest
{
   private HttpClient client = new HttpClient();
   public static final String BASE_URI = "http://localhost:8080/resteasy-cdi/";
  
   public void testPlainTextReadonlyResource(String uri, String body)
   {
      GetMethod get = new GetMethod(uri);
      get.addRequestHeader("Accept", "text/plain");
      try
      {
         int status = client.executeMethod(get);
         assertEquals(200, status);
         assertTrue(get.getResponseBodyAsString().contains(body));
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }
      finally
      {
         get.releaseConnection();
      }
   }
  
   public void testPlainTextReadonlyResource(String uri, boolean body)
   {
      testPlainTextReadonlyResource(uri, String.valueOf(body));
   }
}
TOP

Related Classes of org.jboss.resteasy.cdi.test.AbstractTest

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.