SF.net SVN: controltier:[10358] branches/controltier-3-6-support/common/src

2 views
Skip to first unread message

gsch...@users.sourceforge.net

unread,
Aug 22, 2011, 9:40:34 PM8/22/11
to controltier...@googlegroups.com
Revision: 10358
http://controltier.svn.sourceforge.net/controltier/?rev=10358&view=rev
Author: gschueler
Date: 2011-08-23 01:40:33 +0000 (Tue, 23 Aug 2011)
Log Message:
-----------
Fix command error handlers in static workflow commands

Modified Paths:
--------------
branches/controltier-3-6-support/common/src/java/com/controltier/shared/convert/TypeXMLHandlerGenerator.java
branches/controltier-3-6-support/common/src/test/com/controltier/shared/convert/TestTypeXMLHandlerGenerator.java
branches/controltier-3-6-support/common/src/test/com/controltier/shared/convert/test-type1.xml

Modified: branches/controltier-3-6-support/common/src/java/com/controltier/shared/convert/TypeXMLHandlerGenerator.java
===================================================================
--- branches/controltier-3-6-support/common/src/java/com/controltier/shared/convert/TypeXMLHandlerGenerator.java 2011-08-01 23:59:37 UTC (rev 10357)
+++ branches/controltier-3-6-support/common/src/java/com/controltier/shared/convert/TypeXMLHandlerGenerator.java 2011-08-23 01:40:33 UTC (rev 10358)
@@ -1366,6 +1366,10 @@
*/
Element cmdExec = erhandler.addElement("command");
cmdExec.addAttribute("name", cmdName);
+ //if static context, set the module value
+ if(cmd.isStaticAccess()) {
+ cmdExec.addAttribute("module", "${context.module}");
+ }
/**
* Add the <arg line="${cmdName.argline}"/>
*/

Modified: branches/controltier-3-6-support/common/src/test/com/controltier/shared/convert/TestTypeXMLHandlerGenerator.java
===================================================================
--- branches/controltier-3-6-support/common/src/test/com/controltier/shared/convert/TestTypeXMLHandlerGenerator.java 2011-08-01 23:59:37 UTC (rev 10357)
+++ branches/controltier-3-6-support/common/src/test/com/controltier/shared/convert/TestTypeXMLHandlerGenerator.java 2011-08-23 01:40:33 UTC (rev 10358)
@@ -66,6 +66,7 @@
File wfhandler3;
File wfhandler4;
File wfhandler5;
+ File wfhandler6;
File bsfcommand1;
File dcommand1;
File dcommand2;
@@ -84,6 +85,7 @@
wfhandler3,
wfhandler4,
wfhandler5,
+ wfhandler6,
bsfcommand1,
dcommand1,
dcommand2,
@@ -104,6 +106,7 @@
"wfcommand3.xml",
"wfcommand4.xml",
"wfcommand5.xml",
+ "wfcommand6.xml",
"bsfcommand1.xml",
"dcommand1.xml",
"dcommand2.xml",
@@ -138,6 +141,7 @@
wfhandler3 = new File(cmdsDir, "wfcommand3.xml");
wfhandler4 = new File(cmdsDir, "wfcommand4.xml");
wfhandler5 = new File(cmdsDir, "wfcommand5.xml");
+ wfhandler6 = new File(cmdsDir, "wfcommand6.xml");
bsfcommand1 = new File(cmdsDir, "bsfcommand1.xml");
dcommand1 = new File(cmdsDir, "dcommand1.xml");
dcommand2 = new File(cmdsDir, "dcommand2.xml");
@@ -196,6 +200,7 @@
assertFalse("handler file should not have been generated: " + wfhandler3, wfhandler3.exists());
assertFalse("handler file should not have been generated: " + wfhandler4, wfhandler4.exists());
assertFalse("handler file should not have been generated: " + wfhandler5, wfhandler5.exists());
+ assertFalse("handler file should not have been generated: " + wfhandler6, wfhandler6.exists());
assertFalse("handler file should not have been generated: " + bsfcommand1, bsfcommand1.exists());
assertFalse("handler file should not have been generated: " + dcommand1, dcommand1.exists());
assertFalse("handler file should not have been generated: " + dcommand2, dcommand2.exists());
@@ -235,6 +240,7 @@
assertTrue("handler file was not generated: " + wfhandler3, wfhandler3.exists());
assertTrue("handler file was not generated: " + wfhandler4, wfhandler4.exists());
assertTrue("handler file was not generated: " + wfhandler5, wfhandler5.exists());
+ assertTrue("handler file was not generated: " + wfhandler6, wfhandler6.exists());
assertTrue("handler file was not generated: " + bsfcommand1, bsfcommand1.exists());
assertTrue("handler file was not generated: " + dcommand1, dcommand1.exists());
assertTrue("handler file was not generated: " + dcommand2, dcommand2.exists());
@@ -258,7 +264,7 @@
assertTrue("module.commands property not found", mp.containsKey("module.commands"));
assertTrue("wrong module.commands value",
mp.getProperty("module.commands").equals(
- "execCommand1,execCommand2,antcommand1,wfcommand1,wfcommand2,wfcommand3,wfcommand4,wfcommand5,antcommand2,antcommand3,testcommand4,bsfcommand1,dcommand1,dcommand2,dcommand3,dcommand4,dcommand5"));
+ "execCommand1,execCommand2,antcommand1,wfcommand1,wfcommand2,wfcommand3,wfcommand4,wfcommand5,wfcommand6,antcommand2,antcommand3,testcommand4,bsfcommand1,dcommand1,dcommand2,dcommand3,dcommand4,dcommand5"));

// examine the commands.properties data. Check: testcommand4
final Properties cp = new Properties();
@@ -601,7 +607,7 @@
"suc...@example.com",
"${modules.dir}/Deployment/templates/notice.html",
"[${context.type}:${context.name} @ ${framework.node.hostname}] ${command.name} - SUCCESS",
- "Workflow failed.", "HANDLER", list, "wfcommand1", null);
+ "Workflow failed.", "HANDLER", list, "wfcommand1", null, false);
assertXpathTextEquals("The module attribute was not found in the command element",
"Amodule",
handlerdoc.getRootElement(),
@@ -638,7 +644,7 @@
"suc...@example.com",
"${modules.dir}/Deployment/templates/notice.html",
"[${context.type}:${context.name} @ ${framework.node.hostname}] ${command.name} - SUCCESS",
- "Workflow failed.", "IGNORE", list, "wfcommand2", null);
+ "Workflow failed.", "IGNORE", list, "wfcommand2", null, false);

}
//test wfcommand3.xml should have been written correctly
@@ -670,7 +676,7 @@
"suc...@example.com",
"${modules.dir}/Deployment/templates/notice.html",
"[${context.type}:${context.name} @ ${framework.node.hostname}] ${command.name} - SUCCESS",
- "Workflow failed.", "FAIL", list, "wfcommand3", null);
+ "Workflow failed.", "FAIL", list, "wfcommand3", null, false);

}
//test wfcommand4.xml should have been written correctly
@@ -702,10 +708,10 @@
null,
null,
null,
- "Workflow failed.", "FAIL", list, "wfcommand4", null);
+ "Workflow failed.", "FAIL", list, "wfcommand4", null, false);

}
- //test wfcommand4.xml should have been written correctly
+ //test wfcommand5.xml should have been written correctly
{
Document handlerdoc = null;
try {
@@ -734,10 +740,42 @@
null,
null,
null,
- null, "HANDLER", list, "wfcommand5", "wfcommand4");
+ null, "HANDLER", list, "wfcommand5", "wfcommand4", false);

}
+ //test wfcommand6.xml should have been written correctly
+ {
+ Document handlerdoc = null;
+ try {
+ SAXReader reader = new SAXReader(documentFactory);
+ handlerdoc = reader.read(wfhandler6);
+ assertNotNull("document was null", handlerdoc);
+ } catch (DocumentException e) {
+ fail("Unable to parse xml document: " + e.getMessage());
+ }

+ //test that extra targets in the handler have not been erased
+ assertXpathNotNull("execute target in document was not found",
+ handlerdoc.getRootElement(),
+ "target[@name='-execute']");
+ ArrayList list = new ArrayList();
+ list.add("antcommand2");
+ list.add("antcommand3");
+ list.add("testcommand4");
+
+ assertWorkflowCommand(handlerdoc,
+ "true",
+ -1,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null, "HANDLER", list, "wfcommand6", "antcommand2", true);
+
+ }
+
// examine the commands.properties data. Check: testcommand4
final Properties cprops = new Properties();
cprops.load(new FileInputStream(cmdProps));
@@ -1414,7 +1452,7 @@
String succEmailMessagefile,
String succEmailSubject,
String errReport, String errHandlerType, ArrayList wfCommands, String cmdName,
- String errCmdName) {
+ String errCmdName, final boolean isStatic) {

//-execute target
assertXpathNotNull("document does not have -execute target definition",
@@ -1480,6 +1518,9 @@
if (null != errCmdName) {
assertXpathNotNull("command element was missing", errHandlerElem, "command");
assertXpathTextEquals("command name was wrong", errCmdName, errHandlerElem, "command/@name");
+ if(isStatic){
+ assertXpathTextEquals("command name was wrong", "${context.module}", errHandlerElem, "command/@module");
+ }
}
} else if ("FAIL".equals(errHandlerType)) {
assertEquals("incorrect number of attributes", 0, errHandlerElem.attributes().size());
@@ -1523,10 +1564,12 @@
wfCommands.size(),
controllers.size());
HashMap ctxAttrs = new HashMap();
- ctxAttrs.put("project", "${context.project}");
- ctxAttrs.put("resourceType", "${context.type}");
- ctxAttrs.put("resourceName", "${context.name}");
- ctxAttrs.put("ignoremalformed","true");
+ if(!isStatic){
+ ctxAttrs.put("project", "${context.project}");
+ ctxAttrs.put("resourceType", "${context.type}");
+ ctxAttrs.put("resourceName", "${context.name}");
+ ctxAttrs.put("ignoremalformed","true");
+ }
for (int i = 0; i < controllers.size() ; i++) {
final String wfCommandName = (String) wfCommands.get(i);
Element wfexec = (Element) controllers.get(i);

Modified: branches/controltier-3-6-support/common/src/test/com/controltier/shared/convert/test-type1.xml
===================================================================
--- branches/controltier-3-6-support/common/src/test/com/controltier/shared/convert/test-type1.xml 2011-08-01 23:59:37 UTC (rev 10357)
+++ branches/controltier-3-6-support/common/src/test/com/controltier/shared/convert/test-type1.xml 2011-08-23 01:40:33 UTC (rev 10358)
@@ -220,8 +220,28 @@
</workflow>

</command>
+ <command name="wfcommand6" description="static workflow with command error-handler"
+ command-type="WorkflowCommand" error-handler-type="HANDLER" is-static="true">
+ <opts>
+ <opt parameter="param1" description="the file name" required="false" property="opts.paramWRONG"
+ type="string" default=""/>
+ <opt parameter="param2" description="the installation root" required="true"
+ property="opts.param2" type="string" default="some default"/>
+ <opt parameter="param3" description="the other opt root" required="false"
+ property="opts.x" type="boolean" default="" defaultproperty="lemmings"/>
+ </opts>
+ <error-handler quiet="true">
+ <command name="antcommand2"/>
+ </error-handler>
+ <workflow>
+ <command name="antcommand2"/>
+ <command name="antcommand3"/>
+ <command name="testcommand4"/>
+ </workflow>

+ </command>

+
<command name="antcommand2" description="this command has no ant implementation, so will not modify the handler"
command-type="AntCommand" is-static="true">
<opts>

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Reply all
Reply to author
Forward
0 new messages