コード例 #1
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());
  }
コード例 #2
0
  @Test
  public void testGetRequests() throws Exception {
    JavaArchive jar = getLoopyArchive();

    try {
      admin.deploy("loopy.jar", jar.as(ZipExporter.class).exportAsInputStream());
      deployVdb();
      Translator t = admin.getTranslator("loopy");
      assertNotNull(t);

      admin.updateSource("bqt", 1, "Source", "loopy", "java:jboss/datasources/ExampleDS");
      Connection conn =
          TeiidDriver.getInstance()
              .connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user", null);
      Collection<? extends Session> sessions = admin.getSessions();
      assertEquals(1, sessions.size());
      Session s = sessions.iterator().next();

      Statement stmt = conn.createStatement();

      Collection<? extends Request> requests = admin.getRequests();

      assertEquals(0, requests.size());

      stmt.execute("select * from source.smalla");

      requests = admin.getRequests();
      assertEquals(1, requests.size());

      Request r = requests.iterator().next();
      assertEquals("select * from source.smalla", r.getCommand());
      assertNotNull(r.getExecutionId());
      assertNotNull(r.getSessionId());

      stmt.execute("select * from source.smalla");
      Collection<? extends Request> requests2 = admin.getRequestsForSession(s.getSessionId());
      assertEquals(1, requests2.size());

      Request r2 = requests.iterator().next();
      assertEquals("select * from source.smalla", r2.getCommand());
      assertEquals(s.getSessionId(), r2.getSessionId());

      stmt.close();
      conn.close();

      requests = admin.getRequests();
      assertEquals(0, requests.size());

    } finally {
      admin.undeploy("loopy.jar");
    }
  }