[teiid-commits] teiid SVN: r1479 - in trunk/test-integration/db/src/main/java/org/teiid/test/framework: connection and 1 other directory.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Thu Sep 24 10:45:26 EDT 2009


Author: vhalbert at redhat.com
Date: 2009-09-24 10:45:26 -0400 (Thu, 24 Sep 2009)
New Revision: 1479

Modified:
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java
   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/DataSourceConnection.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
Log:
Teiid 773 - working on a hudson timeout issue, not seeing it locally

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java	2009-09-24 14:40:50 UTC (rev 1478)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java	2009-09-24 14:45:26 UTC (rev 1479)
@@ -5,6 +5,7 @@
 import java.util.Properties;
 
 import org.teiid.test.framework.connection.ConnectionStrategyFactory;
+import org.teiid.test.util.PropUtils;
 
 public class ConfigPropertyLoader {
 		
@@ -32,21 +33,8 @@
 		}
 	    
 		private static void loadProperties(String filename) {
-			props = System.getProperties();
-		    try {
-		        InputStream in = ConfigPropertyLoader.class.getResourceAsStream("/"+ filename);
-		        if (in != null) {
-		        	Properties lprops = new Properties();
-		        	lprops.load(in);
-		        	props.putAll(lprops);
-		        	
-		        }
-		        else {
-		        	throw new RuntimeException("Failed to load properties from file '"+filename+ "' configuration file");
-		        }
-		    } catch (IOException e) {
-		        throw new RuntimeException("Error loading properties from file '"+filename+ "'" + e.getMessage());
-		    }
+			props =PropUtils.loadProperties("/"+ filename, System.getProperties());
+
 		}
 		
 		public static void cleanup() {

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java	2009-09-24 14:40:50 UTC (rev 1478)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java	2009-09-24 14:45:26 UTC (rev 1479)
@@ -9,6 +9,7 @@
 import java.util.Set;
 
 import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.connection.ConnectionStrategyFactory;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
@@ -30,29 +31,45 @@
 
 	    }
 	    
-	    
-	    protected Set getDataSources() {
-	    	Set dss = null;
+	    protected void setupData(TransactionQueryTest test) {
+        	test.setDataSources(connStrategy.getDataSources());
+        	test.setupDataSources();
 	    	
-	    	
-	    	return dss;
 	    }
 	    
-   	    
 	    protected void before(TransactionQueryTest test){}
 	    
 	    protected void after(TransactionQueryTest test) {}
 	        
 	    public void runTransaction(TransactionQueryTest test) {
+	    	
+	    	try {
+	    			    		
+		        try {		 
+		        	
+		        	runIt(test);
+		        	
+		        } finally {
+		        	debug("	test.cleanup");
+
+		        	test.cleanup();
+		        }
+	    		
+	    	} finally {
+	    		// cleanup all connections created for this test.
+	    		ConnectionStrategyFactory.destroyInstance();
+	    	}
+	    }
+	    
+	    private void runIt(TransactionQueryTest test) {
 	    		    	
 	    	detail("Start transaction test: " + test.getTestName());
 
 	        try {  
-	        	test.setDataSources(connStrategy.getDataSources());
-	        	test.setupDataSources();
+	        	setupData(test);
 	        	
 	        	debug("	setConnection");
-	            test.setConnection(getConnection());
+	            test.setConnection(this.connStrategy.getConnection());
 	            test.setExecutionProperties(this.props);
 	            debug("	before(test)");
 	                        
@@ -86,7 +103,7 @@
 	        }
 	        
             if (test.exceptionExpected() && !test.exceptionOccurred()) {
-            	throw new TransactionRuntimeException("Expected exception, but one did not occur");
+            	throw new TransactionRuntimeException("Expected exception, but one did not occur for test: " + this.getClass().getName() + "." + test.getTestName());
             }
 	        
 	        try {
@@ -99,33 +116,25 @@
 	        }catch(Exception e) {
 	            throw new TransactionRuntimeException(e);
 	        }
-	        
-            debug("	test.cleanup");
-
-            test.cleanup();
             
 	    	detail("Completed transaction test: " + test.getTestName());
 
 
-	    }
+	    }       
 	    
-	    protected Connection getConnection() throws QueryTestFailedException {
-	    	return this.connStrategy.getConnection();
-	    }	        
-	    
 	    public Properties getEnvironmentProperties() {
 	    	return props;
 	    }
 	    
 	    protected void debug(String message) {
 	    	if (debug) {
-	    		System.out.println(message);
+	    		System.out.println("[" + this.getClass().getSimpleName() + "] " + message);
 	    	}
 	    	
 	    }
 	    
 	    protected void detail(String message) {
-	    	System.out.println(message);
+	    	System.out.println("[" + this.getClass().getSimpleName() + "] " + message);
 	    }
 	    
 

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java	2009-09-24 14:40:50 UTC (rev 1478)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java	2009-09-24 14:45:26 UTC (rev 1479)
@@ -33,7 +33,8 @@
 	
 	
 	/**
-	 * Called by the @link TransactionContainer to set the datasoures used to create the connector bindings.
+	 * Called by the @link TransactionContainer to set the datasoures used to create the connector bindings and
+	 * used to create direct connection to the sources.
 	 * @param datasources
 	 *
 	 * @since

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	2009-09-24 14:40:50 UTC (rev 1478)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java	2009-09-24 14:45:26 UTC (rev 1479)
@@ -63,6 +63,14 @@
      */
     public abstract Connection getConnection() throws QueryTestFailedException;
     
+    /**
+     * Implement shutdown of your type of connecton
+     * 
+     *
+     * @since
+     */
+    public abstract void shutdown();
+
     public Connection getAdminConnection() throws QueryTestFailedException{
     	return null;
     }
@@ -72,7 +80,6 @@
     	return autoCommit;
     }
 
-    public abstract void shutdown();
     
     public XAConnection getXAConnection() throws QueryTestFailedException {
         return null;

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java	2009-09-24 14:40:50 UTC (rev 1478)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java	2009-09-24 14:45:26 UTC (rev 1479)
@@ -20,27 +20,27 @@
 import com.metamatrix.jdbc.EmbeddedDataSource;
 
 public class DataSourceConnection extends ConnectionStrategy {
-	
-	   public static final String DS_USER = "user"; //$NON-NLS-1$
-	    
-	    // need both user variables because Teiid uses 'user' and connectors use 'username'
-	    public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
-	    public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD;     //$NON-NLS-1$
-	    
-	    // the driver is only used for making direct connections to the source, the 
-	    // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE driver class
-	    public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
-	 
-	    public static final String DS_SERVERNAME = "servername"; //$NON-NLS-1$
-	    public static final String DS_SERVERPORT = "portnumber"; //$NON-NLS-1$
-	    public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
-	    public static final String DS_DATABASENAME = "databasename"; //$NON-NLS-1$
-	    public static final String DS_APPLICATION_NAME = "application-name"; //$NON-NLS-1$
-	    
-//	    public static final String JNDINAME_USERTXN = "usertxn-jndiname"; //$NON-NLS-1$
-	    
 
+	public static final String DS_USER = "user"; //$NON-NLS-1$
 
+	// need both user variables because Teiid uses 'user' and connectors use
+	// 'username'
+	public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
+	public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD; //$NON-NLS-1$
+
+	// the driver is only used for making direct connections to the source, the
+	// connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE
+	// driver class
+	public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
+
+	public static final String DS_SERVERNAME = "servername"; //$NON-NLS-1$
+	public static final String DS_SERVERPORT = "portnumber"; //$NON-NLS-1$
+	public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
+	public static final String DS_DATABASENAME = "databasename"; //$NON-NLS-1$
+	public static final String DS_APPLICATION_NAME = "application-name"; //$NON-NLS-1$
+
+	//	    public static final String JNDINAME_USERTXN = "usertxn-jndiname"; //$NON-NLS-1$
+
 	private String driver = null;
 	private String username = null;
 	private String pwd = null;
@@ -48,106 +48,109 @@
 	private String databaseName = null;
 	private String serverName = null;
 	private String portNumber = null;
-	
-	
-    private XAConnection xaConnection;    
- 
-   public DataSourceConnection(Properties props) throws QueryTestFailedException {
-	   super(props);
-   }
 
-   
+	private XAConnection xaConnection;
 
-	public void validate()  {
-	   	databaseName = this.getEnvironment().getProperty(DS_DATABASENAME);
-   	if (databaseName == null || databaseName.length() == 0) {
-   		throw new TransactionRuntimeException("Property " + DS_DATABASENAME + " was not specified");
-   	}
-   	
-	   	serverName = this.getEnvironment().getProperty(DS_SERVERNAME);
-   	if (serverName == null || serverName.length() == 0) {
-   		throw new TransactionRuntimeException("Property " + DS_SERVERNAME + " was not specified");
-   	}
+	public DataSourceConnection(Properties props)
+			throws QueryTestFailedException {
+		super(props);
+	}
 
-   	
-   	this.portNumber = this.getEnvironment().getProperty(DS_SERVERPORT);
-       
-       this.applName = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
-       
-       driver = this.getEnvironment().getProperty(DS_DRIVER);
-   	if (driver == null || driver.length() == 0) {
-   		throw new TransactionRuntimeException("Property " + DS_DRIVER + " was not specified");
-   	}
-   	
-   	this.username = this.getEnvironment().getProperty(DS_USER);
-   	this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
-      	
+	public void validate() {
+		databaseName = this.getEnvironment().getProperty(DS_DATABASENAME);
+		if (databaseName == null || databaseName.length() == 0) {
+			throw new TransactionRuntimeException("Property " + DS_DATABASENAME
+					+ " was not specified");
+		}
+
+		serverName = this.getEnvironment().getProperty(DS_SERVERNAME);
+		if (serverName == null || serverName.length() == 0) {
+			throw new TransactionRuntimeException("Property " + DS_SERVERNAME
+					+ " was not specified");
+		}
+
+		this.portNumber = this.getEnvironment().getProperty(DS_SERVERPORT);
+
+		this.applName = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
+
+		driver = this.getEnvironment().getProperty(DS_DRIVER);
+		if (driver == null || driver.length() == 0) {
+			throw new TransactionRuntimeException("Property " + DS_DRIVER
+					+ " was not specified");
+		}
+
+		this.username = this.getEnvironment().getProperty(DS_USER);
+		if (username == null) {
+			this.username = this.getEnvironment().getProperty(DS_USERNAME);
+		}
+		this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
+
 	}
 
 	public Connection getConnection() throws QueryTestFailedException {
-       try {
-           return getXAConnection().getConnection();
-       } catch (QueryTestFailedException qtf) {
-    	   throw qtf;
-       } catch (Exception e) {
-    	   e.printStackTrace();
-           throw new QueryTestFailedException(e);
-       }
-   }
-   
-   public synchronized XAConnection getXAConnection() throws QueryTestFailedException {
-       if (xaConnection == null) {
-       	  validate();
-           try {
-               xaConnection = createConnection();
-           } catch (Exception e) {
-               throw new QueryTestFailedException(e);
-           }
-       }
-       return xaConnection;
-   }    
+		try {
+			return getXAConnection().getConnection();
+		} catch (QueryTestFailedException qtf) {
+			throw qtf;
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw new QueryTestFailedException(e);
+		}
+	}
 
-   private XAConnection createConnection() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
-       System.out.println("Creating Datasource Connection: \"" + this.serverName + " - " + this.databaseName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+	public synchronized XAConnection getXAConnection()
+			throws QueryTestFailedException {
+		if (xaConnection == null) {
+			validate();
+			try {
+				xaConnection = createConnection();
+			} catch (Exception e) {
+				throw new QueryTestFailedException(e);
+			}
+		}
+		return xaConnection;
+	}
 
-	   
-	   BaseDataSource dataSource = (BaseDataSource)Class.forName(this.driver).newInstance();
+	private XAConnection createConnection() throws SQLException,
+			InstantiationException, IllegalAccessException,
+			ClassNotFoundException {
+		System.out
+				.println("Creating Datasource Connection: \"" + this.serverName + " - " + this.databaseName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
 
-       dataSource.setDatabaseName(this.databaseName);
-       if (this.applName != null) {
-       	dataSource.setApplicationName(this.applName);
-       }
-       
-       if (dataSource instanceof EmbeddedDataSource) {
-           ((EmbeddedDataSource)dataSource).setBootstrapFile(this.serverName);
-       } else {
-           ((TeiidDataSource)dataSource).setServerName(this.serverName);
-           ((TeiidDataSource)dataSource).setPortNumber(Integer.parseInt(this.portNumber));            
-       }
-       
-       dataSource.setUser("admin");
-       dataSource.setPassword("teiid");
-       
-//       if (this.username != null) {
-//       	dataSource.setUser(this.username);
-//       	dataSource.setPassword(this.pwd);
-//       }
-	    	   
-       
-       return ((XADataSource)dataSource).getXAConnection();
-   }  
+		BaseDataSource dataSource = (BaseDataSource) Class.forName(this.driver)
+				.newInstance();
 
-   public void shutdown() {
-       try {
+		dataSource.setDatabaseName(this.databaseName);
+		if (this.applName != null) {
+			dataSource.setApplicationName(this.applName);
+		}
 
+		if (dataSource instanceof EmbeddedDataSource) {
+			((EmbeddedDataSource) dataSource).setBootstrapFile(this.serverName);
+		} else {
+			((TeiidDataSource) dataSource).setServerName(this.serverName);
+			((TeiidDataSource) dataSource).setPortNumber(Integer
+					.parseInt(this.portNumber));
+		}
 
-           if (this.xaConnection != null) {
-               this.xaConnection.close();
-           }
-       } catch (SQLException e) {
-           // ignore..
-       }
-       
-       this.xaConnection = null;
-   }
+		if (this.username != null) {
+			dataSource.setUser(this.username);
+			dataSource.setPassword(this.pwd);
+		}
+
+		return ((XADataSource) dataSource).getXAConnection();
+	}
+
+	public void shutdown() {
+		try {
+
+			if (this.xaConnection != null) {
+				this.xaConnection.close();
+			}
+		} catch (SQLException e) {
+			// ignore..
+		}
+
+		this.xaConnection = null;
+	}
 }

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java	2009-09-24 14:40:50 UTC (rev 1478)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java	2009-09-24 14:45:26 UTC (rev 1479)
@@ -13,10 +13,8 @@
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
-import com.metamatrix.jdbc.api.ExecutionProperties;
 
 
-
 /** 
  * The DriverConnection strategy that can get connections in standalone mode
  * or embedded mode. 



More information about the teiid-commits mailing list