@Test public void testMatchesObjectClass() throws Exception { rpc.setPattern("java.lang.Object.*"); assertTrue(rpc.matches(Exception.class.getMethod("hashCode"), IOException.class)); // Doesn't match a method from Throwable assertFalse(rpc.matches(Exception.class.getMethod("getMessage"), Exception.class)); }
@Test public void testWildcardForOneClass() throws Exception { rpc.setPattern("java.lang.Object.*"); assertTrue(rpc.matches(Object.class.getMethod("hashCode"), String.class)); assertTrue(rpc.matches(Object.class.getMethod("wait"), String.class)); }
@Test public void testSpecificMatch() throws Exception { rpc.setPattern("java.lang.String.hashCode"); assertTrue(rpc.matches(Object.class.getMethod("hashCode"), String.class)); assertFalse(rpc.matches(Object.class.getMethod("hashCode"), Object.class)); }
@Test public void testWildcard() throws Exception { rpc.setPattern(".*Object.hashCode"); assertTrue(rpc.matches(Object.class.getMethod("hashCode"), Object.class)); assertFalse(rpc.matches(Object.class.getMethod("wait"), Object.class)); }
@Test public void testWithExclusion() throws Exception { this.rpc.setPattern(".*get.*"); this.rpc.setExcludedPattern(".*Age.*"); assertTrue(this.rpc.matches(TestBean.class.getMethod("getName"), TestBean.class)); assertFalse(this.rpc.matches(TestBean.class.getMethod("getAge"), TestBean.class)); }
@Test public void testExactMatch() throws Exception { rpc.setPattern("java.lang.Object.hashCode"); exactMatchTests(rpc); rpc = (AbstractRegexpMethodPointcut) SerializationTestUtils.serializeAndDeserialize(rpc); exactMatchTests(rpc); }