[seam-commits] Seam SVN: r14630 - branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/src/test/java/org/jboss/seam/example/restbay/test.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Apr 23 05:02:29 EDT 2012
Author: maschmid
Date: 2012-04-23 05:02:28 -0400 (Mon, 23 Apr 2012)
New Revision: 14630
Modified:
branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/src/test/java/org/jboss/seam/example/restbay/test/ResourceQueryTest.java
Log:
restbay example, fix ResourceQueryTest test to not be dependant on undefined ordering of categories
Modified: branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/src/test/java/org/jboss/seam/example/restbay/test/ResourceQueryTest.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/src/test/java/org/jboss/seam/example/restbay/test/ResourceQueryTest.java 2012-04-23 09:01:01 UTC (rev 14629)
+++ branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/src/test/java/org/jboss/seam/example/restbay/test/ResourceQueryTest.java 2012-04-23 09:02:28 UTC (rev 14630)
@@ -1,5 +1,9 @@
package org.jboss.seam.example.restbay.test;
+import static org.junit.Assert.assertTrue;
+
+import java.util.regex.Pattern;
+
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OverProtocol;
import org.jboss.arquillian.junit.Arquillian;
@@ -9,15 +13,14 @@
import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
-import org.jboss.seam.mock.SeamTest;
import org.jboss.seam.mock.ResourceRequestEnvironment;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.assertEquals;
+
/**
*
* @author Jozef Hartinger
@@ -63,8 +66,15 @@
@Override
protected void onResponse(EnhancedMockHttpServletResponse response)
{
- String expectedResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><collection><category><categoryId>3</categoryId><name>Books</name></category><category><categoryId>4</categoryId><name>Cameras and Photography</name></category></collection>";
- assertEquals("Unexpected response.", expectedResponse, response.getContentAsString());
+ String responseString = response.getContentAsString();
+ String expectedResponseRegex = "<\\?xml version=\"1\\.0\" encoding=\"UTF-8\" standalone=\"yes\"\\?>" +
+ "<collection>" +
+ "(<category>" +
+ "<categoryId>[^<]+</categoryId><name>[^<]+</name>" +
+ "(<parent><categoryId>[^<]+</categoryId><name>[^<]+</name></parent>)?" +
+ "</category>){2}" +
+ "</collection>";
+ assertTrue("The response string doesn't match the expected response. " + responseString, Pattern.matches(expectedResponseRegex, responseString));
}
}.run();
More information about the seam-commits
mailing list