/*
* This file is part of the WfMOpen project.
* Copyright (C) 2001-2005 Danet GmbH (www.danet.de), GS-AN.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: Activity.java 2330 2007-03-29 11:45:42Z schnelle $
*
* $Log$
* Revision 1.8 2007/03/27 21:59:42 mlipp
* Fixed lots of checkstyle warnings.
*
* Revision 1.7 2007/02/02 08:18:29 schnelle
* Prepared tests with an Umlaut.
*
* Revision 1.6 2007/02/01 08:49:23 drmlipp
* Fixed.
*
* Revision 1.5 2007/01/31 15:13:20 schnelle
* Unified method to create the base url.
*
* Revision 1.4 2007/01/31 13:39:45 schnelle
* Implemented setUp of test cases.
*
* Revision 1.3 2007/01/31 10:57:36 schnelle
* Adapted to change in receiver key.
*
* Revision 1.2 2007/01/30 11:56:15 drmlipp
* Merged Wf-XML branch.
*
* Revision 1.1.2.3 2007/01/10 14:17:21 schnelle
* Implemented unsubscribe.
*
* Revision 1.1.2.2 2006/12/20 14:38:33 schnelle
* Implemented Factory GetDefinition.
*
* Revision 1.1.2.1 2006/12/14 08:51:05 schnelle
* Implemented CompleteActivity.
*
* Revision 1.1.2.1 2006/12/12 09:35:19 schnelle
* Implemented ChangeState for Instance.
*
* Revision 1.1.2.2 2006/12/11 12:22:31 schnelle
* Support of process creation with a later start.
*
* Revision 1.1.2.1 2006/12/01 15:31:28 schnelle
* Separation of test cases dependend on the role.
*
* Revision 1.4.6.7 2006/12/01 14:18:00 schnelle
* Added support for schema type for data in create process
*
* Revision 1.4.6.6 2006/12/01 12:50:11 schnelle
* Basic import of context data for process creation.
*
* Revision 1.4.6.5 2006/11/30 12:45:20 schnelle
* Basic implementation of Factory CreateInstance.
*
* Revision 1.4.6.4 2006/11/30 10:38:21 schnelle
* Implementation of Factory ListInstance.
*
* Revision 1.4.6.3 2006/11/29 14:13:03 schnelle
* Take respect to namespaces of asap requests and responses.
*
* Revision 1.4.6.2 2006/11/29 11:05:40 schnelle
* Full implementation of the request and response headers.
*
* Revision 1.4.6.1 2006/11/28 15:32:35 schnelle
* Proper selection of the response generator.
*
* Revision 1.4 2006/09/29 12:32:11 drmlipp
* Consistently using WfMOpen as projct name now.
*
* Revision 1.3 2005/01/24 21:11:39 mlipp
* Extended.
*
* Revision 1.2 2005/01/24 20:26:01 mlipp
* Reverted saaj back to 1.1 to fit Axis version.
*
* Revision 1.1 2005/01/23 21:44:23 mlipp
* Initial version.
*
*/
package wfxml;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPMessage;
import de.danet.an.util.XMLUtil;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Test WfXML activity resource.
* @author Dirk Schnelle
*/
public class Activity extends TestCase {
/** The activity resource. */
private String activity;
private String timestamp;
/**
* Constructor of this TestCase.
* @param name name of this test case.
*/
public Activity(String name) {
super (name);
}
/**
* Creates this test suite.
* @return created test suite.
*/
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(new Activity("getProperties"));
suite.addTest(new Activity("setProperties"));
suite.addTest(new Activity("completeActivity"));
return suite;
}
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
timestamp = XMLUtil.toXsdLocalDateTime(new java.util.Date());
// String sender = Factory.class.getName() + "/setUp";
// String id = "43";
// ServiceRegistry.importDefinition(sender, id);
String factory = ServiceRegistry.getTestProcessFactory();
String instance = Factory.startTestProcess(factory,
"wfxmltest activity " + timestamp);
activity = Instance.getFirstActivity(instance);
super.setUp();
}
/**
* Test Activity GetProperties.
* @exception Exception
* Test failed.
*/
public void getProperties() throws Exception {
String sender = Activity.class.getName() + "/getProperties";
String id = "44";
SOAPMessage message = Basic.createMessage();
Basic.fillRequestHeadet(message, activity, sender, id);
Basic.createActionElement(message, "GetPropertiesRq");
SOAPMessage response = Basic.call(message);
Basic.checkNoFault(response);
assertEquals(sender, Basic.getHeaderValue(response, "ReceiverKey"));
assertEquals(activity, Basic.getHeaderValue(response, "SenderKey"));
assertEquals(id, Basic.getHeaderValue(response, "RequestID"));
SOAPBodyElement processlist = Basic.getFirstBodyElement(response);
Name answerName = processlist.getElementName();
assertEquals(Basic.WFXML_NS, answerName.getURI());
assertEquals("GetPropertiesRs", answerName.getLocalName());
}
/**
* Test Activity GetProperties.
* @exception Exception
* Test failed.
*/
public void setProperties() throws Exception {
String sender = Activity.class.getName() + "/setProperties";
String id = "44";
SOAPMessage message = Basic.createMessage();
Basic.fillRequestHeadet(message, activity, sender, id);
SOAPElement action = Basic
.createActionElement(message, "SetPropertiesRq");
SOAPElement name = action.addChildElement("Name", "wfxml");
name.addTextNode("dummy activity name");
SOAPElement description
= action.addChildElement("Description", "wfxml");
description.addTextNode("dummy activity description");
SOAPMessage response = Basic.call(message);
Basic.checkNoFault(response);
assertEquals(sender, Basic.getHeaderValue(response, "ReceiverKey"));
assertEquals(activity, Basic.getHeaderValue(response, "SenderKey"));
assertEquals(id, Basic.getHeaderValue(response, "RequestID"));
SOAPBodyElement processlist = Basic.getFirstBodyElement(response);
Name answerName = processlist.getElementName();
assertEquals(Basic.WFXML_NS, answerName.getURI());
assertEquals("SetPropertiesRs", answerName.getLocalName());
}
/**
* Test Activity CompletActivity.
* @exception Exception
* Test failed.
*/
public void completeActivity() throws Exception {
String sender = Activity.class.getName() + "/completeActivity";
String id = "activity42";
SOAPMessage message = Basic.createMessage();
Basic.fillRequestHeadet(message, activity, sender, id);
Basic.createActionElement(message, "CompleteActivityRq");
SOAPMessage response = Basic.call(message);
Basic.checkNoFault(response);
assertEquals(sender, Basic.getHeaderValue(response, "ReceiverKey"));
assertEquals(activity, Basic.getHeaderValue(response, "SenderKey"));
assertEquals(id, Basic.getHeaderValue(response, "RequestID"));
}
}