Пример #1
0
  public void initRealmStuff() throws Exception {

    String dbFolder = "target/advjdbctest";
    if ((new File(dbFolder)).exists()) {
      deleteDir(new File(dbFolder));
    }

    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);
  }
  public void initRealmStuff() throws Exception {
    String dbFolder = "target/ReadOnlyTest";
    if ((new File(dbFolder)).exists()) {
      deleteDir(new File(dbFolder));
    }

    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER);
    ds.setUrl("jdbc:h2:target/ReadOnlyTest/CARBON_TEST");

    DatabaseCreator creator = new DatabaseCreator(ds);
    creator.createRegistryDatabase();

    this.addIntialData(ds);
    RealmConfigXMLProcessor builder = new RealmConfigXMLProcessor();
    InputStream inStream =
        this.getClass().getClassLoader().getResource("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"));
  }