Examples of AsynchronousFacade


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

        + (tt1 - tt0)
        + " (ms).Average time "
        + time
        + " (ms).");
    BusinessModel bm = new BusinessModel(10);
    AsynchronousFacade Fbm = (AsynchronousFacade)bm;
    long total = 0;
    int iOk = 0;
    int nb1 = 200;
    int nb2 = 5;
    AsynchronousTask[] Tbm = new AsynchronousTask[nb2];
    for (int j = 0; j < nb1; j++) {
      long t0 = System.currentTimeMillis();
      for (int i = 0; i < nb2; i++) {
        bm.processBusinessModel();
        Tbm[i] = Fbm.getAsynchronousTask();
      }
      long t1 = System.currentTimeMillis();
      total += (t1 - t0);
      for (int i = 0; i < nb2; i++) {
        int ok = Fbm.getResponseCode(Tbm[i]);
        if (ok == OK)
          iOk++;
      }
    }
    System.out.println(
View Full Code Here

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

  public static void testResponseTimeReturned() {
    BusinessModel bm1 = new BusinessModel(200);
    int ERROR = 20;
    long t0 = System.currentTimeMillis();
    bm1.processBusinessModel();
    AsynchronousFacade asynchronousFacade1 = (AsynchronousFacade)bm1;
    assertEquals(
      "Method is not succesfull !",
      OK,
      asynchronousFacade1.getResponseCode());
    long t1 = System.currentTimeMillis();
    long startingTime =
      asynchronousFacade1.getThreadManagerResponse().getStartingTime();
    long endingTime =
      asynchronousFacade1.getThreadManagerResponse().getEndingTime();
    assertTrue(
      "starting time issue ? " + (startingTime - t0),
      (startingTime - t0) < ERROR);
    assertTrue(
      "ending time issue ? " + (t1 - endingTime),
View Full Code Here

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

      "not an instance of AsynchronousFacade",
      object instanceof AsynchronousFacade);
    assertTrue(
      "static method not an asynchronous call:" + (t1 - t0) + " ms.",
      (t1 - t0) < 100);
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)object;
    AsynchronousTask asynchronousTask1 =
      asynchronousFacade.getAsynchronousTask();
    assertEquals(
      "Method does not return the right value !",
      200,
      ((Long)asynchronousFacade.getReturnValue(asynchronousTask1))
        .longValue());
  }
View Full Code Here

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

    System.out.println(System.currentTimeMillis()-t0);
    long t1 = System.currentTimeMillis();
    assertTrue(
      "static method not an asynchronous call:" + (t1 - t0) + " ms.",
      (t1 - t0) < 160);
    AsynchronousFacade asynchronousFacade1 = (AsynchronousFacade)object1;
    assertEquals(
      "Method did not timeout !",
      TIMEOUT,
      asynchronousFacade1.getResponseCode());
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)object2;
    AsynchronousTask asynchronousTask2 =
      asynchronousFacade.getAsynchronousTask();
    assertEquals(
      "Method does not return the right value !",
      150,
      ((Long)asynchronousFacade.getReturnValue(asynchronousTask2))
        .longValue());
  }
View Full Code Here

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

  }

  public void run() {

    AsynchronousFacade asynchronousFacade =

      (AsynchronousFacade)businessModel;

    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

      "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

    BusinessModel bm1 = new BusinessModel();

    bm1.processBusinessModel2(15);

    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;

    AsynchronousTask asynchronousTask1 =

      asynchronousFacade.getAsynchronousTask();

    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

  public static void test2AsynchronousCallOnSameInstance2() {

    BusinessModel bm1 = new BusinessModel();

    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;

    asynchronousFacade.setTimeout(50);

    bm1.processBusinessModel2(1000);

    AsynchronousTask asynchronousTask1 =

      asynchronousFacade.getAsynchronousTask();

    asynchronousFacade.setTimeout(200);

    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

  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);
View Full Code Here

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

    BusinessModel bm1 = new BusinessModel();

      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
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.