Author: kpiwko(a)redhat.com
Date: 2009-10-21 10:03:01 -0400 (Wed, 21 Oct 2009)
New Revision: 11609
Modified:
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java
Log:
JBSEAM-4451
Modified:
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java
===================================================================
---
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java 2009-10-21
11:24:33 UTC (rev 11608)
+++
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java 2009-10-21
14:03:01 UTC (rev 11609)
@@ -37,7 +37,12 @@
@Override
protected void prepareData()
{
- newComponentProperties = new String[] { "hi", "HiLocal",
"Hi", "hi", "hiPage" };
+ // war version
+ if(SeamGenTest.WAR)
+ newComponent = new ComponentHolder("hi", null, "Hi",
"hi", "hiPage");
+ // ear version
+ else
+ newComponent = new ComponentHolder("hi", "HiLocal",
"Hi", "hi", "hiPage");
}
@Override
Modified:
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java
===================================================================
---
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java 2009-10-21
11:24:33 UTC (rev 11608)
+++
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java 2009-10-21
14:03:01 UTC (rev 11609)
@@ -21,11 +21,14 @@
*/
package org.jboss.seam.test.functional.seamgen;
+import static org.testng.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import static org.testng.Assert.assertTrue;
-
/**
* This class verifies functionality of "new-action command".
* @author Jozef Hartinger
@@ -34,7 +37,7 @@
public class NewActionTest extends SeleniumSeamGenTest
{
- protected String[] newComponentProperties;
+ protected ComponentHolder newComponent;
@BeforeClass
public void createNewAction() throws InterruptedException {
@@ -48,8 +51,8 @@
@Test(groups = { "newActionGroup" }, dependsOnGroups = {
"newProjectGroup" })
public void testNewComponent()
{
- String form = "id=" + newComponentProperties[0] + "Form";
- String button = form + ":" + newComponentProperties[3];
+ String form = "id=" + newComponent.name + "Form";
+ String button = form + ":" + newComponent.actionMethod;
browser.open(getComponentPath());
@@ -60,23 +63,72 @@
browser.clickAndWait(button);
assertTrue(browser.isElementPresent(MESSAGES));
- assertTrue(browser.getText(MESSAGES).contains(newComponentProperties[3]));
+ assertTrue(browser.getText(MESSAGES).contains(newComponent.actionMethod));
}
public void generateNewComponent()
{
- seamGen.newAction(newComponentProperties);
+ seamGen.newAction(newComponent.asArray());
}
protected void prepareData() {
- newComponentProperties = new String[]{ "ping", "PingLocal",
"Ping", "ping", "pingPage" };
+ // war version
+ if(SeamGenTest.WAR)
+ newComponent = new ComponentHolder("ping", null, "Ping",
"ping", "pingPage");
+ // ear version
+ else
+ newComponent = new ComponentHolder("ping", "PingLocal",
"Ping", "ping", "pingPage");
}
public String getComponentPath() {
- return "/" + APP_NAME + "/" + newComponentProperties[4] +
".seam";
+ return "/" + APP_NAME + "/" + newComponent.pageName +
".seam";
}
protected void deployNewComponent() {
seamGen.restart();
+ }
+}
+
+/**
+ * Holds component input for seam-gen
+ * @author kpiwko
+ *
+ */
+class ComponentHolder {
+ String name;
+ String localInterface;
+ String beanClass;
+ String actionMethod;
+ String pageName;
+
+ /**
+ * Constructs new component holder
+ * @param name Name of component
+ * @param localInterface Name of local interface
+ * @param beanClass Name of bean class
+ * @param actionMethod Name of action method
+ * @param pageName Name of Seam page
+ */
+ public ComponentHolder(String name, String localInterface, String beanClass, String
actionMethod, String pageName) {
+ this.name = name;
+ this.localInterface = localInterface;
+ this.beanClass = beanClass;
+ this.actionMethod = actionMethod;
+ this.pageName = pageName;
}
+
+ /**
+ * Return properties set in holder as array of strings
+ * @return Constructed array
+ */
+ public String[] asArray() {
+ List<String> list = new ArrayList<String>();
+ if(name!=null) list.add(name);
+ if(localInterface!=null) list.add(localInterface);
+ if(beanClass!=null) list.add(beanClass);
+ if(actionMethod!=null) list.add(actionMethod);
+ if(pageName!=null) list.add(pageName);
+
+ return list.toArray(new String[] {});
+ }
}
Modified:
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java
===================================================================
---
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java 2009-10-21
11:24:33 UTC (rev 11608)
+++
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java 2009-10-21
14:03:01 UTC (rev 11609)
@@ -39,8 +39,8 @@
public void testNewComponent()
{
- String form = "id=" + newComponentProperties[0] + "Form";
- String button = form + ":" + newComponentProperties[3];
+ String form = "id=" + newComponent.name + "Form";
+ String button = form + ":" + newComponent.actionMethod;
String field = form + ":" + "valueField:value";
String value = "world";
@@ -55,17 +55,22 @@
browser.clickAndWait(button);
assertTrue(browser.isElementPresent(MESSAGES), "Message not found.");
- assertEquals(browser.getText(MESSAGES), newComponentProperties[3] + " " +
value, "Unexpected form output.");
+ assertEquals(browser.getText(MESSAGES), newComponent.actionMethod + " " +
value, "Unexpected form output.");
}
@Override
protected void prepareData() {
- newComponentProperties = new String[]{ "hello", "HelloLocal",
"Hello", "hello", "helloPage" };
+ // war version
+ if (SeamGenTest.WAR)
+ newComponent = new ComponentHolder("hello", null, "Hello",
"hello", "helloPage");
+ // ear version
+ else
+ newComponent = new ComponentHolder("hello", "HelloLocal",
"Hello", "hello", "helloPage");
}
@Override
public void generateNewComponent()
{
- seamGen.newForm(newComponentProperties);
+ seamGen.newForm(newComponent.asArray());
}
}
Modified:
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java
===================================================================
---
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java 2009-10-21
11:24:33 UTC (rev 11608)
+++
branches/community/Seam_2_2/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java 2009-10-21
14:03:01 UTC (rev 11609)
@@ -197,7 +197,7 @@
*/
class InputStreamEater extends Thread
{
- private static final String INPUT_CHALLENGE = "[input]";
+ private static final String INPUT_CHALLENGE = "[input] Enter";
private BufferedReader stream;
private OutputStreamFeeder feederToNotify;
private PrintStream out;