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 ToContainsFilterTest extends TestCase { 62 63 public void testNullArgs() { 64 try { 65 new ToContainsFilter(null); 66 fail("Parameter can not be null"); 67 } 68 catch (IllegalArgumentException e) { 69 assertTrue(true); 70 } 71 } 72 73 public void testAccept() { 74 MockToPacket packet = new MockToPacket("foo@bar.com"); 75 76 ToContainsFilter toContainsFilter = new ToContainsFilter(""); 77 assertTrue(toContainsFilter.accept(packet)); 78 79 toContainsFilter = new ToContainsFilter("foo"); 80 assertTrue(toContainsFilter.accept(packet)); 81 82 toContainsFilter = new ToContainsFilter("foo@bar.com"); 83 assertTrue(toContainsFilter.accept(packet)); 84 85 toContainsFilter = new ToContainsFilter("bar@foo.com"); 86 assertFalse(toContainsFilter.accept(packet)); 87 88 toContainsFilter = new ToContainsFilter("blah-stuff,net"); 89 assertFalse(toContainsFilter.accept(packet)); 90 } 91 92 95 private class MockToPacket extends MockPacket { 96 private String to; 97 public MockToPacket(String to) { 98 this.to = to; 99 } 100 public String getTo() { 101 return to; 102 } 103 } 104 } 105 | Popular Tags |