@After public void cleanup() { for (Resource resource : jndiResources) { try { resource.release(); } catch (Exception e) { } } }
public static Name makeNamingEntryName (NameParser parser, NamingEntry namingEntry) throws NamingException { return makeNamingEntryName(parser, (namingEntry==null?null:namingEntry.getJndiName())); }
public Link (String jndiName, String link) throws NamingException { super(jndiName); save(link); _link=link; }
public Resource (String jndiName, Object objToBind) throws NamingException { super(jndiName); save(objToBind); } }
public Transaction (UserTransaction userTransaction) throws NamingException { super (USER_TRANSACTION); save(userTransaction); }
public EnvEntry (String jndiName, Object objToBind, boolean overrideWebXml) throws NamingException { super(jndiName); save(objToBind); this.overrideWebXml = overrideWebXml; }
@Before public void setUp() throws Exception { // make sure to reinit properly new P6TestFramework("ds") { }; jndiResources = new ArrayList<Resource>(); // create the real data sources and bind to jndi JdbcDataSource realDs1 = new JdbcDataSource(); realDs1.setUser("sa"); realDs1.setURL("jdbc:h2:mem:multids1"); jndiResources.add(new Resource("jdbc/realDs1", realDs1)); JdbcDataSource realDs2 = new JdbcDataSource(); realDs2.setUser("sa"); realDs2.setURL("jdbc:h2:mem:multids2"); jndiResources.add(new Resource("jdbc/realDs2", realDs2)); JDBCDataSource realDs3 = new JDBCDataSource(); realDs3.setUser("sa"); realDs3.setPassword(""); realDs3.setUrl("jdbc:hsqldb:mem:multids3"); jndiResources.add(new Resource("jdbc/realDs3", realDs3)); // create the spy wrapper data sources and bind to jndi P6DataSource spyDs1 = new P6DataSource(); spyDs1.setRealDataSource("jdbc/realDs1"); jndiResources.add(new Resource("jdbc/spyDs1", spyDs1)); P6DataSource spyDs3 = new P6DataSource(); spyDs3.setRealDataSource("jdbc/realDs3"); jndiResources.add(new Resource("jdbc/spyDs3", spyDs3)); // reset captured log messages ((P6TestLogger) P6LogQuery.getLogger()).clearLogs(); }
public static Name makeNamingEntryName (NameParser parser, NamingEntry namingEntry) throws NamingException { return makeNamingEntryName(parser, (namingEntry==null?null:namingEntry.getJndiName())); }
public Resource (Object scope, String jndiName, Object objToBind) throws NamingException { super(scope, jndiName); save(objToBind); }
public Link(Object scope, String jndiName, String link) throws NamingException { //jndiName is the name according to the web.xml //objectToBind is the name in the environment super(scope, jndiName); save(link); _link=link; }
@Before public void setup() throws Exception { // make sure to reinit properly new P6TestFramework("ds") { }; user = "sa"; password ="sa"; // please note non-typical DB name // however it seems that the typical one "jdbc:h2:mem:p6spy" // caused authorization exception, see: https://github.com/p6spy/p6spy/issues/76 // in some test execution sequences (on some setups only) // I suspect non-proper cleanup in some of the previous tests causing this error // url = "jdbc:h2:mem:p6spy"; url = "jdbc:h2:mem:p6spyDSTest"; driverClass = "org.h2.Driver"; P6DataSource spyDs = new P6DataSource(); spyDs.setRealDataSource("jdbc/realDs"); spyDsResource = new Resource("jdbc/spyDs", spyDs); ((P6TestLogger) P6LogQuery.getLogger()).clearLogs(); }
public static Name makeNamingEntryName (NameParser parser, NamingEntry namingEntry) throws NamingException { return makeNamingEntryName(parser, (namingEntry==null?null:namingEntry.getJndiName())); }
/** * @param jndiName * @param objToBind */ public Resource (String jndiName, Object objToBind) throws NamingException { super(jndiName); save(objToBind); }
@Test public void testGenericDataSourceWithOutDriverManager() throws Exception { // Create and bind the real data source // Note: This will get the driver from the DriverManager realDs = new TestBasicDataSource(); realDs.setDriverClassName(driverClass); realDs.setUrl(url); realDs.setUsername(user); realDs.setPassword(password); realDs.setUseDriverManager(false); realDsResource = new Resource("jdbc/realDs", realDs); P6TestUtil.setupTestData(realDs); // get the data source from JNDI DataSource ds = new JndiDataSourceLookup().getDataSource("jdbc/spyDs"); assertNotNull("JNDI data source not found", ds); // get the connection con = ds.getConnection(); // verify that the connection class is a proxy assertTrue("Connection is not a proxy", AbstractWrapper.isProxy(con)); }
@After public void tearDownXADataSourceTest() { ((BitronixTransactionManager) tm).shutdown(); for (PoolingDataSource psd : poolingDSs) { try { psd.close(); } catch (Exception e) { e.printStackTrace(); } } poolingDSs = null; for (Resource resource : jndiResources) { try { resource.release(); } catch (Exception e) { e.printStackTrace(); } } jndiResources = null; }
public static Name makeNamingEntryName (NameParser parser, NamingEntry namingEntry) throws NamingException { return makeNamingEntryName(parser, (namingEntry==null?null:namingEntry.getJndiName())); }
@Test public void testGenericDataSourceWithDriverManager() throws Exception { // Create and bind the real data source // Note: This will get the driver from the DriverManager realDs = new TestBasicDataSource(); realDs.setDriverClassName(driverClass); realDs.setUrl(url); realDs.setUsername(user); realDs.setPassword(password); realDs.setUseDriverManager(true); realDsResource = new Resource("jdbc/realDs", realDs); P6TestUtil.setupTestData(realDs); // get the data source from JNDI DataSource ds = new JndiDataSourceLookup().getDataSource("jdbc/spyDs"); assertNotNull("JNDI data source not found", ds); // get the connection con = ds.getConnection(); // verify that the connection class is a proxy assertTrue("Connection is not a proxy", AbstractWrapper.isProxy(con)); Statement stmt = con.createStatement(); stmt.execute("select 1 from customers"); stmt.close(); assertTrue(((P6TestLogger) P6LogQuery.getLogger()).getLastEntry().indexOf("select 1") != -1); assertEquals("Incorrect number of spy log messages", 1, ((P6TestLogger) P6LogQuery.getLogger()).getLogs().size()); }
public static Name makeNamingEntryName (NameParser parser, NamingEntry namingEntry) throws NamingException { return makeNamingEntryName(parser, (namingEntry==null?null:namingEntry.getJndiName())); }
setXADSProperties(realInTestDs, testOptions.getUrl().replace("p6spy:", ""), testOptions.getUser(), testOptions.getPassword()); jndiResources.add(new Resource("jdbc/realInTestDs", realInTestDs)); inTestDs.setAllowLocalTransactions(true); inTestDs.init(); jndiResources.add(new Resource("jdbc/inTestDs", inTestDs)); poolingDSs.add(inTestDs); .newInstance(); setXADSProperties(realFixedDs, "jdbc:h2:mem:p6spy_realFixedDs", "sa", "sa"); jndiResources.add(new Resource("jdbc/realFixedDs", realFixedDs)); fixedDs.setAllowLocalTransactions(true); fixedDs.init(); jndiResources.add(new Resource("jdbc/fixedDs", fixedDs)); poolingDSs.add(fixedDs);