{
public static void testContext1()
throws Exception
{
UserActivity ua = UserActivityFactory.userActivity();
DemoHLS demoHLS = new DemoHLS();
HLS[] currentHLS = ActivityManagerFactory.activityManager().allHighLevelServices();
for (HLS hls : currentHLS) {
ActivityManagerFactory.activityManager().removeHLS(hls);
}
try
{
ActivityManagerFactory.activityManager().addHLS(demoHLS);
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
org.w3c.dom.Document doc = docBuilder.newDocument();
org.w3c.dom.Element root = doc.createElement("Context1-test");
doc.appendChild(root);
ua.start();
System.out.println("Started: "+ua.activityName());
ua.start();
System.out.println("Started: "+ua.activityName()+"\n");
ContextManager contextManager = new ContextManager();
Context[] contexts = contextManager.contexts();
Context theContext = null;
for (int i = 0; i < contexts.length; i++) {
if (contexts[i] != null) {
theContext = contexts[i];
break;
}
}
if (theContext == null) {
fail("Demo context not found");
}
if (!(theContext instanceof DemoSOAPContextImple)) {
fail("Demo context not found");
}
((SOAPContext)theContext).serialiseToElement(root);
System.out.println("Context is " + root.getTextContent());
ua.end();
System.out.println("\nFinished child activity.\n");
contexts = contextManager.contexts();
theContext = null;
for (int i = 0; i < contexts.length; i++) {
if (contexts[i] != null) {
theContext = contexts[i];
break;
}
}
if (theContext == null) {
fail("Demo context not found");
}
if (!(theContext instanceof DemoSOAPContextImple)) {
fail("Demo context not found");
}
doc = docBuilder.newDocument();
root = doc.createElement("Context1-test");
doc.appendChild(root);
((SOAPContext)theContext).serialiseToElement(root);
System.out.println("Context is " + root.getTextContent());
ua.end();
System.out.println("\nFinished parent activity.\n");
}
catch (Exception ex)