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

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Sun Aug 1 13:11:43 EDT 2010


Author: aslak
Date: 2010-08-01 13:11:42 -0400 (Sun, 01 Aug 2010)
New Revision: 6872

Added:
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/producer/field/named/
   core/trunk/tests-arquillian/src/test/resources/org/jboss/weld/tests/producer/
Removed:
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/
Modified:
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java
Log:
WELD-493 Converted NamedProducerTest to Arquillian

Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/producer/field/named (from rev 6868, core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named)

Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java	2010-08-01 16:19:26 UTC (rev 6868)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java	2010-08-01 17:11:42 UTC (rev 6872)
@@ -20,14 +20,18 @@
 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 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.WebClient;
 import com.gargoylesoftware.htmlunit.html.HtmlElement;
@@ -41,19 +45,27 @@
  * @author Pete Muir
  *
  */
- at Artifact(addCurrentPackage=false)
- at Classes({User.class, NewUserAction.class, Employee.class, SaveAction.class})
- at IntegrationTest(runLocally=true)
- at Resources({
-   @Resource(destination=WarArtifactDescriptor.WEB_XML_DESTINATION, source="web.xml"),
-   @Resource(destination="view.xhtml", source="view.xhtml"),
-   @Resource(destination="home.xhtml", source="home.xhtml"),
-   @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml")
-})
-public class NamedProducerTest extends AbstractWeldTest
+ at Category(Integration.class)
+ at RunWith(Arquillian.class)
+ at Run(RunModeType.AS_CLIENT)
+public class NamedProducerTest
 {
-   
-   @Test(description = "forum post")
+   @Deployment
+   public static WebArchive createDeployment() 
+   {
+      return ShrinkWrap.create(WebArchive.class, "test.war")
+               .addClasses(User.class, NewUserAction.class, Employee.class, SaveAction.class)
+               .addWebResource(NamedProducerTest.class.getPackage(), "web.xml", "web.xml")
+               .addWebResource(NamedProducerTest.class.getPackage(), "faces-config.xml", "faces-config.xml")
+               .addResource(NamedProducerTest.class.getPackage(), "view.xhtml", "view.xhtml")
+               .addResource(NamedProducerTest.class.getPackage(), "home.xhtml", "home.xhtml")
+               .addWebResource(EmptyAsset.INSTANCE, "beans.xml");
+   }
+
+   /*
+    * description = "forum post"
+    */
+   @Test
    public void testNamedProducerWorks() throws Exception
    {
       WebClient client = new WebClient();
@@ -61,10 +73,13 @@
       
       HtmlPage page = client.getPage(getPath("/view.jsf"));
       // Check the page rendered ok
-      assert getFirstMatchingElement(page, HtmlSubmitInput.class, "saveButton") != null;
+      Assert.assertNotNull(getFirstMatchingElement(page, HtmlSubmitInput.class, "saveButton"));
    }
    
-   @Test(description = "WELD-404")
+   /*
+    * description = "WELD-404"
+    */
+   @Test
    public void testNamedProducerFieldLoosesValues() throws Exception
    {
       WebClient client = new WebClient();
@@ -74,13 +89,21 @@
       HtmlSubmitInput saveButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "saveButton");
       HtmlTextInput employeeFieldName = getFirstMatchingElement(page, HtmlTextInput.class, "employeeFieldName");
       HtmlTextInput employeeMethodName = getFirstMatchingElement(page, HtmlTextInput.class, "employeeMethodName");
-      assert employeeFieldName != null;
-      assert employeeMethodName != null;
-      assert saveButton != null;
+      
+      Assert.assertNotNull(employeeFieldName);
+      Assert.assertNotNull(employeeMethodName);
+      Assert.assertNotNull(saveButton);
+      
       employeeFieldName.setValueAttribute("Pete");
       employeeMethodName.setValueAttribute("Gavin");
       saveButton.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)
    {
@@ -101,7 +124,6 @@
  
    protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page, Class<T> elementClass, String id)
    {
-     
      Set<T> inputs = getElements(page.getBody(), elementClass);
      for (T input : inputs)
      {
@@ -112,5 +134,4 @@
      }
      return null;
    }
-   
-}
+}
\ No newline at end of file

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



More information about the weld-commits mailing list