List of usage examples for org.apache.commons.dbcp BasicDataSource setUrl
public synchronized void setUrl(String url)
Sets the #url .
Note: this method currently has no effect once the pool has been initialized.
From source file:org.wso2.carbon.identity.openidconnect.DefaultOIDCClaimsCallbackHandlerTest.java
private JWTClaimsSet getJwtClaimSet(JWTClaimsSet.Builder jwtClaimsSetBuilder, OAuthTokenReqMessageContext requestMsgCtx) { OAuthServerConfiguration mockOAuthServerConfiguration = PowerMockito.mock(OAuthServerConfiguration.class); DataSource dataSource = mock(DataSource.class); mockStatic(JDBCPersistenceManager.class); JDBCPersistenceManager jdbcPersistenceManager = mock(JDBCPersistenceManager.class); mockStatic(OAuthServerConfiguration.class); when(OAuthServerConfiguration.getInstance()).thenReturn(mockOAuthServerConfiguration); when(mockOAuthServerConfiguration.isConvertOriginalClaimsFromAssertionsToOIDCDialect()).thenReturn(true); JWTClaimsSet jwtClaimsSet = null;/*from w w w.j a v a 2 s.c o m*/ try { if (connection.isClosed()) { BasicDataSource dataSource1 = new BasicDataSource(); dataSource1.setDriverClassName("org.h2.Driver"); dataSource1.setUsername("username"); dataSource1.setPassword("password"); dataSource1.setUrl("jdbc:h2:mem:test" + DB_NAME); Connection connection1 = null; connection1 = dataSource1.getConnection(); Mockito.when(dataSource.getConnection()).thenReturn(connection1); } else { Mockito.when(dataSource.getConnection()).thenReturn(connection); } } catch (Exception e) { log.error("Error while obtaining the datasource. "); } Mockito.when(jdbcPersistenceManager.getInstance()).thenReturn(jdbcPersistenceManager); Mockito.when(jdbcPersistenceManager.getDataSource()).thenReturn(dataSource); jwtClaimsSet = defaultOIDCClaimsCallbackHandler.handleCustomClaims(jwtClaimsSetBuilder, requestMsgCtx); //return jwtClaimsSet; return jwtClaimsSet; }
From source file:org.wso2.carbon.identity.openidconnect.util.TestUtils.java
public static void initiateH2Base() throws SQLException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.h2.Driver"); dataSource.setUsername("username"); dataSource.setPassword("password"); dataSource.setUrl("jdbc:h2:mem:test" + DB_NAME); Connection connection = dataSource.getConnection(); connection.createStatement().executeUpdate("RUNSCRIPT FROM '" + getFilePath(H2_SCRIPT_NAME) + "'"); dataSourceMap.put(DB_NAME, dataSource); }
From source file:org.wso2.carbon.registry.core.jdbc.utils.RegistryDataSource.java
public RegistryDataSource(DataBaseConfiguration config) { BasicDataSource basicDataSource = new BasicDataSource(); basicDataSource.setUrl(config.getDbUrl()); basicDataSource.setDriverClassName(config.getDriverName()); basicDataSource.setUsername(config.getUserName()); basicDataSource.setPassword(config.getResolvedPassword()); if (config.getMaxActive() != null) { basicDataSource.setMaxActive(Integer.parseInt(config.getMaxActive())); } else {/* w ww. j a va 2 s .c o m*/ basicDataSource.setMaxActive(DEFAULT_MAX_ACTIVE); } if (config.getMaxWait() != null) { basicDataSource.setMaxWait(Integer.parseInt(config.getMaxWait())); } else { basicDataSource.setMaxWait(DEFAULT_MAX_WAIT); } if (config.getMaxIdle() != null) { basicDataSource.setMaxIdle(Integer.parseInt(config.getMaxIdle())); } if (config.getMinIdle() != null) { basicDataSource.setMinIdle(Integer.parseInt(config.getMinIdle())); } else { basicDataSource.setMinIdle(DEFAULT_MIN_IDLE); } this.dataSource = basicDataSource; }
From source file:org.wso2.carbon.registry.core.test.performance.BasicPerformanceTest.java
public void setUp() { //String connURL = "jdbc:log4jdbc:derby:target/REG1_DB"; //String connURL = "jdbc:derby:target/REG1_DB"; String connURL = "jdbc:mysql://localhost:3306/registry1"; BasicDataSource ds = new BasicDataSource(); //ds.setUrl(connURL + ";"); //ds.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver"); ds.setDriverClassName("com.mysql.jdbc.Driver"); ds.setUrl(connURL); ds.setUsername("root"); ds.setPassword("password"); // ds.setMaxWait(1000*60*2); ds.setMaxActive(150);/*w ww . j a v a 2 s . c om*/ ds.setMaxIdle(1000 * 60 * 2); ds.setMinIdle(5); //ds.setDriverClassName("net.sf.log4jdbc.DriverSpy"); //DerbyDatabaseCreator creator = new DerbyDatabaseCreator(ds); DatabaseCreator creator = new DatabaseCreator(ds); try { creator.createRegistryDatabase(); } catch (Exception e) { fail("Failed to create database. Caused by: " + e.getMessage()); } //String fileName = "target/db/registry"; //File file = new File(fileName); //if (! file.exists()) { //creator.createDefaultDatabaseTables(); //} // UserRealm realm = new DefaultRealm(); // DefaultRealmConfig config = (DefaultRealmConfig) realm.getBootstrapRealmConfiguration(); // config.setConnectionURL(connURL); // realm.init(config); // UserRealm registryRealm = new UserRealm(realm); // // InputStream configStream = // Thread.currentThread().getContextClassLoader().getResourceAsStream("registry.xml"); // RegistryContext regContext = new RegistryContext(configStream, registryRealm); // embeddedRegistryService = new EmbeddedRegistryService(regContext); // adminRegistry = embeddedRegistryService.getUserRegistry( // RegistryConstants.ADMIN_USER, RegistryConstants.ADMIN_PASSWORD); System.out.println("~~~~~setup method done~~~~~"); }
From source file:org.wso2.carbon.registry.migration.utils.DBUtils.java
public static void initializeDB() throws APIManagementException, ClassNotFoundException, IllegalAccessException, InstantiationException { String dbUrl = CommandHandler.getDBUrl(); String driver = CommandHandler.getDBDriver(); String username = CommandHandler.getDBUsername(); String password = CommandHandler.getDBPassword(); if (dbUrl == null || driver == null || username == null || password == null) { System.out.println("Required DB configuration parameters unspecified. So API Store and API Publisher " + "will not work as expected."); }//w ww. j av a 2 s . c o m BasicDataSource basicDataSource = new BasicDataSource(); basicDataSource.setDriverClassName(driver); basicDataSource.setUrl(dbUrl); basicDataSource.setUsername(username); basicDataSource.setPassword(password); dataSource = basicDataSource; }
From source file:org.wso2.carbon.registry.social.impl.test.people.userprofile.PersonManagerImplTest.java
public void initObjStuff() throws Exception { String dbFolder = "target/PersonManagerTest"; if ((new File(dbFolder)).exists()) { deleteDir(new File(dbFolder)); }//www. ja v a2 s. com BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(SocialImplTestConstants.DB_DRIVER); ds.setUrl(TEST_URL); DatabaseCreator creator = new DatabaseCreator(ds); creator.createRegistryDatabase(); realm = new DefaultRealm(); InputStream inStream = this.getClass().getClassLoader() .getResource(PersonManagerImplTest.JDBC_TEST_USERMGT_XML).openStream(); RealmConfiguration realmConfig = TestRealmConfigBuilder.buildRealmConfigWithJDBCConnectionUrl(inStream, TEST_URL); realm.init(realmConfig, ClaimTestUtil.getClaimTestData(), ClaimTestUtil.getProfileTestData(), 0); }
From source file:org.wso2.carbon.user.core.authman.AdvancedPermissionTreeTest.java
public void initRealmStuff() throws Exception { String dbFolder = "target/permTreetest"; if ((new File(dbFolder)).exists()) { deleteDir(new File(dbFolder)); }/*ww w . ja v a 2 s.c o m*/ BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER); ds.setUrl(TEST_URL); DatabaseCreator creator = new DatabaseCreator(ds); creator.createRegistryDatabase(); realm = new DefaultRealm(); InputStream inStream = this.getClass().getClassLoader().getResource(JDBCRealmTest.JDBC_TEST_USERMGT_XML) .openStream(); RealmConfiguration realmConfig = TestRealmConfigBuilder.buildRealmConfigWithJDBCConnectionUrl(inStream, TEST_URL); realm.init(realmConfig, ClaimTestUtil.getClaimTestData(), ClaimTestUtil.getProfileTestData(), 0); }
From source file:org.wso2.carbon.user.core.claim.ClaimDAOTest.java
public void setUp() throws Exception { super.setUp(); String dbFolder = "target/ClaimTestDatabase"; if ((new File(dbFolder)).exists()) { deleteDir(new File(dbFolder)); }//ww w . ja v a 2s .c o m BasicDataSource ds = new BasicDataSource(); // ds.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver"); // ds.setUrl("jdbc:derby:target/ClaimTestDatabase/CARBON_TEST;create=true"); ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER); ds.setUrl("jdbc:h2:target/ClaimTestDatabase/CARBON_TEST"); DatabaseCreator creator = new DatabaseCreator(ds); creator.createRegistryDatabase(); claims = ClaimTestUtil.getClaimTestData(); //profConfigs = ClaimTestUtil.getProfileTestData(); claimDAO = new ClaimDAO(ds, 0); //profileDAO = new ProfileConfigDAO(ds, 0); }
From source file:org.wso2.carbon.user.core.hybrid.AdvancedHybridRoleManagerTest.java
public void initRealmStuff() throws Exception { String dbFolder = "target/hybridroletest"; if ((new File(dbFolder)).exists()) { deleteDir(new File(dbFolder)); }// w w w . j ava 2 s . co m BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER); ds.setUrl("jdbc:h2:target/hybridroletest/UM_ADV_TEST"); DatabaseCreator creator = new DatabaseCreator(ds); creator.createRegistryDatabase(); // hybridRoleMan = new HybridRoleManager(ds, 0); }
From source file:org.wso2.carbon.user.core.hybrid.HybridRoleManagerTest.java
public void initRealmStuff() throws Exception { String dbFolder = "target/hybridroletest"; if ((new File(dbFolder)).exists()) { deleteDir(new File(dbFolder)); }//w ww . j a v a 2 s . c o m BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER); ds.setUrl("jdbc:h2:target/HybridRoleTest/CARBON_TEST"); DatabaseCreator creator = new DatabaseCreator(ds); creator.createRegistryDatabase(); // taking the tenant id = 0 // hybridRoleMan = new HybridRoleManager(ds, 0); }