Examples of IExpiring


Examples of org.jamesii.core.util.misc.session.IExpiring

   * checks that after calling it {@link IExpiring#hasBeenActive()} returns
   * true.
   */
  public void testHasBeenActive() {

    IExpiring testObject = getTestObject();

    Method[] methods = getInterface().getMethods();

    // after two times calling this method has to return false
    testObject.hasBeenActive();
    assertFalse(testObject.hasBeenActive());

    // after activated(), hasBeenActive has to return true
    testObject.activated();
    assertTrue(testObject.hasBeenActive());

    for (Method m : methods) {
      try {
        testObject = getTestObject();
        testObject.hasBeenActive(); // let's make sure the method will return
                                    // false next time if we don't do anything
        Class<?>[] paramTypes = m.getParameterTypes();
        Object[] params = new Object[paramTypes.length];
        m.invoke(testObject, params);
      } catch (IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
        fail();
      } catch (InvocationTargetException e) {
        // there'll probably a big fuss going on inside the method but we'll
        // ignore it
      }
      boolean b = testObject.hasBeenActive();
      if (!b) {
        System.out.println(m.getName() + " is not resetting #hasBeenActive()!");
      }
    }
  }
View Full Code Here

Examples of org.jamesii.core.util.misc.session.IExpiring

  /**
   * Perfoms a test whether the object is subject to the garbage collector after
   * calling {@link IExpiring#expire()}.
   */
  public void testDisposal() {
    IExpiring sessionObject = bringObjectInContext();
    WeakReference<IExpiring> testRef = new WeakReference<>(sessionObject);
    assertNotNull(testRef.get());
    sessionObject.activated();
    sessionObject.hasBeenActive();
    sessionObject.hasBeenActive();
    sessionObject.expire();
    sessionObject = null;
    System.gc();
    assertNull("There should be no references left to the object.",
        testRef.get());
  }
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.