[teiid-commits] teiid SVN: r1119 - in trunk: client/src/main/java/com/metamatrix/dqp/embedded and 9 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Jul 10 16:48:30 EDT 2009


Author: rareddy
Date: 2009-07-10 16:48:29 -0400 (Fri, 10 Jul 2009)
New Revision: 1119

Added:
   trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
   trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java
   trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
   trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java
Modified:
   trunk/build/kit-embedded/examples/portfolio/java/JDBCClient.java
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java
   trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java
   trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDriver.java
   trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java
   trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java
   trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
   trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
   trunk/embedded/src/main/java/org/teiid/transport/LogonImpl.java
   trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestCase3473.java
   trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestMMDatabaseMetaData.java
   trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestXQueryServices.java
Log:
TEIID-701: TeiidDriver has been modified to handle the "embedded" based URL format. So, user can now use the TeiidDriver for connecting to the Server instance though socket of invoke embedded runtime.

Modified: trunk/build/kit-embedded/examples/portfolio/java/JDBCClient.java
===================================================================
--- trunk/build/kit-embedded/examples/portfolio/java/JDBCClient.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/build/kit-embedded/examples/portfolio/java/JDBCClient.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -35,18 +35,18 @@
 			System.exit(-1);
 		}
 
-		System.out.println("Executing using the EmbeddedDriver");
+		System.out.println("Executing using the TeiidDriver");
 		execute(getDriverConnection(), args[0]);
 
 		System.out.println("");
-		System.out.println("Executing using the EmbeddedDataSource");
+		System.out.println("Executing using the TeiidDataSource");
 		// this is showing how to make a Data Source connection. 
 		execute(getDataSourceConnection(), args[0]);
 	}
 	
 	static Connection getDriverConnection() throws Exception {
 		String url = "jdbc:metamatrix:Portfolio";
-		Class.forName("com.metamatrix.jdbc.EmbeddedDriver");
+		Class.forName("org.teiid.jdbc.TeiidDriver");
 		
 		return DriverManager.getConnection(url);		
 	}

Modified: trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -53,7 +53,7 @@
     public static final String BOOTURL = "bootURL"; //$NON-NLS-1$
     public static final String ENABLE_SOCKETS = "sockets.enabled"; //$NON-NLS-1$
     public static final String HOST_ADDRESS = "hostAddress"; //$NON-NLS-1$
-	
+    public static final String DQP_BOOTSTRAP_FILE = "bootstrapFile"; //$NON-NLS-1$
     
     public interface BufferService {
         /**

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -954,7 +954,7 @@
     }
     
    
-    static String getResourceMessage(String key) {
+    protected static String getResourceMessage(String key) {
         ResourceBundle messages = ResourceBundle.getBundle(BUNDLE_NAME);          
         String messageTemplate = messages.getString(key);
         return MessageFormat.format(messageTemplate, (Object[])null);

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -517,7 +517,7 @@
         checkConnection();
         
         if (dbmm == null) {
-            dbmm = MMDatabaseMetaData.newInstance(getBaseDriver(), this);
+            dbmm = new MMDatabaseMetaData(this);
         }       
         return dbmm;
     }
@@ -938,13 +938,6 @@
 			((SocketServerConnection)this.serverConn).selectNewServerInstance(this.getDQP());
 		}
 	}
-	
-	public BaseDriver getBaseDriver() {
-		if (this.serverConn instanceof SocketServerConnection) {
-			return new TeiidDriver();
-		}
-		return new EmbeddedDriver();
-	}
 	
 	public boolean isSameProcess(MMConnection conn) throws CommunicationException {
 		return this.serverConn.isSameInstance(conn.serverConn);

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -24,6 +24,7 @@
 
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
+import java.sql.Driver;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
@@ -40,6 +41,8 @@
 import java.util.Map;
 import java.util.logging.Logger;
 
+import org.teiid.jdbc.TeiidDriver;
+
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.common.types.DataTypeManager;
@@ -306,21 +309,14 @@
 
     // driver's connection object used in constructin this object.
     private MMConnection driverConnection;
-    private BaseDriver driver;
 
-    static com.metamatrix.jdbc.api.DatabaseMetaData newInstance(BaseDriver driver, MMConnection connection) throws SQLException {
-        return new MMDatabaseMetaData(driver, connection);        
-    }
-    
     /**
      * <p>Constructor which initializes with the connection object on which metadata
      * is sought
      * @param driver's connection object.
      * @throws SQLException if the connection is already closed.
      */
-    MMDatabaseMetaData(BaseDriver driver, MMConnection connection) throws SQLException {
-        // set driver's connection object
-        this.driver = driver;
+    MMDatabaseMetaData(MMConnection connection) {
         this.driverConnection = connection;
     }
 
@@ -830,7 +826,7 @@
      * @throws SQLException if a database access error occurs.
      */
     public int getDatabaseMinorVersion() throws SQLException {
-        return this.driver.getMinorVersion();
+        return TeiidDriver.getInstance().getMinorVersion();
     }
 
     /**
@@ -839,7 +835,7 @@
      * @throws SQLException if a database access error occurs.
      */
     public int getDatabaseMajorVersion() throws SQLException {
-        return this.driver.getMajorVersion();
+        return TeiidDriver.getInstance().getMajorVersion();
     }
 
     /**
@@ -875,7 +871,7 @@
      * @throws SQLException if there is an error accessing product release info.
      */
     public String getDatabaseProductVersion() throws SQLException {
-        return this.driver.getMajorVersion() + "." + this.driver.getMinorVersion(); //$NON-NLS-1$
+        return TeiidDriver.getInstance().getMajorVersion() + "." + TeiidDriver.getInstance().getMinorVersion(); //$NON-NLS-1$
     }
 
     /**
@@ -892,7 +888,7 @@
      * @return int representing the driver's major version
      */
     public int getDriverMajorVersion() {
-        return this.driver.getMajorVersion();
+        return TeiidDriver.getInstance().getMajorVersion();
     }
 
     /**
@@ -900,7 +896,7 @@
      * @return int representing the driver's minor version
      */
     public int getDriverMinorVersion() {
-        return this.driver.getMinorVersion();
+        return TeiidDriver.getInstance().getMinorVersion();
     }
 
     /**
@@ -909,7 +905,7 @@
      * @throws SQLException, if the connection is already closed.
      */
     public String getDriverName() throws SQLException {
-        return this.driver.getDriverName();
+        return TeiidDriver.getInstance().getDriverName();
     }
 
     /**

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -43,7 +43,7 @@
     private static final String JDBC_PROTOCOL = "jdbc:teiid:"; //$NON-NLS-1$
     private static final String OLD_JDBC_PROTOCOL = "jdbc:metamatrix:"; //$NON-NLS-1$
     
-    private static final String[] KNOWN_PROPERTIES = {
+    public static final String[] KNOWN_PROPERTIES = {
         BaseDataSource.APP_NAME,
         BaseDataSource.VDB_NAME,
         BaseDataSource.VERSION,

Added: trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java	                        (rev 0)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -0,0 +1,437 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.metamatrix.common.classloader.PostDelegatingClassLoader;
+import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.api.ServerConnectionFactory;
+import com.metamatrix.common.comm.exception.CommunicationException;
+import com.metamatrix.common.comm.exception.ConnectionException;
+import com.metamatrix.common.protocol.MMURLConnection;
+import com.metamatrix.common.protocol.MetaMatrixURLStreamHandlerFactory;
+import com.metamatrix.common.protocol.URLHelper;
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
+import com.metamatrix.jdbc.BaseDataSource;
+import com.metamatrix.jdbc.JDBCPlugin;
+import com.metamatrix.jdbc.MMConnection;
+import com.metamatrix.jdbc.MMSQLException;
+import com.metamatrix.jdbc.util.MMJDBCURL;
+
+
+final class EmbeddedProfile {
+    /** 
+     * Match URL like
+     * - jdbc:metamatrix:BQT at c:/foo.properties;version=1..
+     * - jdbc:metamatrix:BQT at c:\\foo.properties;version=1..
+     * - jdbc:metamatrix:BQT@\\foo.properties;version=1..
+     * - jdbc:metamatrix:BQT@/foo.properties;version=1..
+     * - jdbc:metamatrix:BQT at ../foo.properties;version=1..
+     * - jdbc:metamatrix:BQT at ./foo.properties;version=1..
+     * - jdbc:metamatrix:BQT at file:///c:/foo.properties;version=1..
+     * - jdbc:metamatrix:BQT
+     * - jdbc:metamatrix:BQT;verson=1  
+     */
+    static final String URL_PATTERN = "jdbc:(teiid|metamatrix):(\\w+)@(([^;]*)[;]?)((.*)*)"; //$NON-NLS-1$
+    static final String BASE_PATTERN = "jdbc:(teiid|metamatrix):((\\w+)[;]?)(;([^@])+)*"; //$NON-NLS-1$
+
+    private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
+    
+    private static EmbeddedTransport currentTransport = null;
+    static Pattern urlPattern = Pattern.compile(URL_PATTERN);
+    static Pattern basePattern = Pattern.compile(BASE_PATTERN);
+    
+    /**
+     * This method tries to make a connection to the given URL. This class
+     * will return a null if this is not the right driver to connect to the given URL.
+     * @param The URL used to establish a connection.
+     * @return Connection object created
+     * @throws SQLException if it is unable to establish a connection to the MetaMatrix server.
+     */
+    public static Connection connect(String url, Properties info) 
+        throws SQLException {
+        Connection conn = null;
+        // create a properties obj if it is null
+        if (info == null) {
+            info = new Properties();
+        } else {
+        	info = PropertiesUtils.clone(info);
+        }
+
+        // parse the URL to add it's properties to properties object
+        parseURL(url, info);            
+        conn = createConnection(info);
+
+        // logging
+        String logMsg = JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess"); //$NON-NLS-1$
+        logger.fine(logMsg);
+        
+        return conn;
+
+    }
+    
+    static Connection createConnection(Properties info) throws SQLException{
+        
+        // first validate the properties as this may called from the EmbeddedDataSource
+        // and make sure we have all the properties we need.
+        validateProperties(info);
+        
+        URL dqpURL;
+		try {
+			dqpURL = URLHelper.buildURL(info.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE));
+		} catch (MalformedURLException e) {
+			throw MMSQLException.create(e);
+		}
+        
+        // now create the connection
+        EmbeddedTransport transport = getDQPTransport(dqpURL, info);                        
+        
+        Connection conn = transport.createConnection(dqpURL, info);
+        
+        return conn;
+    }
+    
+    /**
+     * Get the DQP transport or build the transport if one not available from the 
+     * DQP URL supplied. DQP transport contains all the details about DQP.   
+     * @param dqpURL - URL to the DQP.properties file
+     * @return EmbeddedTransport
+     * @throws SQLException
+     * @since 4.4
+     */
+    private synchronized static EmbeddedTransport getDQPTransport(URL dqpURL, Properties info) throws SQLException {      
+        EmbeddedTransport transport = currentTransport;
+        if (transport == null || !currentTransport.getURL().equals(dqpURL)) {
+        	// shutdown any previous instance; we do encourage single instance in a given VM
+       		shutdown();
+       		try {
+       			transport = new EmbeddedTransport(dqpURL, info);
+       		} catch (SQLException e) {
+                logger.log(Level.SEVERE, "Could not start the embedded engine", e); //$NON-NLS-1$
+       			throw e;
+       		}
+        }
+        currentTransport = transport;
+        return transport;
+    }
+
+    /**
+     * This method parses the URL and adds properties to the the properties object. These include required and any optional
+     * properties specified in the URL. 
+     * Expected URL format -- 
+     * jdbc:metamatrix:local:VDB@<pathToConfigFile>logFile=<logFile.log>; logLevel=<logLevel>;txnAutoWrap=<?>;credentials=mycredentials;
+     * 
+     * @param The URL needed to be parsed.
+     * @param The properties object which is to be updated with properties in the URL.
+     * @throws SQLException if the URL is not in the expected format.
+     */
+     static void parseURL(String url, Properties info) throws SQLException {
+        if (url == null || url.trim().length() == 0) {
+            String logMsg = getResourceMessage("EmbeddedDriver.URL_must_be_specified"); //$NON-NLS-1$
+            throw new SQLException(logMsg);
+        }
+                
+        try {
+            MMJDBCURL jdbcURL = new MMJDBCURL(url);
+
+            // Set the VDB Name
+            info.setProperty(BaseDataSource.VDB_NAME, jdbcURL.getVDBName());
+
+            // Need to resolve the URL fully, if we are using the default URL like
+            // jdbc:metamatrix:<vdbName>.., where as this fully qualifies to
+            // jdbc:metamatrix:<vdbName>@classpath:<vdbName>/mm.properties;...
+            String connectionURL = jdbcURL.getConnectionURL();
+            if (connectionURL == null) {
+                connectionURL = getDefaultConnectionURL();
+                info.setProperty("vdb.definition", jdbcURL.getVDBName()+".vdb"); //$NON-NLS-1$ //$NON-NLS-2$
+            }
+            info.setProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE, connectionURL);
+                       
+            Properties optionalParams = jdbcURL.getProperties();
+            MMJDBCURL.normalizeProperties(info);
+            
+            Enumeration keys = optionalParams.keys();
+            while (keys.hasMoreElements()) {
+                String propName = (String)keys.nextElement();
+                // Don't let the URL properties override the passed-in Properties object.
+                if (!info.containsKey(propName)) {
+                    info.setProperty(propName, optionalParams.getProperty(propName));
+                }
+            }
+            // add the property only if it is new because they could have
+            // already been specified either through url or otherwise.
+            if(! info.containsKey(BaseDataSource.VDB_VERSION) && jdbcURL.getVDBVersion() != null) {
+                info.setProperty(BaseDataSource.VDB_VERSION, jdbcURL.getVDBVersion());
+            }
+            if(!info.containsKey(BaseDataSource.APP_NAME)) {
+                info.setProperty(BaseDataSource.APP_NAME, BaseDataSource.DEFAULT_APP_NAME);
+            }
+        } catch (Exception e) {
+            throw new SQLException(e); 
+        }        
+    }
+
+    /** 
+     * Create the default connection URL, if one is not supplied
+     * @param jdbcURL
+     * @return default connection URL
+     */
+    static String getDefaultConnectionURL() {        
+        return "classpath:/deploy.properties"; //$NON-NLS-1$
+    }
+    
+    /** 
+     * validate some required properties 
+     * @param info the connection properties to be validated
+     * @throws SQLException
+     * @since 4.3
+     */
+    static void validateProperties(Properties info) throws SQLException {
+        // VDB Name has to be there
+        String value = null;
+        value = info.getProperty(BaseDataSource.VDB_NAME);
+        if (value == null || value.trim().length() == 0) {
+            String logMsg = getResourceMessage("MMDataSource.Virtual_database_name_must_be_specified"); //$NON-NLS-1$
+            throw new SQLException(logMsg);
+        }
+
+    }
+    
+    public static boolean acceptsURL(String url) {
+        Matcher m = urlPattern.matcher(url);
+        boolean matched = m.matches();
+        if (matched) {
+            // make sure the group (2) which is the name of the file 
+            // does not start with mm:// or mms://
+            String name = m.group(3).toLowerCase();
+            return (!name.startsWith("mm://") && !name.startsWith("mms://") && (name.endsWith(".properties")||name.endsWith(".properties;"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+        }
+
+        // Check if this can match our default one, then allow it.
+        m = basePattern.matcher(url);
+        matched = m.matches();
+        return matched;
+    }    
+
+     
+    /**
+     * Shutdown the DQP instance which has been started using the given URL 
+     * @param dqpURL
+     */
+    public static synchronized void shutdown() {
+        if (currentTransport != null) {
+        	currentTransport.shutdown();
+        	currentTransport = null;
+        }
+    }
+    
+    /** 
+     * inner class to hold DQP tansportMap object
+     * @since 4.3
+     */
+    static class EmbeddedTransport {
+		private ServerConnectionFactory connectionFactory;
+        private ClassLoader classLoader; 
+        private URL url;
+
+        public EmbeddedTransport(URL dqpURL, Properties info) throws SQLException {
+
+        	this.url = dqpURL;
+        	
+            //Load the properties from dqp.properties file
+            Properties props = loadDQPProperties(dqpURL);
+            props.putAll(info);
+            
+            props = PropertiesUtils.resolveNestedProperties(props);
+                        
+            // a non-delegating class loader will be created from where all third party dependent jars can be loaded
+            ArrayList<URL> runtimeClasspathList = new ArrayList<URL>();
+            String libLocation = props.getProperty(DQPEmbeddedProperties.DQP_LIBDIR, "./lib/"); //$NON-NLS-1$
+            if (!libLocation.endsWith("/")) { //$NON-NLS-1$
+            	libLocation = libLocation + "/"; //$NON-NLS-1$
+            }
+
+            // find jars in the "lib" directory; patches is reverse alpaha and not case sensitive so small letters then capitals
+            if (!EmbeddedProfile.getDefaultConnectionURL().equals(dqpURL.toString())) {
+	            runtimeClasspathList.addAll(libClassPath(dqpURL, libLocation+"patches/", MMURLConnection.REVERSEALPHA)); //$NON-NLS-1$
+	            runtimeClasspathList.addAll(libClassPath(dqpURL, libLocation, MMURLConnection.DATE));
+            
+	            try {
+		            String configLocation = props.getProperty(DQPEmbeddedProperties.VDB_DEFINITION, "./deploy/"); //$NON-NLS-1$ 
+		            if (!configLocation.endsWith("/")) { //$NON-NLS-1$
+		            	configLocation = configLocation + "/"; //$NON-NLS-1$
+		            }
+		            runtimeClasspathList.add(URLHelper.buildURL(dqpURL, configLocation));
+	            } catch(IOException e) {
+	            	// ignore..
+	            }            
+            }
+                        
+            URL[] dqpClassPath = runtimeClasspathList.toArray(new URL[runtimeClasspathList.size()]);
+            this.classLoader = new PostDelegatingClassLoader(dqpClassPath, this.getClass().getClassLoader(), new MetaMatrixURLStreamHandlerFactory());
+            
+            String logMsg = getResourceMessage("EmbeddedDriver.use_classpath"); //$NON-NLS-1$
+            logger.log(Level.FINER, logMsg + " " + Arrays.toString(dqpClassPath)); //$NON-NLS-1$
+
+            // Now using this class loader create the connection factory to the dqp.            
+            ClassLoader current = Thread.currentThread().getContextClassLoader();            
+            try {
+                Thread.currentThread().setContextClassLoader(this.classLoader);            
+                String className = "com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl"; //$NON-NLS-1$
+                Class<?> clazz = this.classLoader.loadClass(className);            
+                this.connectionFactory = (ServerConnectionFactory)clazz.newInstance();                
+            } catch (Exception e) {
+            	throw MMSQLException.create(e, "Could not load the embedded server, please ensure that your classpath is set correctly."); //$NON-NLS-1$                
+            } finally {
+                Thread.currentThread().setContextClassLoader(current);
+            }                        
+        }
+                
+        URL getURL() {
+        	return this.url;
+        }
+
+        /**
+         * Note that this only works when embedded loaded with "mmfile" protocol in the URL.
+         * @param dqpURL
+         * @return
+         */
+        private List<URL> libClassPath (URL dqpURL, String directory, String sortStyle) {
+            ObjectInputStream in =  null;
+            ArrayList<URL> urlList = new ArrayList<URL>();
+            try {
+            	urlList.add(URLHelper.buildURL(dqpURL, directory));
+                dqpURL = URLHelper.buildURL(dqpURL, directory+"?action=list&filter=.jar&sort="+sortStyle); //$NON-NLS-1$       
+                in = new ObjectInputStream(dqpURL.openStream());
+                String[] urls = (String[])in.readObject();
+                for (int i = 0; i < urls.length; i++) {
+                    urlList.add(URLHelper.buildURL(urls[i]));
+                }             
+            } catch(IOException e) {
+            	//ignore, treat as if lib does not exist
+            }  catch(ClassNotFoundException e) {
+            	//ignore, treat as if lib does not exist            	
+            } finally {
+                if (in != null) {
+                    try{in.close();}catch(IOException e) {}
+                }
+            }        
+            return urlList;
+        }        
+        
+        /**
+         * Load DQP Properties from the URL supplied. 
+         * @param dqpURL - URL to the "dqp.properties" object
+         * @return Properties loaded
+         * @throws SQLException
+         */
+        Properties loadDQPProperties(URL dqpURL) throws SQLException {
+            InputStream in = null;
+            try{
+                in = dqpURL.openStream();
+                Properties props = new Properties();
+                props.load(in);
+                
+                String logMsg = getResourceMessage("EmbeddedDriver.use_properties"); //$NON-NLS-1$
+                logger.log(Level.FINER, logMsg + props);
+                return props;
+            }catch(IOException e) {
+                String logMsg = getResourceMessage("EmbeddedTransport.invalid_dqpproperties_path", new Object[] {dqpURL}); //$NON-NLS-1$
+                throw MMSQLException.create(e, logMsg);
+            }finally {
+                if (in != null) {
+                    try{in.close();}catch(IOException e) {}
+                }
+            }
+        }
+     
+        /**
+         * Shutdown the current transport 
+         */
+        void shutdown() {
+            this.connectionFactory.shutdown(false);                                    
+        }
+        
+        /**
+         * Create a connection to the DQP defined by this transport object based on 
+         * properties supplied 
+         * @param info
+         * @return Connection
+         */
+        Connection createConnection(URL url, Properties info) throws SQLException {
+            ClassLoader current = null;            
+            try {
+                current = Thread.currentThread().getContextClassLoader();             
+                Thread.currentThread().setContextClassLoader(classLoader);       
+                try {
+                	info.setProperty(DQPEmbeddedProperties.BOOTURL, url.toExternalForm());
+					ServerConnection conn = connectionFactory.createConnection(info);
+					return new MMConnection(conn, info, url.toExternalForm());
+				} catch (CommunicationException e) {
+					throw MMSQLException.create(e);
+				} catch (ConnectionException e) {
+					throw MMSQLException.create(e);
+				}
+            } finally {
+                Thread.currentThread().setContextClassLoader(current);
+            }            
+        }
+        
+    }
+    
+    private static final String BUNDLE_NAME = "com.metamatrix.jdbc.basic_i18n"; //$NON-NLS-1$
+    
+
+    static String getResourceMessage(String key, Object[] args) {
+        ResourceBundle messages = ResourceBundle.getBundle(BUNDLE_NAME);          
+        String messageTemplate = messages.getString(key);
+        return MessageFormat.format(messageTemplate, args);
+    }
+    
+   
+    static String getResourceMessage(String key) {
+        ResourceBundle messages = ResourceBundle.getBundle(BUNDLE_NAME);          
+        String messageTemplate = messages.getString(key);
+        return MessageFormat.format(messageTemplate, (Object[])null);
+    }    
+
+}


Property changes on: trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java	                        (rev 0)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.metamatrix.common.api.MMURL;
+import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.exception.CommunicationException;
+import com.metamatrix.common.comm.exception.ConnectionException;
+import com.metamatrix.common.comm.platform.socket.client.SocketServerConnectionFactory;
+import com.metamatrix.common.util.ApplicationInfo;
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.jdbc.BaseDataSource;
+import com.metamatrix.jdbc.BaseDriver;
+import com.metamatrix.jdbc.JDBCPlugin;
+import com.metamatrix.jdbc.MMConnection;
+import com.metamatrix.jdbc.MMSQLException;
+import com.metamatrix.jdbc.api.ConnectionProperties;
+import com.metamatrix.jdbc.util.MMJDBCURL;
+
+/**
+ * <p> The java.sql.DriverManager class uses this class to connect to Teiid Server or Teiid Embedded.
+ * The TeiidDriver class has a static initializer, which
+ * is used to instantiate and register itself with java.sql.DriverManager. The
+ * DriverManager's <code>getConnection</code> method calls <code>connect</code>
+ * method on available registered drivers. </p>
+ */
+
+final class SocketProfile {
+	
+	private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
+    
+    /**
+     *  Suports JDBC URLS of format
+     *  - jdbc:teiid:BQT at mm://localhost:####;version=1
+     *  - jdbc:teiid:BQT at mms://localhost:####;version=1
+     *  - jdbc:teiid:BQT at mm(s)://host1:####,host2:####,host3:####;version=1
+     */
+    
+    // This host/port pattern allows just a . or a - to be in the host part.
+    static final String HOST_PORT_PATTERN = "[\\p{Alnum}\\.\\-]+:\\d+"; //$NON-NLS-1$
+    static final String URL_PATTERN = "jdbc:(metamatrix|teiid):(\\w+)@((mm[s]?://"+HOST_PORT_PATTERN+"(,"+HOST_PORT_PATTERN+")*)[;]?){1}((.*)*)"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    static Pattern urlPattern = Pattern.compile(URL_PATTERN);
+    
+    /**
+     * This method tries to make a connection to the given URL. This class
+     * will return a null if this is not the right driver to connect to the given URL.
+     * @param The URL used to establish a connection.
+     * @return Connection object created
+     * @throws SQLException if it is unable to establish a connection to the server.
+     */
+    public static Connection connect(String url, Properties info) throws SQLException {
+
+        MMConnection myConnection = null;
+        // create a properties obj if it is null
+        if(info == null) {
+            info = new Properties();
+        } else {
+            info = PropertiesUtils.clone(info);
+        }
+
+        try {
+            // parse the URL to add it's properties to properties object
+            parseURL(url, info);
+
+            myConnection = createConnection(url, info);
+        } catch (MetaMatrixCoreException e) {
+            logger.log(Level.SEVERE, "Could not create connection", e); //$NON-NLS-1$
+            throw MMSQLException.create(e, e.getMessage());
+        }
+
+        // logging
+        String logMsg = JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess"); //$NON-NLS-1$
+        logger.fine(logMsg);
+
+        return myConnection;
+    }
+
+    static MMConnection createConnection(String url, Properties info)
+        throws ConnectionException, CommunicationException {
+
+        ServerConnection serverConn = SocketServerConnectionFactory.getInstance().createConnection(info);
+
+        // construct a MMConnection object.
+        MMConnection connection = new MMConnection(serverConn, info, url);
+        return connection;
+    }
+
+    /**
+     * This method parses the URL and adds properties to the the properties object.
+     * These include required and any optional properties specified in the URL.
+     * @param The URL needed to be parsed.
+     * @param The properties object which is to be updated with properties in the URL.
+     * @throws SQLException if the URL is not in the expected format.
+     */
+    protected static void parseURL(String url, Properties info) throws SQLException {
+        if(url == null) {
+            String msg = JDBCPlugin.Util.getString("MMDriver.urlFormat"); //$NON-NLS-1$
+            throw new MMSQLException(msg);
+        }
+        try {
+            MMJDBCURL jdbcURL = new MMJDBCURL(url);
+            info.setProperty(BaseDataSource.VDB_NAME, jdbcURL.getVDBName());
+            info.setProperty(MMURL.CONNECTION.SERVER_URL, jdbcURL.getConnectionURL());
+            Properties optionalParams = jdbcURL.getProperties();
+            MMJDBCURL.normalizeProperties(info);
+            Enumeration keys = optionalParams.keys();
+            while (keys.hasMoreElements()) {
+                String propName = (String)keys.nextElement();
+                // Don't let the URL properties override the passed-in Properties object.
+                if (!info.containsKey(propName)) {
+                    info.setProperty(propName, optionalParams.getProperty(propName));
+                }
+            }
+            // add the property only if it is new because they could have
+            // already been specified either through url or otherwise.
+            if(!info.containsKey(BaseDataSource.VDB_VERSION) && jdbcURL.getVDBVersion() != null) {
+                info.setProperty(BaseDataSource.VDB_VERSION, jdbcURL.getVDBVersion());
+            }
+            if(!info.containsKey(BaseDataSource.APP_NAME)) {
+                info.setProperty(BaseDataSource.APP_NAME, BaseDataSource.DEFAULT_APP_NAME);
+            }
+
+        } catch(IllegalArgumentException iae) {
+            throw new MMSQLException(JDBCPlugin.Util.getString("MMDriver.urlFormat")); //$NON-NLS-1$
+        }  
+    }
+    
+
+    public static boolean acceptsURL(String url) {
+        Matcher m = urlPattern.matcher(url);
+        return m.matches();
+    }
+}
+
+


Property changes on: trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -22,11 +22,14 @@
 
 package org.teiid.jdbc;
 
+import java.net.URL;
 import java.sql.Connection;
+import java.sql.SQLException;
 import java.util.Properties;
 
 import com.metamatrix.common.api.MMURL;
-import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.common.protocol.URLHelper;
+import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
 import com.metamatrix.jdbc.BaseDataSource;
 import com.metamatrix.jdbc.JDBCPlugin;
 import com.metamatrix.jdbc.MMSQLException;
@@ -97,7 +100,9 @@
      */
     private String autoFailover;
     
-    private String discoveryStrategy;
+    private String discoveryStrategy;
+    
+    private String bootstrapFile;
     
     /**
      * Constructor for MMDataSource.
@@ -112,8 +117,6 @@
     protected Properties buildProperties(final String userName, final String password) {               
         Properties props = super.buildProperties(userName, password);
         
-        props.setProperty(MMURL.CONNECTION.SERVER_URL,this.buildServerURL());
-        
         if (this.getAutoFailover() != null) {
             props.setProperty(MMURL.CONNECTION.AUTO_FAILOVER, this.getAutoFailover());
         }
@@ -127,7 +130,15 @@
         }
 
         return props;
-    }
+    }
+    
+    private Properties buildServerProperties(final String userName, final String password) {               
+        Properties props = buildProperties(userName, password);
+        
+        props.setProperty(MMURL.CONNECTION.SERVER_URL,this.buildServerURL());
+
+        return props;
+    }    
 
     protected String buildServerURL() {
     	if ( this.alternateServers == null ) {
@@ -212,17 +223,42 @@
      * @throws java.sql.SQLException if a database-access error occurs
      * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String)
      */
-    public Connection getConnection(String userName, String password) throws java.sql.SQLException {
-        try {
-            validateProperties(userName,password);
-            final Properties props = buildProperties(userName, password);
-            final TeiidDriver driver = new TeiidDriver();
-            return driver.createConnection(buildURL(), props);
-        } catch (MetaMatrixCoreException e) {
-            throw MMSQLException.create(e, e.getMessage());
-        }
-    }
-
+    public Connection getConnection(String userName, String password) throws java.sql.SQLException {
+    	final TeiidDriver driver = new TeiidDriver();
+
+    	// check if this is embedded connection 
+    	if (getEmbeddedBootstrapFile() != null) {
+    		validateEmbeddedProperties(userName,password);
+	        final Properties props = buildEmbeddedProperties(userName, password);	 
+	        String url = new MMJDBCURL(getDatabaseName(), getEmbeddedBootstrapFile(), props).getJDBCURL();
+	        return driver.connect(url, props);    		    		
+    	}
+    	
+    	// if not proceed with socket connection.
+        validateProperties(userName,password);
+        final Properties props = buildServerProperties(userName, password);	        
+        return driver.connect(buildURL(), props);
+    	
+    }
+    
+	private Properties buildEmbeddedProperties(final String userName, final String password) {
+		Properties props = buildProperties(userName, password);
+
+		if (this.getEmbeddedBootstrapFile().equals(EmbeddedProfile.getDefaultConnectionURL())) {
+			props.put(DQPEmbeddedProperties.VDB_DEFINITION, getDatabaseName() + ".vdb"); //$NON-NLS-1$
+		}
+		props.put(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE, this.bootstrapFile);
+		return props;
+	}
+
+	private void validateEmbeddedProperties(final String userName, final String password) throws java.sql.SQLException {
+		super.validateProperties(userName, password);
+		String reason = reasonWhyInvalidConfigFile(this.bootstrapFile);
+		if (reason != null) {
+			throw new SQLException(reason);
+		}
+	}    
+	
    /**
      * @see java.lang.Object#toString()
      */
@@ -485,6 +521,46 @@
 	public void setDiscoveryStrategy(String discoveryStrategy) {
 		this.discoveryStrategy = discoveryStrategy;
 	}
-
+
+    /**
+     * Returns the path and file name from which embedded DQP configuration information will be read.
+     * 
+     * @return the name of the config file for this data source; may be null
+     */
+    public String getEmbeddedBootstrapFile() {
+        return bootstrapFile;
+    }
+
+    /**
+     * Sets file name from which embedded DQP configuration information * will be read.
+     * 
+     * @param configFile
+     *            The name of the config file name to set
+     */
+    public void setEmbeddedBootstrapFile(final String configFile) {
+        this.bootstrapFile = configFile;
+    }
+    
+    /**
+     * Return the reason why the supplied config file may be invalid, or null if it is considered valid.
+     * 
+     * @param configFile
+     *            a possible value for the property
+     * @return the reason why the property is invalid, or null if it is considered valid
+     * @see #setEmbeddedBootstrapFile(String)
+     */
+    public static String reasonWhyInvalidConfigFile(final String configFile) {
+        if(configFile == null) {
+            return getResourceMessage("EmbeddedDataSource.The_configFile_property_is_null"); //$NON-NLS-1$
+        }
+        
+        try {
+            URL url = URLHelper.buildURL(configFile);
+            url.openStream();
+        } catch (Exception e) {
+            return getResourceMessage("EmbeddedDataSource.The_configFile_does_not_exist_or_cant_be_read"); //$NON-NLS-1$
+        }        
+        return null;
+    }    
 }
 

Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDriver.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDriver.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -23,6 +23,7 @@
 package org.teiid.jdbc;
 
 import java.sql.Connection;
+import java.sql.Driver;
 import java.sql.DriverManager;
 import java.sql.DriverPropertyInfo;
 import java.sql.SQLException;
@@ -32,50 +33,32 @@
 import java.util.Properties;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import com.metamatrix.common.api.MMURL;
-import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.common.comm.exception.ConnectionException;
-import com.metamatrix.common.comm.platform.socket.client.SocketServerConnectionFactory;
 import com.metamatrix.common.util.ApplicationInfo;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
 import com.metamatrix.jdbc.BaseDataSource;
-import com.metamatrix.jdbc.BaseDriver;
 import com.metamatrix.jdbc.JDBCPlugin;
-import com.metamatrix.jdbc.MMConnection;
 import com.metamatrix.jdbc.MMSQLException;
-import com.metamatrix.jdbc.api.ConnectionProperties;
 import com.metamatrix.jdbc.util.MMJDBCURL;
 
 /**
- * <p> The java.sql.DriverManager class uses this class to connect to Teiid Server or Teiid Embedded.
- * The TeiidDriver class has a static initializer, which
- * is used to instantiate and register itself with java.sql.DriverManager. The
- * DriverManager's <code>getConnection</code> method calls <code>connect</code>
- * method on available registered drivers. </p>
+ * JDBC Driver class for Teiid Embedded and Teiid Server. This class automatically registers with the 
+ * {@link DriverManager}
+ * 
+ *  The accepted URL format for the connection
+ *  <ul>
+ *  	<li> Server/socket connection:<b> jdbc:teiid:&lt;vdb-name&gt;@mm[s]://&lt;server-name&gt;:&lt;port&gt;;[user=&lt;user-name&gt;][password=&lt;user-password&gt;][other-properties]*</b>
+ *  	<li> Embedded  connection:<b> jdbc:teiid:&lt;vdb-name&gt;@&lt;file-path-to-deploy.properties&gt;;[user=&lt;user-name&gt;][password=&lt;user-password&gt;][other-properties]*</b>
+ *  </ul>
+ *  The user, password properties are needed if the user authentication is turned on. All the "other-properties" are simple name value pairs.
+ *  Look at {@link MMJDBCURL} KNOWN_PROPERTIES for list of known properties allowed.
  */
 
-public final class TeiidDriver extends BaseDriver {
+public final class TeiidDriver implements Driver {
+	
 	private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
+	static final String DRIVER_NAME = "Teiid JDBC Driver"; //$NON-NLS-1$
 	
-    static final String DRIVER_NAME = "Teiid JDBC Driver"; //$NON-NLS-1$
-    
-    /**
-     *  Suports JDBC URLS of format
-     *  - jdbc:teiid:BQT at mm://localhost:####;version=1
-     *  - jdbc:teiid:BQT at mms://localhost:####;version=1
-     *  - jdbc:teiid:BQT at mm(s)://host1:####,host2:####,host3:####;version=1
-     */
-    
-    // This host/port pattern allows just a . or a - to be in the host part.
-    static final String HOST_PORT_PATTERN = "[\\p{Alnum}\\.\\-]+:\\d+"; //$NON-NLS-1$
-    static final String URL_PATTERN = "jdbc:(metamatrix|teiid):(\\w+)@((mm[s]?://"+HOST_PORT_PATTERN+"(,"+HOST_PORT_PATTERN+")*)[;]?){1}((.*)*)"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    static Pattern urlPattern = Pattern.compile(URL_PATTERN);
-    
     private static TeiidDriver INSTANCE = new TeiidDriver();
         
     // Static initializer
@@ -101,7 +84,7 @@
     }
 
     /**
-     * This method tries to make a metamatrix connection to the given URL. This class
+     * This method tries to make a connection to the given URL. This class
      * will return a null if this is not the right driver to connect to the given URL.
      * @param The URL used to establish a connection.
      * @return Connection object created
@@ -109,102 +92,26 @@
      */
     public Connection connect(String url, Properties info) throws SQLException {
 
-        MMConnection myConnection = null;
-        // create a properties obj if it is null
-        if(info == null) {
-            info = new Properties();
-        } else {
-            info = PropertiesUtils.clone(info);
-        }
-
-        // The url provided is in the correct format.
-        if (!acceptsURL(url)) {
-        	return null;
-        }
-
-        try {
-            // parse the URL to add it's properties to properties object
-            parseURL(url, info);
-
-            myConnection = createConnection(url, info);
-        } catch (MetaMatrixCoreException e) {
-            logger.log(Level.SEVERE, "Could not create connection", e); //$NON-NLS-1$
-            throw MMSQLException.create(e, e.getMessage());
-        }
-
-        // logging
-        String logMsg = JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess"); //$NON-NLS-1$
-        logger.fine(logMsg);
-
-        return myConnection;
+    	if (EmbeddedProfile.acceptsURL(url)) {
+    		return EmbeddedProfile.connect(url, info);
+    	}
+    	else if (SocketProfile.acceptsURL(url)) {
+    		return SocketProfile.connect(url, info);
+    	}
+    	return null;
     }
-
-    MMConnection createConnection(String url, Properties info)
-        throws ConnectionException, CommunicationException {
-
-        ServerConnection serverConn = SocketServerConnectionFactory.getInstance().createConnection(info);
-
-        // construct a MMConnection object.
-        MMConnection connection = new MMConnection(serverConn, info, url);
-        return connection;
-    }
-
-    /**
-     * This method parses the URL and adds properties to the the properties object.
-     * These include required and any optional properties specified in the URL.
-     * Expected URL format -- jdbc:metamatrix:local:VDB at server:port;version=1;user=logon;
-     * password=pw;logFile=<logFile.log>;
-     * logLevel=<logLevel>;txnAutoWrap=<?>;credentials=mycredentials
-     * @param The URL needed to be parsed.
-     * @param The properties object which is to be updated with properties in the URL.
-     * @throws SQLException if the URL is not in the expected format.
-     */
-    protected void parseURL(String url, Properties info) throws SQLException {
-        if(url == null) {
-            String msg = JDBCPlugin.Util.getString("MMDriver.urlFormat"); //$NON-NLS-1$
-            throw new MMSQLException(msg);
-        }
-        try {
-            MMJDBCURL jdbcURL = new MMJDBCURL(url);
-            info.setProperty(BaseDataSource.VDB_NAME, jdbcURL.getVDBName());
-            info.setProperty(MMURL.CONNECTION.SERVER_URL, jdbcURL.getConnectionURL());
-            Properties optionalParams = jdbcURL.getProperties();
-            MMJDBCURL.normalizeProperties(info);
-            Enumeration keys = optionalParams.keys();
-            while (keys.hasMoreElements()) {
-                String propName = (String)keys.nextElement();
-                // Don't let the URL properties override the passed-in Properties object.
-                if (!info.containsKey(propName)) {
-                    info.setProperty(propName, optionalParams.getProperty(propName));
-                }
-            }
-            // add the property only if it is new because they could have
-            // already been specified either through url or otherwise.
-            if(!info.containsKey(BaseDataSource.VDB_VERSION) && jdbcURL.getVDBVersion() != null) {
-                info.setProperty(BaseDataSource.VDB_VERSION, jdbcURL.getVDBVersion());
-            }
-            if(!info.containsKey(BaseDataSource.APP_NAME)) {
-                info.setProperty(BaseDataSource.APP_NAME, BaseDataSource.DEFAULT_APP_NAME);
-            }
-
-        } catch(IllegalArgumentException iae) {
-            throw new MMSQLException(JDBCPlugin.Util.getString("MMDriver.urlFormat")); //$NON-NLS-1$
-        }  
-    }
     
     /**
      * Returns true if the driver thinks that it can open a connection to the given URL.
-     * Typically drivers will return true if they understand the subprotocol specified
-     * in the URL and false if they don't.
-     * Expected URL format is
-     * jdbc:metamatrix:subprotocol:VDB at server:port;version=1;logFile=<logFile.log>;logLevel=<logLevel>;txnAutoWrap=<?>
+     * Expected URL format for server mode is
+     * jdbc:teiid::VDB at mm://server:port;version=1;user=username;password=password
+     * 
      * @param The URL used to establish a connection.
      * @return A boolean value indicating whether the driver understands the subprotocol.
      * @throws SQLException, should never occur
      */
     public boolean acceptsURL(String url) throws SQLException {
-        Matcher m = urlPattern.matcher(url);
-        return m.matches();
+    	return EmbeddedProfile.acceptsURL(url) || SocketProfile.acceptsURL(url);
     }
 
     /**
@@ -223,27 +130,37 @@
         return ApplicationInfo.getInstance().getMinorReleaseVersion();
     }
 
-    /** 
-     * @see com.metamatrix.jdbc.BaseDriver#getDriverName()
-     * @since 4.3
-     */
     public String getDriverName() {
         return DRIVER_NAME;
     }
     
-    @Override
-    protected List<DriverPropertyInfo> getAdditionalPropertyInfo(String url,
-    		Properties info) {
-    	List<DriverPropertyInfo> dpis = new LinkedList<DriverPropertyInfo>();
-        DriverPropertyInfo dpi = new DriverPropertyInfo(MMURL.CONNECTION.SERVER_URL, info.getProperty(MMURL.CONNECTION.SERVER_URL));
-        dpi.required = true;
-        dpis.add(dpi);
-        dpis.add(new DriverPropertyInfo(BaseDataSource.USER_NAME, info.getProperty(BaseDataSource.USER_NAME)));
-        dpis.add(new DriverPropertyInfo(BaseDataSource.PASSWORD, info.getProperty(BaseDataSource.PASSWORD)));
-        dpis.add(new DriverPropertyInfo(ConnectionProperties.PROP_CLIENT_SESSION_PAYLOAD, info.getProperty(BaseDataSource.PASSWORD)));
-        return dpis;
-    }
+    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
+        if(info == null) {
+            info = new Properties();
+        }
+
+        // construct list of driverPropertyInfo objects
+        List<DriverPropertyInfo> driverProps = new LinkedList<DriverPropertyInfo>();
+
+        for (String property: MMJDBCURL.KNOWN_PROPERTIES) {
+        	DriverPropertyInfo dpi = new DriverPropertyInfo(property, info.getProperty(property));
+        	driverProps.add(dpi);
+        }
+                
+        // create an array of DriverPropertyInfo objects
+        DriverPropertyInfo [] propInfo = new DriverPropertyInfo[driverProps.size()];
+
+        // copy the elements from the list to the array
+        return driverProps.toArray(propInfo);
+    }    
     
+    /**
+     * This method returns true if the driver passes jdbc compliance tests.
+     * @return true if the driver is jdbc complaint, else false.
+     */
+    public boolean jdbcCompliant() {
+        return false;
+    }
 }
 
 

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-07-10 16:41:23 UTC (rev 1118)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -23,7 +23,9 @@
 package com.metamatrix.jdbc.api;
 
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -40,9 +42,9 @@
 
 import org.junit.After;
 import org.teiid.adminapi.Admin;
+import org.teiid.jdbc.TeiidDriver;
 
 import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.jdbc.EmbeddedDriver;
 import com.metamatrix.script.io.MetadataReader;
 import com.metamatrix.script.io.ResultSetReader;
 import com.metamatrix.script.io.StringArrayReader;
@@ -56,7 +58,7 @@
 public class AbstractMMQueryTestCase {
 	
 	static {
-		new EmbeddedDriver();
+		new TeiidDriver();
 	}
 	
     protected com.metamatrix.jdbc.api.Connection internalConnection = null;

Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -23,16 +23,12 @@
 package com.metamatrix.jdbc.util;
 
 import java.net.URLEncoder;
-import java.sql.DriverManager;
-import java.sql.SQLException;
 import java.util.Properties;
 
 import junit.framework.TestCase;
 
 import com.metamatrix.common.api.MMURL;
 import com.metamatrix.jdbc.BaseDataSource;
-import com.metamatrix.jdbc.EmbeddedDriver;
-import com.metamatrix.jdbc.MMDriver;
 import com.metamatrix.jdbc.api.ConnectionProperties;
 import com.metamatrix.jdbc.api.ExecutionProperties;
 
@@ -331,4 +327,21 @@
         assertEquals("mm://slwxp172:44401,slabc123:12345", result);         //$NON-NLS-1$
     }
 
+    public void testBuildEmbeedURL() {
+    	MMJDBCURL url = new MMJDBCURL("vdb", "/home/foo/deploy.properties", new Properties()); //$NON-NLS-1$ //$NON-NLS-2$
+    	assertEquals("jdbc:teiid:vdb@/home/foo/deploy.properties", url.getJDBCURL()); //$NON-NLS-1$
+    	
+    	Properties p = new Properties();
+    	p.setProperty("user", "test"); //$NON-NLS-1$ //$NON-NLS-2$
+    	p.setProperty("password", "pass"); //$NON-NLS-1$ //$NON-NLS-2$
+    	p.setProperty("autoFailover", "true"); //$NON-NLS-1$ //$NON-NLS-2$
+    	p.setProperty("any", "thing"); //$NON-NLS-1$ //$NON-NLS-2$
+    	
+    	url = new MMJDBCURL("vdb", "/home/foo/deploy.properties", p); //$NON-NLS-1$ //$NON-NLS-2$
+    	assertTrue(url.getJDBCURL().startsWith("jdbc:teiid:vdb@/home/foo/deploy.properties;user=test;")); //$NON-NLS-1$
+    	assertTrue(url.getJDBCURL().indexOf("any=thing")!=-1); //$NON-NLS-1$
+    	assertTrue(url.getJDBCURL().indexOf("password=pass")!=-1); //$NON-NLS-1$
+    	assertTrue(url.getJDBCURL().indexOf("autoFailover=true")!=-1); //$NON-NLS-1$
+    	
+    }
 }

Added: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
===================================================================
--- trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java	                        (rev 0)
+++ trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -0,0 +1,158 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.jdbc;
+
+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.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import org.junit.Test;
+
+import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
+import com.metamatrix.jdbc.BaseDataSource;
+import com.metamatrix.jdbc.api.ExecutionProperties;
+
+
+public class TestEmbeddedProfile {
+    EmbeddedProfile EmbeddedProfile = new EmbeddedProfile();
+    
+    /*
+     * Test method for 'com.metamatrix.jdbc.EmbeddedEmbeddedProfile.acceptsURL(String)'
+     * // (\\w:[\\\\,\\/]|file:\\/\\/|\\/|\\\\|(\\.){1,2}){1}
+     */
+    @Test public void testAcceptsURL() {    
+//        // Windows Path
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:\\metamatrix\\dqp\\dqp.properties")); //$NON-NLS-1$
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:\\metamatrix\\dqp\\dqp.properties;version=1")); //$NON-NLS-1$
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:\\metamatrix\\dqp\\dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
+        
+        // Alternative windows path
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:/metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
+
+        // Abosolute path (Unix or windows)
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
+
+        // relative path
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at ../../metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at ../../metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at ../../metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
+        
+        // File URL should be supported (not sure)
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at file:///c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at testdata/dqp/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
+        
+        // ClassPath based URL
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at classpath:/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
+        
+        // These are specific to the MMorg.teiid.jdbc.EmbeddedProfile and should not be suported
+        assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at mm://host:7001;version=1")); //$NON-NLS-1$
+        assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at mms://host:7001;version=1")); //$NON-NLS-1$
+        //assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at http://host:7001;version=1"));
+        
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT")); //$NON-NLS-1$
+        assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT!/path/foo.properties")); //$NON-NLS-1$
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT;")); //$NON-NLS-1$
+        assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT;version=1;logFile=foo.txt")); //$NON-NLS-1$
+    }
+
+    @Test public void testParseURL() throws SQLException{
+        Properties p = new Properties();
+        org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT at c:\\metamatrix\\dqp\\dqp.properties", p); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+        assertEquals("c:\\metamatrix\\dqp\\dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
+        assertEquals(3, p.size());        
+    }
+
+    @Test public void testParseURL2() throws SQLException {
+        Properties p = new Properties();       
+        org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@\\metamatrix\\dqp\\dqp.properties;version=3", p); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+        assertEquals("\\metamatrix\\dqp\\dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("3")); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VERSION).equals("3")); //$NON-NLS-1$
+        assertEquals(5, p.size());
+    }
+    
+    @Test public void testParseURL3() throws SQLException{
+        Properties p = new Properties();
+        org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=4;txnAutoWrap=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VERSION).equals("4")); //$NON-NLS-1$
+        assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
+        assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("YES")); //$NON-NLS-1$
+        assertEquals(7, p.size());        
+    }
+    
+    @Test public void testParseURL4() throws SQLException{
+        Properties p = new Properties();
+        org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT at testdata/dqp/dqp.properties;partialResultsMode=true", p); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+        assertEquals("testdata/dqp/dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
+        assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true")); //$NON-NLS-1$
+        assertEquals(4, p.size());                
+    }
+    
+    @Test public void testParseURL5() throws SQLException{
+        Properties p = new Properties();
+        org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT", p); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+        assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties"));         //$NON-NLS-1$
+    }
+    
+    @Test public void testParseURL55() throws SQLException{
+        Properties p = new Properties();
+        org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT;", p); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+        assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties"));         //$NON-NLS-1$
+    }    
+       
+    @Test public void testParseURL6() throws SQLException{
+        Properties p = new Properties();
+        org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT;partialResultsMode=true;version=1", p); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+        assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
+        assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true")); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("1")); //$NON-NLS-1$
+        assertTrue(p.getProperty("vdb.definition").equals("BQT.vdb")); //$NON-NLS-1$ //$NON-NLS-2$
+        assertEquals(7, p.size());                
+        
+    }
+    
+    @Test public void test() throws Exception {
+        try {
+            Class.forName("org.teiid.jdbc.TeiidDriver"); //$NON-NLS-1$
+            DriverManager.getConnection("jdbc:metamatrix:Parts at invalidConfig.properties;version=1"); //$NON-NLS-1$
+            fail();
+        } catch (SQLException e) {
+        }
+    }
+}


Property changes on: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java
===================================================================
--- trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java	                        (rev 0)
+++ trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.sql.SQLException;
+import java.util.Properties;
+
+import org.junit.Test;
+
+import com.metamatrix.common.api.MMURL;
+import com.metamatrix.jdbc.BaseDataSource;
+import com.metamatrix.jdbc.api.ExecutionProperties;
+
+public class TestSocketProfile {
+    public String localhost = "localhost"; //$NON-NLS-1$
+    
+    /** Valid format of urls*/
+    @Test public void testAcceptsURL1()  throws Exception   {
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:jvdb at mm://localhost:1234")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:metamatrix:jvdb at mm://localhost:1234")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234;version=x")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$       
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mms://localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:jvdb at mms://localhost:1234")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234;version=x")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$       
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mms://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mms://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://127.0.0.1:1234;logLevel=2")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mms://127.0.0.1:1234")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://127.0.0.1:1234,localhost.mydomain.com:63636;logLevel=2")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://my-host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$
+        assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://123.123.123.123:53535,127.0.0.1:1234")); //$NON-NLS-1$
+        
+        assertTrue(!SocketProfile.acceptsURL("jdbc:metamatrix:jvdb at localhost:1234")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:jvdb at localhost:1234")); //$NON-NLS-1$
+
+        //DQP type
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:jvdb at c:/dqp.properties;version=1")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:jvdb@/foo/dqp.properties;version=1")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:jvdb at ../foo/dqp.properties;version=1")); //$NON-NLS-1$
+        
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:jvdb at mm://localhost:port")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:vdb at localhost:port;version=x")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$       
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;stickyConnections=false;socketsPerVM=4")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:vdb at mm://my_host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$        
+    }
+
+    /** Invalid format of urls*/
+    @Test public void testAcceptsURL2() throws Exception    {
+        assertTrue(!SocketProfile.acceptsURL("jdbc:matamatrix:test")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("metamatrix:test")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc&matamatrix:test")); //$NON-NLS-1$
+        assertTrue(!SocketProfile.acceptsURL("jdbc;metamatrix:test")); //$NON-NLS-1$
+    }   
+
+    @Test public void testParseURL() throws SQLException{
+        Properties p = new Properties();
+        SocketProfile.parseURL("jdbc:teiid:BQT at mm://slwxp157:1234", p); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+        assertTrue(p.getProperty(MMURL.CONNECTION.SERVER_URL).equals("mm://slwxp157:1234")); //$NON-NLS-1$
+        assertEquals(3, p.size());        
+    }
+
+    @Test public void testParseURL2() throws SQLException {
+        Properties p = new Properties();       
+        SocketProfile.parseURL("jdbc:teiid:BQT at mms://slwxp157:1234;version=3", p); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("3")); //$NON-NLS-1$
+        assertTrue(p.getProperty(MMURL.CONNECTION.SERVER_URL).equals("mms://slwxp157:1234")); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VERSION).equals("3")); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.APP_NAME).equals(BaseDataSource.DEFAULT_APP_NAME));
+        assertEquals(5, p.size());
+    }
+    
+    @Test public void testParseURL3() throws SQLException{
+        Properties p = new Properties();
+        SocketProfile.parseURL("jdbc:teiid:BQT at mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302;version=4;txnAutoWrap=ON;partialResultsMode=YES;ApplicationName=Client", p); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4"));         //$NON-NLS-1$
+        assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
+        assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("YES")); //$NON-NLS-1$
+        assertTrue(p.getProperty(MMURL.CONNECTION.SERVER_URL).equals("mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302")); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.VERSION).equals("4")); //$NON-NLS-1$
+        assertTrue(p.getProperty(BaseDataSource.APP_NAME).equals("Client")); //$NON-NLS-1$
+        assertEquals(7, p.size());        
+    }    
+}


Property changes on: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
===================================================================
--- trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -22,121 +22,33 @@
 
 package org.teiid.jdbc;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import java.sql.DriverPropertyInfo;
-import java.sql.SQLException;
-import java.util.Properties;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
-import com.metamatrix.common.api.MMURL;
-import com.metamatrix.jdbc.BaseDataSource;
-import com.metamatrix.jdbc.api.ExecutionProperties;
-
-public class TestTeiidDriver extends TestCase {
+public class TestTeiidDriver {
     TeiidDriver drv = new TeiidDriver();
-    public String localhost = "localhost"; //$NON-NLS-1$
-    
-    public TestTeiidDriver(String name)    {
-        super(name);
-        
-    }
-    
-    protected void setUp() throws Exception {
-    }
 
-    /** Valid format of urls*/
-    public void testAcceptsURL1()  throws Exception   {
-        assertNotNull(drv);
-        assertTrue(drv.acceptsURL("jdbc:teiid:jvdb at mm://localhost:1234")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:metamatrix:jvdb at mm://localhost:1234")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234;version=x")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$       
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mms://localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:jvdb at mms://localhost:1234")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234;version=x")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$       
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mms://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mms://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://127.0.0.1:1234;logLevel=2")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mms://127.0.0.1:1234")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://127.0.0.1:1234,localhost.mydomain.com:63636;logLevel=2")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://my-host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$
-        assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://123.123.123.123:53535,127.0.0.1:1234")); //$NON-NLS-1$
-        
-        assertTrue(!drv.acceptsURL("jdbc:metamatrix:jvdb at localhost:1234")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:jvdb at localhost:1234")); //$NON-NLS-1$
-
-        //DQP type
-        assertTrue(!drv.acceptsURL("jdbc:teiid:jvdb at c:/dqp.properties;version=1")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:jvdb@/foo/dqp.properties;version=1")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:jvdb at ../foo/dqp.properties;version=1")); //$NON-NLS-1$
-        
-        assertTrue(!drv.acceptsURL("jdbc:teiid:jvdb at mm://localhost:port")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:vdb at localhost:port;version=x")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$       
-        assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234;stickyConnections=false;socketsPerVM=4")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc:teiid:vdb at mm://my_host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$        
-    }
-
-    /** Invalid format of urls*/
-    public void testAcceptsURL2() throws Exception    {
-        assertNotNull(drv);
-        assertTrue(!drv.acceptsURL("jdbc:matamatrix:test")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("metamatrix:test")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc&matamatrix:test")); //$NON-NLS-1$
-        assertTrue(!drv.acceptsURL("jdbc;metamatrix:test")); //$NON-NLS-1$
-    }   
-
-    public void testParseURL() throws SQLException{
-        Properties p = new Properties();
-        TeiidDriver.getInstance().parseURL("jdbc:teiid:BQT at mm://slwxp157:1234", p); //$NON-NLS-1$
-        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
-        assertTrue(p.getProperty(MMURL.CONNECTION.SERVER_URL).equals("mm://slwxp157:1234")); //$NON-NLS-1$
-        assertEquals(3, p.size());        
-    }
-
-    public void testParseURL2() throws SQLException {
-        Properties p = new Properties();       
-        TeiidDriver.getInstance().parseURL("jdbc:teiid:BQT at mms://slwxp157:1234;version=3", p); //$NON-NLS-1$
-        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
-        assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("3")); //$NON-NLS-1$
-        assertTrue(p.getProperty(MMURL.CONNECTION.SERVER_URL).equals("mms://slwxp157:1234")); //$NON-NLS-1$
-        assertTrue(p.getProperty(BaseDataSource.VERSION).equals("3")); //$NON-NLS-1$
-        assertTrue(p.getProperty(BaseDataSource.APP_NAME).equals(BaseDataSource.DEFAULT_APP_NAME));
-        assertEquals(5, p.size());
-    }
     
-    public void testParseURL3() throws SQLException{
-        Properties p = new Properties();
-        TeiidDriver.getInstance().parseURL("jdbc:teiid:BQT at mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302;version=4;txnAutoWrap=ON;partialResultsMode=YES;ApplicationName=Client", p); //$NON-NLS-1$
-        assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
-        assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4"));         //$NON-NLS-1$
-        assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
-        assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("YES")); //$NON-NLS-1$
-        assertTrue(p.getProperty(MMURL.CONNECTION.SERVER_URL).equals("mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302")); //$NON-NLS-1$
-        assertTrue(p.getProperty(BaseDataSource.VERSION).equals("4")); //$NON-NLS-1$
-        assertTrue(p.getProperty(BaseDataSource.APP_NAME).equals("Client")); //$NON-NLS-1$
-        assertEquals(7, p.size());        
-    }    
-    
-    public void testGetPropertyInfo1() throws Exception {        
+    @Test public void testGetPropertyInfo1() throws Exception {        
         DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:teiid:vdb at mm://localhost:12345", null); //$NON-NLS-1$
-
-        assertEquals(6, info.length);
-        assertEquals(true, info[0].required);
-        assertEquals("VirtualDatabaseName", info[0].name); //$NON-NLS-1$
-        assertEquals("vdb", info[0].value); //$NON-NLS-1$
+        assertEquals(19, info.length);
     }
     
+    @Test public void testAccepts() throws Exception {
+    	assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:12345")); //$NON-NLS-1$
+    	assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
+    	assertTrue(drv.acceptsURL("jdbc:teiid:vdb")); //$NON-NLS-1$
+    	assertTrue(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
+    	
+    	assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb at mm://localhost:12345")); //$NON-NLS-1$
+    	assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb at mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
+    	assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb")); //$NON-NLS-1$
+    	assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
+    	
+    }
+    
 }

Modified: trunk/embedded/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- trunk/embedded/src/main/java/org/teiid/transport/LogonImpl.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/embedded/src/main/java/org/teiid/transport/LogonImpl.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -40,6 +40,7 @@
 import com.metamatrix.common.api.MMURL;
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.common.util.LogConstants;
+import com.metamatrix.core.CoreConstants;
 import com.metamatrix.dqp.client.ResultsFuture;
 import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
 import com.metamatrix.jdbc.api.ConnectionProperties;
@@ -67,7 +68,7 @@
 		
         String applicationName = connProps.getProperty(MMURL.CONNECTION.APP_NAME);
         // user may be null if using trustedToken to log on
-        String user = connProps.getProperty(MMURL.CONNECTION.USER_NAME);
+        String user = connProps.getProperty(MMURL.CONNECTION.USER_NAME, CoreConstants.DEFAULT_ANON_USERNAME);
         // password may be null if using trustedToken to log on
         String password = connProps.getProperty(MMURL.CONNECTION.PASSWORD);
 		Credentials credential = null;

Modified: trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestCase3473.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestCase3473.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestCase3473.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -71,7 +71,7 @@
 
 			@Override
 			protected void setUp() throws Exception {
-                Class.forName("com.metamatrix.jdbc.EmbeddedDriver"); //$NON-NLS-1$
+                Class.forName("org.teiid.jdbc.TeiidDriver"); //$NON-NLS-1$
                 conn = DriverManager.getConnection(serverUrl);
                 dbmd = (MMDatabaseMetaData)conn.getMetaData();
 			}

Modified: trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestMMDatabaseMetaData.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestMMDatabaseMetaData.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestMMDatabaseMetaData.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -50,6 +50,7 @@
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.teiid.jdbc.TeiidDriver;
 
 import com.metamatrix.common.util.ApplicationInfo;
 import com.metamatrix.core.util.UnitTestUtil;
@@ -85,7 +86,7 @@
 
     @Before
     public void setUp() throws Exception {
-        dbmd = new MMDatabaseMetaData((BaseDriver)DriverManager.getDriver(serverUrl), (MMConnection) conn);
+        dbmd = new MMDatabaseMetaData((MMConnection) conn);
     }
 
     @AfterClass
@@ -97,7 +98,7 @@
     
     @BeforeClass
     public static void oneTimeSetUp() throws Exception {
-        Class.forName(EmbeddedDriver.class.getName());
+        Class.forName(TeiidDriver.class.getName());
         conn = DriverManager.getConnection(serverUrl);
     }
     

Modified: trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestXQueryServices.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestXQueryServices.java	2009-07-10 16:41:23 UTC (rev 1118)
+++ trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestXQueryServices.java	2009-07-10 20:48:29 UTC (rev 1119)
@@ -30,8 +30,9 @@
 
 import junit.framework.TestCase;
 
+import org.teiid.jdbc.TeiidDriver;
+
 import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.jdbc.EmbeddedDriver;
 import com.metamatrix.jdbc.MMSQLException;
 
 /**
@@ -47,7 +48,7 @@
      * This is then not an effective test of xquery, but shows how a procedure without a resultset should behave.
      */
     public void testXQueryCall() throws Exception {
-    	Class.forName(EmbeddedDriver.class.getName());
+    	Class.forName(TeiidDriver.class.getName());
     	Connection conn = DriverManager.getConnection("jdbc:metamatrix:xq@" + UnitTestUtil.getTestDataPath() + "/xquery/xquery.properties;txnAutoWrap=OFF;user=test" ); //$NON-NLS-1$ //$NON-NLS-2$
     	CallableStatement cs = conn.prepareCall("{? = call xqs.test}"); //$NON-NLS-1$
     	assertFalse(cs.execute());




More information about the teiid-commits mailing list