[153046] oda.consumer creates log folders in improper place
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.consumer/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.connectivity.oda.consumer/META-INF/MANIFEST.MF
index 42b66d3..735547c 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.consumer/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.connectivity.oda.consumer/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: DTP ODA Consumer Helper Component Plug-in
 Bundle-SymbolicName: org.eclipse.datatools.connectivity.oda.consumer;singleton:=true
-Bundle-Version: 3.0.2.200608111
+Bundle-Version: 3.0.2.200608221
 Bundle-Localization: plugin
 Bundle-Vendor: Eclipse.org
 Require-Bundle: org.eclipse.core.runtime,
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.consumer/src/org/eclipse/datatools/connectivity/oda/consumer/helper/OdaConsumerPlugin.java b/plugins/org.eclipse.datatools.connectivity.oda.consumer/src/org/eclipse/datatools/connectivity/oda/consumer/helper/OdaConsumerPlugin.java
index 243339d..027e9d7 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.consumer/src/org/eclipse/datatools/connectivity/oda/consumer/helper/OdaConsumerPlugin.java
+++ b/plugins/org.eclipse.datatools.connectivity.oda.consumer/src/org/eclipse/datatools/connectivity/oda/consumer/helper/OdaConsumerPlugin.java
@@ -23,16 +23,33 @@
  */
 public class OdaConsumerPlugin extends Plugin
 {
+    private static OdaConsumerPlugin sm_plugin;
+
+    public OdaConsumerPlugin()
+    {
+        super();
+        sm_plugin = this;
+    }
+
+    /**
+     * Returns the shared instance of this plugin activator.
+     * @return
+     */
+    public static OdaConsumerPlugin getDefault()
+    {
+        return sm_plugin;
+    }
 
     /* (non-Javadoc)
      * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
      */
     public void stop( BundleContext context ) throws Exception
     {
-        // release plugin's singleton instances
+        // release plugin's singleton instance(s)
         ExtensionExplorer.releaseInstance();
         
         super.stop( context );
+        sm_plugin = null;
     }
 
 }
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.consumer/src/org/eclipse/datatools/connectivity/oda/consumer/helper/OdaDriver.java b/plugins/org.eclipse.datatools.connectivity.oda.consumer/src/org/eclipse/datatools/connectivity/oda/consumer/helper/OdaDriver.java
index d22705a..8293610 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.consumer/src/org/eclipse/datatools/connectivity/oda/consumer/helper/OdaDriver.java
+++ b/plugins/org.eclipse.datatools.connectivity.oda.consumer/src/org/eclipse/datatools/connectivity/oda/consumer/helper/OdaDriver.java
@@ -22,6 +22,7 @@
 import org.eclipse.datatools.connectivity.oda.IDriver;
 import org.eclipse.datatools.connectivity.oda.LogConfiguration;
 import org.eclipse.datatools.connectivity.oda.OdaException;
+import org.eclipse.datatools.connectivity.oda.consumer.internal.impl.LogPathHelper;
 import org.eclipse.datatools.connectivity.oda.consumer.nls.Messages;
 import org.eclipse.datatools.connectivity.oda.consumer.util.manifest.DriverExtensionManifest;
 import org.eclipse.datatools.connectivity.oda.consumer.util.manifest.ExtensionExplorer;
@@ -471,23 +472,39 @@
 						 logConfig + " )\t"; //$NON-NLS-1$
 		logMethodCalled( context );
 		
+        // set log configuration for the oda consumer helper
 		try
 		{
-			setContextClassloader();
-			
-			// set the ODA consumer manager's log directory to the ODA driver's 
+			// set the ODA consumer helper's log directory to the ODA driver's 
 			// log directory only the first time setLogConfiguration() is called and 
 			// if the caller didn't already specify a directory using setLogDirectory().
 			if( LogManager.getLogger( getLoggerName() ) == null && 
 				m_logDirectory == null )
-				m_logDirectory = logConfig.getLogDirectory();
+            {
+                m_logDirectory = 
+                	LogPathHelper.getConsumerLogParent( 
+                			logConfig.getDataSourceId() ).getPath();
+            }
 
             // set log configuration values in the ODA consumer helper of the driver,
             // whose logging requires a log directory
-            if( m_logDirectory != null && m_logDirectory.length() > 0 )			
+            if( m_logDirectory != null && m_logDirectory.length() > 0 )	
+            {
                 LogManager.getLogger( getLoggerName(), logConfig.getLogLevel(), 
 								  m_logDirectory, "OdaHelperLog", null ); //$NON-NLS-1$
-			
+            }
+        }
+        catch( RuntimeException ex )
+        {
+            // unable to set consumer logger, ignore
+        	ex.printStackTrace();
+        }
+
+        // next, set log configuration in the underlying ODA driver
+        try
+        {
+            setContextClassloader();
+            
             // set log configuration values in the underlying ODA driver
 			getDriver().setLogConfiguration( logConfig );
 		}
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.consumer/src/org/eclipse/datatools/connectivity/oda/consumer/internal/impl/LogPathHelper.java b/plugins/org.eclipse.datatools.connectivity.oda.consumer/src/org/eclipse/datatools/connectivity/oda/consumer/internal/impl/LogPathHelper.java
new file mode 100644
index 0000000..c68f969
--- /dev/null
+++ b/plugins/org.eclipse.datatools.connectivity.oda.consumer/src/org/eclipse/datatools/connectivity/oda/consumer/internal/impl/LogPathHelper.java
@@ -0,0 +1,65 @@
+/*
+ *************************************************************************
+ * Copyright (c) 2006 Actuate Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *  Actuate Corporation - initial API and implementation
+ *  
+ *************************************************************************
+ */
+
+package org.eclipse.datatools.connectivity.oda.consumer.internal.impl;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConsumerPlugin;
+
+/**
+ * Internal helper of the oda consumer component to determine 
+ * its trace logging path. 
+ */
+public class LogPathHelper
+{
+    private static final String LOG_SUBFOLDER_NAME = "logs"; //$NON-NLS-1$
+
+    /**
+     * Returns the plugin's default log parent file
+     * under its workspace state location.
+     * @return	the plugin's log path
+     * @throws  IllegalStateException when the plugin activator 
+     * 					is not instantiated yet
+     */
+    public static IPath getPluginLogPath() throws IllegalStateException
+    {
+        // try to use plugin's default state location's log folder as its parent
+        OdaConsumerPlugin thePlugin = OdaConsumerPlugin.getDefault();
+        if( thePlugin == null )
+            throw new IllegalStateException( "OdaConsumerPlugin.getDefault()" ); //$NON-NLS-1$
+
+        return thePlugin.getStateLocation()
+               		.append( LOG_SUBFOLDER_NAME ); 	
+    }
+    
+    /**
+     * Returns the log directory of the ODA consumer helper,
+     * appended with the sub-directory, if specified.
+     * @param subdirName the name of sub-directory to append in the
+     * 					 odaconsumer plugin's log path; may be null
+     * 					 or empty for no sub-directory
+     * @return
+     */
+    public static File getConsumerLogParent( String subdirName )
+    {
+    	IPath pluginLogPath = getPluginLogPath();
+    	
+    	if( subdirName == null || subdirName.length() == 0 )
+    		return pluginLogPath.toFile();
+    	return pluginLogPath.append( subdirName ).toFile();
+    }
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.oda/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.connectivity.oda/META-INF/MANIFEST.MF
index 5951cdc..88a9544 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.connectivity.oda/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: DTP Open Data Access
 Bundle-SymbolicName: org.eclipse.datatools.connectivity.oda; singleton:=true
-Bundle-Version: 3.0.2.200608141
+Bundle-Version: 3.0.2.200608221
 Bundle-Vendor: Eclipse.org
 Bundle-Localization: plugin
 Export-Package: org.eclipse.datatools.connectivity.oda,
diff --git a/plugins/org.eclipse.datatools.connectivity.oda/src/org/eclipse/datatools/connectivity/oda/util/logging/LogManager.java b/plugins/org.eclipse.datatools.connectivity.oda/src/org/eclipse/datatools/connectivity/oda/util/logging/LogManager.java
index afe9f2f..30d35ea 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda/src/org/eclipse/datatools/connectivity/oda/util/logging/LogManager.java
+++ b/plugins/org.eclipse.datatools.connectivity.oda/src/org/eclipse/datatools/connectivity/oda/util/logging/LogManager.java
@@ -21,7 +21,9 @@
 import java.text.ParseException;
 import java.util.Hashtable;
 
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.datatools.connectivity.oda.nls.Messages;
+import org.eclipse.datatools.connectivity.oda.util.OdaPlugin;
 
 import com.ibm.icu.text.SimpleDateFormat;
 
@@ -33,6 +35,8 @@
  */
 public class LogManager
 {
+    private static final String LOG_SUBFOLDER_NAME = "logs"; //$NON-NLS-1$
+    
 	private static Hashtable m_loggers = new Hashtable();
     private static SimpleDateFormat sm_dateFormat;
 
@@ -279,7 +283,7 @@
     										   String logPrefix, String formatterClassName )
     {   	
     	// set the file handler with the file name and formatter
-    	String logfileName = generateFileName( logDirectory, logPrefix );
+    	String logfileName = generateAbsoluteFileName( logDirectory, logPrefix );
     	
     	// cache exceptions that could occur when users use a customized 
     	// formatter, so that they can take a look at the log to see if something
@@ -330,21 +334,55 @@
         return sm_dateFormat;
     }
     
-    // logic to generate the proper file name:
-    // <logDirectory>/<logPrefix>-YYYYMMDD-HHmmss.log
-    private static String generateFileName( String logDirectory,
-    										String logPrefix )
+    /**
+     * Logic to generate the absolute file name:
+     * <logDirectory>/<logPrefix>-YYYYMMDD-HHmmss.log
+     * If the specified <logDirectory> is not an absolute path,
+     * set it relative to the oda plugin's default log folder.
+     */ 
+    private static String generateAbsoluteFileName( String logDirectory,
+    										        String logFilePrefix )
     {
-    	String logfileName = ( logDirectory.endsWith( "/" ) || //$NON-NLS-1$
-    						   logDirectory.endsWith( "\\" ) ) ? //$NON-NLS-1$
-    						 logDirectory : logDirectory + "/"; //$NON-NLS-1$
-
-    	logfileName += logPrefix + "-"; //$NON-NLS-1$
+        File logDir = getAbsoluteParent( logDirectory );
+        
+        // format the filename with given prefix, followed by timestamp and .log suffix
+        String logfileName = logFilePrefix + "-"; //$NON-NLS-1$
     	
     	Timestamp timestamp = new Timestamp( System.currentTimeMillis() );
-    	logfileName += getDateFormat().format( timestamp ) + ".log"; //$NON-NLS-1$
-    	
-    	return logfileName;
+    	logfileName += getDateFormat().format( timestamp ) + ".log"; //$NON-NLS-1$    	
+       
+    	return new File( logDir, logfileName ).getPath();
+    }
+    
+    private static File getAbsoluteParent( String logDirectory )
+    {
+        assert( logDirectory != null && logDirectory.length() > 0 );
+        File logParent = new File( logDirectory );
+        if( logParent.isAbsolute() )
+            return logParent;   // use as is
+        
+        // the specified logDirectory is relative, 
+        // set its parent to be the oda plugin's default log folder 
+        logParent = getPluginLogPath().append( logDirectory ).toFile(); 
+        return logParent;
+    }
+    
+    /**
+     * Returns the plugin's default log parent file
+     * in the workspace state location.
+     * @return
+     * @throws  IllegalStateException when the plugin activator 
+     * 					is not instantiated yet
+     */
+    private static IPath getPluginLogPath() throws IllegalStateException
+    {
+        // try to use oda plugin's default state location's log folder as its parent
+        OdaPlugin odaPlugin = OdaPlugin.getDefault();
+        if( odaPlugin == null )
+            throw new IllegalStateException( "OdaPlugin.getDefault()" ); //$NON-NLS-1$
+
+        return odaPlugin.getStateLocation()
+                        .append( LOG_SUBFOLDER_NAME ); 	
     }
     
     // use reflection to generate the specified log formatter class instance
diff --git a/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/META-INF/MANIFEST.MF
index 85cd855..d7d012c 100644
--- a/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/META-INF/MANIFEST.MF
@@ -2,9 +2,10 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: DTP ODA Consumer Helper Tests Suite
 Bundle-SymbolicName: org.eclipse.datatools.connectivity.oda.consumer.tests;singleton:=true
-Bundle-Version: 3.0.2.200607071
+Bundle-Version: 3.0.2.200608221
 Bundle-Localization: plugin
 Bundle-Vendor: Eclipse.org
 Require-Bundle: org.junit,
  org.eclipse.datatools.connectivity.oda.consumer,
- org.eclipse.datatools.connectivity.oda.flatfile;resolution:=optional
+ org.eclipse.datatools.connectivity.oda.flatfile;resolution:=optional,
+ org.eclipse.core.runtime
diff --git a/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/FlatFileTestCase.java b/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/FlatFileTestCase.java
new file mode 100644
index 0000000..e3bbbed
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/FlatFileTestCase.java
@@ -0,0 +1,72 @@
+/*
+ *************************************************************************
+ * Copyright (c) 2006 Actuate Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *  Actuate Corporation - initial API and implementation
+ *  
+ *************************************************************************
+ */
+
+package org.eclipse.datatools.connectivity.oda.consumer.tests;
+
+import org.eclipse.datatools.connectivity.oda.IConnection;
+import org.eclipse.datatools.connectivity.oda.IDriver;
+import org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConnection;
+import org.eclipse.datatools.connectivity.oda.consumer.helper.OdaDriver;
+
+import junit.framework.TestCase;
+
+/**
+ * @author lchan
+ *
+ */
+public class FlatFileTestCase extends TestCase
+{
+	static final String TEST_FLATFILE_ID = 
+		"org.eclipse.datatools.connectivity.oda.flatfile"; //$NON-NLS-1$
+
+	private static IDriver sm_odaDriver;
+	private static IConnection sm_odaConn;
+	
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception
+	{
+		super.setUp();
+		
+		if( sm_odaDriver == null )
+			sm_odaDriver = new OdaDriver( TEST_FLATFILE_ID );
+		if( sm_odaConn == null )
+			sm_odaConn = sm_odaDriver.getConnection( TEST_FLATFILE_ID );
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception
+	{
+		super.tearDown();
+		// up to subclass to close connection at tearDown
+	}
+
+	protected static IConnection getOdaConn()
+	{
+		return sm_odaConn;
+	}
+
+	protected static IDriver getOdaDriver()
+	{
+		return sm_odaDriver;
+	}
+
+	public final void testOpenConnection()
+	{
+		assertTrue( sm_odaConn instanceof OdaConnection );
+	}
+}
diff --git a/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/OdaBlobTest.java b/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/OdaBlobTest.java
index c30f38e..a26159c 100644
--- a/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/OdaBlobTest.java
+++ b/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/OdaBlobTest.java
@@ -16,24 +16,14 @@
 
 import java.io.IOException;
 
-import junit.framework.TestCase;
-
 import org.eclipse.datatools.connectivity.oda.IBlob;
-import org.eclipse.datatools.connectivity.oda.IConnection;
-import org.eclipse.datatools.connectivity.oda.IDriver;
 import org.eclipse.datatools.connectivity.oda.OdaException;
 import org.eclipse.datatools.connectivity.oda.consumer.helper.OdaBlob;
 import org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConnection;
-import org.eclipse.datatools.connectivity.oda.consumer.helper.OdaDriver;
 import org.eclipse.datatools.connectivity.oda.impl.Blob;
 
-public class OdaBlobTest extends TestCase
+public class OdaBlobTest extends FlatFileTestCase
 {
-    private static final String TEST_FLATFILE_ID = 
-        "org.eclipse.datatools.connectivity.oda.flatfile"; //$NON-NLS-1$
-
-    private static IDriver sm_odaDriver;
-    private static IConnection sm_odaConn;
     private static IBlob sm_driverBlob;
     
     private static final byte[] sm_bytesData = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 
@@ -42,15 +32,6 @@
     protected void setUp() throws Exception
     {
         super.setUp();
-        if( sm_odaDriver == null )
-        {
-            sm_odaDriver = new OdaDriver( TEST_FLATFILE_ID );
-        }
-        if( sm_odaConn == null )
-        {
-            sm_odaConn = sm_odaDriver.getConnection( TEST_FLATFILE_ID );
-            assertTrue( sm_odaConn instanceof OdaConnection );
-        }
         if( sm_driverBlob == null )
         {
             sm_driverBlob = new DriverTestBlob( sm_bytesData );
@@ -64,8 +45,8 @@
     {
         super.tearDown();
         
-/*        if( sm_odaConn != null )
-            sm_odaConn.close();
+/*        if( getOdaConn() != null )
+            getOdaConn().close();
 */    
         sm_driverBlob = null;
     }
@@ -75,7 +56,8 @@
      */
     public void testGetLeadingBytes() throws OdaException, IOException
     {       
-        IBlob testBlob = new OdaTestBlob( sm_driverBlob, (OdaConnection) sm_odaConn, 5 );
+        IBlob testBlob = new OdaTestBlob( sm_driverBlob, 
+        						(OdaConnection) getOdaConn(), 5 );
         int startPos = 1;
         int fetchLen = 7;
         
@@ -94,7 +76,8 @@
      */
     public void testGetSkippedBytes() throws OdaException, IOException
     {       
-        IBlob testBlob = new OdaTestBlob( sm_driverBlob, (OdaConnection) sm_odaConn, 5 );
+        IBlob testBlob = new OdaTestBlob( sm_driverBlob, 
+        								(OdaConnection) getOdaConn(), 5 );
         int startPos = 4;
         int fetchLen = 7;
         
@@ -114,7 +97,7 @@
      */
     public void testGetMoreThanAvailableBytes() throws OdaException, IOException
     {       
-        IBlob testBlob = new OdaTestBlob( sm_driverBlob, (OdaConnection) sm_odaConn, 5 );
+        IBlob testBlob = new OdaTestBlob( sm_driverBlob, (OdaConnection) getOdaConn(), 5 );
         int startPos = 13;
         int fetchLen = 7;
         int streamLen = sm_bytesData.length;
@@ -134,7 +117,7 @@
      */
     public void testGetRemainingBytes() throws OdaException, IOException
     {       
-        IBlob testBlob = new OdaTestBlob( sm_driverBlob, (OdaConnection) sm_odaConn, 5 );
+        IBlob testBlob = new OdaTestBlob( sm_driverBlob, (OdaConnection) getOdaConn(), 5 );
         int startPos = 13;
         int fetchLen = -1;
         int streamLen = sm_bytesData.length;
@@ -178,7 +161,7 @@
      */
     public void testGetBytesNoData() throws OdaException, IOException
     {
-        IBlob testBlob = new OdaTestBlob( sm_driverBlob, (OdaConnection) sm_odaConn, 5 );
+        IBlob testBlob = new OdaTestBlob( sm_driverBlob, (OdaConnection) getOdaConn(), 5 );
         
         byte[] retrievedBytes = testBlob.getBytes( 17, 3 );
         assertEquals( 0, retrievedBytes.length );
@@ -200,7 +183,7 @@
      */
     public void testSkipBytesBeyondStream() throws OdaException, IOException
     {
-        IBlob testBlob = new OdaTestBlob( sm_driverBlob, (OdaConnection) sm_odaConn, 5 );
+        IBlob testBlob = new OdaTestBlob( sm_driverBlob, (OdaConnection) getOdaConn(), 5 );
         
         boolean caughtException = false;
         try
@@ -247,7 +230,7 @@
     public void testGetEmptyStream() throws OdaException, IOException
     {       
         IBlob driverBlob = new DriverTestBlob( new byte[0] );
-        IBlob testBlob = new OdaTestBlob( driverBlob, (OdaConnection) sm_odaConn, 5 );
+        IBlob testBlob = new OdaTestBlob( driverBlob, (OdaConnection) getOdaConn(), 5 );
         int startPos = 0;
         int fetchLen = -1;
         
@@ -263,7 +246,7 @@
     private byte[] getBufferedBytes( int startPos, int fetchLen, int defaultBufferSize ) 
         throws OdaException, IOException
     {
-        IBlob testBlob = new OdaTestBlob( sm_driverBlob, (OdaConnection) sm_odaConn, defaultBufferSize );
+        IBlob testBlob = new OdaTestBlob( sm_driverBlob, (OdaConnection) getOdaConn(), defaultBufferSize );
         
         // triggers test driver to throw exception on the optional method - length()
         DriverTestBlob driverBlob = (DriverTestBlob) sm_driverBlob;
diff --git a/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/OdaClobTest.java b/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/OdaClobTest.java
index 5e0810a..9685f26 100644
--- a/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/OdaClobTest.java
+++ b/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/OdaClobTest.java
@@ -16,24 +16,14 @@
 
 import java.io.IOException;
 
-import junit.framework.TestCase;
-
 import org.eclipse.datatools.connectivity.oda.IClob;
-import org.eclipse.datatools.connectivity.oda.IConnection;
-import org.eclipse.datatools.connectivity.oda.IDriver;
 import org.eclipse.datatools.connectivity.oda.OdaException;
 import org.eclipse.datatools.connectivity.oda.consumer.helper.OdaClob;
 import org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConnection;
-import org.eclipse.datatools.connectivity.oda.consumer.helper.OdaDriver;
 import org.eclipse.datatools.connectivity.oda.impl.Clob;
 
-public class OdaClobTest extends TestCase
+public class OdaClobTest extends FlatFileTestCase
 {
-    private static final String TEST_FLATFILE_ID = 
-        "org.eclipse.datatools.connectivity.oda.flatfile"; //$NON-NLS-1$
-
-    private static IDriver sm_odaDriver;
-    private static IConnection sm_odaConn;
     private static IClob sm_driverClob;
     
     private static final String sm_testData = "abcdefghijklmnopqrstuvwxyz";
@@ -41,15 +31,6 @@
     protected void setUp() throws Exception
     {
         super.setUp();
-        if( sm_odaDriver == null )
-        {
-            sm_odaDriver = new OdaDriver( TEST_FLATFILE_ID );
-        }
-        if( sm_odaConn == null )
-        {
-            sm_odaConn = sm_odaDriver.getConnection( TEST_FLATFILE_ID );
-            assertTrue( sm_odaConn instanceof OdaConnection );
-        }
         if( sm_driverClob == null )
         {
             sm_driverClob = new DriverTestClob( sm_testData );
@@ -63,8 +44,8 @@
     {
         super.tearDown();
         
-/*        if( sm_odaConn != null )
-            sm_odaConn.close();
+/*        if( getOdaConn() != null )
+            getOdaConn().close();
 */    
         sm_driverClob = null;
     }
@@ -74,7 +55,8 @@
      */
     public void testGetLeadingChars() throws OdaException, IOException
     {       
-        IClob testClob = new OdaTestClob( sm_driverClob, (OdaConnection) sm_odaConn, 5 );
+        IClob testClob = new OdaTestClob( sm_driverClob, 
+        						(OdaConnection) getOdaConn(), 5 );
         int startPos = 1;
         int fetchLen = 7;
         
@@ -87,7 +69,8 @@
      */
     public void testGetSkippedChars() throws OdaException, IOException
     {       
-        IClob testClob = new OdaTestClob( sm_driverClob, (OdaConnection) sm_odaConn, 5 );
+        IClob testClob = new OdaTestClob( sm_driverClob, 
+        								(OdaConnection) getOdaConn(), 5 );
         int startPos = 6;
         int fetchLen = 7;
         
@@ -101,7 +84,8 @@
      */
     public void testGetMoreThanAvailableChars() throws OdaException, IOException
     {       
-        IClob testClob = new OdaTestClob( sm_driverClob, (OdaConnection) sm_odaConn, 5 );
+        IClob testClob = new OdaTestClob( sm_driverClob, 
+        								(OdaConnection) getOdaConn(), 5 );
         int startPos = 23;
         int fetchLen = 7;
 
@@ -114,7 +98,8 @@
      */
     public void testGetRemainingChars() throws OdaException, IOException
     {       
-        IClob testClob = new OdaTestClob( sm_driverClob, (OdaConnection) sm_odaConn, 5 );
+        IClob testClob = new OdaTestClob( sm_driverClob, 
+        								(OdaConnection) getOdaConn(), 5 );
         int startPos = 16;
         int fetchLen = -1;
 
@@ -153,7 +138,8 @@
      */
     public void testGetCharsNoData() throws OdaException, IOException
     {
-        IClob testClob = new OdaTestClob( sm_driverClob, (OdaConnection) sm_odaConn, 5 );
+        IClob testClob = new OdaTestClob( sm_driverClob, 
+        								(OdaConnection) getOdaConn(), 5 );
         int startPos = 27;
         int fetchLen = 3;
        
@@ -179,7 +165,8 @@
      */
     public void testSkipCharsBeyondStream() throws OdaException, IOException
     {
-        IClob testClob = new OdaTestClob( sm_driverClob, (OdaConnection) sm_odaConn, 5 );
+        IClob testClob = new OdaTestClob( sm_driverClob, 
+        								(OdaConnection) getOdaConn(), 5 );
         
         boolean caughtException = false;
         try
@@ -226,7 +213,8 @@
     public void testGetEmptyStream() throws OdaException, IOException
     {       
         IClob driverClob = new DriverTestClob( new String() );
-        IClob testClob = new OdaTestClob( driverClob, (OdaConnection) sm_odaConn, 5 );
+        IClob testClob = new OdaTestClob( driverClob, 
+        								(OdaConnection) getOdaConn(), 5 );
         int startPos = 0;
         int fetchLen = -1;
         
@@ -242,7 +230,8 @@
     private String getBufferedSubString( int startPos, int fetchLen, int defaultBufferSize ) 
         throws OdaException, IOException
     {
-        IClob testClob = new OdaTestClob( sm_driverClob, (OdaConnection) sm_odaConn, defaultBufferSize );
+        IClob testClob = new OdaTestClob( sm_driverClob, 
+        								(OdaConnection) getOdaConn(), defaultBufferSize );
         
         // triggers test driver to throw exception on the optional method - length()
         DriverTestClob driverBlob = (DriverTestClob) sm_driverClob;
diff --git a/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/TraceLogTest.java b/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/TraceLogTest.java
new file mode 100644
index 0000000..d1cb646
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.consumer.tests/src/org/eclipse/datatools/connectivity/oda/consumer/tests/TraceLogTest.java
@@ -0,0 +1,152 @@
+/*
+ *************************************************************************
+ * Copyright (c) 2006 Actuate Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *  Actuate Corporation - initial API and implementation
+ *  
+ *************************************************************************
+ */
+
+package org.eclipse.datatools.connectivity.oda.consumer.tests;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.datatools.connectivity.oda.LogConfiguration;
+import org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConsumerPlugin;
+import org.eclipse.datatools.connectivity.oda.consumer.helper.OdaDriver;
+import org.eclipse.datatools.connectivity.oda.util.OdaPlugin;
+import org.eclipse.datatools.connectivity.oda.util.logging.Level;
+
+public class TraceLogTest extends FlatFileTestCase
+{
+	private static final String TEST_LOG_PREFIX = "OdaHelperLog"; //$NON-NLS-1$
+    private static File sm_testLogDir;
+	
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        
+        if( sm_testLogDir == null )
+        {
+	        sm_testLogDir = 
+	        		OdaConsumerPlugin.getDefault().getStateLocation()
+	        			.append( "logs" )
+	        			.append( TEST_FLATFILE_ID ).toFile();
+        }
+        cleanupTestLogFiles( sm_testLogDir );
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        
+        if( getOdaConn() != null )
+            getOdaConn().close();
+
+        // turn off OdaDriver's logging before log files can be deleted
+		LogConfiguration offLogConfig = 
+		    new LogConfiguration( 
+		    		TEST_FLATFILE_ID,
+					 Level.OFF, 
+					 "./OdaLogs",
+					 TEST_LOG_PREFIX, 
+					 "java.util.logging.SimpleFormatter" );
+    	getOdaDriver().setLogConfiguration( offLogConfig );
+		
+        cleanupTestLogFiles( sm_testLogDir );
+    }
+    
+	private void cleanupTestLogFiles( File logDir ) throws IOException
+    {        
+		if( logDir == null || ! logDir.exists() )
+			return;		// nothing to clear
+        File[] filesInDir = logDir.listFiles();
+        if( filesInDir == null )
+            return;		// nothing to clear
+        
+        for ( int i = 0; i < filesInDir.length; i += 1 )
+        {         
+            boolean deleted = filesInDir[i].delete();
+            if ( ! deleted )
+                throw new IOException( "Cannot delete file: " + filesInDir[i].getName() );
+        }
+    }
+
+    public void testDefaultLogDir() throws Exception
+    {
+    	LogConfiguration logConfig = new LogConfiguration( TEST_FLATFILE_ID,
+    						 Level.FINE, 
+    						 "./OdaLogs",
+    						 TEST_LOG_PREFIX, 
+    						 "java.util.logging.SimpleFormatter" );
+    	
+    	assertFalse( hasTestLogFiles( sm_testLogDir ) );
+    	getOdaDriver().setLogConfiguration( logConfig );
+    	
+    	assertTrue( sm_testLogDir.exists() );
+    	assertTrue( hasTestLogFiles( sm_testLogDir ) );
+    }
+    
+    public void testSetLogDir() throws Exception
+    {
+    	LogConfiguration logConfig = new LogConfiguration( TEST_FLATFILE_ID,
+    						 Level.FINE, 
+    						 "./OdaLogs",
+    						 TEST_LOG_PREFIX, 
+    						 "java.util.logging.SimpleFormatter" );
+    	
+    	assertFalse( hasTestLogFiles( sm_testLogDir ) );
+    	
+    	String ownLogDir = "testSetLogDir";
+    	if( getOdaDriver() instanceof OdaDriver )
+    	{
+    		// overrides the default log dir
+    		((OdaDriver) getOdaDriver()).setLogDirectory( ownLogDir );
+    	}
+    		
+    	getOdaDriver().setLogConfiguration( logConfig );
+    	
+    	// default log dir still should not exist
+    	assertFalse( hasTestLogFiles( sm_testLogDir ) );
+    	
+    	// expects to find log file relative to the oda LogManager base dir
+    	File relativeBaseDir = 
+    		OdaPlugin.getDefault().getStateLocation()
+        			.append( "logs" )
+        			.append( ownLogDir ).toFile();
+    	assertTrue( hasTestLogFiles( relativeBaseDir ) );
+    	
+    	// cleanup 
+    	LogConfiguration offLogConfig = new LogConfiguration( 
+    										logConfig.getDataSourceId(),
+    										Level.OFF,
+    										logConfig.getLogDirectory(),
+    										logConfig.getLogPrefix(),
+    										logConfig.getFormatterClassName() );
+    	getOdaDriver().setLogConfiguration( offLogConfig );
+        cleanupTestLogFiles( relativeBaseDir );
+    }
+    
+    private boolean hasTestLogFiles( File logDir )
+    {
+    	String[] filesInDir = logDir.list();
+    	if( filesInDir == null )
+        	return false;
+
+    	for( int i = 0; i < filesInDir.length; i++ )
+    	{
+    		if( filesInDir[i].startsWith( TEST_LOG_PREFIX ) )
+    			return true;
+    	}    	
+    	return false;
+    }
+}