Package de.nava.informa.utils

Examples of de.nava.informa.utils.PersistChanGrpMgr


    // Create an array of ChannelGroupManagers
    managers = new PersistChanGrpMgr[nManagers];
    int channelIndex = 0;

    for (int i = 0; i < nManagers; i++) {
      managers[i] = new PersistChanGrpMgr(scaleSessHandler, true);
      assertNotNull(managers[i]);
      managers[i].createGroup(generateChanGrpName(i));
      managers[i].setGlobalObserver(new ChannelLogRecordObserver());
      for (int chans = 0; chans < nChans; chans++) {
        Channel nextChan = managers[i].addChannel(RssUrlTestData.get(channelIndex++));
View Full Code Here


  private void restoreScaleChannelGroups() throws Exception {
    managers = new PersistChanGrpMgr[nManagers];
    int channelIndex = 0;

    for (int i = 0; i < nManagers; i++) {
      managers[i] = new PersistChanGrpMgr(scaleSessHandler, true);
      assertNotNull(managers[i]);
      managers[i].createGroup(generateChanGrpName(i));
      managers[i].setGlobalObserver(new informaLogObserver());
      for (int chans = 0; chans < nChans; chans++) {
        Channel nextChan = managers[i].addChannel(RssUrlTestData.get(channelIndex++));
View Full Code Here

          ItemLogEntry entry = copyItemLog[i];
          synchronized (entry) {

            if (!entry.deleted) {
              // Delete it and mark it deleted, and note that we deleted one.
              PersistChanGrpMgr theGrp = managers[entry.getPersistChanGrpMgrIdx()];

              Channel theChan = (Channel) entry.theItem.getChannel();
              theGrp.deActivate();
              int before = theGrp.getItemCount(theChan);
              int after = theGrp.deleteItemFromChannel(theChan, entry.theItem);

              if (getActiveSemaphor()) theGrp.activate();
              logger.debug("Deleted. Count before =" + before + " /after: " + after);
              assertEquals("Not the rigth number of items", before, after + 1);

              entry.deleted = true;
              foundOne = true;
View Full Code Here

   *
   * @exception Exception (Caught by JUnit)
  
   */
  public void testEmptyGroups() throws Exception {
    PersistChanGrpMgr agroup, bgroup, cgroup;
    agroup = makeEmptyGroup("Group Foo");
    bgroup = makeEmptyGroup("Group Bar");
    cgroup = makeEmptyGroup("Group Too");
    assertValidGroup(agroup, "Group Foo", 0);
    assertValidGroup(bgroup, "Group Bar", 0);
View Full Code Here

   * Create a group, and add some channels and see if all is well
   *
   * @exception Exception (Caught by JUnit)
   */
  public void testGroupWithChannels() throws Exception {
    PersistChanGrpMgr agroup;
    agroup = makeEmptyGroup("Group Secret With Channels");
    assertValidGroup(agroup, "Group Secret With Channels", 0);

    addChannel(agroup, "Joho", "http://www.hyperorg.com/blogger/index.rdf");
    addChannel(agroup, "Raliable", "http://www.raibledesigns.com/rss/rd");
View Full Code Here

   * work.
   *
   * @throws Exception
   */
  public void testAddingExistingChannel() throws Exception {
    final PersistChanGrpMgr agroup;
    agroup = makeEmptyGroup("A Group");
    assertValidGroup(agroup, "A Group", 0);
    addGenChannels(agroup, 5, 3);

    final PersistChanGrpMgr bgroup;
    bgroup = makeEmptyGroup("B Group");
    assertValidGroup(bgroup, "B Group", 0);
    addGenChannels(bgroup, 5, 3);

    // Add a certain channel to this group
View Full Code Here

   * Test the functioning of the hasChannel() method.
   *
   * @throws Exception
   */
  public void testChannelMembership() throws Exception {
    final PersistChanGrpMgr agroup;
    agroup = makeEmptyGroup("Membership Group");
    addGenChannels(agroup, 3, 3);

    final Iterator channels = agroup.getChannelGroup().getChannels().iterator();
    while (channels.hasNext()) {
      final Channel nextchan = (Channel) channels.next();
      assertTrue("Expected member channel not found", agroup.hasChannel(nextchan));
    }
  }
View Full Code Here

   * Test activation and deactivation of PersistChanGrpMgrs
   *
   * @throws Exception
   */
  public void testGroupDeactivate() throws Exception {
    final PersistChanGrpMgr group1, group2, group3;
    group1 = makeEmptyGroup("Activation Group 1");
    group2 = makeEmptyGroup("Activation Group 2");
    group3 = makeEmptyGroup("Activation Group 3");

    addGenChannels(group1, 5, 3);
    addGenChannels(group2, 5, 3);
    addGenChannels(group3, 5, 3);
   
    assertFalse("expected group 1 to be inactive", group1.isActivated());
    assertFalse("expected group 2 to be inactive", group2.isActivated());
    assertFalse("expected group 3 to be inactive", group3.isActivated());
   
    group1.activate();
    assertTrue("expected group 1 to be active", group1.isActivated());
    assertFalse("expected group 2 to be inactive", group2.isActivated());
    assertFalse("expected group 3 to be inactive", group3.isActivated());

    Thread.sleep(500);
   
    group2.activate();
    assertTrue("expected group 1 to be active", group1.isActivated());
    assertTrue("expected group 2 to be active", group2.isActivated());
    assertFalse("expected group 3 to be inactive", group3.isActivated());
   
    Thread.sleep(500);

    group3.activate();
    assertTrue("expected group 1 to be active", group1.isActivated());
    assertTrue("expected group 2 to be active", group2.isActivated());
    assertTrue("expected group 3 to be active", group3.isActivated());
   
    Thread.sleep(500);

    group1.deActivate(true);
    assertFalse("expected group 1 to be inactive", group1.isActivated());
    assertTrue("expected group 2 to be active", group2.isActivated());
    assertTrue("expected group 3 to be active", group3.isActivated());
   
    Thread.sleep(500);

    group2.deActivate(true);
    assertFalse("expected group 1 to be inactive", group1.isActivated());
    assertFalse("expected group 2 to be inactive", group2.isActivated());
    assertTrue("expected group 3 to be active", group3.isActivated());
   
    Thread.sleep(500);

    group3.deActivate(true);
    assertFalse("expected group 1 to be inactive", group1.isActivated());
    assertFalse("expected group 2 to be inactive", group2.isActivated());
    assertFalse("expected group 3 to be inactive", group3.isActivated());  
  }
View Full Code Here

   *
   * @throws Exception
   */
  public void testMoveChannelBetweenGroups() throws Exception {
    // Create the two groups
    PersistChanGrpMgr sourceGrp, destGrp;
    sourceGrp = makeEmptyGroup("Source Group");
    destGrp = makeEmptyGroup("Destination Group");

    // Populate source group with some channels.
    int count = 5;
    int sourceHas = count;
    int destHas = 0;
    addGenChannels(sourceGrp, count, 3);

    // Now move them one by one to the other ChannelGroup and verify the counts as we go
    for (int i = 0; i < count; i++) {
      // Verify that each group has the expected number of channels
      assertValidGroup(sourceGrp, "Source Group", sourceHas - i);
      assertValidGroup(destGrp, "Destination Group", destHas + i);

      // Identify the first channel after ensuring that there is at least one.
      Channel channelToMove;
      Collection chans = sourceGrp.getChannelGroup().getChannels();
      Iterator iter = chans.iterator();
      assertTrue(chans.size() > 0);
      channelToMove = (Channel) iter.next();
      sourceGrp.moveChannelTo(channelToMove, destGrp);
    }
  }
View Full Code Here

   *
   * @throws Exception
   */
  public void testDeleteItemsFromChannels() throws Exception {
    // Create a ChannelGroup and populate it with channels and items
    PersistChanGrpMgr delGrp;
    delGrp = makeEmptyGroup("deleteTest Group");
    int count = 10;
    addGenChannels(delGrp, count, 5);

    Object[] channels = delGrp.getChannelGroup().getChannels().toArray();
    assertEquals("Wrong number of channels in group", channels.length, count);

    // Iterate through all the new channels
    for (int i = 0; i < count; i++) {
      Channel aChan = (Channel) channels[i];
      Object[] items = aChan.getItems().toArray();
      int howManyItems = items.length;

      // Now iterate through all the items of this channel, and delete them one by one
      for (int j = 0; j < howManyItems; j++) {
        Item anItem = (Item) items[j];
        assertEquals("Wrong number of items after delete", howManyItems - j, aChan.getItems()
            .size());
        delGrp.deleteItemFromChannel(aChan, anItem);
      }
    }
  }
View Full Code Here

TOP

Related Classes of de.nava.informa.utils.PersistChanGrpMgr

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.