[teiid-commits] teiid SVN: r3304 - in branches/7.4.x/client/src: test/java/org/teiid/jdbc and 1 other directory.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Jul 8 20:08:36 EDT 2011


Author: van.halbert
Date: 2011-07-08 20:08:35 -0400 (Fri, 08 Jul 2011)
New Revision: 3304

Modified:
   branches/7.4.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java
   branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestConnection.java
   branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
Log:
TEIID-1651 missed adding the jdbc4spec property to JDBC URL set of properties

Modified: branches/7.4.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java	2011-07-06 18:34:49 UTC (rev 3303)
+++ branches/7.4.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java	2011-07-09 00:08:35 UTC (rev 3304)
@@ -58,7 +58,8 @@
             ExecutionProperties.PROP_XML_FORMAT,
             ExecutionProperties.PROP_XML_VALIDATION,
             EmbeddedProfile.USE_CALLING_THREAD,
-            ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS)));
+            ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS,
+            ExecutionProperties.JDBC4COLUMNNAMEANDLABELSEMANTICS)));
     
     public static final Set<String> KNOWN_PROPERTIES = getKnownProperties();
     

Modified: branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestConnection.java
===================================================================
--- branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestConnection.java	2011-07-06 18:34:49 UTC (rev 3303)
+++ branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestConnection.java	2011-07-09 00:08:35 UTC (rev 3304)
@@ -22,7 +22,8 @@
 
 package org.teiid.jdbc;
 
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.stub;
 
 import java.sql.SQLException;
 import java.util.Properties;
@@ -38,8 +39,6 @@
 import org.teiid.client.util.ResultsFuture;
 import org.teiid.client.xa.XATransactionException;
 import org.teiid.client.xa.XidImpl;
-import org.teiid.jdbc.BaseDataSource;
-import org.teiid.jdbc.ConnectionImpl;
 import org.teiid.net.ServerConnection;
 
 
@@ -48,13 +47,28 @@
 	protected static final String STD_DATABASE_NAME         = "QT_Ora9DS"; //$NON-NLS-1$
     protected static final int STD_DATABASE_VERSION      = 1; 
     
-    static String serverUrl = "jdbc:metamatrix:QT_Ora9DS at mm://localhost:7001;version=1;user=metamatrixadmin;password=mm"; //$NON-NLS-1$
+    static String serverUrl = "jdbc:teiid:QT_Ora9DS at mm://localhost:7001;version=1;user=metamatrixadmin;password=mm"; //$NON-NLS-1$
 
     public TestConnection(String name) {
         super(name);
     }
     
+    static class  InnerDriver extends TeiidDriver {
+    	String iurl = null;
+    	public InnerDriver(String url) {
+    		iurl = url;
+    	}
+
+    	public void parseUrl(Properties props) throws SQLException {
+ 				super.parseURL(iurl, props);
+    	}
+    }
+    
     public static ConnectionImpl getMMConnection() {
+    	return getMMConnection(serverUrl);  	
+    }
+    
+    public static ConnectionImpl getMMConnection(String url) {
     	ServerConnection mock = mock(ServerConnection.class);
     	DQP dqp = mock(DQP.class);
     	try {
@@ -79,13 +93,20 @@
 		} catch (XATransactionException e) {
 			throw new RuntimeException(e);
 		}
+		
+		Properties props = new Properties();
+		
+		try {
+			new InnerDriver(url).parseUrl(props);
+		} catch (SQLException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
     	stub(mock.getService(DQP.class)).toReturn(dqp);
-    	Properties props = new Properties();
-    	props.setProperty(BaseDataSource.VDB_NAME, STD_DATABASE_NAME);
-    	props.setProperty(BaseDataSource.VDB_VERSION, String.valueOf(STD_DATABASE_VERSION));
-    	props.setProperty(BaseDataSource.USER_NAME, "metamatrixadmin"); //$NON-NLS-1$
-    	stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(1, "metamatrixadmin"), STD_DATABASE_NAME,STD_DATABASE_VERSION , "fake")); //$NON-NLS-1$
-    	return new ConnectionImpl(mock, props, serverUrl);
+    	
+    	stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(1, "admin"), STD_DATABASE_NAME,STD_DATABASE_VERSION , "fake")); //$NON-NLS-1$
+    	return new ConnectionImpl(mock, props, url);
     }
 
     public void testGetMetaData() throws Exception {
@@ -103,7 +124,7 @@
 
     /** test getUserName() through DriverManager */
     public void testGetUserName2() throws Exception {        
-        assertEquals("Actual userName is not equal to the expected one. ", "metamatrixadmin", getMMConnection().getUserName()); //$NON-NLS-1$ //$NON-NLS-2$
+        assertEquals("Actual userName is not equal to the expected one. ", "admin", getMMConnection().getUserName()); //$NON-NLS-1$ //$NON-NLS-2$
     }
       
     /** test isReadOnly default value on Connection */
@@ -129,4 +150,27 @@
             // error expected
         }
     }
+    
+    /**
+     * Test the default of the JDBC4 spec semantics is true
+     */
+    public void testDefaultSpec() throws Exception {
+        assertEquals("true",
+        		(getMMConnection().getExecutionProperties().getProperty(ExecutionProperties.JDBC4COLUMNNAMEANDLABELSEMANTICS) == null ? "true" : "false"));
+    } 
+    
+    /**
+     * Test turning off the JDBC 4 semantics
+     */
+    public void testTurnOnSpec() throws Exception {
+        assertEquals("true", getMMConnection(serverUrl + ";useJDBC4ColumnNameAndLabelSemantics=true").getExecutionProperties().getProperty(ExecutionProperties.JDBC4COLUMNNAMEANDLABELSEMANTICS));
+    }    
+    
+    /**
+     * Test turning off the JDBC 4 semantics
+     */
+    public void testTurnOffSpec() throws Exception {
+        assertEquals("false", getMMConnection(serverUrl + ";useJDBC4ColumnNameAndLabelSemantics=false").getExecutionProperties().getProperty(ExecutionProperties.JDBC4COLUMNNAMEANDLABELSEMANTICS));
+    }
+
 }

Modified: branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
===================================================================
--- branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java	2011-07-06 18:34:49 UTC (rev 3303)
+++ branches/7.4.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java	2011-07-09 00:08:35 UTC (rev 3304)
@@ -138,7 +138,7 @@
     @Test public void testGetPropertyInfo1() throws Exception {        
         DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:teiid:vdb at mm://localhost:12345;applicationName=x", null); //$NON-NLS-1$
 
-        assertEquals(20, info.length);
+        assertEquals(21, info.length);
         assertEquals(false, info[0].required);
         assertEquals("ApplicationName", info[0].name); //$NON-NLS-1$
         assertEquals("x", info[0].value); //$NON-NLS-1$



More information about the teiid-commits mailing list