use of org.apache.tomcat.jdbc.pool.TrapException in project tomcat by apache.
the class TestJdbcInterceptorConfigParsing method testWhitespace.
@Test
public void testWhitespace() throws Exception {
String interceptorConfig = "FirstInterceptor ; \n" + "SecondInterceptor (parm1 = value1 , parm2= value2 ) ; \n\n" + "\t org.cyb.ThirdInterceptor(parm1=value1); \n" + "EmptyParmValInterceptor(parm1= )";
PoolProperties props = new PoolProperties();
props.setJdbcInterceptors(interceptorConfig);
InterceptorDefinition[] interceptorDefs = props.getJdbcInterceptorsAsArray();
assertNotNull(interceptorDefs);
// 5 items because parser automatically inserts TrapException interceptor to front of list
assertEquals(interceptorDefs.length, 5);
assertEquals(interceptorDefs[0].getClassName(), TrapException.class.getName());
assertNotNull(interceptorDefs[1]);
assertEquals(interceptorDefs[1].getClassName(), "FirstInterceptor");
assertNotNull(interceptorDefs[2]);
assertEquals(interceptorDefs[2].getClassName(), "SecondInterceptor");
assertNotNull(interceptorDefs[3]);
assertEquals(interceptorDefs[3].getClassName(), "org.cyb.ThirdInterceptor");
Map<String, InterceptorProperty> secondProps = interceptorDefs[2].getProperties();
assertNotNull(secondProps);
assertEquals(secondProps.size(), 2);
assertNotNull(secondProps.get("parm1"));
assertEquals(secondProps.get("parm1").getValue(), "value1");
assertNotNull(secondProps.get("parm2"));
// Bug 54395
assertEquals(secondProps.get("parm2").getValue(), "value2");
Map<String, InterceptorProperty> thirdProps = interceptorDefs[3].getProperties();
assertNotNull(thirdProps);
assertEquals(thirdProps.size(), 1);
assertNotNull(thirdProps.get("parm1"));
assertEquals(thirdProps.get("parm1").getValue(), "value1");
Map<String, InterceptorProperty> emptyParmValProps = interceptorDefs[4].getProperties();
assertNotNull(emptyParmValProps);
assertEquals(emptyParmValProps.size(), 1);
assertNotNull(emptyParmValProps.get("parm1"));
assertEquals(emptyParmValProps.get("parm1").getValue(), "");
}
use of org.apache.tomcat.jdbc.pool.TrapException in project tomcat by apache.
the class TestJdbcInterceptorConfigParsing method testBasic.
@Test
public void testBasic() throws Exception {
String interceptorConfig = "FirstInterceptor;SecondInterceptor(parm1=value1,parm2=value2)";
PoolProperties props = new PoolProperties();
props.setJdbcInterceptors(interceptorConfig);
InterceptorDefinition[] interceptorDefs = props.getJdbcInterceptorsAsArray();
assertNotNull(interceptorDefs);
// 3 items because parser automatically inserts TrapException interceptor to front of list
assertEquals(interceptorDefs.length, 3);
assertEquals(interceptorDefs[0].getClassName(), TrapException.class.getName());
assertNotNull(interceptorDefs[1]);
assertEquals(interceptorDefs[1].getClassName(), "FirstInterceptor");
assertNotNull(interceptorDefs[2]);
assertEquals(interceptorDefs[2].getClassName(), "SecondInterceptor");
Map<String, InterceptorProperty> secondProps = interceptorDefs[2].getProperties();
assertNotNull(secondProps);
assertEquals(secondProps.size(), 2);
assertNotNull(secondProps.get("parm1"));
assertEquals(secondProps.get("parm1").getValue(), "value1");
assertNotNull(secondProps.get("parm2"));
assertEquals(secondProps.get("parm2").getValue(), "value2");
}
Aggregations