Search in sources :

Example 1 with DummyTransactionManager

use of org.infinispan.transaction.tm.DummyTransactionManager in project teiid by teiid.

the class TestExternalMatViews method createServer.

private FakeServer createServer(String nodeName, String ispn, String jgroups) throws Exception {
    FakeServer server = new FakeServer(false);
    EmbeddedConfiguration config = new EmbeddedConfiguration();
    config.setInfinispanConfigFile(ispn);
    config.setJgroupsConfigFile(jgroups);
    config.setNodeName(nodeName);
    config.setTransactionManager(new DummyTransactionManager());
    server.start(config, true);
    return server;
}
Also used : DummyTransactionManager(org.infinispan.transaction.tm.DummyTransactionManager) FakeServer(org.teiid.jdbc.FakeServer) EmbeddedConfiguration(org.teiid.runtime.EmbeddedConfiguration)

Example 2 with DummyTransactionManager

use of org.infinispan.transaction.tm.DummyTransactionManager in project teiid by teiid.

the class TestReplication method createServer.

private FakeServer createServer(String ispn, String jgroups) throws Exception {
    FakeServer server = new FakeServer(false);
    EmbeddedConfiguration config = new EmbeddedConfiguration();
    config.setInfinispanConfigFile(ispn);
    config.setJgroupsConfigFile(jgroups);
    config.setTransactionManager(new DummyTransactionManager());
    server.start(config, true);
    return server;
}
Also used : DummyTransactionManager(org.infinispan.transaction.tm.DummyTransactionManager) FakeServer(org.teiid.jdbc.FakeServer) EmbeddedConfiguration(org.teiid.runtime.EmbeddedConfiguration)

Example 3 with DummyTransactionManager

use of org.infinispan.transaction.tm.DummyTransactionManager in project teiid by teiid.

the class TestEmbeddedServer method testTransactionWithCatchBlocks.

@Test
public void testTransactionWithCatchBlocks() throws Exception {
    String ddl = "create procedure px1() returns (a string) as\n" + "          begin atomic\n" + "            begin\n" + "              error 'aaaa';\n" + "            end\n" + "            exception e\n" + "            select 'bbbbb';\n" + "          end;\n" + "          create procedure px2() returns (a string) as\n" + "          begin atomic\n" + "            select 'bbbbb';\n" + "          end;" + "    create foreign table batch_test (a varchar) options (updatable true);";
    String sql = "begin \n" + "  loop on (select s.a as a from (call procs.px1()) as s) as x \n" + "  begin \n" + "    insert into batch_test (a) values (x.a); \n" + "  end \n" + "end;";
    EmbeddedConfiguration ec = new EmbeddedConfiguration();
    DummyTransactionManager tm = new DummyTransactionManager();
    ec.setTransactionManager(tm);
    ec.setUseDisk(false);
    es.start(ec);
    HardCodedExecutionFactory ef = new HardCodedExecutionFactory();
    ef.addUpdate("INSERT INTO batch_test (a) VALUES ('bbbbb')", new int[] { 1 });
    es.addTranslator("t", ef);
    ModelMetaData mmd1 = new ModelMetaData();
    mmd1.setName("procs");
    mmd1.addSourceMetadata("ddl", ddl);
    mmd1.addSourceMapping("t", "t", null);
    es.deployVDB("vdb", mmd1);
    Connection c = es.getDriver().connect("jdbc:teiid:vdb", null);
    Statement s = c.createStatement();
    s.execute(sql);
    s.execute("set autoCommitTxn on");
    try {
        s.execute(sql);
        fail();
    } catch (SQLException e) {
    }
    assertNotNull(s.getWarnings());
}
Also used : DummyTransactionManager(org.infinispan.transaction.tm.DummyTransactionManager) TeiidSQLException(org.teiid.jdbc.TeiidSQLException) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 4 with DummyTransactionManager

use of org.infinispan.transaction.tm.DummyTransactionManager in project teiid by teiid.

the class TestInternalConnection method testInternalLocalNestedTransactions.

@Test
public void testInternalLocalNestedTransactions() throws Exception {
    useTxn = true;
    EmbeddedConfiguration config = new EmbeddedConfiguration();
    config.setSecurityHelper(new ThreadLocalSecurityHelper());
    config.setTransactionManager(new DummyTransactionManager());
    es.start(config);
    es.deployVDB(new ByteArrayInputStream(vdb.getBytes()));
    Connection conn = null;
    TeiidDriver driver = es.getDriver();
    conn = driver.connect("jdbc:teiid:test;autoCommitTxn=on", null);
    try {
        PreparedStatement ps = conn.prepareStatement("select func(?)");
        ps.setInt(1, 1);
        ps.execute();
    } finally {
        if (conn != null) {
            conn.close();
        }
    }
    conn = driver.connect("jdbc:teiid:test;autoCommitTxn=on", null);
    try {
        conn.setAutoCommit(false);
        PreparedStatement ps = conn.prepareStatement("select func(?)");
        ps.setInt(1, 1);
        ps.execute();
        conn.commit();
    } finally {
        if (conn != null) {
            conn.close();
        }
    }
}
Also used : DummyTransactionManager(org.infinispan.transaction.tm.DummyTransactionManager) ByteArrayInputStream(java.io.ByteArrayInputStream) Connection(java.sql.Connection) EmbeddedConfiguration(org.teiid.runtime.EmbeddedConfiguration) PreparedStatement(java.sql.PreparedStatement) Test(org.junit.Test)

Aggregations

DummyTransactionManager (org.infinispan.transaction.tm.DummyTransactionManager)4 EmbeddedConfiguration (org.teiid.runtime.EmbeddedConfiguration)3 Test (org.junit.Test)2 FakeServer (org.teiid.jdbc.FakeServer)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)1 TeiidSQLException (org.teiid.jdbc.TeiidSQLException)1