use of com.newrelic.agent.extension.util.MethodMapper in project newrelic-java-agent by newrelic.
the class MethodMatcherTests method createOrMethodMatcherNameOnly.
@Test
public void createOrMethodMatcherNameOnly() throws XmlException {
Method m1 = new Method();
m1.setName("m1");
Method m2 = new Method();
m2.setName("m2");
MethodMatcher matcher = MethodMatcherUtility.createMethodMatcher("myclass", Arrays.asList(m1, m2), new HashMap<String, MethodMapper>(), "EXT");
Assert.assertNotNull(matcher);
Assert.assertTrue(matcher + " not of type OrMethodMatcher", matcher instanceof OrMethodMatcher);
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "()V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "(I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "([I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m2", "()V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m2", "(I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m2", "([I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m3", "()V", com.google.common.collect.ImmutableSet.<String>of()));
}
use of com.newrelic.agent.extension.util.MethodMapper in project newrelic-java-agent by newrelic.
the class MethodMatcherTests method createOrMethodMatcherMix.
@Test
public void createOrMethodMatcherMix() throws XmlException {
Method m1 = new Method();
m1.setName("m1");
m1.setParameters(new MethodParameters(Arrays.asList("int")));
Method m2 = new Method();
m2.setName("m2");
MethodMatcher matcher = MethodMatcherUtility.createMethodMatcher("myclass", Arrays.asList(m1, m2), new HashMap<String, MethodMapper>(), "EXT");
Assert.assertNotNull(matcher);
Assert.assertTrue(matcher + " not of type OrMethodMatcher", matcher instanceof OrMethodMatcher);
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "()V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "(I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "([I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m2", "()V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m2", "(I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m2", "([I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m3", "()V", com.google.common.collect.ImmutableSet.<String>of()));
}
use of com.newrelic.agent.extension.util.MethodMapper in project newrelic-java-agent by newrelic.
the class MethodMatcherTests method createOrMethodMatcherExactOnly.
@Test
public void createOrMethodMatcherExactOnly() throws XmlException {
Method m1 = new Method();
m1.setName("m1");
m1.setParameters(new MethodParameters(Arrays.asList("int")));
Method m2 = new Method();
m2.setName("m2");
m2.setParameters(new MethodParameters(Arrays.asList("int[]")));
Method m3 = new Method();
m3.setName("m3");
m3.setParameters(new MethodParameters(null));
Method m4 = new Method();
m4.setName("m4");
m4.setParameters(new MethodParameters(Collections.EMPTY_LIST));
MethodMatcher matcher = MethodMatcherUtility.createMethodMatcher("myclass", Arrays.asList(m1, m2, m3, m4), new HashMap<String, MethodMapper>(), "EXT");
Assert.assertNotNull(matcher);
Assert.assertTrue(matcher + " not of type OrMethodMatcher", matcher instanceof OrMethodMatcher);
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "()V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "(I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "([I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m2", "()V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m2", "(I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m2", "([I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m3", "()V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m3", "(I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m4", "()V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m4", "(I)V", com.google.common.collect.ImmutableSet.<String>of()));
}
use of com.newrelic.agent.extension.util.MethodMapper in project newrelic-java-agent by newrelic.
the class MethodMatcherTests method createMethodMatcherNameOnly.
@Test
public void createMethodMatcherNameOnly() throws XmlException {
Method m1 = new Method();
m1.setName("m1");
MethodMatcher matcher = MethodMatcherUtility.createMethodMatcher("myclass", Arrays.asList(m1), new HashMap<String, MethodMapper>(), "EXT");
Assert.assertNotNull(matcher);
Assert.assertTrue(matcher + " not of type NameMethodMatcher", matcher instanceof NameMethodMatcher);
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "()V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "(I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "([I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m2", "()V", com.google.common.collect.ImmutableSet.<String>of()));
}
use of com.newrelic.agent.extension.util.MethodMapper in project newrelic-java-agent by newrelic.
the class MethodMatcherTests method createMethodMatcherExactOnly.
@Test
public void createMethodMatcherExactOnly() throws XmlException {
Method m1 = new Method();
m1.setName("m1");
m1.setParameters(new MethodParameters(Arrays.asList("int")));
MethodMatcher matcher = MethodMatcherUtility.createMethodMatcher("myclass", Arrays.asList(m1), new HashMap<String, MethodMapper>(), "EXT");
Assert.assertNotNull(matcher);
Assert.assertTrue(matcher + " not of type ExactParamsMethodMatcher", matcher instanceof ExactParamsMethodMatcher);
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "()V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertTrue(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "(I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m1", "([I)V", com.google.common.collect.ImmutableSet.<String>of()));
Assert.assertFalse(matcher.matches(MethodMatcher.UNSPECIFIED_ACCESS, "m2", "()V", com.google.common.collect.ImmutableSet.<String>of()));
}
Aggregations