ref1_2.decrementChannelCount();
   public void testAddRemoveReference() throws Exception   {      doSetup(false);            Channel channel1 = new SimpleChannel(0, ms);      Channel channel2 = new SimpleChannel(1, ms);      Message[] messages = createMessages(10);                 for (int i = 0; i < 5; i++)      {         Message m1 = messages[i * 2];         Message m2 = messages[i * 2 + 1];                  MessageReference ref1_1 = ms.reference(m1);         MessageReference ref1_2 = ms.reference(m1);                         MessageReference ref2_1 = ms.reference(m2);         MessageReference ref2_2 = ms.reference(m2);                           ref1_1.incrementChannelCount();         ref1_2.incrementChannelCount();         ref2_1.incrementChannelCount();         ref2_2.incrementChannelCount();         pm.addReference(channel1.getChannelID(), ref1_1, null);         pm.addReference(channel1.getChannelID(), ref2_1, null);                           pm.addReference(channel2.getChannelID(), ref1_2, null);         pm.addReference(channel2.getChannelID(), ref2_2, null);               List refs = getReferenceIds(channel1.getChannelID());                  assertNotNull(refs);         assertEquals(2, refs.size());         assertTrue(refs.contains(new Long(m1.getMessageID())));         assertTrue(refs.contains(new Long(m2.getMessageID())));                  refs = getReferenceIds(channel2.getChannelID());                  assertNotNull(refs);         assertEquals(2, refs.size());         assertTrue(refs.contains(new Long(m1.getMessageID())));         assertTrue(refs.contains(new Long(m2.getMessageID())));                  List msgs = getMessageIds();         assertNotNull(msgs);         assertEquals(2, msgs.size());         assertTrue(msgs.contains(new Long(m1.getMessageID())));         assertTrue(msgs.contains(new Long(m2.getMessageID())));                           ref1_1.decrementChannelCount();         pm.removeReference(channel1.getChannelID(), ref1_1, null);                           refs = getReferenceIds(channel1.getChannelID());         assertNotNull(refs);         assertEquals(1, refs.size());         assertTrue(refs.contains(new Long(m2.getMessageID())));                  refs = getReferenceIds(channel2.getChannelID());         assertNotNull(refs);         assertEquals(2, refs.size());         assertTrue(refs.contains(new Long(m1.getMessageID())));         assertTrue(refs.contains(new Long(m2.getMessageID())));                  msgs = getMessageIds();         assertNotNull(msgs);         assertEquals(2, msgs.size());         assertTrue(msgs.contains(new Long(m1.getMessageID())));         assertTrue(msgs.contains(new Long(m2.getMessageID())));                  ref1_2.decrementChannelCount();         pm.removeReference(channel2.getChannelID(), ref1_2, null);                  refs = getReferenceIds(channel1.getChannelID());         assertNotNull(refs);         assertEquals(1, refs.size());         assertTrue(refs.contains(new Long(m2.getMessageID())));                  refs = getReferenceIds(channel2.getChannelID());         assertNotNull(refs);         assertEquals(1, refs.size());                  assertTrue(refs.contains(new Long(m2.getMessageID())));                  msgs = getMessageIds();         assertNotNull(msgs);         assertEquals(1, msgs.size());         assertTrue(msgs.contains(new Long(m2.getMessageID())));                  ref2_1.decrementChannelCount();         pm.removeReference(channel1.getChannelID(), ref2_1, null);                  refs = getReferenceIds(channel1.getChannelID());         assertNotNull(refs);         assertTrue(refs.isEmpty());                  refs = getReferenceIds(channel2.getChannelID());         assertNotNull(refs);         assertEquals(1, refs.size());                  assertTrue(refs.contains(new Long(m2.getMessageID())));                  msgs = getMessageIds();         assertNotNull(msgs);         assertEquals(1, msgs.size());         assertTrue(msgs.contains(new Long(m2.getMessageID())));                  ref2_2.decrementChannelCount();         pm.removeReference(channel2.getChannelID(), ref2_2, null);                  refs = getReferenceIds(channel1.getChannelID());         assertNotNull(refs);         assertTrue(refs.isEmpty());                  refs = getReferenceIds(channel2.getChannelID());         assertNotNull(refs);         assertTrue(refs.isEmpty());                  msgs = getMessageIds();         assertNotNull(msgs);         assertTrue(msgs.isEmpty());                  }   }