List of usage examples for org.apache.commons.dbcp BasicDataSource setDriverClassName
public synchronized void setDriverClassName(String driverClassName)
Sets the jdbc driver class name.
Note: this method currently has no effect once the pool has been initialized.
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."); }/*from ww w .java 2 s .c om*/ 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)); }// ww w .j a va 2 s. c o m 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)); }/*from w w w. j a va 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)); }/*from w w w . j av a2 s.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 ww . java 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 .ja v a 2s.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); }
From source file:org.wso2.carbon.user.core.jdbc.AdvancedJDBCRealmTest.java
public void initRealmStuff() throws Exception { String dbFolder = "target/advjdbctest"; if ((new File(dbFolder)).exists()) { deleteDir(new File(dbFolder)); }/*from w w 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(), MultitenantConstants.SUPER_TENANT_ID); }
From source file:org.wso2.carbon.user.core.jdbc.AdvancedReadOnlyJDBCRealmTest.java
public void initRealmStuff() throws Exception { String dbFolder = "target/advjdbcrotest"; if ((new File(dbFolder)).exists()) { deleteDir(new File(dbFolder)); }/* w ww.j a v a2 s . c o m*/ BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER); ds.setUrl("jdbc:h2:target/advjdbcrotest/CARBON_TEST"); DatabaseCreator creator = new DatabaseCreator(ds); creator.createRegistryDatabase(); this.addIntialData(ds); RealmConfigXMLProcessor builder = new RealmConfigXMLProcessor(); InputStream inStream = this.getClass().getClassLoader().getResource("adv-jdbc-readonly-test.xml") .openStream(); RealmConfiguration realmConfig = builder.buildRealmConfiguration(inStream); inStream.close(); realm = new DefaultRealm(); realm.init(realmConfig, ClaimTestUtil.getClaimTestData(), ClaimTestUtil.getProfileTestData(), 0); assertTrue(realm.getUserStoreManager().isExistingRole("adminx")); }
From source file:org.wso2.carbon.user.core.jdbc.JDBCRealmTest.java
public void initRealmStuff(String dbUrl) throws Exception { String dbFolder = "target/BasicJDBCDatabaseTest"; if ((new File(dbFolder)).exists()) { deleteDir(new File(dbFolder)); }//from w ww . ja va 2 s .c o m BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER); ds.setUrl(dbUrl); 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(), MultitenantConstants.SUPER_TENANT_ID); ds.close(); }
From source file:org.wso2.carbon.user.core.jdbc.JDBCRealmTest.java
public void testAuthorizationClearence() throws Exception { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER); ds.setUrl("jdbc:h2:target/clear-resources/WSO2CARBON_DB_CLEAR"); ds.setUsername("wso2carbon"); ds.setPassword("wso2carbon"); realm = new DefaultRealm(); Map<String, Object> properties = new HashMap<String, Object>(); properties.put(UserCoreConstants.DATA_SOURCE, ds); RealmConfigXMLProcessor xmlProcessor = new RealmConfigXMLProcessor(); InputStream stream = new FileInputStream("target/clear-resources/user-mgt-clear.xml"); RealmConfiguration configuration = xmlProcessor.buildRealmConfiguration(stream); JDBCAuthorizationManager jdbcAuthnManager = new JDBCAuthorizationManager(configuration, properties, null, null, realm, 0);/*from ww w . j av a2 s . com*/ String[] roles = jdbcAuthnManager.getAllowedRolesForResource("/permission/admin", "ui.execute"); assertEquals(roles.length, 1); jdbcAuthnManager.clearPermissionTree(); //the tree should automatically be loaded on next call roles = jdbcAuthnManager.getAllowedRolesForResource("/permission/admin", "ui.execute"); assertEquals(roles.length, 1); }