Author: rareddy
Date: 2009-08-25 15:38:18 -0400 (Tue, 25 Aug 2009)
New Revision: 1277
Added:
trunk/test-integration/src/test/java/org/teiid/runtime/
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/MyFunctions.java
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestDqpReDeployment.java
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/Util.java
trunk/test-integration/src/test/resources/admin/
trunk/test-integration/src/test/resources/admin/Admin.vdb
trunk/test-integration/src/test/resources/admin/BQT1Binding.cdk
trunk/test-integration/src/test/resources/admin/Empty.vdb
trunk/test-integration/src/test/resources/admin/QT_Ora9DSwDEF.vdb
trunk/test-integration/src/test/resources/admin/TestEmpty.vdb
trunk/test-integration/src/test/resources/admin/TestORS.vdb
trunk/test-integration/src/test/resources/admin/TestORS1.vdb
trunk/test-integration/src/test/resources/admin/TestORSInvalid.vdb
trunk/test-integration/src/test/resources/admin/dqp.properties
trunk/test-integration/src/test/resources/admin/extensions/
trunk/test-integration/src/test/resources/admin/extensions/FunctionDefinitions.xmi
trunk/test-integration/src/test/resources/admin/log/
trunk/test-integration/src/test/resources/admin/loopback.cdk
trunk/test-integration/src/test/resources/admin/loopback_archive.caf
trunk/test-integration/src/test/resources/admin/loopbackconn.jar
Modified:
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java
trunk/pom.xml
trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java
Log:
TEIID-779: Moved the Admin API specific tests into test integration.
Modified:
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java
===================================================================
---
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java 2009-08-24
22:41:19 UTC (rev 1276)
+++
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java 2009-08-25
19:38:18 UTC (rev 1277)
@@ -39,12 +39,12 @@
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.Stack;
import org.junit.After;
import org.teiid.adminapi.Admin;
import org.teiid.jdbc.TeiidDriver;
-import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.script.io.MetadataReader;
import com.metamatrix.script.io.ResultSetReader;
import com.metamatrix.script.io.StringArrayReader;
@@ -66,16 +66,12 @@
protected Statement internalStatement = null;
protected int updateCount = -1;
protected String DELIMITER = " "; //$NON-NLS-1$
+ private Stack<com.metamatrix.jdbc.api.Connection> contexts = new
Stack<Connection>();
@After public void tearDown() throws Exception {
closeConnection();
}
- public com.metamatrix.jdbc.api.Connection getConnection(String vdb){
- String propsFile =
UnitTestUtil.getTestDataPath()+"/mmquery/mm.properties"; //$NON-NLS-1$
- return getConnection(vdb, propsFile);
- }
-
public Admin getAdmin() {
try {
assertNotNull(this.internalConnection);
@@ -85,6 +81,18 @@
}
}
+ public void pushConnection() {
+ this.contexts.push(this.internalConnection);
+ this.internalConnection = null;
+ }
+
+ public void popConnection() {
+ this.internalConnection = this.contexts.pop();
+ }
+
+ public void setConnection(com.metamatrix.jdbc.api.Connection c) {
+ this.internalConnection = c;
+ }
public com.metamatrix.jdbc.api.Connection getConnection(String vdb, String
propsFile){
return getConnection(vdb, propsFile, ""); //$NON-NLS-1$
}
@@ -392,20 +400,22 @@
if (this.internalStatement != null){
try {
this.internalStatement.close();
- this.internalStatement = null;
} catch(SQLException e) {
throw new RuntimeException(e);
- }
+ } finally {
+ this.internalStatement = null;
+ }
}
}
public void closeResultSet() {
if (this.internalResultSet != null) {
try {
- this.internalResultSet.close();
- this.internalResultSet = null;
+ this.internalResultSet.close();
} catch(SQLException e) {
// ignore
+ } finally {
+ this.internalResultSet = null;
}
}
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-08-24 22:41:19 UTC (rev 1276)
+++ trunk/pom.xml 2009-08-25 19:38:18 UTC (rev 1277)
@@ -149,10 +149,6 @@
<name>java.io.tmpdir</name>
<value>${basedir}/target</value>
</property>
- <property>
- <name>teiid.home</name>
- <value>${basedir}/target</value>
- </property>
</systemProperties>
</configuration>
</plugin>
Modified: trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2009-08-24
22:41:19 UTC (rev 1276)
+++ trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2009-08-25
19:38:18 UTC (rev 1277)
@@ -98,22 +98,25 @@
public Object invoke(Object arg0, Method arg1, Object[] arg2) throws Throwable {
if (!isOpen()) {
throw ExceptionUtil.convertException(arg1, new
MetaMatrixComponentException(JDBCPlugin.Util.getString("LocalTransportHandler.session_inactive")));
//$NON-NLS-1$
- }
+ }
+ Throwable exception = null;
ClassLoader current = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(classLoader);
- DQPWorkContext.setWorkContext(workContext);
-
- if (!(iface.equals(ILogon.class))) {
- sessionService.validateSession(workContext.getSessionId());
- }
-
try {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ DQPWorkContext.setWorkContext(workContext);
+
+ if (!(iface.equals(ILogon.class))) {
+ sessionService.validateSession(workContext.getSessionId());
+ }
return arg1.invoke(clientServices.getClientService(iface), arg2);
} catch (InvocationTargetException e) {
- throw e.getTargetException();
+ exception = e.getTargetException();
+ } catch(Throwable t){
+ exception = t;
} finally {
Thread.currentThread().setContextClassLoader(current);
}
+ throw ExceptionUtil.convertException(arg1, exception);
}
});
}
Modified:
trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java
===================================================================
---
trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java 2009-08-24
22:41:19 UTC (rev 1276)
+++
trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java 2009-08-25
19:38:18 UTC (rev 1277)
@@ -22,30 +22,1162 @@
package com.metamatrix.server.integration;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
import java.sql.Connection;
+import java.sql.SQLException;
import java.util.Collection;
+import java.util.Properties;
+import org.junit.Before;
import org.junit.Test;
import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+import org.teiid.adminapi.AdminOptions;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.ConnectorType;
+import org.teiid.adminapi.EmbeddedLogger;
+import org.teiid.adminapi.ExtensionModule;
+import org.teiid.adminapi.LogConfiguration;
import org.teiid.adminapi.ProcessObject;
+import org.teiid.adminapi.VDB;
+import org.teiid.runtime.adminapi.Util;
-import static org.junit.Assert.*;
-
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.FileUtils;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.jdbc.MMConnection;
import com.metamatrix.jdbc.api.AbstractMMQueryTestCase;
public class TestAdminApi extends AbstractMMQueryTestCase {
- private static final String DQP_PROP_FILE = UnitTestUtil.getTestDataPath() +
"/authcheck/bqt.properties;"; //$NON-NLS-1$
- private static final String VDB = "bqt"; //$NON-NLS-1$
-
+ private static final String STAR = "*"; //$NON-NLS-1$
+ private static final String PROPS_FILE =
UnitTestUtil.getTestDataPath()+"/admin/dqp.properties;user=admin;password=teiid";
//$NON-NLS-1$
+ private static final String BQT = "BQT"; //$NON-NLS-1$
+ private static final String ADMIN = "admin"; //$NON-NLS-1$
+ private static final String VDB_NAME = "TestEmpty"; //$NON-NLS-1$
+ private static final String VDB_FILE =
UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"; //$NON-NLS-1$
+
+
+ @Before
+ public void setUp() throws Exception {
+ FileUtils.copy(UnitTestUtil.getTestDataPath()+"/admin/Admin.vdb",
UnitTestUtil.getTestScratchPath()+"/Admin.vdb"); //$NON-NLS-1$ //$NON-NLS-2$
+ FileUtils.copy(UnitTestUtil.getTestDataPath()+"/ServerConfig.xml",
UnitTestUtil.getTestScratchPath()+"/configuration.xml"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ private void cleanDeploy() throws Exception {
+ Collection<VDB> vdbs = getAdmin().getVDBs(STAR);
+ for(VDB vdb:vdbs) {
+ if (!vdb.getName().equalsIgnoreCase(ADMIN)) {
+ deleteVDB(vdb.getName(), vdb.getVDBVersion());
+ }
+ }
+
+ Collection<ConnectorBinding> bindings =
getAdmin().getConnectorBindings(STAR);
+ for(ConnectorBinding b:bindings) {
+ getAdmin().stopConnectorBinding(b.getIdentifier(), true);
+ getAdmin().deleteConnectorBinding(b.getIdentifier());
+ }
+ }
+
@Test public void testGetProcess() throws Exception {
- Connection conn = getConnection(VDB, DQP_PROP_FILE,
"user=admin;password=teiid;"); //$NON-NLS-1$
- Admin admin = ((MMConnection)conn).getAdminAPI();
- Collection<ProcessObject> processes = admin.getProcesses("*");
//$NON-NLS-1$
+ getConnection(ADMIN, PROPS_FILE);
+ Collection<ProcessObject> processes = getAdmin().getProcesses(STAR);
assertEquals(1, processes.size());
assertNotNull(processes.iterator().next().getInetAddress());
- }
+ }
+
+ // Setting AutoCommit to "false" was failing in the DQP. This was happening
because
+ // when auto commit is false, it loads a user transaction and that needs a Txn
+ // manager which currently not available in the DQP. Currently this has been stubbed
+ // not to use the txn messaging in the embedded connection.
+ @Test public void testDefect19748_setAutoCommitFalse() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ getAdmin().addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
+ getAdmin().changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ pushConnection();
+ Connection c = getConnection(VDB_NAME, PROPS_FILE);
+ try {
+ c.setAutoCommit(false);
+ execute("select * from smalla"); //$NON-NLS-1$
+ }catch(SQLException e) {
+ fail("Embedded driver should have let the user set the
autocommit=false"); //$NON-NLS-1$
+ }
+ closeConnection();
+ popConnection();
+
+ closeConnection();
+ }
+ @Test public void testDefect19748_setAutoCommitFalse_txnoff() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ getAdmin().addVDB(BQT, Util.getBinaryFile(VDB_FILE), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
+ getAdmin().changeVDBStatus(BQT, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ pushConnection();
+ Connection c = getConnection(BQT, PROPS_FILE+";txnAutoWrap=OFF");
//$NON-NLS-1$
+ try {
+ c.setAutoCommit(false);
+ execute("select * from smalla"); //$NON-NLS-1$
+ assertRowCount(10);
+ }catch(SQLException e) {
+ fail("Embedded driver should have let the user set the
autocommit=false"); //$NON-NLS-1$
+ //pass
+ }
+ closeConnection();
+ popConnection();
+ closeConnection();
+ }
+
+ @Test public void testDefect19748_commit_txnoff() throws Exception {
+ Connection c = getConnection(ADMIN, PROPS_FILE+";txnAutoWrap=OFF");
//$NON-NLS-1$
+ cleanDeploy();
+ try {
+ c.commit();
+ }catch(SQLException e) {
+ fail("Embedded driver should have have let the user commit; because of txn
off"); //$NON-NLS-1$
+ }
+ closeConnection();
+ }
+
+ @Test public void testBindingNames() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ Collection bindings = getAdmin().getConnectorBindings(STAR);
+
+ int size = bindings.size();
+
+ assertFalse("VDB does not exist", hasVDB(BQT)); //$NON-NLS-1$
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+ assertTrue("VDB does not exist", hasVDB(BQT)); //$NON-NLS-1$
+
+ bindings = getAdmin().getConnectorBindings(STAR);
+ assertEquals("Two bindings should exist", 2+size, bindings.size());
//$NON-NLS-1$
+
+ bindings = getAdmin().getConnectorBindingsInVDB("BQT*"); //$NON-NLS-1$
+ assertEquals("Two bindings should exist", 2+size, bindings.size());
//$NON-NLS-1$
+
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT1 Oracle
9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT2 Oracle
9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+
+ // make sure when the VDB is gone all the enclosed bindings are gone too
+ deleteVDB(BQT, "1"); //$NON-NLS-1$
+
+ assertFalse("Binding must be available", hasBinding("BQT_1.BQT1
Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("Binding must be available", hasBinding("BQT_1.BQT2
Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ closeConnection();
+ }
+
+ @Test public void testDeleteBindings() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ assertFalse("VDB does not exist", hasVDB(BQT)); //$NON-NLS-1$
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ try {
+ getAdmin().deleteConnectorBinding("BQT_1.BQT2 Oracle 9i Simple Cap");
//$NON-NLS-1$
+ fail("must have failed to delete due to active assosiation to VDB");
//$NON-NLS-1$
+ } catch(Exception e) {
+ }
+
+ getAdmin().assignBindingToModel("BQT_1.BQT1 Oracle 9i Simple Cap",
"BQT", "1", "BQT2"); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$
+ getAdmin().assignBindingToModel("BQT_1.BQT1 Oracle 9i Simple Cap",
"BQT", "1", "SP"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+
+ assertFalse("Binding not found", hasBinding("BQT_1.BQT2 Oracle 9i
Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Check that config state has changed
+ assertTrue("Binding must be found", hasBinding("BQT_1.BQT1 Oracle 9i
Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // make sure when the VDB is gone all the enclosed bindings are gone too
+ deleteVDB(BQT, "1"); //$NON-NLS-1$
+
+ assertFalse("Binding must be available", hasBinding("BQT_1.BQT1
Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ closeConnection();
+ }
+
+ @Test public void testBindingNames_sharedBinding() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ getAdmin().addConnectorBinding("BQT1 Oracle 9i Simple Cap",
Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/BQT1Binding.cdk"),
new AdminOptions(AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("Binding must be available", hasBinding("BQT1 Oracle 9i
Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ assertTrue("VDB does exist", hasVDB(BQT, "1")); //$NON-NLS-1$
//$NON-NLS-2$
+
+ Collection bindings = getAdmin().getConnectorBindings(STAR);
+ int initialSize = bindings.size();
+
+ assertTrue("Binding must be available", hasBinding("BQT1 Oracle 9i
Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT1 Oracle
9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT2 Oracle
9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ assertTrue("VDB does exist", hasVDB(BQT, "2")); //$NON-NLS-1$
//$NON-NLS-2$
+
+ bindings = getAdmin().getConnectorBindings(STAR);
+
+ assertTrue("Addtion of the same VDB should",
bindings.size()==initialSize); //$NON-NLS-1$
+
+ // the bindings are shared
+ assertTrue("Binding must be available", hasBinding("BQT1 Oracle 9i
Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT1 Oracle
9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT2 Oracle
9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ deleteVDB(BQT, "1"); //$NON-NLS-1$
+
+ //still bindings are there
+ assertTrue("Binding must be available", hasBinding("BQT1 Oracle 9i
Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT1 Oracle
9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT2 Oracle
9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ deleteVDB(BQT, "2"); //$NON-NLS-1$
+
+ // deletion of VDB should remove the bindings specific to VDB?
+ assertTrue("Binding must be available", hasBinding("BQT1 Oracle 9i
Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("Binding must be available", hasBinding("BQT_1.BQT1
Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("Binding must be available", hasBinding("BQT_1.BQT2
Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ getAdmin().deleteConnectorBinding("BQT1 Oracle 9i Simple Cap");
//$NON-NLS-1$
+ assertFalse("Binding must not available", hasBinding("BQT1 Oracle 9i
Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ closeConnection();
+ }
+
+
+
+ @Test public void testStartStopConnectorBindings() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+ assertTrue("VDB does not exist", hasVDB(BQT, "1"));
//$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT1 Oracle
9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT2 Oracle
9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ execute("SELECT * FROM System.models"); //$NON-NLS-1$
+ assertRowCount(9);
+ closeConnection();
+ popConnection();
+
+ getAdmin().stopConnectorBinding("BQT_1.BQT1 Oracle 9i Simple Cap", true);
//$NON-NLS-1$
+ //calling second time has no effect
+ getAdmin().stopConnectorBinding("BQT_1.BQT1 Oracle 9i Simple Cap", true);
//$NON-NLS-1$
+
+ try {
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM BQT1.SmallA"); // this should fail
//$NON-NLS-1$
+ fail("maust have failed, since the connector is not started.");
//$NON-NLS-1$
+ }catch(Exception e) {
+ //pass
+ }finally {
+ closeConnection();
+ popConnection();
+ }
+
+ // start the binding using un-qualified, should not start
+ try {
+ getAdmin().startConnectorBinding("BQT1 Oracle 9i Simple Cap");
//$NON-NLS-1$
+ fail("must have failed to start"); //$NON-NLS-1$
+ }catch(Exception e) {
+ //pass
+ }
+
+ // start correctly
+ getAdmin().startConnectorBinding("BQT_1.BQT1 Oracle 9i Simple Cap");
//$NON-NLS-1$
+ // calling second time should have no effect
+ getAdmin().startConnectorBinding("BQT_1.BQT1 Oracle 9i Simple Cap");
//$NON-NLS-1$
+
+ // test again
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ closeConnection();
+ popConnection();
+
+ closeConnection();
+ }
+
+ @Test public void testStartStopNonExistentConnectorBindings() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ try {
+ getAdmin().startConnectorBinding("fakeConnector"); //$NON-NLS-1$
+ fail("must have failed to start");//$NON-NLS-1$
+ }catch(Exception e) {
+ }
+
+ try {
+ getAdmin().stopConnectorBinding("fakeConnector", true);//$NON-NLS-1$
+ fail("must have failed to stop");//$NON-NLS-1$
+ }catch(Exception e) {
+ }
+
+ try {
+ getAdmin().deleteConnectorBinding("fakeConnector"); //$NON-NLS-1$
+ fail("Must have failed delete a unknown connector"); //$NON-NLS-1$
+ }catch(AdminException e) {
+ //pass
+ }
+
+ try {
+ getAdmin().exportConnectorBinding("fakeConnector"); //$NON-NLS-1$
+ fail("Must have failed exporting a unknown connector"); //$NON-NLS-1$
+ }catch(AdminException e) {
+ //pass
+ }
+
+ try {
+ getAdmin().assignBindingToModel("fakeConnector", BQT, "1",
"BQT1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ fail("Must have failed assigning non-existing binding to the model");
//$NON-NLS-1$
+ }catch(AdminException e) {
+ //pass
+ }
+
+ closeConnection();
+ }
+
+ @Test public void testConnectorTypes() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ Collection<ConnectorType> types = getAdmin().getConnectorTypes(STAR);
+ for (ConnectorType type:types) {
+ // System.out.println(type.getName());
+ }
+ assertEquals("31 types expected", 31, types.size()); //$NON-NLS-1$
+
+
+ assertTrue("Should be available", hasConnectorType("Loopback
Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ getAdmin().deleteConnectorType("Loopback Connector"); //$NON-NLS-1$
+
+ assertFalse("must have been deleted", hasConnectorType("Loopback
Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ try {
+ getAdmin().deleteConnectorType("Oracle ANSI JDBC Connector");
//$NON-NLS-1$
+ fail("must have failed as this type in use by BQT "); //$NON-NLS-1$
+ } catch(Exception e) {
+ //pass
+ }
+
+ try {
+ getAdmin().deleteConnectorType("FakeConnector"); //$NON-NLS-1$
+ fail("must have failed as this type as this is unknown"); //$NON-NLS-1$
+ } catch(Exception e) {
+ //pass
+ }
+
+ getAdmin().addConnectorType("Loopback Connector",
Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"));
//$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Should be available", hasConnectorType("Loopback
Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ try {
+ getAdmin().addConnectorType("Loopback Connector",
Util.getCharacterFile(UnitTestUtil.getTestScratchPath()+"/loopback.cdk"));
//$NON-NLS-1$ //$NON-NLS-2$
+ fail("must have fail to add existing type"); //$NON-NLS-1$
+ } catch(Exception e) {
+ //pass
+ }
+
+
+ // try exporting
+
Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/textfileexport.cdk",getAdmin().exportConnectorType("Text
File Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+ File cdkFile = new
File(UnitTestUtil.getTestScratchPath()+"/textfileexport.cdk"); //$NON-NLS-1$
+ assertTrue("Connector type Export should exist", cdkFile.exists());
//$NON-NLS-1$
+ cdkFile.delete();
+
+ closeConnection();
+ }
+
+ @Test public void testUpdateConnectorBindingProperty() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+ assertTrue("VDB does not exist", hasVDB(BQT, "1"));
//$NON-NLS-1$ //$NON-NLS-2$
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("select * from BQT1.smalla"); //$NON-NLS-1$
+ assertRowCount(50);
+ closeConnection();
+ popConnection();
+
+ Collection<ConnectorBinding> bindings =
getAdmin().getConnectorBindings("BQT_1.BQT1 Oracle 9i Simple Cap");
//$NON-NLS-1$
+ for (ConnectorBinding binding:bindings) {
+ getAdmin().setProperty(binding.getIdentifier(),
ConnectorBinding.class.getName(), "RowCount", "10"); //$NON-NLS-1$
//$NON-NLS-2$
+ getAdmin().stopConnectorBinding(binding.getIdentifier(), true);
+ getAdmin().startConnectorBinding(binding.getIdentifier());
+ }
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("select * from BQT1.smalla"); //$NON-NLS-1$
+ assertRowCount(10);
+ closeConnection();
+ popConnection();
+
+ // changes are persistent after the restart too.
+ getAdmin().restart();
+
+ closeConnection();
+
+ getConnection(BQT, PROPS_FILE);
+ execute("select * from BQT1.smalla"); //$NON-NLS-1$
+ assertRowCount(10);
+ closeConnection();
+
+ }
+
+ @Test public void testVDBAddsConnectorTypes() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ assertFalse(hasVDB(BQT));
+
+ if (hasConnectorType("Oracle ANSI JDBC Connector")) { //$NON-NLS-1$
+ getAdmin().deleteConnectorType("Oracle ANSI JDBC Connector");
//$NON-NLS-1$
+ }
+ assertFalse("binding must exist", hasConnectorType("Oracle ANSI JDBC
Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+ assertTrue("VDB does exist", hasVDB(BQT, "1")); //$NON-NLS-1$
//$NON-NLS-2$
+
+ assertTrue("connector type must exist", hasConnectorType("Oracle ANSI
JDBC Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+ deleteVDB(BQT, "1"); //$NON-NLS-1$
+ closeConnection();
+ }
+
+ @Test public void testAdminOptions_addvdb_conflict_ignore() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // we start out with no bindings
+ assertFalse("VDB does not exist", hasVDB("Empty"));
//$NON-NLS-1$ //$NON-NLS-2$
+
+ getAdmin().addConnectorBinding("Loopback",
Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"), new
AdminOptions(AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("Loopback"));
//$NON-NLS-1$ //$NON-NLS-2$
+
+ // we add a vdb, loop back which returns 10 rows
+ addVDB("Empty",
UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("VDB does not exist", hasVDB("Empty",
"1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ pushConnection();
+ getConnection("Empty", PROPS_FILE); //$NON-NLS-1$
+ execute("SELECT * FROM Oracle.SmallA"); //$NON-NLS-1$
+ assertRowCount(1);
+ closeConnection();
+ popConnection();
+
+ getAdmin().restart();
+
+ closeConnection();
+
+ getConnection("Empty", PROPS_FILE); //$NON-NLS-1$
+ execute("SELECT * FROM Oracle.SmallA"); //$NON-NLS-1$
+ assertRowCount(1);
+ closeConnection();
+
+ }
+
+
+ @Test public void testAdminOptions_addvdb_conflict_overwrite() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // we start out with no bindings
+ assertFalse("VDB does not exist", hasVDB("Empty"));
//$NON-NLS-1$ //$NON-NLS-2$
+
+ getAdmin().addConnectorBinding("Loopback",
Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"), new
AdminOptions(AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("Loopback"));
//$NON-NLS-1$ //$NON-NLS-2$
+
+ // we add a vdb, loop back which returns 10 rows
+ getAdmin().addVDB("Empty",
Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"), new
AdminOptions(AdminOptions.OnConflict.OVERWRITE)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("VDB does not exist", hasVDB("Empty",
"1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ pushConnection();
+ getConnection("Empty", PROPS_FILE); //$NON-NLS-1$
+ execute("SELECT * FROM Oracle.SmallA"); //$NON-NLS-1$
+ assertRowCount(10);
+ closeConnection();
+ popConnection();
+
+ getAdmin().restart();
+
+ pushConnection();
+ getConnection("Empty", PROPS_FILE); //$NON-NLS-1$
+ execute("SELECT * FROM Oracle.SmallA"); //$NON-NLS-1$
+ assertRowCount(10);
+ closeConnection();
+ popConnection();
+ }
+
+
+ @Test public void testAdminOptions_addvdb_conflict_Exception() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // we start out with no bindings
+ assertFalse("VDB does not exist", hasVDB("Empty"));
//$NON-NLS-1$ //$NON-NLS-2$
+
+ getAdmin().addConnectorBinding("Loopback",
Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"), new
AdminOptions(AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("Loopback"));
//$NON-NLS-1$ //$NON-NLS-2$
+
+ assertFalse("VDB does not exist", hasVDB("Empty",
"1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ // we add a vdb, loop back which returns 10 rows
+ try {
+ // we add a vdb, loop back which returns 10 rows
+ getAdmin().addVDB("Empty",
Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"), new
AdminOptions(AdminOptions.OnConflict.EXCEPTION)); //$NON-NLS-1$ //$NON-NLS-2$
+ fail("Must have failed to Add a vdb, as loopback already exists");
//$NON-NLS-1$
+ }catch(AdminException e) {
+ // pass
+ }
+
+ assertFalse("VDB does not exist", hasVDB("Empty",
"1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ closeConnection();
+ }
+
+ @Test public void testGetSessions() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ assertEquals(1, getAdmin().getSessions(STAR).size());
+
+ for (int i = 0; i < 10; i++) {
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ }
+
+ assertEquals(11, getAdmin().getSessions(STAR).size());
+
+ for (int i = 0; i < 10; i++) {
+ closeConnection();
+ popConnection();
+ }
+
+ assertEquals(1, getAdmin().getSessions(STAR).size());
+
+ closeConnection();
+ }
+
+ @Test public void testSessionTermination() throws Exception {
+ com.metamatrix.jdbc.api.Connection c = getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ assertEquals(1, getAdmin().getSessions(STAR).size());
+
+ pushConnection();
+ MMConnection c2 = (MMConnection)getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+
+ // terminate the session
+ c.getAdminAPI().terminateSession(c2.getConnectionId());
+
+ // make sure it is gone
+ assertEquals(1, c.getAdminAPI().getSessions(STAR).size());
+
+ try {
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ fail("must have failed to execute"); //$NON-NLS-1$
+ }catch(Exception e) {
+ // success
+ try {
+ closeConnection();
+ } catch (Exception e1) {
+ }
+ }
+
+ popConnection();
+ closeConnection();
+ }
+
+ @Test public void testAddExtensionModules() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ assertFalse(hasExtensionModule("Loopy.jar")); //$NON-NLS-1$
+
+ getAdmin().addExtensionModule("JAR File", "Loopy.jar",
Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/loopbackconn.jar"),
"JAR File"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ assertTrue("Expected extension module",
hasExtensionModule("Loopy.jar")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // try to add a duplicate
+ try {
+ getAdmin().addExtensionModule("JAR File", "Loopy.jar",
Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/loopbackconn.jar"),
"JAR File"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ fail("should have failed to add the extension module as it is
duplicate"); //$NON-NLS-1$
+ } catch(Exception e) {
+ //pass
+ }
+
+ //export the extension
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/ext.jar",
getAdmin().exportExtensionModule("Loopy.jar")); //$NON-NLS-1$ //$NON-NLS-2$
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/ext.jar");
//$NON-NLS-1$
+ assertTrue(f.exists());
+ f.delete();
+
+ // delete the extension
+ getAdmin().deleteExtensionModule("Loopy.jar"); //$NON-NLS-1$
+
+ // Assert that no vdb with this name exists
+ assertFalse("Expected no prior extension module",
hasExtensionModule("Loopy.jar")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ closeConnection();
+ }
+
+ @Test public void testExportConfiguration() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/serverconfigexport.xml",
getAdmin().exportConfiguration()); //$NON-NLS-1$
+ File f = new
File(UnitTestUtil.getTestScratchPath()+"/serverconfigexport.xml");
//$NON-NLS-1$
+ assertTrue("Exported configuration must exist", f.exists());
//$NON-NLS-1$
+ f.delete();
+ closeConnection();
+ }
+
+ // Test exporting VDB and adding the same VDB and make sure it exported correctly
+ @Test public void testExportVDB() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // Assert that no vdb with this name exists
+ assertFalse("Expected no prior VDB", hasVDB(BQT)); //$NON-NLS-1$
+
+ // Add .VDB with included .DEF
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ // Check that config state has changed
+ assertTrue("Expected new VDB", hasVDB(BQT)); //$NON-NLS-1$
+
+ // Export the VDB
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/bqtexport.vdb",
getAdmin().exportVDB(BQT, "1")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ closeConnection();
+
+ // Assert bqt.vdb exists
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/bqtexport.vdb");
//$NON-NLS-1$
+ assertTrue(f.exists());
+ f.delete();
+ }
+
+ @Test public void testVDBModified() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ // make susre it exists as file
+ File vdb = new File(UnitTestUtil.getTestScratchPath()+"/BQT_1.vdb");
//$NON-NLS-1$
+ assertTrue("Persisted VDB file does not exists", vdb.exists());
//$NON-NLS-1$
+
+ // Check when it last modified
+ long modified = vdb.lastModified();
+ Thread.sleep(1000);
+ getAdmin().assignBindingToModel("BQT_1.BQT1 Oracle 9i Simple Cap", BQT,
"1", "BQT2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ // the deployed VDB is modified not the original vdb
+ assertTrue(vdb.lastModified() == modified);
+
+ closeConnection();
+ }
+
+ @Test public void testIncompleteVDB() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ VDB vdb = getAdmin().addVDB(BQT,
Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/Empty.vdb"), new
AdminOptions (AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$
+
+ assertTrue("Status must have been INCOMPLTE", !(vdb.getState() ==
VDB.ACTIVE)); //$NON-NLS-1$
+
+ try {
+ getAdmin().changeVDBStatus(BQT, "1", VDB.ACTIVE); //$NON-NLS-1$
+ fail("must have failed to set status to active"); //$NON-NLS-1$
+ } catch(Exception e) {
+
+ }
+
+ pushConnection();
+ try {
+ getConnection(BQT, PROPS_FILE);
+ fail("must have failed to get connection"); //$NON-NLS-1$
+ }catch(Exception e) {
+
+ }
+ popConnection();
+
+ getAdmin().addConnectorBinding("Loopback",
Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"), new
AdminOptions(AdminOptions.OnConflict.OVERWRITE)); //$NON-NLS-1$ //$NON-NLS-2$
+ getAdmin().startConnectorBinding("Loopback"); //$NON-NLS-1$
+ getAdmin().assignBindingToModel("Loopback", BQT, "1",
"Oracle"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ getAdmin().changeVDBStatus(BQT, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ closeConnection();
+ popConnection();
+
+ closeConnection();
+ }
+
+ @Test public void testUseLatestVersion() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // this returns 50 rows
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ // this returns 10 row
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb");
//$NON-NLS-1$
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("select * from Oracle.smalla"); //$NON-NLS-1$
+ assertRowCount(10);
+ closeConnection();
+ popConnection();
+ closeConnection();
+ }
+
+ @Test public void testDeleteVDBHavingActiveConnection() throws Exception {
+ helpDeleteVDBHavingActiveConnection(false);
+ helpDeleteVDBHavingActiveConnection(true);
+ }
+
+ // Test to delete a VDB with active connection to it
+ // 1) we should be able to delete the vdb; hasVDB should return false
+ // 2) should be able to continue the old connection, as it is
+ // 3) No new connections are allowed
+ // 4) if you add another VDB with same name, it can be given different version
+ // 5) The old one can not switch over to the new connection.
+ void helpDeleteVDBHavingActiveConnection(boolean terminate) throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // this returns 50 rows
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ assertTrue("VDB does not exist", hasVDB(BQT)); //$NON-NLS-1$
+
+ // make another context and create a 2nd connection
+ pushConnection();
+ MMConnection vdbConn = (MMConnection)getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ // we have not closed the connection here, kept active connection
+ popConnection();
+
+ // testcase (1) (here the file should still exist; but report as non existent from
API)
+ deleteVDB(BQT, "1"); //$NON-NLS-1$
+ assertFalse("VDB should exist because we still have an active user",
hasVDB(BQT, "1")); //$NON-NLS-1$ //$NON-NLS-2$
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/BQT_1.vdb");
//$NON-NLS-1$
+ assertTrue("since the connection is still open this file should exist",
f.exists()); //$NON-NLS-1$
+
+ // testcase (2)
+ // switch to 2nd connection and try to execute, since we did not close it should
work fine
+ pushConnection();
+ setConnection(vdbConn);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ popConnection();
+
+ // testcase (3)
+ // try to make third connection and should fail, because we do not allow
connections
+ // to non-active vdbs
+ pushConnection();
+ try {
+ getConnection(BQT, PROPS_FILE);
+ fail("Must have failed to connect to the VDB as it is deleted");
//$NON-NLS-1$
+ }catch(Exception e) {
+ // yes failed to connect
+ }
+ popConnection();
+
+ // testcase (4)
+ // Add the VDB again to the configuration it should give new version
+ getAdmin().addVDB(BQT,
Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"),
new AdminOptions(AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$
+ assertTrue("Empty VDB must exist", hasVDB(BQT, "2"));
//$NON-NLS-1$ //$NON-NLS-2$
+
+ // testcase (5)
+ // try to execute the 2nd connection, it should still go after the deleted vdb
+ // as we keep until this connections goes dead.
+ pushConnection();
+ setConnection(vdbConn);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ popConnection();
+
+ // now make a 4th new connection this should work
+ pushConnection();
+ getConnection(BQT, PROPS_FILE+";version=2"); //$NON-NLS-1$
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ closeConnection();
+ popConnection();
+
+ if (terminate) {
+ getAdmin().terminateSession(vdbConn.getConnectionId());
+ }
+ else {
+ // clean up 2nd connection
+ pushConnection();
+ setConnection(vdbConn);
+ closeConnection();
+ assertFalse("The vdb must have deleted as the connection closed",
f.exists()); //$NON-NLS-1$
+ popConnection();
+ }
+
+ // now make a 5th new connection this should work
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ closeConnection();
+ popConnection();
+
+ // here it should be gone we call delete
+ deleteVDB(BQT, "2"); //$NON-NLS-1$
+ assertFalse("VDB should exist because we still have an active user",
hasVDB(BQT, "2")); //$NON-NLS-1$ //$NON-NLS-2$
+ f = new File(UnitTestUtil.getTestScratchPath()+"/BQT_2.vdb");
//$NON-NLS-1$
+ assertFalse("since the connection is still open this file should exist",
f.exists()); //$NON-NLS-1$
+
+ // close the 1st connection
+ closeConnection();
+ }
+
+ private void helpConnectorBindingAddTest(int option, int rows) throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // this returns 50 rows
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb");
//$NON-NLS-1$
+
+ getAdmin().addConnectorBinding("Loopback",
Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"), new
AdminOptions(option)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM Oracle.SmallA"); //$NON-NLS-1$
+ assertRowCount(rows);
+ closeConnection();
+ popConnection();
+ }
+
+ @Test public void testConnectorBindingAdd_optionIgnore() throws Exception {
+ helpConnectorBindingAddTest(AdminOptions.OnConflict.IGNORE, 10);
+ }
+
+ @Test public void testConnectorBindingAdd_optionException() throws Exception {
+ try {
+ helpConnectorBindingAddTest(AdminOptions.OnConflict.EXCEPTION, 10);
+ fail("Must have failed to add connector"); //$NON-NLS-1$
+ } catch(Exception e) {
+
+ }
+ }
+
+ @Test public void testConnectorBindingAdd_optionOverwrite() throws Exception {
+ helpConnectorBindingAddTest(AdminOptions.OnConflict.OVERWRITE, 1);
+ }
+
+ @Test public void testAddConnectorBindingWithProeprties() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // this returns 50 rows
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb");
//$NON-NLS-1$
+
+ Properties props = new Properties();
+
+ props.setProperty("MaxResultRows","10000"); //$NON-NLS-1$
//$NON-NLS-2$
+ props.setProperty("ConnectorThreadTTL", "120000"); //$NON-NLS-1$
//$NON-NLS-2$
+ props.setProperty("ConnectorMaxThreads","5"); //$NON-NLS-1$
//$NON-NLS-2$
+ props.setProperty("metamatrix.service.essentialservice",
"false"); //$NON-NLS-1$ //$NON-NLS-2$
+
props.setProperty("ConnectorClassPath","extensionjar:loopbackconn.jar;extensionjar:jdbcconn.jar");
//$NON-NLS-1$ //$NON-NLS-2$
+ props.setProperty("RowCount","12"); //$NON-NLS-1$ //$NON-NLS-2$
+
props.setProperty("ServiceClassName","com.metamatrix.server.connector.service.ConnectorService");
//$NON-NLS-1$ //$NON-NLS-2$
+
props.setProperty("ConnectorClass","com.metamatrix.connector.loopback.LoopbackConnector");
//$NON-NLS-1$ //$NON-NLS-2$
+ props.setProperty("WaitTime", "0"); //$NON-NLS-1$
//$NON-NLS-2$
+
+ // Add the connector binding
+ getAdmin().addConnectorBinding("Loopy", "Loopback Connector",
props, new AdminOptions(AdminOptions.OnConflict.OVERWRITE)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("Connector binding must exist", hasBinding("Loopy"));
//$NON-NLS-1$ //$NON-NLS-2$
+
+ getAdmin().assignBindingToModel("Loopy", "BQT", "1",
"Oracle"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ getAdmin().startConnectorBinding("Loopy"); //$NON-NLS-1$
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM Oracle.SmallA"); //$NON-NLS-1$
+ assertRowCount(12);
+ closeConnection();
+ popConnection();
+
+ closeConnection();
+ }
+
+ @Test public void testConnectorArchive() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // this returns 50 rows
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ assertFalse(hasConnectorType("Loopback")); //$NON-NLS-1$
+ assertFalse(hasExtensionModule("jdbcconn.jar")); //$NON-NLS-1$
+ assertFalse(hasExtensionModule("loopbackconn.jar")); //$NON-NLS-1$
+
+ getAdmin().addConnectorArchive(Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/loopback_archive.caf"),
new AdminOptions(AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$
+
+ assertTrue(hasConnectorType("Loopback")); //$NON-NLS-1$
+ assertTrue(hasExtensionModule("jdbcconn.jar")); //$NON-NLS-1$
+ assertTrue(hasExtensionModule("loopbackconn.jar")); //$NON-NLS-1$
+
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/loopback_archive.caf");
//$NON-NLS-1$
+ Util.writeToFile(f.getCanonicalPath(),
getAdmin().exportConnectorArchive("Loopback")); //$NON-NLS-1$
+ assertTrue(f.exists());
+ f.delete();
+
+ getAdmin().deleteExtensionModule("jdbcconn.jar"); //$NON-NLS-1$
+ getAdmin().deleteExtensionModule("loopbackconn.jar"); //$NON-NLS-1$
+ getAdmin().deleteConnectorType("Loopback"); //$NON-NLS-1$
+
+ assertFalse(hasConnectorType("Loopback")); //$NON-NLS-1$
+ assertFalse(hasExtensionModule("jdbcconn.jar")); //$NON-NLS-1$
+ assertFalse(hasExtensionModule("loopbackconn.jar")); //$NON-NLS-1$
+
+ closeConnection();
+ }
+
+ public class MyLogger implements EmbeddedLogger{
+ StringBuffer sb = new StringBuffer();
+ public void log(int logLevel, long timestamp, String componentName, String
threadName, String message, Throwable throwable) {
+ sb.append("logLevel=").append(logLevel); //$NON-NLS-1$
+ sb.append("message=").append(message); //$NON-NLS-1$
+ }
+
+ public String getLog() {
+ return sb.toString();
+ }
+ }
+
+ @Test public void testLogListener() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+
+ MyLogger log = new MyLogger();
+
+ getAdmin().setLogListener(log);
+ //force a critical log
+ LogConfiguration c = getAdmin().getLogConfiguration();
+ for(String context:c.getContexts()) {
+ c.setLogLevel(context, LogConfiguration.DETAIL);
+ }
+ getAdmin().setLogConfiguration(c);
+
+ // this returns 50 rows
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb");
//$NON-NLS-1$
+
+ assertTrue("Log should not be empty", log.getLog().length() > 0);
//$NON-NLS-1$
+ closeConnection();
+ }
+
+// /**
+// * SIP51, SIP52
+// * @throws Exception
+// */
+// @Test public void testDeleteInvalidVdb() throws Exception {
+// getConnection(ADMIN, PROPS_FILE);
+// cleanDeploy();
+//
+// String VDB_NAME = "DeleteInvalid"; //$NON-NLS-1$
+// try {
+// // Try clean deployment twice
+// try {
+// addVDB(VDB_NAME,
UnitTestUtil.getTestDataPath()+"/admin/TestORSInvalid.vdb"); //$NON-NLS-1$
+// fail("Failed with exception "); //$NON-NLS-1$
+// } catch (Exception e) {
+// //pass
+// }
+// } catch (Exception x) {
+// fail("Failed with exception " + Util.getStackTraceAsString(x));
//$NON-NLS-1$
+// } finally {
+// closeConnection();
+// }
+// }
+//
+// /**
+// * Opens connection to the VDB and tries to deploy when conn is open.
+// * The redeployment should not affect the current connection.
+// * @throws Exception
+// */
+// @Test public void testKeepConnectionReplaceVdb () throws Exception {
+// getConnection(ADMIN, PROPS_FILE);
+// cleanDeploy();
+//
+// String VDB_NAME = "ReplaceActive"; //$NON-NLS-1$
+// try {
+// VDB vdb = addVDB(VDB_NAME,
UnitTestUtil.getTestDataPath()+"/admin/TestORS.vdb"); //$NON-NLS-1$
+// String currentVersion = vdb.getVDBVersion();
+// assertEquals("1", currentVersion); //$NON-NLS-1$
+//
+// // Connect and run test query
+// pushConnection();
+// Connection c1 = getConnection( VDB_NAME, PROPS_FILE);
+// execute("SELECT * FROM C_REPOS_DB_RELEASE"); //$NON-NLS-1$
+//
+// // Redeploy the VDB while the connection is open. New VDB has A_CCOUNT
table
+// vdb = deployVdbClean(admin, VDB_NAME,
UnitTestUtil.getTestDataPath()+"/admin/TestORS1.vdb"); //$NON-NLS-1$
+//
+// testConnection(testConn, "select * from C_ACCOUNT", false,
"Redeploy V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+// } catch (Exception x) {
+// fail("Failed with exception " + Util.getStackTraceAsString(x));
//$NON-NLS-1$
+// } finally {
+// Util.closeQuietly(conn);
+// }
+// }
+
+ VDB addVDB(String name, String vdbFile) {
+ try {
+ return getAdmin().addVDB(name, Util.getBinaryFile(vdbFile), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new MetaMatrixRuntimeException();
+ }
+ }
+
+ /**
+ * Checks to make sure the given VDB exists in the system
+ * @param vdbName - name of the VDB
+ * @return boolean - true if exists; false otherwise
+ */
+ boolean hasVDB(String vdbName) {
+ try {
+ Collection<VDB> vdbs = getAdmin().getVDBs(vdbName);
+ for (VDB vdb:vdbs) {
+ if (vdb.getName().equals(vdbName)) {
+ return true;
+ }
+ }
+ } catch (AdminException e) {
+ }
+ return false;
+ }
+
+ /**
+ * Checks to make sure the given VDB with version exists in the system
+ * @param vdbName - name of the VDB
+ * @param version - version of the VDB
+ * @return boolean - true if exists; false otherwise
+ */
+ boolean hasVDB(String vdbName, String version) {
+ try {
+ Collection<VDB> vdbs = getAdmin().getVDBs(vdbName);
+ for (VDB vdb:vdbs) {
+ if (vdb.getName().equals(vdbName) && vdb.getVDBVersion().equals(version))
{
+ return true;
+ }
+ }
+ } catch (AdminException e) {
+ }
+ return false;
+ }
+
+ /**
+ * Checks to make sure the given binging exists.
+ * @param bindingName - Name of the Binding.
+ * @return boolean - true if exists; false otherwise
+ */
+ boolean hasBinding(String bindingName) {
+ try {
+ Collection<ConnectorBinding> bindings =
getAdmin().getConnectorBindings(AdminObject.WILDCARD + AdminObject.DELIMITER +
bindingName);
+ for (ConnectorBinding binding:bindings) {
+ if (binding.getName().equals(bindingName)) {
+ return true;
+ }
+ }
+ } catch (AdminException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ /**
+ * Checks if given Connector Type exists in system
+ * @param typeName - Binding type name
+ * @return boolean - true if exists; false otherwise
+ */
+ boolean hasConnectorType(String typeName) {
+ try {
+ Collection<ConnectorType> types = getAdmin().getConnectorTypes(typeName);
+ for (ConnectorType type:types) {
+ if (type.getName().equals(typeName)) {
+ return true;
+ }
+ }
+ } catch (AdminException e) {
+ }
+ return false;
+ }
+
+ /**
+ * Checks if given Extension Module exists in system
+ * @param name - Extension Module name
+ * @return boolean - true if exists; false otherwise
+ */
+ boolean hasExtensionModule(String name) {
+ try {
+ Collection<ExtensionModule> modules =
getAdmin().getExtensionModules(name);
+ for(ExtensionModule module:modules) {
+ if (module.getName().equals(name)) {
+ return true;
+ }
+ }
+ }catch(Exception e) {}
+ return false;
+ }
+
+ void deleteVDB(String name, String version) {
+ try {
+ getAdmin().changeVDBStatus(name, version, VDB.DELETED);
+ } catch (AdminException e) {
+ throw new MetaMatrixRuntimeException();
+ }
+ }
}
Added: trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/MyFunctions.java
===================================================================
--- trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/MyFunctions.java
(rev 0)
+++
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/MyFunctions.java 2009-08-25
19:38:18 UTC (rev 1277)
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2000-2005 MetaMatrix, Inc. All rights reserved.
+ */
+package org.teiid.runtime.adminapi;
+
+/**
+ */
+public class MyFunctions {
+
+ public static Object getPropertyNoArgs() {
+ return "xyz"; //$NON-NLS-1$
+ }
+
+ public static Object getProperty(Object propertyName) {
+ return System.getProperty((String)propertyName);
+ }
+
+}
Property changes on:
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/MyFunctions.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestDqpReDeployment.java
===================================================================
---
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestDqpReDeployment.java
(rev 0)
+++
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestDqpReDeployment.java 2009-08-25
19:38:18 UTC (rev 1277)
@@ -0,0 +1,287 @@
+package org.teiid.runtime.adminapi;
+
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.Iterator;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminOptions;
+import org.teiid.adminapi.Session;
+import org.teiid.adminapi.VDB;
+
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.core.util.UnitTestUtil;
+
+public class TestDqpReDeployment {
+
+ String DEPLOY_FILE =
UnitTestUtil.getTestDataPath()+"/admin/dqp.properties;user=admin;password=teiid";
//$NON-NLS-1$
+ String ADMIN_URL_PREFIX = "jdbc:teiid:admin@"; //$NON-NLS-1$
+
+ @Before
+ public void setUp() throws Exception {
+ FileUtils.copy(UnitTestUtil.getTestDataPath()+"/admin/Admin.vdb",
UnitTestUtil.getTestScratchPath()+"/Admin.vdb"); //$NON-NLS-1$ //$NON-NLS-2$
+ FileUtils.copy(UnitTestUtil.getTestDataPath()+"/ServerConfig.xml",
UnitTestUtil.getTestScratchPath()+"/configuration.xml"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ Connection conn = null;
+
+ conn = Util.getConnection(ADMIN_URL_PREFIX + DEPLOY_FILE);
+ com.metamatrix.jdbc.api.Connection mmconn = (com.metamatrix.jdbc.api.Connection)
conn;
+ Admin admin = mmconn.getAdminAPI();
+
+ // Remove any existing VDBs from the previous tests.
+ Iterator iter = admin.getVDBs("*").iterator(); //$NON-NLS-1$
+ while (iter.hasNext()) {
+ VDB vdb = (VDB)iter.next();
+ if (!vdb.getName().equalsIgnoreCase("admin")){ //$NON-NLS-1$
+ admin.changeVDBStatus(vdb.getName(), vdb.getVDBVersion(), VDB.DELETED);
+ }
+ }
+ }
+
+
+ /**
+ * Opens connection to the VDB and tries to deploy when conn is open.
+ * The redeployment should not affect the current connection.
+ * @throws Exception
+ */
+ @Test public void testKeepConnectionReplaceVdb () throws Exception {
+ Connection conn = null;
+ Connection testConn = null;
+ String VDB_NAME = "ReplaceActive"; //$NON-NLS-1$
+ try {
+ conn = Util.getConnection(ADMIN_URL_PREFIX + DEPLOY_FILE);
+ com.metamatrix.jdbc.api.Connection mmconn =
(com.metamatrix.jdbc.api.Connection) conn;
+ Admin admin = mmconn.getAdminAPI();
+
+ VDB vdb = deployVdbClean(admin, VDB_NAME,
UnitTestUtil.getTestDataPath()+"/admin/TestORS.vdb"); //$NON-NLS-1$
+ String currentVersion = vdb.getVDBVersion();
+ assertEquals("1", currentVersion); //$NON-NLS-1$
+
+ // Connect and run test query
+ testConn = Util.getConnection("jdbc:teiid:" + VDB_NAME +
"@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "SELECT * FROM C_REPOS_DB_RELEASE", true,
"Initial Test"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Redeploy the VDB while the connection is open. New VDB has A_CCOUNT
table
+ vdb = deployVdbClean(admin, VDB_NAME,
UnitTestUtil.getTestDataPath()+"/admin/TestORS1.vdb"); //$NON-NLS-1$
+
+ testConnection(testConn, "select * from C_ACCOUNT", false,
"Redeploy V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (Exception x) {
+ fail("Failed with exception " + Util.getStackTraceAsString(x));
//$NON-NLS-1$
+ } finally {
+ Util.closeQuietly(conn);
+ }
+ }
+
+ /**
+ * Redeploy while there is an opened connection. Restart the DQP to have the changes
take effect
+ * Validate that the open connection becomes invalid and a new connection gets the
latest VDB
+ * @throws Exception
+ */
+ @Test public void testReplaceVdbWithDqpRestart() throws Exception {
+ Connection conn = null;
+ Connection testConn = null;
+ Connection newTestConn = null;
+
+ String VDB_NAME = "ReplaceRestart"; //$NON-NLS-1$
+ try {
+ conn = Util.getConnection(ADMIN_URL_PREFIX + DEPLOY_FILE);
+ com.metamatrix.jdbc.api.Connection mmconn =
(com.metamatrix.jdbc.api.Connection) conn;
+ Admin admin = mmconn.getAdminAPI();
+ VDB vdb = deployVdbClean(admin, VDB_NAME,
UnitTestUtil.getTestDataPath()+"/admin/TestORS.vdb"); //$NON-NLS-1$
+ String currentVersion = vdb.getVDBVersion();
+ assertEquals("1", currentVersion); //$NON-NLS-1$
+
+ // Connect and run test query
+ testConn = Util.getConnection("jdbc:teiid:" + VDB_NAME +
"@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "SELECT * FROM C_REPOS_DB_RELEASE", true,
"Initial V1 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "select * from C_ACCOUNT", false,
"Initial V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Redeploy the VDB while the connection is open. New VDB has A_CCOUNT
table
+ vdb = deployVdbClean(admin, VDB_NAME,
UnitTestUtil.getTestDataPath()+"/admin/TestORS1.vdb"); //$NON-NLS-1$
+
+ admin.restart();
+ Thread.sleep(2000);
+
+ newTestConn = Util.getConnection("jdbc:teiid:" + VDB_NAME +
"@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(newTestConn, "select * from C_ACCOUNT", true,
"Redeploy V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "SELECT 1", false, "Stale Conn
test"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ } catch (Exception x) {
+ fail("Failed with exception " + Util.getStackTraceAsString(x));
//$NON-NLS-1$
+ } finally {
+ Util.closeQuietly(conn);
+ Util.closeQuietly(testConn);
+ Util.closeQuietly(newTestConn);
+ }
+ }
+
+ /**
+ * SIP53 Scenario 1
+ * Redeployment when there are no active connections. The new connection should get
the latest version
+ * @throws Exception
+ */
+ @Test public void testReplaceNonActiveVdb () throws Exception {
+ Connection conn = null;
+ Connection testConn = null;
+ String VDB_NAME = "ReplaceNonActive"; //$NON-NLS-1$
+ try {
+ conn = Util.getConnection(ADMIN_URL_PREFIX + DEPLOY_FILE);
+ com.metamatrix.jdbc.api.Connection mmconn =
(com.metamatrix.jdbc.api.Connection) conn;
+ Admin admin = mmconn.getAdminAPI();
+
+ VDB vdb = deployVdbClean(admin, VDB_NAME,
UnitTestUtil.getTestDataPath()+"/admin/TestORS.vdb"); //$NON-NLS-1$
+ String currentVersion = vdb.getVDBVersion();
+ assertEquals("1", currentVersion); //$NON-NLS-1$
+
+ // Connect and run test query
+ testConn = Util.getConnection("jdbc:teiid:" + VDB_NAME +
"@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "SELECT * FROM C_REPOS_DB_RELEASE", true,
"Initial V1 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "select * from C_ACCOUNT", false,
"Initial V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.closeQuietly(testConn);
+
+ // Verify that there are no sessions left reset all sessions to the VDB
+ Iterator sessionIter = admin.getSessions("*").iterator();
//$NON-NLS-1$
+ while(sessionIter.hasNext()) {
+ Session session = (Session)sessionIter.next();
+ if (VDB_NAME.equals(session.getVDBName()) &&
currentVersion.equals(session.getVDBVersion())) {
+ fail("There should not be any sessions open against the
VDB"); //$NON-NLS-1$
+ }
+ }
+
+ // Redeploy the VDB while the connection is open. New VDB has A_CCOUNT
table
+ vdb = deployVdbClean(admin, VDB_NAME,
UnitTestUtil.getTestDataPath()+"/admin/TestORS1.vdb"); //$NON-NLS-1$
+
+ testConn = Util.getConnection("jdbc:teiid:" + VDB_NAME +
"@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "select * from C_ACCOUNT", true,
"Redeploy V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (Exception x) {
+ fail("Failed with exception " + Util.getStackTraceAsString(x));
//$NON-NLS-1$
+ } finally {
+ Util.closeQuietly(conn);
+ Util.closeQuietly(testConn);
+ }
+ }
+
+ /**
+ * SIP53 Scenario 2
+ * Similar to the <code>testReplaceNonActiveVdb</code>. Uses the session
shutdown instead of
+ * expecting connections to be closed
+ * @throws Exception
+ */
+ @Test public void testReplaceVdbWithSessionClose() throws Exception {
+ Connection conn = null;
+ Connection testConn = null;
+ Connection newTestConn = null;
+ String VDB_NAME = "ReplaceSessionClose"; //$NON-NLS-1$
+ try {
+ conn = Util.getConnection(ADMIN_URL_PREFIX + DEPLOY_FILE);
+ com.metamatrix.jdbc.api.Connection mmconn =
(com.metamatrix.jdbc.api.Connection) conn;
+ Admin admin = mmconn.getAdminAPI();
+ VDB vdb = deployVdbClean(admin, VDB_NAME,
UnitTestUtil.getTestDataPath()+"/admin/TestORS.vdb"); //$NON-NLS-1$
+ String currentVersion = vdb.getVDBVersion();
+
+ // Connect and run test query
+ testConn = Util.getConnection("jdbc:teiid:" + VDB_NAME +
"@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "SELECT * FROM C_REPOS_DB_RELEASE", true,
"Initial V1 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "select * from C_ACCOUNT", false,
"Initial V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // reset all sessions to the VDB
+ Iterator sessionIter = admin.getSessions("*").iterator();
//$NON-NLS-1$
+ boolean sessionFound = false;
+ while(sessionIter.hasNext()) {
+ Session session = (Session)sessionIter.next();
+ if (VDB_NAME.equals(session.getVDBName()) &&
currentVersion.equals(session.getVDBVersion())) {
+ admin.terminateSession(session.getSessionID());
+ sessionFound = true;
+ }
+ }
+ if ( ! sessionFound ) {
+ fail("Did not find the expected connection to terminate");
//$NON-NLS-1$
+ }
+
+ // Redeploy the VDB while the connection is open. New VDB has A_CCOUNT
table
+ vdb = deployVdbClean(admin, VDB_NAME,
UnitTestUtil.getTestDataPath()+"/admin/TestORS1.vdb"); //$NON-NLS-1$
+
+ newTestConn = Util.getConnection("jdbc:teiid:" + VDB_NAME +
"@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(newTestConn, "select * from C_ACCOUNT", true,
"Redeploy V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "SELECT 1", false, "Stale Conn
test"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ } catch (Exception x) {
+ fail("Failed with exception " + Util.getStackTraceAsString(x));
//$NON-NLS-1$
+ } finally {
+ Util.closeQuietly(conn);
+ Util.closeQuietly(testConn);
+ Util.closeQuietly(newTestConn);
+ }
+ }
+
+ /**
+ * SIP51, SIP52
+ * @throws Exception
+ */
+ @Test public void testDeleteInvalidVdb() throws Exception {
+ Connection conn = null;
+ String VDB_NAME = "DeleteInvalid"; //$NON-NLS-1$
+ try {
+ conn = Util.getConnection(ADMIN_URL_PREFIX + DEPLOY_FILE);
+ com.metamatrix.jdbc.api.Connection mmconn =
(com.metamatrix.jdbc.api.Connection) conn;
+ Admin admin = mmconn.getAdminAPI();
+ // Try clean deployment twice
+ try {
+ deployVdbClean(admin, VDB_NAME,
UnitTestUtil.getTestDataPath()+"/admin/TestORSInvalid.vdb"); //$NON-NLS-1$
+ fail("Failed with exception "); //$NON-NLS-1$
+ } catch (Exception e) {
+ //pass
+ }
+ } catch (Exception x) {
+ fail("Failed with exception " + Util.getStackTraceAsString(x));
//$NON-NLS-1$
+ } finally {
+ Util.closeQuietly(conn);
+ }
+ }
+
+
+ private VDB deployVdbClean(Admin admin, String vdbName, String vdbFile) throws
Exception{
+
+ VDB vdb;
+ // Remove any existing VDBs from the previous tests.
+ Iterator iter = admin.getVDBs(vdbName).iterator();
+ while (iter.hasNext()) {
+ vdb = (VDB)iter.next();
+ admin.changeVDBStatus(vdb.getName(), vdb.getVDBVersion(), VDB.DELETED);
+ }
+
+ vdb = admin.addVDB(vdbName,Util.getBinaryFile(vdbFile), new
AdminOptions(AdminOptions.OnConflict.OVERWRITE));
+ return vdb;
+ }
+
+ void testConnection(Connection conn, String sql, boolean expectSuccess, String
testName) {
+ Statement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery(sql);
+ if ( ! rs.next() ) {
+ fail(sql + "executed with 0 rows returned"); //$NON-NLS-1$
+ }
+ } catch (Exception e) {
+ if (expectSuccess) {
+ fail(testName + " failed for [" + sql + "] with " +
e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } finally {
+ Util.closeQuietly(null, stmt, rs);
+ }
+ }
+
+
+
+
+}
Property changes on:
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestDqpReDeployment.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java
===================================================================
---
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java
(rev 0)
+++
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java 2009-08-25
19:38:18 UTC (rev 1277)
@@ -0,0 +1,522 @@
+/*
+ * Copyright (c) 2000-2005 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.runtime.adminapi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminOptions;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.Session;
+import org.teiid.adminapi.VDB;
+import org.teiid.jdbc.TeiidDriver;
+
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.core.util.UnitTestUtil;
+import com.metamatrix.jdbc.MMConnection;
+import com.metamatrix.jdbc.api.Connection;
+
+/**
+ * @since 4.3
+ */
+public class TestEmbeddedAdmin {
+
+ private static final String VDB_FILE =
UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"; //$NON-NLS-1$
+ private static final String VDB_NAME = "TestEmpty"; //$NON-NLS-1$
+
+ String configFile = UnitTestUtil.getTestDataPath()+"/admin/dqp.properties";
//$NON-NLS-1$
+ Connection conn = null;
+ Connection adminConn = null;
+ Admin admin = null;
+ Statement stmt = null;
+ ResultSet result = null;
+
+ /* Utility methods */
+ private Connection getConnection(String vdb, String configFile) throws SQLException
{
+ String url =
"jdbc:teiid:"+vdb+"@"+configFile+";user=admin;password=teiid";
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new TeiidDriver();
+ Connection conn = (Connection)DriverManager.getConnection(url);
+ return conn;
+ }
+
+ Admin getAdmin() throws Exception{
+ adminConn = getConnection("admin", configFile); //$NON-NLS-1$
+ return adminConn.getAdminAPI();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ FileUtils.copy(UnitTestUtil.getTestDataPath()+"/admin/Admin.vdb",
UnitTestUtil.getTestScratchPath()+"/Admin.vdb"); //$NON-NLS-1$ //$NON-NLS-2$
+ FileUtils.copy(UnitTestUtil.getTestDataPath()+"/ServerConfig.xml",
UnitTestUtil.getTestScratchPath()+"/configuration.xml"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+
+ @After
+ public void tearDown() throws Exception {
+ if (result != null) {
+ result.close();
+ }
+ if (stmt != null) {
+ stmt.close();
+ }
+ if (adminConn != null) {
+ adminConn.close();
+ }
+ if (conn != null) {
+ conn.close();
+ }
+ }
+
+ void cleanupVDB(Admin admin, String name, String version) {
+ try {
+ // make sure we delete any
+ admin.changeVDBStatus(name, version, VDB.DELETED);
+ }catch(Exception e) {
+ //ignore it might say not found
+ }
+ }
+
+ /* Test methods */
+ @Test public void testGetConnectionToAdmin() throws Exception {
+ conn = getConnection("admin", configFile); //$NON-NLS-1$
+ assertFalse("Found a Closed Connection to Admin", conn.isClosed());
//$NON-NLS-1$
+ }
+
+ @Test public void testAddTwoVDBsWithSameNameandVersion() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ boolean found = false;
+ Collection vdbs = admin.getVDBs(VDB_NAME);
+ for (Iterator i = vdbs.iterator(); i.hasNext();) {
+ VDB vdb = (VDB)i.next();
+ if (vdb.getName().equals(VDB_NAME) &&
vdb.getVDBVersion().equals("1")) { //$NON-NLS-1$
+ found = true;
+ }
+ }
+ assertTrue("Deployed VDB not found in the configuration", found);
//$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ found = false;
+ vdbs = admin.getVDBs(VDB_NAME);
+ for (Iterator i = vdbs.iterator(); i.hasNext();) {
+ VDB vdb = (VDB)i.next();
+ if (vdb.getName().equals(VDB_NAME) &&
vdb.getVDBVersion().equals("2")) { //$NON-NLS-1$
+ found = true;
+ }
+ }
+ assertTrue("Deployed VDB not found in the configuration", found);
//$NON-NLS-1$
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ cleanupVDB(admin, VDB_NAME, "2"); //$NON-NLS-1$
+ }
+
+ @Test public void testDeployVdbImbeddedDef() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ boolean found = false;
+ Collection vdbs = admin.getVDBs(VDB_NAME);
+ for (Iterator i = vdbs.iterator(); i.hasNext();) {
+ VDB vdb = (VDB)i.next();
+ if (vdb.getName().equals(VDB_NAME)) {
+ found = true;
+ }
+ }
+ assertTrue("Deployed VDB not found in the configuration", found);
//$NON-NLS-1$
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testUndeployVdb() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ boolean found = false;
+ Collection vdbs = admin.getVDBs(VDB_NAME);
+ for (Iterator i = vdbs.iterator(); i.hasNext();) {
+ VDB vdb = (VDB)i.next();
+ if (vdb.getName().equals(VDB_NAME)) {
+ found = true;
+ }
+ }
+ assertTrue("Deployed VDB not found in the configuration", found);
//$NON-NLS-1$
+
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.DELETED); //$NON-NLS-1$
+
+ found = false;
+ vdbs = admin.getVDBs(VDB_NAME);
+ for (Iterator i = vdbs.iterator(); i.hasNext();) {
+ VDB vdb = (VDB)i.next();
+ if (vdb.getName().equals(VDB_NAME)) {
+ found = true;
+ }
+ }
+ assertFalse("Deployed VDB found in the configuration after delete",
found); //$NON-NLS-1$
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testUndeployNonExistantVdb() throws Exception {
+ admin = getAdmin();
+ try {
+ admin.changeVDBStatus("DoesNotExist", "1", VDB.DELETED);
//$NON-NLS-1$ //$NON-NLS-2$
+ fail("Must have failed to delete a non existing VDB");
//$NON-NLS-1$
+ } catch (AdminException err) {
+ assertEquals("VDB \"DoesNotExist\" version \"1\"
does not exist or not in valid state.", err.getMessage()); //$NON-NLS-1$
+ }
+ }
+
+ @Test public void testGetConnectionToExistingVdb() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ conn = getConnection(VDB_NAME, configFile);
+ assertFalse("found a closed connection", conn.isClosed());
//$NON-NLS-1$
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testGetConnectionToNonExistingVdb() throws Exception {
+ try {
+ getConnection("DoesNotExist", configFile); //$NON-NLS-1$
+ fail("found a Connection to a non avtive VDB"); //$NON-NLS-1$
+ } catch (SQLException err) {
+ assertEquals("VDB \"DoesNotExist\" version
\"latest\" does not exist or not in valid state.", err.getMessage());
//$NON-NLS-1$
+ }
+ }
+
+ @Test public void testGetConnectionToNotActiveVdb() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.INACTIVE); //$NON-NLS-1$
+
+ try {
+ conn = getConnection(VDB_NAME, configFile);
+ fail("found a Connection to a non avtive VDB");
//$NON-NLS-1$
+ } catch (SQLException err) {
+ assertEquals("Unexpected error finding latest version of Virtual
Database TestEmpty", err.getMessage()); //$NON-NLS-1$
+ } finally {
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+ }
+
+
+ @Test public void testSelectNonPrepared() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ conn = getConnection(VDB_NAME, configFile);
+ Statement stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery("SELECT * FROM smalla");
//$NON-NLS-1$
+ if (!rs.next()) {
+ fail("SELECT * FROM smalla failed"); //$NON-NLS-1$
+ }
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testSelectPrepared() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ conn = getConnection(VDB_NAME, configFile);
+ executePreparedStatement("SELECT * FROM smalla"); //$NON-NLS-1$
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testStopConnectorBinding() throws Exception {
+ addVDB();
+
+ admin.stopConnectorBinding("Loopback", true); //$NON-NLS-1$
+
+ try {
+ executeStatement("SELECT * FROM smalla"); //$NON-NLS-1$
+ fail("Ran statement on closed connector binding! Wrong!");
//$NON-NLS-1$
+ }catch(Exception e) {
+ // pass good
+ }
+
+ admin.startConnectorBinding("Loopback"); //$NON-NLS-1$
+ executeStatement("SELECT * FROM smalla"); //$NON-NLS-1$
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+
+ @Test public void testStopNonExistingConnectorBinding() throws Exception {
+ addVDB();
+
+ try {
+ admin.stopConnectorBinding("NO_CONNECTORS", true); //$NON-NLS-1$
+ fail("stopped a unknown connector Wow!"); //$NON-NLS-1$
+ } catch(AdminException e) {
+ assertEquals("Connector Binding with name \"NO_CONNECTORS\"
does not exist in the configuration", e.getMessage()); //$NON-NLS-1$
+ }
+
+ executeStatement("SELECT * FROM smalla"); //$NON-NLS-1$
+
+ admin.startConnectorBinding("Loopback"); //$NON-NLS-1$
+ executeStatement("SELECT * FROM smalla"); //$NON-NLS-1$
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testAddConnectorBinding() throws Exception {
+ addVDB();
+ String LOOPBACK = "loopy"; //$NON-NLS-1$
+ admin.addConnectorBinding(LOOPBACK,
Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"), new
AdminOptions(AdminOptions.OnConflict.OVERWRITE)); //$NON-NLS-1$
+ admin.startConnectorBinding(LOOPBACK);
+
+ boolean found = true;
+ Collection c = admin.getConnectorBindings(LOOPBACK);
+ for (Iterator i = c.iterator(); i.hasNext();) {
+ ConnectorBinding binding = (ConnectorBinding)i.next();
+ if (binding.getName().equals(LOOPBACK)) {
+ found = true;
+ }
+ }
+ assertTrue("Connector LOOPBACK not found after adding", found);
//$NON-NLS-1$
+
+ admin.assignBindingToModel(LOOPBACK, VDB_NAME, "1",
"Oracle"); //$NON-NLS-1$ //$NON-NLS-2$
+ stmt = conn.createStatement();
+ result = stmt.executeQuery("Select * from smalla"); //$NON-NLS-1$
+ int count = 0;
+ while (result.next()) {
+ count++;
+ }
+ assertEquals("Expected one row", 1, count); //$NON-NLS-1$
+
+
+ Collection cbindings = admin.getConnectorBindings("*"); //$NON-NLS-1$
+ ConnectorBinding binding = null;
+ for (Iterator i = cbindings.iterator(); i.hasNext();) {
+ ConnectorBinding current = (ConnectorBinding)i.next();
+ if (current.getName().equals(LOOPBACK)) {
+ binding = current;
+ }
+ }
+ admin.setProperty(binding.getIdentifier(), ConnectorBinding.class.getName(),
"RowCount", "10"); //$NON-NLS-1$ //$NON-NLS-2$
+ admin.stopConnectorBinding(LOOPBACK, true);
+ admin.startConnectorBinding(LOOPBACK);
+
+ stmt = conn.createStatement();
+ result = stmt.executeQuery("Select * from smalla"); //$NON-NLS-1$
+
+ count = 0;
+ while (result.next()) {
+ count++;
+ }
+ assertEquals("Expected ten rows", 10, count); //$NON-NLS-1$
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testAddUnknownConnectorBinding() throws Exception {
+ addVDB();
+ try {
+ admin.startConnectorBinding("UNKNOWN"); //$NON-NLS-1$
+ fail("Started a unknown connector, BAD"); //$NON-NLS-1$
+ } catch(AdminException e) {
+ assertEquals("Connector Binding with name \"UNKNOWN\" does not
exist in the configuration", e.getMessage()); //$NON-NLS-1$
+ }
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+
+ @Test public void testExtensionModules() throws Exception {
+ addVDB();
+
+ Collection c = admin.getExtensionModules("*"); //$NON-NLS-1$
+ assertEquals(0, c.size());
+
+ admin.addExtensionModule("jar", "loopbackconn.jar",
Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/loopbackconn.jar"),
"Loopback Jar"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ c = admin.getExtensionModules("*"); //$NON-NLS-1$
+ assertEquals(1, c.size());
+
+ admin.deleteExtensionModule("loopbackconn.jar");
//$NON-NLS-1$
+
+ c = admin.getExtensionModules("*"); //$NON-NLS-1$
+ assertEquals(0, c.size());
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testGetSessions() throws Exception {
+ adminConn = getConnection("admin", configFile); //$NON-NLS-1$
+ admin = adminConn.getAdminAPI();
+ admin.restart();
+
+ addVDB();
+ Collection<Session> c = admin.getSessions("*"); //$NON-NLS-1$
+ assertEquals(2, c.size());
+
+ MMConnection myconn = (MMConnection)this.conn;
+
+ admin.terminateSession(myconn.getConnectionId());
+ this.result = null;
+ this.stmt = null;
+ this.conn = null;
+
+ c = admin.getSessions("*"); //$NON-NLS-1$
+ assertEquals(1, c.size());
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+
+ @Test public void testExportVDB() throws Exception {
+ addVDB();
+
+ Util.writeToFile("Test.VDB", admin.exportVDB(VDB_NAME, "1"));
//$NON-NLS-1$ //$NON-NLS-2$
+ File f = new File("Test.VDB"); //$NON-NLS-1$
+ assertTrue("failed to export vdb", f.exists()); //$NON-NLS-1$
+
+ f.delete();
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testExportConnectorBinging() throws Exception {
+ addVDB();
+
+ Util.writeToFile("Oracle.cdk",
admin.exportConnectorBinding("Loopback")); //$NON-NLS-1$ //$NON-NLS-2$
+ File f = new File("Oracle.cdk"); //$NON-NLS-1$
+ assertTrue("failed to export connector binding", f.exists());
//$NON-NLS-1$
+
+ f.delete();
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testExportConnectorType() throws Exception {
+ addVDB();
+
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/loopy.cdk",
admin.exportConnectorType("Loopback Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/loopy.cdk");
//$NON-NLS-1$
+ assertTrue("failed to export connector binding", f.exists());
//$NON-NLS-1$
+
+ f.delete();
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testExportServerConfig() throws Exception {
+ addVDB();
+
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/serverconfig.xml",
admin.exportConfiguration()); //$NON-NLS-1$
+ File f = new
File(UnitTestUtil.getTestScratchPath()+"/serverconfig.xml"); //$NON-NLS-1$
+ assertTrue("failed to export connector binding", f.exists());
//$NON-NLS-1$
+
+ f.delete();
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testExportExtensionModule() throws Exception {
+ addVDB();
+ admin.addExtensionModule("jar", "loopback.jar",
Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/loopbackconn.jar"),
""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/loop.jar",
admin.exportExtensionModule("loopback.jar")); //$NON-NLS-1$ //$NON-NLS-2$
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/loop.jar");
//$NON-NLS-1$
+ assertTrue("failed to export connector binding", f.exists());
//$NON-NLS-1$
+
+ f.delete();
+
+ admin.deleteExtensionModule("loopback.jar"); //$NON-NLS-1$
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+
+ @Test public void testUDF() throws Exception {
+ addVDB();
+ stmt = conn.createStatement();
+ result = stmt.executeQuery("SELECT
GetSystemProperty('path.separator')"); //$NON-NLS-1$
+
+ assertTrue(result.next());
+ assertEquals(System.getProperty("path.separator"),
result.getObject(1)); //$NON-NLS-1$
+ assertTrue(!result.next());
+
+ result.close();
+ stmt.close();
+
+ stmt = conn.createStatement();
+ result = stmt.executeQuery("SELECT getxyz()"); //$NON-NLS-1$
+
+ assertTrue(result.next());
+ assertEquals("xyz", result.getObject(1)); //$NON-NLS-1$
+ assertTrue(!result.next());
+ }
+
+ /**
+ * @throws Exception
+ * @throws AdminException
+ * @since 4.3
+ */
+ private void addVDB() throws Exception{
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ conn = getConnection(VDB_NAME, configFile);
+ executeStatement("SELECT * FROM smalla"); //$NON-NLS-1$
+ }
+
+
+ private void executePreparedStatement(String query) throws Exception{
+ PreparedStatement pstmt = conn.prepareStatement(query);
+ pstmt.execute();
+ result = pstmt.getResultSet();
+ if (!result.next()) {
+ fail("SELECT * FROM smalla"); //$NON-NLS-1$
+ }
+ stmt = pstmt;
+ }
+
+ private void executeStatement(String query) throws Exception{
+ stmt = conn.createStatement();
+ result = stmt.executeQuery(query);
+ if (!result.next()) {
+ fail("SELECT * FROM smalla"); //$NON-NLS-1$
+ }
+ }
+}
Property changes on:
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/Util.java
===================================================================
--- trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/Util.java
(rev 0)
+++ trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/Util.java 2009-08-25
19:38:18 UTC (rev 1277)
@@ -0,0 +1,128 @@
+package org.teiid.runtime.adminapi;
+
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+
+public class Util {
+
+
+ /* Utility methods */
+ public static Connection getConnection(String mmUrl) throws Exception {
+
+ final String DRIVER_NAME = "org.teiid.jdbc.TeiidDriver"; //$NON-NLS-1$
+ final String USER_NAME = "admin";//$NON-NLS-1$
+ final String PASSWORD = "teiid";//$NON-NLS-1$
+
+ Connection conn = null;
+ try {
+ // using the driver
+
+ Class driverClass = Class.forName(DRIVER_NAME);
+ if ( driverClass == null) {
+ throw new Exception("load class for Driver");//$NON-NLS-1$
+ }
+
+ Driver driver = (Driver) driverClass.newInstance();
+
+ DriverManager.registerDriver( driver );
+ conn = DriverManager.getConnection(mmUrl, USER_NAME, PASSWORD);
+ } catch (Exception e) {
+ throw e;
+ }
+
+ return conn;
+ }
+
+ public static void closeQuietly(Connection conn) {
+ try {
+ if (conn != null ) try { conn.close(); } catch (Exception e) {}
+ } catch (Exception x) {
+ // tastes good
+ }
+ }
+
+ public static void closeQuietly(Statement stmt) {
+ try {
+ if (stmt != null ) try { stmt.close(); } catch (Exception e) {}
+ } catch (Exception x) {
+ // tastes good
+ }
+ }
+
+ public static void closeQuietly(ResultSet rs) {
+ try {
+ if (rs != null ) try { rs.close(); } catch (Exception e) {}
+ } catch (Exception x) {
+ // tastes good
+ }
+ }
+
+ public static void closeQuietly(Connection conn, Statement stmt, ResultSet rs) {
+ closeQuietly(conn);
+ closeQuietly(stmt);
+ closeQuietly(rs);
+ }
+
+ public static String getStackTraceAsString(Exception e) {
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(stringWriter);
+ e.printStackTrace(printWriter);
+ StringBuffer error = stringWriter.getBuffer();
+ return error.toString();
+ }
+
+ @SuppressWarnings("deprecation")
+ public static char[] getCharacterFile(String file) throws IOException {
+
+ URL url = new File(file).toURL();
+
+ InputStream in = url.openStream();
+ CharArrayWriter out = new CharArrayWriter(10 * 1024);
+ int b = 0;
+ while ((b = in.read()) != -1) {
+ out.write(b);
+ }
+ return out.toCharArray();
+ }
+
+ @SuppressWarnings("deprecation")
+ public static byte[] getBinaryFile(String file) throws IOException {
+
+ URL url = new File(file).toURL();
+
+ InputStream in = url.openStream();
+ ByteArrayOutputStream out = new ByteArrayOutputStream(10 * 1024);
+ int b = 0;
+ while ((b = in.read()) != -1) {
+ out.write(b);
+ }
+ return out.toByteArray();
+ }
+
+ public static void writeToFile(String name, byte[] contents) throws Exception {
+ FileOutputStream f = new FileOutputStream(name);
+ f.write(contents);
+ f.close();
+ }
+
+ public static void writeToFile(String name, char[] contents) throws Exception {
+ FileWriter f = new FileWriter(name);
+ f.write(contents);
+ f.close();
+ }
+}
Property changes on:
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/Util.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/resources/admin/Admin.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/Admin.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/BQT1Binding.cdk
===================================================================
--- trunk/test-integration/src/test/resources/admin/BQT1Binding.cdk
(rev 0)
+++ trunk/test-integration/src/test/resources/admin/BQT1Binding.cdk 2009-08-25 19:38:18
UTC (rev 1277)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ConfigurationDocument>
+ <Header>
+ <ConfigurationVersion>4.2</ConfigurationVersion>
+ <ApplicationCreatedBy>MetaMatrix Console</ApplicationCreatedBy>
+ <ApplicationVersion>4.0:1949</ApplicationVersion>
+ <UserCreatedBy>MetaMatrixAdmin</UserCreatedBy>
+ <MetaMatrixSystemVersion>4.2</MetaMatrixSystemVersion>
+ <Time>2004-11-15T14:25:39.375-06:00</Time>
+ </Header>
+ <ComponentTypes>
+ <ComponentType Name="Loopback Connector"
ComponentTypeCode="2" Deployable="true" Deprecated="false"
Monitorable="false" SuperComponentType="Connector"
ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup"
LastChangedDate="2004-11-12T03:46:02.937-06:00"
CreatedBy="ConfigurationStartup"
CreationDate="2004-11-12T03:46:02.937-06:00">
+ <PropertyDefinition Name="CapabilitiesClass"
DisplayName="Capabilities Class" ShortDescription=""
DefaultValue="" Multiplicity="1" PropertyType="String"
ValueDelimiter="," IsConstrainedToAllowedValues="true"
IsExpert="true" IsHidden="false" IsMasked="false"
IsModifiable="true" IsPreferred="false" />
+ <PropertyDefinition Name="RowCount" DisplayName="Rows Per
Query" ShortDescription="" DefaultValue="1"
Multiplicity="1" PropertyType="String" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="true"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="true" />
+ <PropertyDefinition Name="ConnectorClass"
DisplayName="Connector Class" ShortDescription=""
DefaultValue="com.metamatrix.connector.loopback.LoopbackConnector"
Multiplicity="1" PropertyType="String" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="true"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="false" />
+ <PropertyDefinition Name="WaitTime" DisplayName="Max Random
Wait Time" ShortDescription="" DefaultValue="0"
Multiplicity="1" PropertyType="String" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="true"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="false" />
+ <PropertyDefinition Name="ConnectorClassPath"
DisplayName="Class Path" ShortDescription=""
DefaultValue="extensionjar:loopbackconn.jar;extensionjar:jdbcconn.jar"
Multiplicity="1" PropertyType="String" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="false"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="false" />
+ </ComponentType>
+ </ComponentTypes>
+ <ConnectorBindings>
+ <Connector Name="BQT1 Oracle 9i Simple Cap"
ComponentType="Loopback Connector" LastChangedBy="metamatrixadmin"
LastChangedDate="2005-07-20T12:58:35.551-06:00"
CreatedBy="metamatrixadmin"
CreationDate="2005-07-20T11:39:55.961-06:00" QueuedService="false"
routingUUID="mmuuid:a6ea7cc0-c651-1f91-940a-b13465b430eb">
+ <Properties>
+ <Property Name="MaxResultRows">10000</Property>
+ <Property
Name="ConnectorThreadTTL">120000</Property>
+ <Property Name="ConnectorMaxThreads">5</Property>
+ <Property
Name="metamatrix.service.essentialservice">false</Property>
+ <Property
Name="ConnectorClassPath">extensionjar:loopbackconn.jar;extensionjar:jdbcconn.jar</Property>
+ <Property Name="RowCount">100</Property>
+ <Property
Name="ServiceClassName">com.metamatrix.server.connector.service.ConnectorService</Property>
+ <Property
Name="ConnectorClass">com.metamatrix.connector.loopback.LoopbackConnector</Property>
+ <Property Name="WaitTime">0</Property>
+ </Properties>
+ </Connector>
+ </ConnectorBindings>
+</ConfigurationDocument>
\ No newline at end of file
Added: trunk/test-integration/src/test/resources/admin/Empty.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/Empty.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/QT_Ora9DSwDEF.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/QT_Ora9DSwDEF.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/TestEmpty.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/TestEmpty.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/TestORS.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/TestORS.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/TestORS1.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/TestORS1.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/TestORSInvalid.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/TestORSInvalid.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/dqp.properties
===================================================================
--- trunk/test-integration/src/test/resources/admin/dqp.properties
(rev 0)
+++ trunk/test-integration/src/test/resources/admin/dqp.properties 2009-08-25 19:38:18 UTC
(rev 1277)
@@ -0,0 +1,12 @@
+dqp.configFile=../../../../target/scratch/configuration.xml
+dqp.buffer.usedisk=false
+xa.enable_recovery=false
+dqp.deploydir=../../../../target/scratch
+dqp.workdir=../../../../target/scratch/work
+membership.enabled=true
+membership.superUser=admin
+membership.superUserPassword=teiid
+auth.check_entitlements=false
+dqp.userDefinedFunctionsFile=extensionjar:FunctionDefinitions.xmi
+processName=localhost
+dqp.extensions=../../../../target/scratch/extensions/;./extensions
\ No newline at end of file
Property changes on: trunk/test-integration/src/test/resources/admin/dqp.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/resources/admin/extensions/FunctionDefinitions.xmi
===================================================================
--- trunk/test-integration/src/test/resources/admin/extensions/FunctionDefinitions.xmi
(rev 0)
+++
trunk/test-integration/src/test/resources/admin/extensions/FunctionDefinitions.xmi 2009-08-25
19:38:18 UTC (rev 1277)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!-- Copyright (c) 2000-2005 MetaMatrix, Inc. All rights reserved. -->
+<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:Diagram="http://www.metamatrix.com/metamodels/Diagram"
xmlns:mmcore="http://www.metamatrix.com/metamodels/Core"
xmlns:mmfunction="http://www.metamatrix.com/metamodels/MetaMatrixFun...
+ <mmcore:ModelAnnotation
xmi:uuid="mmuuid:476bf340-56da-1ebb-a41d-ec14fd2bd1f4"
primaryMetamodelUri="http://www.metamatrix.com/metamodels/MetaMatrix...
+ <Diagram:DiagramContainer
xmi:uuid="mmuuid:0a2f9c80-0014-1f04-862e-867a59458599">
+ <diagram xmi:uuid="mmuuid:094abac0-0014-1f04-862e-867a59458599"
type="packageDiagramType"
target="mmuuid/476bf340-56da-1ebb-a41d-ec14fd2bd1f4">
+ <diagramEntity xmi:uuid="mmuuid:8b0e9c40-0017-1f04-862e-867a59458599"
name="GetSystemProperty"
modelObject="mmuuid/1007f880-0016-1f04-862e-867a59458599"
xPosition="39" yPosition="5" height="86"
width="150"/>
+ <diagramEntity xmi:uuid="mmuuid:2a88da80-002a-1f04-862e-867a59458599"
name="GetSystemProperty"
modelObject="mmuuid/a912c380-0029-1f04-862e-867a59458599"
xPosition="34" yPosition="108" height="71"
width="150"/>
+ </diagram>
+ </Diagram:DiagramContainer>
+ <mmfunction:ScalarFunction
xmi:uuid="mmuuid:1007f880-0016-1f04-862e-867a59458599"
name="GetSystemProperty" category="MyFunctions"
invocationClass="org.teiid.runtime.adminapi.MyFunctions"
invocationMethod="getProperty" deterministic="true">
+ <inputParameters xmi:uuid="mmuuid:e48dac00-0082-1f04-862e-867a59458599"
name="prop" type="string"/>
+ <returnParameter xmi:uuid="mmuuid:98d39a00-0036-1f04-862e-867a59458599"
type="string"/>
+ </mmfunction:ScalarFunction>
+ <mmfunction:ScalarFunction
xmi:uuid="mmuuid:a912c380-0029-1f04-862e-867a59458599"
name="getpushdown" category="MyFunctions"
pushDown="REQUIRED"
invocationClass="org.teiid.runtime.adminapi.MyFunctions"
invocationMethod="getPropertyNoArgs" deterministic="true">
+ <returnParameter xmi:uuid="mmuuid:675e4cc1-003d-1f04-862e-867a59458599"
type="string"/>
+ </mmfunction:ScalarFunction>
+ <mmfunction:ScalarFunction
xmi:uuid="mmuuid:a912c380-0029-1f04-862e-867a59458599" name="getxyz"
category="MyFunctions"
invocationClass="org.teiid.runtime.adminapi.MyFunctions"
invocationMethod="getPropertyNoArgs" deterministic="true">
+ <returnParameter xmi:uuid="mmuuid:675e4cc1-003d-1f04-862e-867a59458599"
type="string"/>
+ </mmfunction:ScalarFunction>
+
+ <mmcore:AnnotationContainer
xmi:uuid="mmuuid:7f2b50c0-00fe-1f04-862e-867a59458599">
+ <annotations xmi:uuid="mmuuid:7e372cc0-00fe-1f04-862e-867a59458599"
description="No arg getter"
annotatedObject="mmuuid/1007f880-0016-1f04-862e-867a59458599"/>
+ <annotations xmi:uuid="mmuuid:43050ec0-06d4-1f04-862e-867a59458599"
description=""
annotatedObject="mmuuid/a912c380-0029-1f04-862e-867a59458599"/>
+ <annotations xmi:uuid="mmuuid:892e2640-06d7-1f04-862e-867a59458599"
description="Property name"
annotatedObject="mmuuid/e48dac00-0082-1f04-862e-867a59458599"/>
+ <annotations xmi:uuid="mmuuid:f2af3440-06d9-1f04-862e-867a59458599"
description="System property"
annotatedObject="mmuuid/98d39a00-0036-1f04-862e-867a59458599"/>
+ </mmcore:AnnotationContainer>
+</xmi:XMI>
Property changes on:
trunk/test-integration/src/test/resources/admin/extensions/FunctionDefinitions.xmi
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/resources/admin/loopback.cdk
===================================================================
--- trunk/test-integration/src/test/resources/admin/loopback.cdk
(rev 0)
+++ trunk/test-integration/src/test/resources/admin/loopback.cdk 2009-08-25 19:38:18 UTC
(rev 1277)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ConfigurationDocument>
+ <Header>
+ <ConfigurationVersion>4.2</ConfigurationVersion>
+ <ApplicationCreatedBy>MetaMatrix Console</ApplicationCreatedBy>
+ <ApplicationVersion>4.0:1949</ApplicationVersion>
+ <UserCreatedBy>MetaMatrixAdmin</UserCreatedBy>
+ <MetaMatrixSystemVersion>4.2</MetaMatrixSystemVersion>
+ <Time>2004-11-15T14:25:39.375-06:00</Time>
+ </Header>
+ <ComponentTypes>
+ <ComponentType Name="Loopback Connector"
ComponentTypeCode="2" Deployable="true" Deprecated="false"
Monitorable="false" SuperComponentType="Connector"
ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup"
LastChangedDate="2004-11-12T03:46:02.937-06:00"
CreatedBy="ConfigurationStartup"
CreationDate="2004-11-12T03:46:02.937-06:00">
+ <ComponentTypeDefn Deprecated="false">
+ <PropertyDefinition Name="CapabilitiesClass"
DisplayName="Capabilities Class" ShortDescription=""
DefaultValue="" Multiplicity="1" PropertyType="String"
ValueDelimiter="," IsConstrainedToAllowedValues="true"
IsExpert="true" IsHidden="false" IsMasked="false"
IsModifiable="true" IsPreferred="false" />
+ </ComponentTypeDefn>
+ <ComponentTypeDefn Deprecated="false">
+ <PropertyDefinition Name="RowCount" DisplayName="Rows
Per Query" ShortDescription="" DefaultValue="1"
Multiplicity="1" PropertyType="String" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="true"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="true" />
+ </ComponentTypeDefn>
+ <ComponentTypeDefn Deprecated="false">
+ <PropertyDefinition Name="ConnectorClass"
DisplayName="Connector Class" ShortDescription=""
DefaultValue="com.metamatrix.connector.loopback.LoopbackConnector"
Multiplicity="1" PropertyType="String" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="true"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="false" />
+ </ComponentTypeDefn>
+ <ComponentTypeDefn Deprecated="false">
+ <PropertyDefinition Name="WaitTime" DisplayName="Max
Random Wait Time" ShortDescription="" DefaultValue="0"
Multiplicity="1" PropertyType="String" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="true"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="false" />
+ </ComponentTypeDefn>
+ <ComponentTypeDefn Deprecated="false">
+ <PropertyDefinition Name="ConnectorClassPath"
DisplayName="Class Path" ShortDescription=""
DefaultValue="extensionjar:loopbackconn.jar;extensionjar:jdbcconn.jar"
Multiplicity="1" PropertyType="String" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="false"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="false" />
+ </ComponentTypeDefn>
+ </ComponentType>
+ </ComponentTypes>
+ <ConnectorBindings>
+ <Connector Name="TestCDK" ComponentType="Loopback
Connector" LastChangedBy="metamatrixadmin"
LastChangedDate="2004-11-15T11:46:14.500-06:00"
CreatedBy="metamatrixadmin"
CreationDate="2004-11-15T11:46:14.500-06:00"
QueuedService="false">
+ <Properties>
+ <Property Name="MaxResultRows">10000</Property>
+ <Property
Name="ConnectorThreadTTL">120000</Property>
+ <Property Name="ConnectorMaxThreads">5</Property>
+ <Property
Name="metamatrix.service.essentialservice">false</Property>
+ <Property
Name="ConnectorClassPath">extensionjar:loopbackconn.jar;extensionjar:jdbcconn.jar</Property>
+ <Property Name="RowCount">1</Property>
+ <Property
Name="ServiceClassName">com.metamatrix.server.connector.service.ConnectorService</Property>
+ <Property
Name="ConnectorClass">com.metamatrix.connector.loopback.LoopbackConnector</Property>
+ <Property Name="WaitTime">0</Property>
+ </Properties>
+ </Connector>
+ </ConnectorBindings>
+</ConfigurationDocument>
+
Added: trunk/test-integration/src/test/resources/admin/loopback_archive.caf
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/loopback_archive.caf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/loopbackconn.jar
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/loopbackconn.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream