[weld-commits] Weld SVN: r6868 - in core/trunk: tests/src/test/resources/org/jboss/weld/tests and 6 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Sun Aug 1 12:19:27 EDT 2010


Author: aslak
Date: 2010-08-01 12:19:26 -0400 (Sun, 01 Aug 2010)
New Revision: 6868

Added:
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/conversation/
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/errorpage/
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/
   core/trunk/tests-arquillian/src/test/resources/org/jboss/weld/tests/contexts/
Removed:
   core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/
   core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/errorpage/
   core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/
Modified:
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/conversation/ClientConversationContextTest.java
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/errorpage/ErrorPageTest.java
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java
   core/trunk/tests-arquillian/src/test/resources/org/jboss/weld/tests/contexts/conversation/web.xml
Log:
WELD-493 Converted contexts tests to Arquillian

Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/conversation (from rev 6838, core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation)

Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/conversation/ClientConversationContextTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/conversation/ClientConversationContextTest.java	2010-07-29 12:21:41 UTC (rev 6838)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/conversation/ClientConversationContextTest.java	2010-08-01 16:19:26 UTC (rev 6868)
@@ -33,14 +33,18 @@
  * limitations under the License.
  */
 
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.impl.packaging.IntegrationTest;
-import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.Resources;
-import org.jboss.testharness.impl.packaging.war.WebXml;
-import org.jboss.weld.test.AbstractWeldTest;
-import org.testng.annotations.Test;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.api.Run;
+import org.jboss.arquillian.api.RunModeType;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.weld.tests.category.Integration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
 
 import com.gargoylesoftware.htmlunit.Page;
 import com.gargoylesoftware.htmlunit.WebClient;
@@ -49,15 +53,10 @@
  * @author Nicklas Karlsson
  * @author Dan Allen
  */
- at Artifact(addCurrentPackage = false)
- at Classes( { ConversationTestPhaseListener.class, Cloud.class })
- at IntegrationTest(runLocally = true)
- at Resources( { 
-   @Resource(destination = "cloud.jspx", source = "cloud.jsf"),
-   @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml")
-})
- at WebXml("web.xml")
-public class ClientConversationContextTest extends AbstractWeldTest
+ at Category(Integration.class)
+ at RunWith(Arquillian.class)
+ at Run(RunModeType.AS_CLIENT)
+public class ClientConversationContextTest 
 {
 
    public static final String CID_REQUEST_PARAMETER_NAME = "cid";
@@ -66,28 +65,40 @@
 
    public static final String LONG_RUNNING_HEADER_NAME = "org.jboss.jsr299.tck.longRunning";
 
-   @Test(groups = { "contexts" })
+   @Deployment
+   public static WebArchive createDeployment() 
+   {
+      return ShrinkWrap.create(WebArchive.class, "test.war")
+               .addClasses(ConversationTestPhaseListener.class, Cloud.class)
+               .addWebResource(ClientConversationContextTest.class.getPackage(), "web.xml", "web.xml")
+               .addWebResource(ClientConversationContextTest.class.getPackage(), "faces-config.xml", "faces-config.xml")
+               .addResource(ClientConversationContextTest.class.getPackage(), "cloud.jsf", "cloud.jspx")
+               .addWebResource(EmptyAsset.INSTANCE, "beans.xml");
+   }
+   
+   @Test
    public void testConversationPropagationToNonExistentConversationLeadsException() throws Exception
    {
       WebClient client = new WebClient();
       client.setThrowExceptionOnFailingStatusCode(false);
       Page page = client.getPage(getPath("/cloud.jsf", "org.jboss.jsr299"));
-      assert page.getWebResponse().getStatusCode() == 500;
+      
+      Assert.assertEquals(500, page.getWebResponse().getStatusCode());
    }
 
-   protected Boolean isLongRunning(Page page)
-   {
-      return Boolean.valueOf(page.getWebResponse().getResponseHeaderValue(LONG_RUNNING_HEADER_NAME));
-   }
+//   protected Boolean isLongRunning(Page page)
+//   {
+//      return Boolean.valueOf(page.getWebResponse().getResponseHeaderValue(LONG_RUNNING_HEADER_NAME));
+//   }
 
    protected String getPath(String viewId, String cid)
    {
-      return getContextPath() + viewId + "?" + CID_REQUEST_PARAMETER_NAME + "=" + cid;
+      // TODO: this should be moved out and be handled by Arquillian
+      return "http://localhost:8080/test/" + viewId + "?" + CID_REQUEST_PARAMETER_NAME + "=" + cid;
    }
 
-   protected String getCid(Page page)
-   {
-      return page.getWebResponse().getResponseHeaderValue(CID_HEADER_NAME);
-   }
-
+//   protected String getCid(Page page)
+//   {
+//      return page.getWebResponse().getResponseHeaderValue(CID_HEADER_NAME);
+//   }
 }
\ No newline at end of file

Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/errorpage (from rev 6838, core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/errorpage)

Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/errorpage/ErrorPageTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/errorpage/ErrorPageTest.java	2010-07-29 12:21:41 UTC (rev 6838)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/errorpage/ErrorPageTest.java	2010-08-01 16:19:26 UTC (rev 6868)
@@ -20,15 +20,21 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.impl.packaging.IntegrationTest;
-import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.Resources;
-import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
-import org.jboss.weld.test.AbstractWeldTest;
-import org.testng.annotations.Test;
+import junit.framework.Assert;
 
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.api.Run;
+import org.jboss.arquillian.api.RunModeType;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.weld.tests.category.Broken;
+import org.jboss.weld.tests.category.Integration;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
 import com.gargoylesoftware.htmlunit.WebClient;
 import com.gargoylesoftware.htmlunit.html.HtmlDivision;
 import com.gargoylesoftware.htmlunit.html.HtmlElement;
@@ -44,18 +50,28 @@
  * @author David Allen
  *
  */
- at Artifact(addCurrentPackage=false)
- at Classes({Storm.class, Rain.class})
- at IntegrationTest(runLocally=true)
- at Resources({
-  @Resource(destination=WarArtifactDescriptor.WEB_XML_DESTINATION, source="web.xml"),
-  @Resource(destination="storm.jspx", source="storm.jsf"),
-  @Resource(destination="error.jspx", source="error.jsf"),
-  @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml")
-})
-public class ErrorPageTest extends AbstractWeldTest
+ at Category(Integration.class)
+ at RunWith(Arquillian.class)
+ at Run(RunModeType.AS_CLIENT)
+public class ErrorPageTest 
 {
-   @Test(description = "WELD-29", groups = { "broken" })
+   @Deployment
+   public static WebArchive createDeployment() 
+   {
+      return ShrinkWrap.create(WebArchive.class, "test.war")
+               .addClasses(Storm.class, Rain.class)
+               .addWebResource(ErrorPageTest.class.getPackage(), "web.xml", "web.xml")
+               .addWebResource(ErrorPageTest.class.getPackage(), "faces-config.xml", "faces-config.xml")
+               .addResource(ErrorPageTest.class.getPackage(), "error.jsf", "error.jspx")
+               .addResource(ErrorPageTest.class.getPackage(), "storm.jsf", "storm.jspx")
+               .addWebResource(EmptyAsset.INSTANCE, "beans.xml");
+   }
+
+   /*
+    * description = "WELD-29"
+    */
+   @Category(Broken.class)
+   @Test
    public void testActionMethodExceptionDoesNotDestroyContext() throws Exception
    {
       WebClient client = new WebClient();
@@ -66,13 +82,21 @@
       HtmlTextInput strength = getFirstMatchingElement(page, HtmlTextInput.class, "stormStrength");
       strength.setValueAttribute("10");
       page = disasterButton.click();
-      assert "Application Error".equals(page.getTitleText());
+      Assert.assertEquals("Application Error", page.getTitleText());
+      
       HtmlDivision conversationValue = getFirstMatchingElement(page, HtmlDivision.class, "conversation");
-      assert conversationValue.asText().equals("10");
+      Assert.assertEquals("10", conversationValue.asText());
+      
       HtmlDivision requestValue = getFirstMatchingElement(page, HtmlDivision.class, "request");
-      assert requestValue.asText().equals("medium");
+      Assert.assertEquals("medium", requestValue.asText());
    }
 
+   protected String getPath(String page)
+   {
+      // TODO: this should be moved out and be handled by Arquillian
+      return "http://localhost:8080/test/" + page;
+   }
+
    protected <T> Set<T> getElements(HtmlElement rootElement, Class<T> elementClass)
    {
      Set<T> result = new HashSet<T>();
@@ -103,5 +127,4 @@
      }
      return null;
    }
-   
-}
+}
\ No newline at end of file

Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation (from rev 6838, core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation)

Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java	2010-07-29 12:21:41 UTC (rev 6838)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java	2010-08-01 16:19:26 UTC (rev 6868)
@@ -17,21 +17,22 @@
 
 package org.jboss.weld.tests.contexts.sessionInvalidation;
 
-import java.io.IOException;
-import java.net.MalformedURLException;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.impl.packaging.IntegrationTest;
-import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.Resources;
-import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
-import org.jboss.weld.test.AbstractWeldTest;
-import org.testng.annotations.Test;
+import junit.framework.Assert;
 
-import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.api.Run;
+import org.jboss.arquillian.api.RunModeType;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.weld.tests.contexts.errorpage.ErrorPageTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
 import com.gargoylesoftware.htmlunit.WebClient;
 import com.gargoylesoftware.htmlunit.html.HtmlElement;
 import com.gargoylesoftware.htmlunit.html.HtmlInput;
@@ -44,17 +45,33 @@
  * @author Pete Muir
  *
  */
- at Artifact(addCurrentPackage=false)
- at Classes({Storm.class,SomeBean.class})
- at IntegrationTest(runLocally=true)
- at Resources({
-   @Resource(destination=WarArtifactDescriptor.WEB_XML_DESTINATION, source="web.xml"),
-   @Resource(destination="storm.jspx", source="storm.jsf"),
-   @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml")
-})
-public class InvalidateSessionTest extends AbstractWeldTest
+//@Artifact(addCurrentPackage=false)
+//@Classes({Storm.class,SomeBean.class})
+//@IntegrationTest(runLocally=true)
+//@Resources({
+//   @Resource(destination=WarArtifactDescriptor.WEB_XML_DESTINATION, source="web.xml"),
+//   @Resource(destination="storm.jspx", source="storm.jsf"),
+//   @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml")
+//})
+ at RunWith(Arquillian.class)
+ at Run(RunModeType.AS_CLIENT)
+public class InvalidateSessionTest
 {
-   @Test(description = "WELD-380, WELD-403")
+   @Deployment
+   public static WebArchive createDeployment() 
+   {
+      return ShrinkWrap.create(WebArchive.class, "test.war")
+               .addClasses(Storm.class, SomeBean.class)
+               .addWebResource(InvalidateSessionTest.class.getPackage(), "web.xml", "web.xml")
+               .addWebResource(InvalidateSessionTest.class.getPackage(), "faces-config.xml", "faces-config.xml")
+               .addResource(InvalidateSessionTest.class.getPackage(), "storm.jsf", "storm.jspx")
+               .addWebResource(EmptyAsset.INSTANCE, "beans.xml");
+   }
+
+   /*
+    * description = "WELD-380, WELD-403"
+    */
+   @Test
    public void testInvalidateSessionCalled() throws Exception
    {
       WebClient client = new WebClient();
@@ -64,16 +81,19 @@
       HtmlSubmitInput invalidateSessionButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "invalidateSessionButton");
       page = invalidateSessionButton.click();
       HtmlInput inputField = getFirstMatchingElement(page, HtmlInput.class, "prop");
-      assert Storm.PROPERTY_VALUE.equals(inputField.getValueAttribute());
+      Assert.assertEquals(Storm.PROPERTY_VALUE, inputField.getValueAttribute());
       
       // Make another request to verify that the session bean value is not the
       // one from the previous invalidated session.
       page = client.getPage(getPath("/storm.jsf"));
       inputField = getFirstMatchingElement(page, HtmlInput.class, "prop");
-      assert SomeBean.DEFAULT_PROPERTY_VALUE.equals(inputField.getValueAttribute());
+      Assert.assertEquals(SomeBean.DEFAULT_PROPERTY_VALUE, inputField.getValueAttribute());
    }
 
-   @Test(description="WELD-461")
+   /*
+    * description = "WELD-461"
+    */
+   @Test
    public void testNoDoubleDestructionOnExternalRedirect() throws Exception
    {
 	   WebClient client = new WebClient();
@@ -82,6 +102,12 @@
 	   button.click();
    }
    
+   protected String getPath(String page)
+   {
+      // TODO: this should be moved out and be handled by Arquillian
+      return "http://localhost:8080/test/" + page;
+   }
+
    protected <T> Set<T> getElements(HtmlElement rootElement, Class<T> elementClass)
    {
      Set<T> result = new HashSet<T>();

Copied: core/trunk/tests-arquillian/src/test/resources/org/jboss/weld/tests/contexts (from rev 6838, core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts)

Modified: core/trunk/tests-arquillian/src/test/resources/org/jboss/weld/tests/contexts/conversation/web.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/conversation/web.xml	2010-07-29 12:21:41 UTC (rev 6838)
+++ core/trunk/tests-arquillian/src/test/resources/org/jboss/weld/tests/contexts/conversation/web.xml	2010-08-01 16:19:26 UTC (rev 6868)
@@ -25,10 +25,6 @@
       <param-value>.jspx</param-value>
    </context-param>
    
-   <listener>
-      <listener-class>org.jboss.testharness.impl.runner.servlet.HarnessServletListener</listener-class>
-   </listener>
-
    <session-config>
       <session-timeout>10</session-timeout>
    </session-config>



More information about the weld-commits mailing list