[seam-commits] Seam SVN: r11269 - branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Sat Jul 11 15:47:21 EDT 2009
Author: jharting
Date: 2009-07-11 15:47:21 -0400 (Sat, 11 Jul 2009)
New Revision: 11269
Modified:
branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test/CategoryResourceTest.java
branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java
branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test/TaskResourceTest.java
Log:
Fixed seam-tasks tests and added to testall
Modified: branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test/CategoryResourceTest.java
===================================================================
--- branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test/CategoryResourceTest.java 2009-07-11 19:37:02 UTC (rev 11268)
+++ branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test/CategoryResourceTest.java 2009-07-11 19:47:21 UTC (rev 11269)
@@ -24,9 +24,12 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
-import org.jboss.seam.resteasy.testfwk.ResourceSeamTest;
-import org.jboss.seam.resteasy.testfwk.MockHttpServletResponse;
-import org.jboss.seam.resteasy.testfwk.MockHttpServletRequest;
+import org.jboss.seam.mock.SeamTest;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
+import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
+import org.jboss.seam.mock.ResourceRequestEnvironment;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -35,7 +38,7 @@
* @author Jozef Hartinger
*
*/
-public class CategoryResourceTest extends ResourceSeamTest
+public class CategoryResourceTest extends SeamTest
{
@DataProvider(name = "query")
public String[][] getQueryData()
@@ -46,11 +49,11 @@
@Test(dataProvider = "query")
public void getCategoryListTest(final String contentType, final String expectedResponse) throws Exception
{
- new ResourceRequest(Method.GET, "/v1/auth/category")
+ new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/v1/auth/category")
{
@Override
- protected void prepareRequest(MockHttpServletRequest request)
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
super.prepareRequest(request);
request.addHeader("Accept", contentType);
@@ -58,7 +61,7 @@
}
@Override
- protected void onResponse(MockHttpServletResponse response)
+ protected void onResponse(EnhancedMockHttpServletResponse response)
{
super.onResponse(response);
assertEquals(response.getStatus(), 200, "Unexpected response code.");
@@ -71,11 +74,11 @@
@Test
public void deleteCategoryTest() throws Exception
{
- new ResourceRequest(Method.DELETE, "/v1/auth/category/Work")
+ new ResourceRequest(new ResourceRequestEnvironment(this), Method.DELETE, "/v1/auth/category/Work")
{
@Override
- protected void prepareRequest(MockHttpServletRequest request)
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
super.prepareRequest(request);
request.addHeader("Accept", "application/xml");
@@ -83,7 +86,7 @@
}
@Override
- protected void onResponse(MockHttpServletResponse response)
+ protected void onResponse(EnhancedMockHttpServletResponse response)
{
super.onResponse(response);
assertEquals(response.getStatus(), 204, "Unexpected response code.");
@@ -100,18 +103,18 @@
final String mimeType = "application/json";
final String expectedResponse = "{\"category\":{\"name\":\"Test Category\"}}";
- new ResourceRequest(Method.PUT, uri)
+ new ResourceRequest(new ResourceRequestEnvironment(this), Method.PUT, uri)
{
@Override
- protected void prepareRequest(MockHttpServletRequest request)
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
super.prepareRequest(request);
request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
}
@Override
- protected void onResponse(MockHttpServletResponse response)
+ protected void onResponse(EnhancedMockHttpServletResponse response)
{
super.onResponse(response);
assertEquals(response.getStatus(), 201, "Unexpected response code.");
@@ -119,11 +122,11 @@
}.run();
- new ResourceRequest(Method.GET, uri)
+ new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, uri)
{
@Override
- protected void prepareRequest(MockHttpServletRequest request)
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
super.prepareRequest(request);
request.addHeader("Accept", mimeType);
@@ -131,7 +134,7 @@
}
@Override
- protected void onResponse(MockHttpServletResponse response)
+ protected void onResponse(EnhancedMockHttpServletResponse response)
{
super.onResponse(response);
assertEquals(response.getStatus(), 200, "Unexpected response code.");
@@ -144,18 +147,18 @@
@Test
public void noAuthorizationHeaderTest() throws Exception
{
- new ResourceRequest(Method.GET, "/v1/auth/category")
+ new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/v1/auth/category")
{
@Override
- protected void prepareRequest(MockHttpServletRequest request)
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
super.prepareRequest(request);
request.addHeader("Accept", "application/xml");
}
@Override
- protected void onResponse(MockHttpServletResponse response)
+ protected void onResponse(EnhancedMockHttpServletResponse response)
{
super.onResponse(response);
assertEquals(response.getStatus(), 401, "Unexpected response code.");
Modified: branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java
===================================================================
--- branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java 2009-07-11 19:37:02 UTC (rev 11268)
+++ branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test/ResolvedTaskResourceQueryTest.java 2009-07-11 19:47:21 UTC (rev 11269)
@@ -24,9 +24,12 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
-import org.jboss.seam.resteasy.testfwk.ResourceSeamTest;
-import org.jboss.seam.resteasy.testfwk.MockHttpServletResponse;
-import org.jboss.seam.resteasy.testfwk.MockHttpServletRequest;
+import org.jboss.seam.mock.SeamTest;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
+import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
+import org.jboss.seam.mock.ResourceRequestEnvironment;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -36,7 +39,7 @@
* @author Jozef Hartinger
*
*/
-public class ResolvedTaskResourceQueryTest extends ResourceSeamTest
+public class ResolvedTaskResourceQueryTest extends SeamTest
{
// We could do this BeforeClass only once but we can't do ResourceRequests there
@@ -46,11 +49,11 @@
final String mimeType = "application/xml";
final String representation = "<task><id>14</id></task>";
- new ResourceRequest(Method.PUT, "/v1/auth/category/School/resolved/14")
+ new ResourceRequest(new ResourceRequestEnvironment(this), Method.PUT, "/v1/auth/category/School/resolved/14")
{
@Override
- protected void prepareRequest(MockHttpServletRequest request)
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
super.prepareRequest(request);
request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
@@ -60,7 +63,7 @@
}
@Override
- protected void onResponse(MockHttpServletResponse response)
+ protected void onResponse(EnhancedMockHttpServletResponse response)
{
super.onResponse(response);
assertEquals(response.getStatus(), 204, "Unexpected response code.");
@@ -81,18 +84,18 @@
@Test(dataProvider="data")
public void editTaskTest(final String mimeType, final String expectedResponsePart) throws Exception
{
- new ResourceRequest(Method.GET, "/v1/user/demo/tasks/resolved")
+ new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/v1/user/demo/tasks/resolved")
{
@Override
- protected void prepareRequest(MockHttpServletRequest request)
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
super.prepareRequest(request);
request.addHeader("Accept", mimeType);
}
@Override
- protected void onResponse(MockHttpServletResponse response)
+ protected void onResponse(EnhancedMockHttpServletResponse response)
{
super.onResponse(response);
assertEquals(response.getStatus(), 200, "Unexpected response code.");
Modified: branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test/TaskResourceTest.java
===================================================================
--- branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test/TaskResourceTest.java 2009-07-11 19:37:02 UTC (rev 11268)
+++ branches/community/Seam_2_2/examples/tasks/src/main/org/jboss/seam/example/tasks/test/TaskResourceTest.java 2009-07-11 19:47:21 UTC (rev 11269)
@@ -24,9 +24,12 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
-import org.jboss.seam.resteasy.testfwk.ResourceSeamTest;
-import org.jboss.seam.resteasy.testfwk.MockHttpServletResponse;
-import org.jboss.seam.resteasy.testfwk.MockHttpServletRequest;
+import org.jboss.seam.mock.SeamTest;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
+import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
+import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
+import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
+import org.jboss.seam.mock.ResourceRequestEnvironment;
import org.testng.annotations.Test;
/**
@@ -34,7 +37,7 @@
* @author Jozef Hartinger
*
*/
-public class TaskResourceTest extends ResourceSeamTest
+public class TaskResourceTest extends SeamTest
{
@Test
public void createTaskTest() throws Exception
@@ -42,11 +45,11 @@
final String mimeType = "application/json";
final String representation = "{\"task\":{\"name\":\"Test task\"}}";
- new ResourceRequest(Method.POST, "/v1/auth/category/School/unresolved")
+ new ResourceRequest(new ResourceRequestEnvironment(this), Method.POST, "/v1/auth/category/School/unresolved")
{
@Override
- protected void prepareRequest(MockHttpServletRequest request)
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
super.prepareRequest(request);
request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
@@ -56,7 +59,7 @@
}
@Override
- protected void onResponse(MockHttpServletResponse response)
+ protected void onResponse(EnhancedMockHttpServletResponse response)
{
super.onResponse(response);
assertEquals(response.getStatus(), 201, "Unexpected response code.");
@@ -71,11 +74,11 @@
final String mimeType = "application/xml";
final String representation = "<task><id>4</id><name>Learn new English vocabulary</name></task>";
- new ResourceRequest(Method.PUT, "/v1/auth/category/School/unresolved/4")
+ new ResourceRequest(new ResourceRequestEnvironment(this), Method.PUT, "/v1/auth/category/School/unresolved/4")
{
@Override
- protected void prepareRequest(MockHttpServletRequest request)
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
super.prepareRequest(request);
request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
@@ -85,7 +88,7 @@
}
@Override
- protected void onResponse(MockHttpServletResponse response)
+ protected void onResponse(EnhancedMockHttpServletResponse response)
{
super.onResponse(response);
assertEquals(response.getStatus(), 204, "Unexpected response code.");
@@ -93,11 +96,11 @@
}.run();
- new ResourceRequest(Method.GET, "/v1/auth/category/School/unresolved/4")
+ new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/v1/auth/category/School/unresolved/4")
{
@Override
- protected void prepareRequest(MockHttpServletRequest request)
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
super.prepareRequest(request);
request.addHeader("Accept", "application/xml");
@@ -105,7 +108,7 @@
}
@Override
- protected void onResponse(MockHttpServletResponse response)
+ protected void onResponse(EnhancedMockHttpServletResponse response)
{
super.onResponse(response);
assertEquals(response.getStatus(), 200, "Unexpected response code.");
@@ -118,18 +121,18 @@
@Test
public void deleteTaskTest() throws Exception
{
- new ResourceRequest(Method.DELETE, "/v1/auth/category/School/unresolved/2")
+ new ResourceRequest(new ResourceRequestEnvironment(this), Method.DELETE, "/v1/auth/category/School/unresolved/2")
{
@Override
- protected void prepareRequest(MockHttpServletRequest request)
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
super.prepareRequest(request);
request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
}
@Override
- protected void onResponse(MockHttpServletResponse response)
+ protected void onResponse(EnhancedMockHttpServletResponse response)
{
super.onResponse(response);
assertEquals(response.getStatus(), 204, "Unexpected response code.");
More information about the seam-commits
mailing list