Examples of AsynchronousFacade


Examples of org.jboss.aspects.asynchronous.aspects.AsynchronousFacade

    this.parameter = parameter;
    this.txt = txt;
   
  }
  public void run() {
    AsynchronousFacade asynchronousFacade =
      (AsynchronousFacade)businessModel;
    long res1 = businessModel.processBusinessModel2(parameter);
    BusinessModel.sleep(sleep);
    AsynchronousTask asynchronousTask1 =
      asynchronousFacade.getAsynchronousTask();
    if (!asynchronousFacade.isDone(asynchronousTask1))
      asynchronousFacade.waitForResponse(asynchronousTask1);
      result =asynchronousFacade.getReturnValue(asynchronousTask1);
  }
View Full Code Here

Examples of org.jboss.aspects.asynchronous.aspects.AsynchronousFacade

      "bm1 is not an instance of AsynchronousFacade",
      bm1 instanceof AsynchronousFacade);
    assertTrue(
      "bm2 is not an instance of AsynchronousFacade",
      bm2 instanceof AsynchronousFacade);
    AsynchronousFacade asynchronousFacade1 = (AsynchronousFacade)bm1;
    AsynchronousFacade asynchronousFacade2 = (AsynchronousFacade)bm2;
    asynchronousFacade1.setId("OK");
    asynchronousFacade2.setId("KO");
    assertNotSame(
      "same instances(ID) of AsynchronousFacade",
      asynchronousFacade1.getId(),
      asynchronousFacade2.getId());
  }
View Full Code Here

Examples of org.jboss.aspects.asynchronous.aspects.AsynchronousFacade

      asynchronousFacade2.getId());
  }
  public static void test2AsynchronousCallOnSameInstance() {
    BusinessModel bm1 = new BusinessModel();
    long res1 = bm1.processBusinessModel2(15);
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;
    AsynchronousTask asynchronousTask1 =
      asynchronousFacade.getAsynchronousTask();
    long res2 = bm1.processBusinessModel2(10);
    AsynchronousTask asynchronousTask2 =
      asynchronousFacade.getAsynchronousTask();
    assertEquals(
      "Method is not succesfull !",
      OK,
      asynchronousFacade.getResponseCode(asynchronousTask1));
    assertTrue(
      "value returned is not an instance of Long",
      asynchronousFacade.getReturnValue(asynchronousTask1)
        instanceof Long);
    assertEquals(
      "Method does not return the right value !"
        + ((Long)asynchronousFacade.getReturnValue(asynchronousTask1))
          .longValue(),
      ((Long)asynchronousFacade.getReturnValue(asynchronousTask1))
        .longValue(),
      15);
    assertEquals(
      "Method is not succesfull !",
      asynchronousFacade.getResponseCode(asynchronousTask2),
      OK);
    assertTrue(
      "value returned is not an instance of Long",
      asynchronousFacade.getReturnValue(asynchronousTask2)
        instanceof Long);
    assertEquals(
      "Method does not return the right value !"
        + ((Long)asynchronousFacade.getReturnValue(asynchronousTask2))
          .longValue(),
      ((Long)asynchronousFacade.getReturnValue(asynchronousTask2))
        .longValue(),
      10);
  }
View Full Code Here

Examples of org.jboss.aspects.asynchronous.aspects.AsynchronousFacade

        .longValue(),
      10);
  }
  public static void test2AsynchronousCallOnSameInstance2() {
    BusinessModel bm1 = new BusinessModel();
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;
    asynchronousFacade.setTimeout(50);
    long res1 = bm1.processBusinessModel2(1000);
    AsynchronousTask asynchronousTask1 =
      asynchronousFacade.getAsynchronousTask();
    asynchronousFacade.setTimeout(200);
    long res2 = bm1.processBusinessModel2(10);
    AsynchronousTask asynchronousTask2 =
      asynchronousFacade.getAsynchronousTask();
    assertEquals(
      "Method did not timeout !",
      TIMEOUT,
      asynchronousFacade.getResponseCode(asynchronousTask1));
    assertEquals(
      "Method is not succesfull !",
      asynchronousFacade.getResponseCode(asynchronousTask2),
      OK);
    assertTrue(
      "value returned is not an instance of Long",
      asynchronousFacade.getReturnValue(asynchronousTask2)
        instanceof Long);
    assertEquals(
      "Method does not return the right value !"
        + ((Long)asynchronousFacade.getReturnValue(asynchronousTask2))
          .longValue(),
      ((Long)asynchronousFacade.getReturnValue(asynchronousTask2))
        .longValue(),
      10);
  }
View Full Code Here

Examples of org.jboss.aspects.asynchronous.aspects.AsynchronousFacade

      10);
  }

  public static void testTimeout() {
    BusinessModel bm1 = new BusinessModel(200);
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;
    asynchronousFacade.setTimeout(100);
    bm1.processBusinessModel();
    long t0 = System.currentTimeMillis();
    //System.out.println(
    //  asynchronousFacade.getAsynchronousTask().getResponse());
    assertEquals(
      "Method did not timeout !",
      TIMEOUT,
      asynchronousFacade.getResponseCode());
    long t1 = System.currentTimeMillis();
    assertTrue("Method time out in " + (t1 - t0) + " ms.", (t1 - t0) < 120);
    assertTrue("Method did not run " + (t1 - t0) + " ms.", (t1 - t0) > 80);
  }
View Full Code Here

Examples of org.jboss.aspects.asynchronous.aspects.AsynchronousFacade

    assertTrue("Method did not run " + (t1 - t0) + " ms.", (t1 - t0) > 80);
  }
  public static void testReturnValue() {
    BusinessModel bm1 = new BusinessModel();
    long value = bm1.processBusinessModel2(10);
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;
    assertEquals(
      "Method is not succesfull !",
      OK,
      asynchronousFacade.getResponseCode());
    assertTrue(
      "value returned is not an instance of Long",
      asynchronousFacade.getReturnValue() instanceof Long);
    assertEquals(
      "Method does not return the right value !"
        + ((Long)asynchronousFacade.getReturnValue()).longValue(),
      ((Long)asynchronousFacade.getReturnValue()).longValue(),
      10);
  }
View Full Code Here

Examples of org.jboss.aspects.asynchronous.aspects.AsynchronousFacade

      10);
  }
  public static void testCleanupCallWhenTimeout() {
    BusinessModelWithCleanup bm1 = new BusinessModelWithCleanup();
    BusinessModelWithCleanup bm2 = new BusinessModelWithCleanup();
    AsynchronousFacade asynchronousFacade1 = (AsynchronousFacade)bm1;
    AsynchronousFacade asynchronousFacade2 = (AsynchronousFacade)bm2;
    asynchronousFacade1.setTimeout(100);
    long value1 = bm1.processBusinessModel2(200);
    long value2 = bm2.processBusinessModel2(200);
    assertEquals(
      "Method did not timeout !",
      TIMEOUT,
      asynchronousFacade1.getResponseCode());
    assertEquals(
      "Method is not successfull !",
      OK,
      asynchronousFacade2.getResponseCode());
    assertEquals("Cleanup method not called", true, bm1.bCleanupCalled);
    assertEquals("Cleanup method called", false, bm2.bCleanupCalled);
  }
View Full Code Here

Examples of org.jboss.aspects.asynchronous.aspects.AsynchronousFacade

    assertEquals("Cleanup method called", false, bm2.bCleanupCalled);
  }
  public static void testIsDone() {
    BusinessModel bm1 = new BusinessModel(200);
    bm1.processBusinessModel();
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;
    long t0 = System.currentTimeMillis();
    assertFalse("isDone returns TRUE  !", asynchronousFacade.isDone());
    long t1 = System.currentTimeMillis();
    assertTrue(
      "isDone is a blocking call " + (t1 - t0) + " ms.",
      (t1 - t0) < 20);
    assertEquals(
      "Method is not succesfull !",
      OK,
      asynchronousFacade.getResponseCode());
    assertTrue("isDone returns FALSE  !", asynchronousFacade.isDone());
  }
View Full Code Here

Examples of org.jboss.aspects.asynchronous.aspects.AsynchronousFacade

    assertTrue("isDone returns FALSE  !", asynchronousFacade.isDone());
  }
  public static void testExceptionRaisedInMethodCall() {
    BusinessModel bm1 = new BusinessModel();
    long value = bm1.processBusinessModel2(-1);
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;
    assertEquals(
      "EXCEPTIONCAUGHT error not returned !",
      EXCEPTIONCAUGHT,
      asynchronousFacade.getResponseCode());
  }
View Full Code Here

Examples of org.jboss.aspects.asynchronous.aspects.AsynchronousFacade

      bm1.processBusinessModel();

    }
    BusinessModel bm1 = new BusinessModel(200);
    bm1.processBusinessModel();
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;
    assertEquals(
      "Pool size not full !",
      CAN_NOT_PROCESS,
      asynchronousFacade.getResponseCode());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.