コード例 #1
0
  private boolean deployVdb() throws AdminException, FileNotFoundException {
    boolean vdbOneDeployed;
    admin.deploy("bqt.vdb", new FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
    AdminUtil.waitForVDBLoad(admin, "bqt", 1, 3);
    vdbOneDeployed = true;

    VDB vdb = admin.getVDB("bqt", 1);
    Model model = vdb.getModels().get(0);
    admin.assignToModel(
        "bqt", 1, model.getName(), "Source", "h2", "java:jboss/datasources/ExampleDS");
    return vdbOneDeployed;
  }
コード例 #2
0
  @Test
  public void testVDBConnectionType() throws Exception {
    admin.deploy("bqt.vdb", new FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));

    VDB vdb = admin.getVDB("bqt", 1);
    Model model = vdb.getModels().get(0);
    admin.updateSource("bqt", 1, "Source", "h2", "java:jboss/datasources/ExampleDS");

    try {
      // should not be able to remove from non-multisource
      admin.removeSource("bqt", 1, model.getName(), "Source");
      fail();
    } catch (AdminException e) {

    }

    assertEquals(ConnectionType.BY_VERSION, vdb.getConnectionType());

    Connection conn =
        TeiidDriver.getInstance()
            .connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user", null);
    conn.close();

    admin.changeVDBConnectionType("bqt", 1, ConnectionType.NONE);

    try {
      TeiidDriver.getInstance()
          .connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user", null);
      fail("should have failed to connect as no new connections allowed");
    } catch (Exception e) {
      // pass
    }

    admin.deploy("bqt2.vdb", new FileInputStream(UnitTestUtil.getTestDataFile("bqt2.vdb")));
    admin.updateSource("bqt", 2, "Source", "h2", "java:jboss/datasources/ExampleDS");

    conn =
        TeiidDriver.getInstance()
            .connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user", null);
    conn.close();

    admin.changeVDBConnectionType("bqt", 2, ConnectionType.ANY);
    conn =
        TeiidDriver.getInstance()
            .connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user", null);
    conn.close();

    vdb = admin.getVDB("bqt", 2);
    model = vdb.getModels().get(0);
    assertEquals(model.getSourceConnectionJndiName("Source"), "java:jboss/datasources/ExampleDS");
    assertEquals(model.getSourceTranslatorName("Source"), "h2");
    assertEquals(ConnectionType.ANY, vdb.getConnectionType());
  }
コード例 #3
0
  @Test
  public void testDataRoleMapping() throws Exception {
    admin.deploy("bqt2.vdb", new FileInputStream(UnitTestUtil.getTestDataFile("bqt2.vdb")));

    VDB vdb = admin.getVDB("bqt", 2);
    Model model = vdb.getModels().get(0);
    admin.assignToModel(
        "bqt", 2, model.getName(), "Source", "h2", "java:jboss/datasources/ExampleDS");

    vdb = admin.getVDB("bqt", 2);
    assertTrue(vdb.isValid());
    List<DataPolicy> policies = vdb.getDataPolicies();
    assertEquals(1, policies.size());

    DataPolicy dp = policies.get(0);
    assertEquals("roleOne", dp.getName());
    assertEquals(2, dp.getPermissions().size());
    assertTrue(dp.isAllowCreateTemporaryTables());
    assertTrue(dp.isAnyAuthenticated());

    List<String> roleNames = dp.getMappedRoleNames();
    assertArrayEquals(new String[] {"ROLE1", "ROLE2"}, roleNames.toArray());

    admin.removeDataRoleMapping("bqt", 2, "roleOne", "ROLE1");

    vdb = admin.getVDB("bqt", 2);
    policies = vdb.getDataPolicies();
    dp = policies.get(0);

    roleNames = dp.getMappedRoleNames();
    assertArrayEquals(new String[] {"ROLE2"}, roleNames.toArray());

    admin.addDataRoleMapping("bqt", 2, "roleOne", "ROLE3");

    vdb = admin.getVDB("bqt", 2);
    policies = vdb.getDataPolicies();
    dp = policies.get(0);

    roleNames = dp.getMappedRoleNames();
    assertArrayEquals(new String[] {"ROLE2", "ROLE3"}, roleNames.toArray());

    admin.setAnyAuthenticatedForDataRole("bqt", 2, "roleOne", false);

    vdb = admin.getVDB("bqt", 2);
    policies = vdb.getDataPolicies();
    dp = policies.get(0);

    assertFalse(dp.isAnyAuthenticated());
  }