001: /*
002: * This file is part of the WfMOpen project.
003: * Copyright (C) 2001-2005 Danet GmbH (www.danet.de), GS-AN.
004: * All rights reserved.
005: *
006: * This program is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published by
008: * the Free Software Foundation; either version 2 of the License, or
009: * (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * $Id: Activity.java,v 1.9 2007/03/29 11:45:41 schnelle Exp $
021: *
022: * $Log: Activity.java,v $
023: * Revision 1.9 2007/03/29 11:45:41 schnelle
024: * Code cleanup.
025: *
026: * Revision 1.8 2007/03/27 21:59:42 mlipp
027: * Fixed lots of checkstyle warnings.
028: *
029: * Revision 1.7 2007/02/02 08:18:29 schnelle
030: * Prepared tests with an Umlaut.
031: *
032: * Revision 1.6 2007/02/01 08:49:23 drmlipp
033: * Fixed.
034: *
035: * Revision 1.5 2007/01/31 15:13:20 schnelle
036: * Unified method to create the base url.
037: *
038: * Revision 1.4 2007/01/31 13:39:45 schnelle
039: * Implemented setUp of test cases.
040: *
041: * Revision 1.3 2007/01/31 10:57:36 schnelle
042: * Adapted to change in receiver key.
043: *
044: * Revision 1.2 2007/01/30 11:56:15 drmlipp
045: * Merged Wf-XML branch.
046: *
047: * Revision 1.1.2.3 2007/01/10 14:17:21 schnelle
048: * Implemented unsubscribe.
049: *
050: * Revision 1.1.2.2 2006/12/20 14:38:33 schnelle
051: * Implemented Factory GetDefinition.
052: *
053: * Revision 1.1.2.1 2006/12/14 08:51:05 schnelle
054: * Implemented CompleteActivity.
055: *
056: * Revision 1.1.2.1 2006/12/12 09:35:19 schnelle
057: * Implemented ChangeState for Instance.
058: *
059: * Revision 1.1.2.2 2006/12/11 12:22:31 schnelle
060: * Support of process creation with a later start.
061: *
062: * Revision 1.1.2.1 2006/12/01 15:31:28 schnelle
063: * Separation of test cases dependend on the role.
064: *
065: * Revision 1.4.6.7 2006/12/01 14:18:00 schnelle
066: * Added support for schema type for data in create process
067: *
068: * Revision 1.4.6.6 2006/12/01 12:50:11 schnelle
069: * Basic import of context data for process creation.
070: *
071: * Revision 1.4.6.5 2006/11/30 12:45:20 schnelle
072: * Basic implementation of Factory CreateInstance.
073: *
074: * Revision 1.4.6.4 2006/11/30 10:38:21 schnelle
075: * Implementation of Factory ListInstance.
076: *
077: * Revision 1.4.6.3 2006/11/29 14:13:03 schnelle
078: * Take respect to namespaces of asap requests and responses.
079: *
080: * Revision 1.4.6.2 2006/11/29 11:05:40 schnelle
081: * Full implementation of the request and response headers.
082: *
083: * Revision 1.4.6.1 2006/11/28 15:32:35 schnelle
084: * Proper selection of the response generator.
085: *
086: * Revision 1.4 2006/09/29 12:32:11 drmlipp
087: * Consistently using WfMOpen as projct name now.
088: *
089: * Revision 1.3 2005/01/24 21:11:39 mlipp
090: * Extended.
091: *
092: * Revision 1.2 2005/01/24 20:26:01 mlipp
093: * Reverted saaj back to 1.1 to fit Axis version.
094: *
095: * Revision 1.1 2005/01/23 21:44:23 mlipp
096: * Initial version.
097: *
098: */
099: package wfxml;
100:
101: import javax.xml.soap.Name;
102: import javax.xml.soap.SOAPBodyElement;
103: import javax.xml.soap.SOAPElement;
104: import javax.xml.soap.SOAPMessage;
105:
106: import de.danet.an.util.XMLUtil;
107:
108: import junit.framework.Test;
109: import junit.framework.TestCase;
110: import junit.framework.TestSuite;
111:
112: /**
113: * Test WfXML activity resource.
114: * @author Dirk Schnelle
115: */
116: public class Activity extends TestCase {
117: /** The activity resource. */
118: private String activity;
119:
120: private String timestamp;
121:
122: /**
123: * Constructor of this TestCase.
124: * @param name name of this test case.
125: */
126: public Activity(String name) {
127: super (name);
128: }
129:
130: /**
131: * Creates this test suite.
132: * @return created test suite.
133: */
134: public static Test suite() {
135: TestSuite suite = new TestSuite();
136: suite.addTest(new Activity("getProperties"));
137: suite.addTest(new Activity("setProperties"));
138: suite.addTest(new Activity("completeActivity"));
139: return suite;
140: }
141:
142: /* (non-Javadoc)
143: * @see junit.framework.TestCase#setUp()
144: */
145: protected void setUp() throws Exception {
146: timestamp = XMLUtil.toXsdLocalDateTime(new java.util.Date());
147:
148: // String sender = Factory.class.getName() + "/setUp";
149: // String id = "43";
150:
151: // ServiceRegistry.importDefinition(sender, id);
152: String factory = ServiceRegistry.getTestProcessFactory();
153: String instance = Factory.startTestProcess(factory,
154: "wfxmltest activity " + timestamp);
155:
156: activity = Instance.getFirstActivity(instance);
157:
158: super .setUp();
159: }
160:
161: /**
162: * Test Activity GetProperties.
163: * @exception Exception
164: * Test failed.
165: */
166: public void getProperties() throws Exception {
167: String sender = Activity.class.getName() + "/getProperties";
168: String id = "44";
169:
170: SOAPMessage message = Basic.createMessage();
171: Basic.fillRequestHeadet(message, activity, sender, id);
172: Basic.createActionElement(message, "GetPropertiesRq");
173:
174: SOAPMessage response = Basic.call(message);
175:
176: Basic.checkNoFault(response);
177:
178: assertEquals(sender, Basic.getHeaderValue(response,
179: "ReceiverKey"));
180: assertEquals(activity, Basic.getHeaderValue(response,
181: "SenderKey"));
182: assertEquals(id, Basic.getHeaderValue(response, "RequestID"));
183:
184: SOAPBodyElement processlist = Basic
185: .getFirstBodyElement(response);
186: Name answerName = processlist.getElementName();
187: assertEquals(Basic.WFXML_NS, answerName.getURI());
188: assertEquals("GetPropertiesRs", answerName.getLocalName());
189: }
190:
191: /**
192: * Test Activity GetProperties.
193: * @exception Exception
194: * Test failed.
195: */
196: public void setProperties() throws Exception {
197: String sender = Activity.class.getName() + "/setProperties";
198: String id = "44";
199:
200: SOAPMessage message = Basic.createMessage();
201: Basic.fillRequestHeadet(message, activity, sender, id);
202: SOAPElement action = Basic.createActionElement(message,
203: "SetPropertiesRq");
204:
205: SOAPElement name = action.addChildElement("Name", "wfxml");
206: name.addTextNode("dummy activity name");
207:
208: SOAPElement description = action.addChildElement("Description",
209: "wfxml");
210: description.addTextNode("dummy activity description");
211:
212: SOAPMessage response = Basic.call(message);
213:
214: Basic.checkNoFault(response);
215:
216: assertEquals(sender, Basic.getHeaderValue(response,
217: "ReceiverKey"));
218: assertEquals(activity, Basic.getHeaderValue(response,
219: "SenderKey"));
220: assertEquals(id, Basic.getHeaderValue(response, "RequestID"));
221:
222: SOAPBodyElement processlist = Basic
223: .getFirstBodyElement(response);
224: Name answerName = processlist.getElementName();
225: assertEquals(Basic.WFXML_NS, answerName.getURI());
226: assertEquals("SetPropertiesRs", answerName.getLocalName());
227: }
228:
229: /**
230: * Test Activity CompletActivity.
231: * @exception Exception
232: * Test failed.
233: */
234: public void completeActivity() throws Exception {
235: String sender = Activity.class.getName() + "/completeActivity";
236: String id = "activity42";
237:
238: SOAPMessage message = Basic.createMessage();
239: Basic.fillRequestHeadet(message, activity, sender, id);
240: Basic.createActionElement(message, "CompleteActivityRq");
241:
242: SOAPMessage response = Basic.call(message);
243:
244: Basic.checkNoFault(response);
245:
246: assertEquals(sender, Basic.getHeaderValue(response,
247: "ReceiverKey"));
248: assertEquals(activity, Basic.getHeaderValue(response,
249: "SenderKey"));
250: assertEquals(id, Basic.getHeaderValue(response, "RequestID"));
251: }
252: }
|