Package com.arjuna.mw.wsas

Examples of com.arjuna.mw.wsas.UserActivity


{

    public static void testStatusCheck()
            throws Exception
    {
      UserActivity ua = UserActivityFactory.userActivity();
 
      if (ua.status() != NoActivity.instance()) {
            fail("Status should be NoActivity " + ua.status());
        }

        ua.start();
   
    if (ua.status() != Active.instance()) {
            fail("Status should be Active " + ua.status());
        }
        Outcome res = ua.end();

        if (!res.completedStatus().equals(Failure.instance())) {
            fail("Completed status should be Failure " + res.completedStatus());
        }
    }
View Full Code Here


{

    public static void testHierarchy()
            throws Exception
    {
        UserActivity ua = UserActivityFactory.userActivity();

  try
  {
      ua.start();
     
      System.out.println("Started: "+ua.activityName());
     
      ua.start();

      System.out.println("Started: "+ua.activityName());

      ActivityHierarchy ctx = ua.currentActivity();
     
      System.out.println("\nHierarchy: "+ctx);

      if (ctx == null) {
            fail("current activity should not be null");
        } else {
            ua.end();

            System.out.println("\nCurrent: "+ua.activityName());
     
            ua.end();

            try {
                if (ua.activityName() != null) {
                    fail("activity name should be null but is " + ua.activityName());
                }
            } catch (NoActivityException ex) {
                // ok if we get here
            }
        }
View Full Code Here

{

    public static void testStartEnd()
            throws Exception
    {
      UserActivity ua = UserActivityFactory.userActivity();
      ua.start();
 
      ua.end();
    }
View Full Code Here

{

    public static void testResume()
            throws Exception
    {
        UserActivity ua = UserActivityFactory.userActivity();

  try
  {
      GlobalId ac1 = null;
      GlobalId ac2 = null;
     
      ua.start();
     
      ac1 = ua.activityId();
     
      System.out.println("Started: "+ac1);
     
      ua.start();
     
      ac2 = ua.activityId();

      System.out.println("\nStarted: "+ac2);
     
      ActivityHierarchy ctx = ua.suspend();
     
      System.out.println("\nSuspended: "+ctx);
     
        if (ua.currentActivity() != null) {
            fail("Current activity shoudl be null " + ua.currentActivity());
        }

        ua.resume(ctx);
   
        if (!ac2.equals(ua.activityId()))
        {
            fail("Current activity id " + ua.activityId() + " should equal " + ac2);
        }

        ua.end();

        if (!ac1.equals(ua.activityId())) {
            fail("Current activity id " + ua.activityId() + " should equal " + ac1);
        }
    } finally {
        WSASTestUtils.cleanup(ua);
    }
    }
View Full Code Here

{

    public static void testService()
            throws Exception
    {
        UserActivity ua = UserActivityFactory.userActivity();
        DemoHLS demoHLS = new DemoHLS();
  try
  {
      ActivityManagerFactory.activityManager().addHLS(demoHLS);
     
      ua.start();
     
      System.out.println("Started: "+ua.activityName());

      ua.start();
     
      System.out.println("Started: "+ua.activityName());

      ua.end();
     
      ua.end();
  }
    catch (Exception ex)
    {
        WSASTestUtils.cleanup(ua);
        throw ex;
View Full Code Here

{

    public static void testSuspend()
            throws Exception
    {
        UserActivity ua = UserActivityFactory.userActivity();

  try
  {
      ua.start();
     
      System.out.println("Started: "+ua.activityName());
     
      ActivityHierarchy ctx = ua.suspend();
     
      System.out.println("\nSuspended: "+ctx);
     
      if (ua.currentActivity() != null) {
            fail("Current activity should be null " + ua.currentActivity());
        }
  }
  catch (Exception ex)
  {
      WSASTestUtils.cleanup(ua);
View Full Code Here

{

    public static void testContext2()
            throws Exception
    {
        UserActivity ua = UserActivityFactory.userActivity();
        DemoHLS demoHLS = new DemoHLS();
        FailureHLS failureHLS = new FailureHLS(); // this constructor means it will lnto fail
        HLS[] currentHLS = ActivityManagerFactory.activityManager().allHighLevelServices();

        for (HLS hls : currentHLS) {
            ActivityManagerFactory.activityManager().removeHLS(hls);
        }
    try
  {
      ActivityManagerFactory.activityManager().addHLS(demoHLS);
      ActivityManagerFactory.activityManager().addHLS(failureHLS);

      DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
      org.w3c.dom.Document doc = docBuilder.newDocument();
      org.w3c.dom.Element root = doc.createElement("Context2-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 theContext1 = null;
        Context theContext2 = null;
        int numContexts = (contexts != null ? contexts.length : 0);

        for (int i = 0; i < numContexts; i++) {
            if (contexts[i] != null) {
                if (theContext1 == null) {
                    theContext1 = contexts[i];
                } else {
                    theContext2 = contexts[i];
                    break;
                }
            }
        }

        if (theContext1 == null || theContext2 == null) {
            fail("Demo contexts not found");
        }

        if (!(theContext1 instanceof DemoSOAPContextImple) ||
                !(theContext1 instanceof DemoSOAPContextImple)) {
            fail("Demo contexts not found");
        }

        ((SOAPContext)theContext1).serialiseToElement(root);
        ((SOAPContext)theContext2).serialiseToElement(root);

        System.out.println("Context is " + root.getTextContent());

      ua.end();

      System.out.println("\nFinished child activity.\n");

      contexts = contextManager.contexts();
        theContext1 = null;
        theContext2 = null;
        numContexts = (contexts != null ? contexts.length : 0);

        for (int i = 0; i < numContexts; i++) {
            if (contexts[i] != null) {
                if (theContext1 == null) {
                    theContext1 = contexts[i];
                } else {
                    theContext2 = contexts[i];
                    break;
                }
            }
        }

        if (theContext1 == null || theContext2 == null) {
            fail("Demo contexts not found");
        }

        if (!(theContext1 instanceof DemoSOAPContextImple) ||
                !(theContext1 instanceof DemoSOAPContextImple)) {
            fail("Demo contexts not found");
        }

        doc = docBuilder.newDocument();
      root = doc.createElement("Context2-test");
        doc.appendChild(root);


        ((SOAPContext)theContext1).serialiseToElement(root);
        ((SOAPContext)theContext2).serialiseToElement(root);

        System.out.println("Context is " + root.getTextContent());

      ua.end();

      System.out.println("\nFinished parent activity.\n");
  }
    catch (Exception ex)
    {
View Full Code Here

{

    public static void testNullEnd()
            throws Exception
    {
        UserActivity ua = UserActivityFactory.userActivity();
  try
  {
      ua.end();
        fail("should have thrown NoActivityException");
    }
  catch (NoActivityException ex)
  {
      // it's ok if we arrive here?
View Full Code Here

{

    public static void testNestedActivity()
            throws Exception
    {
      UserActivity ua = UserActivityFactory.userActivity();
 
        try
        {
      ua.start();
     
      System.out.println("Started: "+ua.activityName());
     
      ua.start();

      String nested = ua.activityName();
     
      System.out.println("Started: "+nested);

      System.out.println("\nEnding: "+nested);
     
      ua.end();

      String parent = ua.activityName();
     
      System.out.println("\nCurrent: "+parent);
     
      System.out.println("\nEnding: "+parent);
     
      ua.end();

        try {
            if (ua.activityName() != null) {
                fail("activity name should be null but is " + ua.activityName());
            }
        } catch (NoActivityException ex) {
            // ok if we get here
        }
View Full Code Here

{

    public static void testContext()
            throws Exception
    {
        UserActivity ua = UserActivityFactory.userActivity();
        HLS[] currentHLS = ActivityManagerFactory.activityManager().allHighLevelServices();

        for (HLS hls : currentHLS) {
            ActivityManagerFactory.activityManager().removeHLS(hls);
        }

  try
  {
      ua.start();
     
      System.out.println("Started: "+ua.activityName());
     
      ua.start();

      System.out.println("Started: "+ua.activityName());
     
      ContextManager manager = new ContextManager();
      com.arjuna.mw.wsas.context.Context[] contexts = manager.contexts();
     
      if ((contexts != null) && (contexts.length != 0)) {
View Full Code Here

TOP

Related Classes of com.arjuna.mw.wsas.UserActivity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.