Package org.apache.wicket.util.time

Examples of org.apache.wicket.util.time.Duration


   */
  @Test
  public void testReentrant() throws Exception
  {
    final PageAccessSynchronizer sync = new PageAccessSynchronizer(Duration.seconds(5));
    final Duration hold = Duration.seconds(1);
    sync.lockPage(0);
    sync.lockPage(0);
  }
View Full Code Here


   */
  @Test
  public void testBlocking() throws Exception
  {
    final PageAccessSynchronizer sync = new PageAccessSynchronizer(Duration.seconds(5));
    final Duration hold = Duration.seconds(1);
    final Time t1locks[] = new Time[1];
    final Time t2locks[] = new Time[1];

    class T1 extends Thread
    {
      @Override
      public void run()
      {
        sync.lockPage(1);
        t1locks[0] = Time.now();
        hold.sleep();
        sync.unlockAllPages();
      }
    }

    class T2 extends Thread
View Full Code Here

        sync.lockPage(5);
      }
    }

    // set up a synchronizer and lock page 5 with locker1
    final Duration timeout = Duration.seconds(30);
    final PageAccessSynchronizer sync = new PageAccessSynchronizer(timeout);
    Locker locker1 = new Locker(sync);

    final long start = System.currentTimeMillis();
    locker1.run();
View Full Code Here

   * @throws Exception
   */
  @Test
  public void failToReleaseUnderLoad() throws Exception
  {
    final Duration duration = Duration.seconds(20); /* seconds */
    final ConcurrentLinkedQueue<Exception> errors = new ConcurrentLinkedQueue<Exception>();
    final long endTime = System.currentTimeMillis() + duration.getMilliseconds();

    // set the synchronizer timeout one second longer than the test runs to prevent
    // starvation to become an issue
    final PageAccessSynchronizer sync = new PageAccessSynchronizer(duration.add(Duration.ONE_SECOND));

    final CountDownLatch latch = new CountDownLatch(100);
    for (int count = 0; count < 100; count++)
    {
      new Thread()
View Full Code Here

   * Tests timer behavior in a component added to an AjaxRequestTarget
   */
  @Test
  public void addedInAjaxSetsTimout()
  {
    Duration dur = Duration.seconds(20);
    final AjaxSelfUpdatingTimerBehavior timer = new AjaxSelfUpdatingTimerBehavior(dur);
    final MockPageWithLinkAndComponent page = new MockPageWithLinkAndComponent();

    page.add(new WebComponent(MockPageWithLinkAndComponent.COMPONENT_ID)
        .setOutputMarkupId(true));
View Full Code Here

   * tests timer behavior in a WebPage.
   */
  @Test
  public void pageRenderSetsTimeout()
  {
    Duration dur = Duration.seconds(20);
    final AjaxSelfUpdatingTimerBehavior timer = new AjaxSelfUpdatingTimerBehavior(dur);
    final MockPageWithLinkAndComponent page = new MockPageWithLinkAndComponent();
    Label label = new Label(MockPageWithLinkAndComponent.COMPONENT_ID, "Hello");
    page.add(label);
    page.add(new Link<Void>(MockPageWithLinkAndComponent.LINK_ID)
View Full Code Here

   * tests timer behavior in a WebPage.
   */
  @Test
  public void ajaxUpdateDoesNotSetTimeout()
  {
    Duration dur = Duration.seconds(20);
    final AjaxSelfUpdatingTimerBehavior timer = new AjaxSelfUpdatingTimerBehavior(dur);
    final MockPageWithLinkAndComponent page = new MockPageWithLinkAndComponent();
    final Label label = new Label(MockPageWithLinkAndComponent.COMPONENT_ID, "Hello");
    page.add(label);
    page.add(new AjaxLink<Void>(MockPageWithLinkAndComponent.LINK_ID)
View Full Code Here

  /**
   */
  @Test
  public void setVisibleSetsTimeout()
  {
    Duration dur = Duration.seconds(20);
    final AjaxSelfUpdatingTimerBehavior timer = new AjaxSelfUpdatingTimerBehavior(dur);
    final MockPageWithLinkAndComponent page = new MockPageWithLinkAndComponent();
    final Label label = new Label(MockPageWithLinkAndComponent.COMPONENT_ID, "Hello");
    page.add(label);
    page.add(new AjaxLink<Void>(MockPageWithLinkAndComponent.LINK_ID)
View Full Code Here

  @Test
  public void testReentrant() throws Exception
  {
    final PageAccessSynchronizer sync = new PageAccessSynchronizer(Duration.seconds(5));
    final Duration hold = Duration.seconds(1);
    sync.lockPage(0);
    sync.lockPage(0);
  }
View Full Code Here

  @Test
  public void testBlocking() throws Exception
  {
    final PageAccessSynchronizer sync = new PageAccessSynchronizer(Duration.seconds(5));
    final Duration hold = Duration.seconds(1);
    final Time t1locks[] = new Time[1];
    final Time t2locks[] = new Time[1];

    class T1 extends Thread
    {
      @Override
      public void run()
      {
        sync.lockPage(1);
        t1locks[0] = Time.now();
        hold.sleep();
        sync.unlockAllPages();
      }
    }

    class T2 extends Thread
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.time.Duration

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.