[teiid-commits] teiid SVN: r2041 - trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Apr 9 13:38:57 EDT 2010


Author: vhalbert at redhat.com
Date: 2010-04-09 13:38:57 -0400 (Fri, 09 Apr 2010)
New Revision: 2041

Modified:
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
Log:
Teiid-773 -  changes to disable embedded type testing and fix the summary property and how it determines where to place the summary files

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java	2010-04-08 21:31:35 UTC (rev 2040)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java	2010-04-09 17:38:57 UTC (rev 2041)
@@ -33,290 +33,311 @@
 
 import com.metamatrix.common.util.PropertiesUtils;
 
+public abstract class ConnectionStrategy {
 
-public abstract class ConnectionStrategy {
-     
-    
     private Properties env = null;
-    private DataSourceFactory dsFactory;
-    // the useProxy is used for non-teiid connections so that the sources are closed and reconnected all the time
+    // private DataSourceFactory dsFactory;
+    // the useProxy is used for non-teiid connections so that the sources are
+    // closed and reconnected all the time
     private boolean useProxy = false;
-    
 
     public ConnectionStrategy(Properties props, DataSourceFactory dsf) {
 	this.env = PropertiesUtils.clone(props);
-	
-	this.dsFactory = dsf;
+
+	// this.dsFactory = dsf;
     }
-    
+
     /*
-     * Lifecycle methods for managing the  connection
+     * Lifecycle methods for managing the connection
      */
-    
+
     /**
      * Returns a connection
+     * 
      * @return Connection
      */
     public abstract Connection getConnection() throws QueryTestFailedException;
-    
+
     public boolean useProxy() {
 	return this.useProxy;
     }
-    
+
     void setUseProxy(boolean useproxy) {
 	this.useProxy = useproxy;
     }
-    
+
     /**
      * @since
      */
-    public void shutdown() {    
+    public void shutdown() {
 
     }
-    
-    public Connection getAdminConnection() throws QueryTestFailedException{
-    	return null;
+
+    public Connection getAdminConnection() throws QueryTestFailedException {
+	return null;
     }
-    
+
     private boolean autoCommit;
+
     public boolean getAutocommit() {
-    	return autoCommit;
+	return autoCommit;
     }
 
-    
     public XAConnection getXAConnection() throws QueryTestFailedException {
-        return null;
+	return null;
     }
-    
+
     /**
-     * In certain testcases, the data that being provided is already preconfigured and should not
-     * be touched by the {@link DataStore} processing.
+     * In certain testcases, the data that being provided is already
+     * preconfigured and should not be touched by the {@link DataStore}
+     * processing.
+     * 
      * @return
      */
     public boolean isDataStoreDisabled() {
 	return ConfigPropertyLoader.getInstance().isDataStoreDisabled();
-	}
-    
+    }
 
-    
-    
     public Properties getEnvironment() {
-    	return env;
+	return env;
     }
 
     public void setEnvironmentProperty(String key, String value) {
 	this.env.setProperty(key, value);
     }
-   
-  
-    
-   
-	void configure() throws QueryTestFailedException {
 
-		if (this.isDataStoreDisabled()) {
-			return;
-		}
+    void configure() throws QueryTestFailedException {
 
-		try {
-			// the the driver strategy is going to be used to connection
-			// directly to the connector binding
-			// source, then no administration can be done
-			Admin admin = AdminFactory.getInstance().createAdmin(this.env.getProperty("admin.user"), this.env.getProperty("admin.password").toCharArray(), this.env.getProperty("admin.url"));
+	if (this.isDataStoreDisabled()) {
+	    return;
+	} else {
+	    
+	 // commenting out until embedded testing is made available and its required to configure
+	 // the vdb and bindings in this mannder
 
-			java.sql.Connection conn = getConnection();
+	    if (true)
+		return;
+	}
 
-			if (!(conn instanceof ConnectionImpl)) {
-				TestLogger.log("ConnectionStrategy configuration:  connection is not of type MMConnection and therefore no vdb setup will be performed");
-				return;
-			}
+	try {
+	    // the the driver strategy is going to be used to connection
+	    // directly to the connector binding
+	    // source, then no administration can be done
+	    Admin admin = AdminFactory.getInstance().createAdmin(
+		    this.env.getProperty("admin.user"),
+		    this.env.getProperty("admin.password").toCharArray(),
+		    this.env.getProperty("admin.url"));
 
-			setupVDBConnectorBindings(admin);
+	    java.sql.Connection conn = getConnection();
 
-			// admin.restart();
-
-			int sleep = 5;
-
-			TestLogger.log("Bouncing the system..(wait " + sleep + " seconds)"); //$NON-NLS-1$
-			Thread.sleep(1000 * sleep);
-			TestLogger.log("done."); //$NON-NLS-1$
-
-		} catch (Throwable e) {
-			e.printStackTrace();
-
-			throw new TransactionRuntimeException(e.getMessage());
-		} finally {
-			// need to close and flush the connection after restarting
-			// this.shutdown();
-
-		}
-	}   
-    
-    protected void setupVDBConnectorBindings(Admin api) throws QueryTestFailedException {
-         
-    	try {
-    	    
-    	VDB vdb = null;
-	    Set<VDB> vdbs = api.getVDBs();
-	    if (vdbs == null || vdbs.isEmpty()) {
-		throw new QueryTestFailedException(
-			"AdminApi.GetVDBS returned no vdbs available");
+	    if (!(conn instanceof ConnectionImpl)) {
+		TestLogger
+			.log("ConnectionStrategy configuration:  connection is not of type MMConnection and therefore no vdb setup will be performed");
+		return;
 	    }
+	    
+	   	   
+	    // setupVDBConnectorBindings(admin);
 
-	    String urlString = this.env.getProperty(DriverConnection.DS_URL);
-	    JDBCURL url = new JDBCURL(urlString);
-	    TestLogger.logDebug("Trying to match VDB : " + url.getVDBName());
+	    // admin.restart();
 
-	    for (Iterator<VDB> iterator = vdbs.iterator(); iterator.hasNext();) {
-		VDB v = (VDB) iterator.next();
-		if (v.getName().equalsIgnoreCase(url.getVDBName())) {
-		    vdb = v;
-		}
+	    int sleep = 5;
 
-	    }
-	    if (vdbs == null) {
-		throw new QueryTestFailedException(
-			"GetVDBS did not return a vdb that matched "
-				+ url.getVDBName());
-	    }
-	    	    
-	    List<Model> models = vdb.getModels();
-	    Iterator<Model> modelIt = models.iterator();
-	    while (modelIt.hasNext()) {
-		Model m = modelIt.next();
+	    TestLogger.log("Bouncing the system..(wait " + sleep + " seconds)"); //$NON-NLS-1$
+	    Thread.sleep(1000 * sleep);
+	    TestLogger.log("done."); //$NON-NLS-1$
 
-		if (!m.isSource())
-		    continue;
+	} catch (Throwable e) {
+	    e.printStackTrace();
 
-		// get the mapping, if defined
-		String mappedName = this.env.getProperty(m.getName());
+	    throw new TransactionRuntimeException(e.getMessage());
+	} finally {
+	    // need to close and flush the connection after restarting
+	    // this.shutdown();
 
-		String useName = m.getName();
-		if (mappedName != null) {
-		    useName = mappedName;
-		}
+	}
+    }
 
-		org.teiid.test.framework.datasource.DataSource ds = this.dsFactory.getDatasource(useName, m.getName());
+    // protected void setupVDBConnectorBindings(Admin api) throws
+    // QueryTestFailedException {
+    //         
+    // try {
+    //    	    
+    // VDB vdb = null;
+    // Set<VDB> vdbs = api.getVDBs();
+    // if (vdbs == null || vdbs.isEmpty()) {
+    // throw new QueryTestFailedException(
+    // "AdminApi.GetVDBS returned no vdbs available");
+    // }
+    //
+    // String urlString = this.env.getProperty(DriverConnection.DS_URL);
+    // JDBCURL url = new JDBCURL(urlString);
+    // TestLogger.logDebug("Trying to match VDB : " + url.getVDBName());
+    //
+    // for (Iterator<VDB> iterator = vdbs.iterator(); iterator.hasNext();) {
+    // VDB v = (VDB) iterator.next();
+    // if (v.getName().equalsIgnoreCase(url.getVDBName())) {
+    // vdb = v;
+    // }
+    //
+    // }
+    // if (vdbs == null) {
+    // throw new QueryTestFailedException(
+    // "GetVDBS did not return a vdb that matched "
+    // + url.getVDBName());
+    // }
+    //	    	    
+    // List<Model> models = vdb.getModels();
+    // Iterator<Model> modelIt = models.iterator();
+    // while (modelIt.hasNext()) {
+    // Model m = modelIt.next();
+    //
+    // if (!m.isSource())
+    // continue;
+    //
+    // // get the mapping, if defined
+    // String mappedName = this.env.getProperty(m.getName());
+    //
+    // String useName = m.getName();
+    // if (mappedName != null) {
+    // useName = mappedName;
+    // }
+    //
+    // org.teiid.test.framework.datasource.DataSource ds =
+    // this.dsFactory.getDatasource(useName, m.getName());
+    //
+    // if (ds != null) {
+    //
+    //		    TestLogger.logInfo("Set up Connector Binding (model:mapping:type): " + m.getName() + ":" + useName + ":" + ds.getConnectorType()); //$NON-NLS-1$
+    //
+    // api.addConnectorBinding(ds.getName(),ds.getConnectorType(),
+    // ds.getProperties());
+    //
+    // api.assignBindingToModel(vdb.getName(), vdb.getVersion(), m.getName(),
+    // ds.getName(), ds.getProperty("jndi-name"));
+    //
+    // api.startConnectorBinding(api.getConnectorBinding(ds.getName()));
+    // } else {
+    // throw new QueryTestFailedException(
+    // "Error: Unable to create binding to map to model : "
+    // + m.getName() + ", the mapped name "
+    // + useName
+    // + " had no datasource properties defined");
+    // }
+    //
+    // }
+    //    		
+    // } catch (QueryTestFailedException qt) {
+    // throw qt;
+    // } catch (Exception t) {
+    // t.printStackTrace();
+    // throw new QueryTestFailedException(t);
+    // }
+    //
+    //    	
+    // }
 
-		if (ds != null) {
+    public synchronized Connection createDriverConnection(String identifier)
+	    throws QueryTestFailedException {
 
-		    TestLogger.logInfo("Set up Connector Binding (model:mapping:type): " + m.getName() + ":" + useName + ":" + ds.getConnectorType()); //$NON-NLS-1$
-
-		    api.addConnectionFactory(ds.getName(),ds.getConnectorType(), ds.getProperties());
-
-		    api.assignConnectionFactoryToModel(vdb.getName(), vdb.getVersion(), m.getName(), ds.getName(), ds.getProperty("jndi-name"));
-
-		    api.startConnectionFactory(ds.getName());
-		} else {
-		    throw new QueryTestFailedException(
-			    "Error: Unable to create binding to map to model : "
-				    + m.getName() + ", the mapped name "
-				    + useName
-				    + " had no datasource properties defined");
-		}
-
-	    }
-    		
-    	} catch (QueryTestFailedException qt) {
-    		throw qt;
-    	} catch (Exception t) {
-    		t.printStackTrace();
-    		throw new QueryTestFailedException(t);
-    	}
-
-    	
-    }
-    
-    public synchronized Connection createDriverConnection(String identifier) throws QueryTestFailedException  {
-
 	DataSource ds = null;
 	if (identifier != null) {
 	    ds = DataSourceMgr.getInstance().getDataSource(identifier);
 	}
 	if (ds == null) {
-	    	throw new TransactionRuntimeException(
-			"Program Error: DataSource is not mapped to Identifier " + identifier);
+	    throw new TransactionRuntimeException(
+		    "Program Error: DataSource is not mapped to Identifier "
+			    + identifier);
 	}
-	
+
 	Connection conn = ds.getConnection();
-	
-	if (conn != null) return conn;
-	
+
+	if (conn != null)
+	    return conn;
+
 	ConnectionStrategy cs = null;
 	if (identifier == null) {
 	    cs = new DriverConnection(ds.getProperties(), null);
- 		
- 	} else {
- 	    cs = new DriverConnection(ds.getProperties(), null);
- 	}
-	
+
+	} else {
+	    cs = new DriverConnection(ds.getProperties(), null);
+	}
+
 	conn = cs.getConnection();
-	
-	conn = (Connection)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {java.sql.Connection.class}, new CloseInterceptor(conn)); 
-	
+
+	conn = (Connection) Proxy.newProxyInstance(Thread.currentThread()
+		.getContextClassLoader(),
+		new Class[] { java.sql.Connection.class },
+		new CloseInterceptor(conn));
+
 	ds.setConnection(conn);
-		
+
 	return conn;
- 
-	
+
     }
 
-    
-    public synchronized XAConnection createDataSourceConnection(String identifier) throws QueryTestFailedException  {	     	
-	
+    public synchronized XAConnection createDataSourceConnection(
+	    String identifier) throws QueryTestFailedException {
+
 	DataSource ds = null;
 	if (identifier != null) {
 	    ds = DataSourceMgr.getInstance().getDataSource(identifier);
 	}
 	if (ds == null) {
-	    	throw new TransactionRuntimeException(
-			"Program Error: DataSource is not mapped to Identifier " + identifier);
+	    throw new TransactionRuntimeException(
+		    "Program Error: DataSource is not mapped to Identifier "
+			    + identifier);
 	}
-	
+
 	XAConnection conn = ds.getXAConnection();
-	
-	if (conn != null) return conn;
-	
+
+	if (conn != null)
+	    return conn;
+
 	ConnectionStrategy cs = null;
 	if (identifier == null) {
 	    cs = new DataSourceConnection(ds.getProperties(), null);
 	} else {
 	    cs = new DataSourceConnection(ds.getProperties(), null);
 	}
-	
+
 	conn = cs.getXAConnection();
-	
-	conn = (XAConnection)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {javax.sql.XAConnection.class}, new CloseInterceptor(conn)); 
 
-	
+	conn = (XAConnection) Proxy.newProxyInstance(Thread.currentThread()
+		.getContextClassLoader(),
+		new Class[] { javax.sql.XAConnection.class },
+		new CloseInterceptor(conn));
+
 	ds.setXAConnection(conn);
-	
+
 	return conn;
-	
 
     }
-    
+
     class CloseInterceptor implements InvocationHandler {
 
-        Connection conn;
-        XAConnection xaconn;
+	Connection conn;
+	XAConnection xaconn;
 
-        CloseInterceptor(Object conn) {
-            if (conn instanceof Connection) {
-        	this.conn = (Connection) conn;
-            } else {
-        	this.xaconn = (XAConnection) conn;
-            }
-        }
-        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-            if (method.getName().equals("close")) { //$NON-NLS-1$
-                return null;
-            }
-            try {
-                return method.invoke(this.conn, args);
-            } catch (InvocationTargetException e) {
-                throw e.getTargetException();
-            }
-        }
-    }  
-    
+	CloseInterceptor(Object conn) {
+	    if (conn instanceof Connection) {
+		this.conn = (Connection) conn;
+	    } else {
+		this.xaconn = (XAConnection) conn;
+	    }
+	}
+
+	public Object invoke(Object proxy, Method method, Object[] args)
+		throws Throwable {
+	    if (method.getName().equals("close")) { //$NON-NLS-1$
+		return null;
+	    }
+	    try {
+		return method.invoke(this.conn, args);
+	    } catch (InvocationTargetException e) {
+		throw e.getTargetException();
+	    }
+	}
+    }
+
 }



More information about the teiid-commits mailing list