1 52 53 package org.jivesoftware.smack.filter; 54 55 import junit.framework.TestCase; 56 import org.jivesoftware.smack.packet.*; 57 58 61 public class PacketIDFilterTest extends TestCase { 62 63 public void testNullArgs() { 64 try { 65 new PacketIDFilter(null); 66 fail("Parameter can not be null"); 67 } 68 catch (IllegalArgumentException e) { 69 assertTrue(true); 70 } 71 } 72 73 public void testAccept() { 74 MockIDPacket packet = new MockIDPacket("foo"); 75 76 PacketIDFilter packetIDFilter = new PacketIDFilter(""); 77 assertFalse(packetIDFilter.accept(packet)); 78 79 packetIDFilter = new PacketIDFilter("foo"); 80 assertTrue(packetIDFilter.accept(packet)); 81 82 packetIDFilter = new PacketIDFilter("fOO"); 83 assertFalse(packetIDFilter.accept(packet)); 84 } 85 86 89 private class MockIDPacket extends MockPacket { 90 private String id; 91 public MockIDPacket(String id) { 92 this.id = id; 93 } 94 public String getPacketID() { 95 return id; 96 } 97 } 98 } 99 | Popular Tags |