Author: jharting
Date: 2010-04-01 05:03:49 -0400 (Thu, 01 Apr 2010)
New Revision: 12354
Modified:
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java
Log:
JBPAPP-3861
Modified:
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java
===================================================================
---
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java 2010-04-01
08:06:43 UTC (rev 12353)
+++
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java 2010-04-01
09:03:49 UTC (rev 12354)
@@ -37,14 +37,12 @@
@Override
protected void prepareData()
{
- if (WAR)
- {
- newComponentProperties = new String[] { "hi", "Hi",
"hi", "hiPage" };
- }
+ // war version
+ if(SeamGenTest.WAR)
+ newComponent = new ComponentHolder("hi", null, "Hi",
"hi", "hiPage");
+ // ear version
else
- {
- newComponentProperties = new String[] { "hi", "HiLocal",
"Hi", "hi", "hiPage" };
- }
+ newComponent = new ComponentHolder("hi", "HiLocal",
"Hi", "hi", "hiPage");
}
@Override
Modified:
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java
===================================================================
---
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java 2010-04-01
08:06:43 UTC (rev 12353)
+++
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java 2010-04-01
09:03:49 UTC (rev 12354)
@@ -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[newComponentProperties.length - 2];
+ String form = "id=" + newComponent.name + "Form";
+ String button = form + ":" + newComponent.actionMethod;
browser.open(getComponentPath());
@@ -60,30 +63,72 @@
browser.clickAndWait(button);
assertTrue(browser.isElementPresent(MESSAGES));
-
assertTrue(browser.getText(MESSAGES).contains(newComponentProperties[newComponentProperties.length
- 2]));
+ assertTrue(browser.getText(MESSAGES).contains(newComponent.actionMethod));
}
public void generateNewComponent()
{
- seamGen.newAction(newComponentProperties);
+ seamGen.newAction(newComponent.asArray());
}
protected void prepareData() {
- if (WAR)
- {
- newComponentProperties = new String[]{ "ping", "Ping",
"ping", "pingPage" };
- }
+ // war version
+ if(SeamGenTest.WAR)
+ newComponent = new ComponentHolder("ping", null, "Ping",
"ping", "pingPage");
+ // ear version
else
- {
- newComponentProperties = new String[]{ "ping", "PingLocal",
"Ping", "ping", "pingPage" };
- }
+ newComponent = new ComponentHolder("ping", "PingLocal",
"Ping", "ping", "pingPage");
}
public String getComponentPath() {
- return "/" + APP_NAME + "/" +
newComponentProperties[newComponentProperties.length - 1] + ".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/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java
===================================================================
---
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java 2010-04-01
08:06:43 UTC (rev 12353)
+++
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java 2010-04-01
09:03:49 UTC (rev 12354)
@@ -39,8 +39,8 @@
public void testNewComponent()
{
- String form = "id=" + newComponentProperties[0] + "Form";
- String button = form + ":" +
newComponentProperties[newComponentProperties.length - 2];
+ String form = "id=" + newComponent.name + "Form";
+ String button = form + ":" + newComponent.actionMethod;
String field = form + ":" + "valueField:value";
String value = "world";
@@ -55,24 +55,22 @@
browser.clickAndWait(button);
assertTrue(browser.isElementPresent(MESSAGES), "Message not found.");
- assertEquals(browser.getText(MESSAGES),
newComponentProperties[newComponentProperties.length - 2] + " " + value,
"Unexpected form output.");
+ assertEquals(browser.getText(MESSAGES), newComponent.actionMethod + " " +
value, "Unexpected form output.");
}
@Override
protected void prepareData() {
- if (WAR)
- {
- newComponentProperties = new String[]{ "hello", "Hello",
"hello", "helloPage" };
- }
+ // war version
+ if (SeamGenTest.WAR)
+ newComponent = new ComponentHolder("hello", null, "Hello",
"hello", "helloPage");
+ // ear version
else
- {
- newComponentProperties = new String[]{ "hello",
"HelloLocal", "Hello", "hello", "helloPage" };
- }
+ newComponent = new ComponentHolder("hello", "HelloLocal",
"Hello", "hello", "helloPage");
}
@Override
public void generateNewComponent()
{
- seamGen.newForm(newComponentProperties);
+ seamGen.newForm(newComponent.asArray());
}
}
Modified:
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java
===================================================================
---
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java 2010-04-01
08:06:43 UTC (rev 12353)
+++
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java 2010-04-01
09:03:49 UTC (rev 12354)
@@ -197,7 +197,7 @@
*/
class InputStreamEater extends Thread
{
- private static final String INPUT_CHALLENGE = "[input]";
+ private static final String INPUT_CHALLENGE = "[input] Enter";
private static final String FALSE_INPUT_CHALLENGE = "skipping input";
private BufferedReader stream;
private OutputStreamFeeder feederToNotify;