Package java.util.concurrent.atomic

Examples of java.util.concurrent.atomic.AtomicInteger


    if (restore)
      OwlUI.getFeedViews();
  }

  private boolean shouldRunInBackground(List<IEntity> entities, List<INews> newsToDelete) {
    AtomicInteger newsCount = new AtomicInteger();
    newsCount.addAndGet(newsToDelete.size());

    for (IEntity entity : entities)
      countNewsWithLimit(entity, newsCount, RUN_IN_BACKGROUND_CAP);

    return newsCount.get() > RUN_IN_BACKGROUND_CAP;
  }
View Full Code Here


    IFeed feed = fFactory.createFeed(null, new URI("feed"));
    INews news = fFactory.createNews(null, feed, new Date());

    DynamicDAO.save(feed);

    final AtomicInteger mode = new AtomicInteger(0);
    final AtomicInteger counter = new AtomicInteger(0);

    NewsListener listener = null;
    try {
      listener = new NewsAdapter() {
        @Override
        public void entitiesUpdated(Set<NewsEvent> events) {
          assertEquals(1, events.size());

          if (mode.get() == 0) {
            assertTrue(CoreUtils.isStickyStateChange(events.iterator().next()));
            assertTrue(CoreUtils.isStickyStateChange(events));
            assertTrue(CoreUtils.isStickyStateChange(events, true));
            counter.incrementAndGet();
          }

          else if (mode.get() == 1) {
            assertFalse(CoreUtils.isStickyStateChange(events.iterator().next()));
            assertFalse(CoreUtils.isStickyStateChange(events));
            assertFalse(CoreUtils.isStickyStateChange(events, true));
            counter.incrementAndGet();
          }

          else if (mode.get() == 2) {
            assertTrue(CoreUtils.isStickyStateChange(events.iterator().next()));
            assertTrue(CoreUtils.isStickyStateChange(events));
            assertFalse(CoreUtils.isStickyStateChange(events, true));
            counter.incrementAndGet();
          }
        }
      };

      DynamicDAO.addEntityListener(INews.class, listener);

      mode.set(0);
      news.setFlagged(true);
      DynamicDAO.save(news);

      mode.set(1);
      news.setTitle("Foo");
      DynamicDAO.save(news);

      mode.set(2);
      news.setFlagged(false);
      DynamicDAO.save(news);

      assertEquals(3, counter.get());
    } finally {
      if (listener != null)
        DynamicDAO.removeEntityListener(INews.class, listener);
    }
  }
View Full Code Here

    INews news = fFactory.createNews(null, feed, new Date());
    news.setState(INews.State.NEW);

    DynamicDAO.save(feed);

    final AtomicInteger mode = new AtomicInteger(0);
    final AtomicInteger counter = new AtomicInteger(0);

    NewsListener listener = null;
    try {
      listener = new NewsAdapter() {
        @Override
        public void entitiesUpdated(Set<NewsEvent> events) {
          assertEquals(1, events.size());

          if (mode.get() == 0) {
            assertTrue(CoreUtils.isStateChange(events.iterator().next()));
            assertTrue(CoreUtils.isStateChange(events));
            counter.incrementAndGet();
          }

          else if (mode.get() == 1) {
            assertFalse(CoreUtils.isStateChange(events.iterator().next()));
            assertFalse(CoreUtils.isStateChange(events));
            counter.incrementAndGet();
          }

          else if (mode.get() == 2) {
            assertTrue(CoreUtils.isStateChange(events.iterator().next()));
            assertTrue(CoreUtils.isStateChange(events));
            counter.incrementAndGet();
          }
        }
      };

      DynamicDAO.addEntityListener(INews.class, listener);

      mode.set(0);
      news.setState(INews.State.READ);
      DynamicDAO.save(news);

      mode.set(1);
      news.setTitle("Foo");
      DynamicDAO.save(news);

      mode.set(2);
      news.setState(INews.State.UNREAD);
      DynamicDAO.save(news);

      assertEquals(3, counter.get());
    } finally {
      if (listener != null)
        DynamicDAO.removeEntityListener(INews.class, listener);
    }
  }
View Full Code Here

    INews news = fFactory.createNews(null, feed, new Date());
    news.setState(INews.State.NEW);

    DynamicDAO.save(feed);

    final AtomicInteger mode = new AtomicInteger(0);
    final AtomicInteger counter = new AtomicInteger(0);

    NewsListener listener = null;
    try {
      listener = new NewsAdapter() {
        @Override
        public void entitiesUpdated(Set<NewsEvent> events) {
          assertEquals(1, events.size());

          if (mode.get() == 0) {
            assertFalse(CoreUtils.gotDeleted(events));
            counter.incrementAndGet();
          }

          else if (mode.get() == 1) {
            assertTrue(CoreUtils.gotDeleted(events));
            counter.incrementAndGet();
          }
        }
      };

      DynamicDAO.addEntityListener(INews.class, listener);

      mode.set(0);
      news.setState(INews.State.READ);
      DynamicDAO.save(news);

      mode.set(1);
      news.setState(INews.State.HIDDEN);
      DynamicDAO.save(news);

      assertEquals(2, counter.get());
    } finally {
      if (listener != null)
        DynamicDAO.removeEntityListener(INews.class, listener);
    }
  }
View Full Code Here

    INews news = fFactory.createNews(null, feed, new Date());
    news.setState(INews.State.NEW);

    DynamicDAO.save(feed);

    final AtomicInteger mode = new AtomicInteger(0);
    final AtomicInteger counter = new AtomicInteger(0);

    NewsListener listener = null;
    try {
      listener = new NewsAdapter() {
        @Override
        public void entitiesUpdated(Set<NewsEvent> events) {
          assertEquals(1, events.size());

          if (mode.get() == 0) {
            assertTrue(CoreUtils.gotDeleted(events));
            counter.incrementAndGet();
          }

          else if (mode.get() == 1) {
            assertTrue(CoreUtils.gotRestored(events));
            counter.incrementAndGet();
          }
        }
      };

      DynamicDAO.addEntityListener(INews.class, listener);

      mode.set(0);
      news.setState(INews.State.HIDDEN);
      DynamicDAO.save(news);

      mode.set(1);
      news.setState(INews.State.UNREAD);
      DynamicDAO.save(news);

      assertEquals(2, counter.get());
    } finally {
      if (listener != null)
        DynamicDAO.removeEntityListener(INews.class, listener);
    }
  }
View Full Code Here

    INews news = fFactory.createNews(null, feed, new Date());
    news.setState(INews.State.NEW);

    DynamicDAO.save(feed);

    final AtomicInteger mode = new AtomicInteger(0);
    final AtomicInteger counter = new AtomicInteger(0);

    NewsListener listener = null;
    try {
      listener = new NewsAdapter() {
        @Override
        public void entitiesUpdated(Set<NewsEvent> events) {
          assertEquals(1, events.size());

          if (mode.get() == 0) {
            assertTrue(CoreUtils.isLabelChange(events.iterator().next()));
            assertTrue(CoreUtils.isLabelChange(events));
            counter.incrementAndGet();
          }

          else if (mode.get() == 1) {
            assertTrue(CoreUtils.isLabelChange(events.iterator().next()));
            assertTrue(CoreUtils.isLabelChange(events));
            counter.incrementAndGet();
          }

          else if (mode.get() == 2) {
            assertFalse(CoreUtils.isLabelChange(events.iterator().next()));
            assertFalse(CoreUtils.isLabelChange(events));
            counter.incrementAndGet();
          }
        }
      };

      DynamicDAO.addEntityListener(INews.class, listener);

      mode.set(0);
      ILabel label = DynamicDAO.save(fFactory.createLabel(null, "Label"));
      news.addLabel(label);
      DynamicDAO.save(news);

      mode.set(1);
      news.removeLabel(label);
      DynamicDAO.save(news);

      mode.set(2);
      news.setTitle("Foo");
      DynamicDAO.save(news);

      assertEquals(3, counter.get());
    } finally {
      if (listener != null)
        DynamicDAO.removeEntityListener(INews.class, listener);
    }
  }
View Full Code Here

    INews news = fFactory.createNews(null, feed, new Date());
    news.setState(INews.State.NEW);

    DynamicDAO.save(feed);

    final AtomicInteger mode = new AtomicInteger(0);
    final AtomicInteger counter = new AtomicInteger(0);

    NewsListener listener = null;
    try {
      listener = new NewsAdapter() {
        @Override
        public void entitiesUpdated(Set<NewsEvent> events) {
          assertEquals(1, events.size());

          if (mode.get() == 0) {
            assertTrue(CoreUtils.isTitleChange(events));
            counter.incrementAndGet();
          }

          else if (mode.get() == 1) {
            assertFalse(CoreUtils.isTitleChange(events));
            counter.incrementAndGet();
          }
        }
      };

      DynamicDAO.addEntityListener(INews.class, listener);

      mode.set(0);
      news.setTitle("Foo");
      DynamicDAO.save(news);

      mode.set(1);
      news.setDescription("Bar");
      DynamicDAO.save(news);

      assertEquals(2, counter.get());
    } finally {
      if (listener != null)
        DynamicDAO.removeEntityListener(INews.class, listener);
    }
  }
View Full Code Here

    INews news = fFactory.createNews(null, feed, new Date());
    news.setState(INews.State.NEW);

    DynamicDAO.save(feed);

    final AtomicInteger mode = new AtomicInteger(0);
    final AtomicInteger counter = new AtomicInteger(0);

    NewsListener listener = null;
    try {
      listener = new NewsAdapter() {
        @Override
        public void entitiesUpdated(Set<NewsEvent> events) {
          assertEquals(1, events.size());

          if (mode.get() == 0) {
            assertTrue(CoreUtils.containsState(events, INews.State.NEW));
            assertFalse(CoreUtils.containsState(events, INews.State.READ));
            counter.incrementAndGet();
          }

          else if (mode.get() == 1) {
            assertTrue(CoreUtils.containsState(events, INews.State.READ));
            assertFalse(CoreUtils.containsState(events, INews.State.NEW));
            counter.incrementAndGet();
          }
        }
      };

      DynamicDAO.addEntityListener(INews.class, listener);

      mode.set(0);
      news.setTitle("Foo");
      DynamicDAO.save(news);

      mode.set(1);
      news.setState(INews.State.READ);
      DynamicDAO.save(news);

      assertEquals(2, counter.get());
    } finally {
      if (listener != null)
        DynamicDAO.removeEntityListener(INews.class, listener);
    }
  }
View Full Code Here

     * @see junit.framework.TestCase#setUp()
     */
    protected void setUp() throws Exception
    {
        super.setUp();
        activeCount = new AtomicInteger( threads );
    }
View Full Code Here

        server.setMaxReadProcessors( readers );
        server.setMaxWriteProcessors( writers );
        server.enablePersistentConnections( persistent );
        server.start();

        activeCount = new AtomicInteger( threads );

        if ( useSingleClient )
        {
            client = new EJClient( "127.0.0.1", port, adapter );
            client.enableCompression( compression );
View Full Code Here

TOP

Related Classes of java.util.concurrent.atomic.AtomicInteger

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.