@Test public void testSets() throws Throwable { pc.setMappedNames(new String[] {"set*", "echo"}); assertEquals(0, nop.getCount()); proxied.getName(); proxied.setName(""); assertEquals(1, nop.getCount()); proxied.echo(null); assertEquals(2, nop.getCount()); }
@Test public void testMatchingOnly() { // Can't do exact matching through isMatch assertTrue(pc.isMatch("echo", "ech*")); assertTrue(pc.isMatch("setName", "setN*")); assertTrue(pc.isMatch("setName", "set*")); assertFalse(pc.isMatch("getName", "set*")); assertFalse(pc.isMatch("setName", "set")); assertTrue(pc.isMatch("testing", "*ing")); }
@Test public void testMatchOneMethod() throws Throwable { pc.addMethodName("echo"); pc.addMethodName("set*"); assertEquals(0, nop.getCount()); proxied.getName(); proxied.getName(); assertEquals(0, nop.getCount()); proxied.echo(null); assertEquals(1, nop.getCount()); proxied.setName(""); assertEquals(2, nop.getCount()); proxied.setAge(25); assertEquals(25, proxied.getAge()); assertEquals(3, nop.getCount()); }
@Test public void testEqualsAndHashCode() throws Exception { NameMatchMethodPointcut pc1 = new NameMatchMethodPointcut(); NameMatchMethodPointcut pc2 = new NameMatchMethodPointcut(); String foo = "foo"; assertEquals(pc1, pc2); assertEquals(pc1.hashCode(), pc2.hashCode()); pc1.setMappedName(foo); assertFalse(pc1.equals(pc2)); assertTrue(pc1.hashCode() != pc2.hashCode()); pc2.setMappedName(foo); assertEquals(pc1, pc2); assertEquals(pc1.hashCode(), pc2.hashCode()); }