Search in sources :

Example 1 with XmlException

use of com.newrelic.agent.extension.util.XmlException in project newrelic-java-agent by newrelic.

the class ExtensionDomParserTest method testPrimitiveReturnType.

@Test
public void testPrimitiveReturnType() throws Exception {
    Extension ext = ExtensionDomParser.readFile(getFile(PRIMITIVE_RETURN_TYPE_FILE_PATH));
    Instrumentation inst = ext.getInstrumentation();
    List<Pointcut> thePcs = inst.getPointcut();
    Assert.assertEquals(1, thePcs.size());
    Pointcut pc = thePcs.get(0);
    Assert.assertNull(pc.getClassName());
    Assert.assertEquals("com.company.SomeInterface", pc.getInterfaceName());
    Assert.assertEquals(1, pc.getMethod().size());
    Assert.assertEquals("boolean", pc.getMethod().iterator().next().getReturnType());
    try {
        ExtensionConversionUtility.convertToPointCutsForValidation(ext);
        Assert.fail();
    } catch (XmlException ex) {
        Assert.assertEquals("The return type 'boolean' is not valid.  Primitive types are not allowed.", ex.getMessage());
    }
}
Also used : Extension(com.newrelic.agent.extension.beans.Extension) Pointcut(com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut) XmlException(com.newrelic.agent.extension.util.XmlException) Instrumentation(com.newrelic.agent.extension.beans.Extension.Instrumentation) Test(org.junit.Test)

Aggregations

Extension (com.newrelic.agent.extension.beans.Extension)1 Instrumentation (com.newrelic.agent.extension.beans.Extension.Instrumentation)1 Pointcut (com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut)1 XmlException (com.newrelic.agent.extension.util.XmlException)1 Test (org.junit.Test)1