Updated junit tests
diff --git a/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/ConnProfilePropProviderTest.java b/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/ConnProfilePropProviderTest.java
new file mode 100644
index 0000000..d98ecab
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/ConnProfilePropProviderTest.java
@@ -0,0 +1,256 @@
+/*
+ *************************************************************************
+ * Copyright (c) 2007 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.profile.tests;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.datatools.connectivity.internal.ConnectionProfileMgmt;
+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.OdaDriver;
+import org.eclipse.datatools.connectivity.oda.consumer.services.IPropertyProvider;
+import org.eclipse.datatools.connectivity.oda.profile.Constants;
+import org.eclipse.datatools.connectivity.oda.util.manifest.ConnectionProfileProperty;
+
+/**
+ * Plugin Test cases of the ODA Connection Profile's Property Provider Service.
+ */
+public class ConnProfilePropProviderTest extends TestCase
+{
+    private static final String TEST_DRIVER_ID = 
+        "org.eclipse.datatools.connectivity.oda.flatfile";
+    private static final String FlatFileProfileName = 
+        "MyFFProfile1wDesc";
+
+    private IPath m_testStoreLocation = null;
+    private File m_testFileStore;
+    private IDriver m_driver = null;
+    private IConnection m_connection;
+
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        if( m_testStoreLocation == null )
+            m_testStoreLocation = new Path( TestUtil.getPluginTestDirectory() );
+        m_testFileStore = TestUtil.copyTestStoreFileFromTemplate( 
+                m_testStoreLocation, 
+                ConnectionProfileMgmt.FILENAME );
+
+        m_connection = getDriver().getConnection( null );
+        assertNotNull( m_connection );
+    }
+
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        if ( m_connection.isOpen() )
+            m_connection.close( );
+        m_connection = null;
+
+        ConnectionProfileMgmt.setStorageLocation( null );
+        m_testFileStore.delete();
+        m_testFileStore = null;
+        super.tearDown();
+    }
+    
+    private IDriver getDriver() throws OdaException
+    {
+        if( m_driver == null )
+            m_driver = new OdaDriver( TEST_DRIVER_ID );        
+        return m_driver;
+    }
+    
+    private HashMap getAppContextForCPProviderService()
+    {
+        HashMap connAppContext = new HashMap();
+        connAppContext.put( IPropertyProvider.ODA_CONSUMER_ID, 
+                            Constants.CONN_PROFILE_APPL_ID );
+        return connAppContext;
+    }
+    
+    public final void testGetProfileByProperties() throws OdaException
+    {
+        m_connection.setAppContext( getAppContextForCPProviderService() );
+
+        Properties connProperties = new Properties();
+        connProperties.put( ConnectionProfileProperty.PROFILE_NAME_PROP_KEY, 
+                            FlatFileProfileName );
+        connProperties.put( ConnectionProfileProperty.PROFILE_STORE_FILE_PATH_PROP_KEY, 
+                            m_testFileStore.toString() );
+        
+        // open should succeed to load properties from profile info in properties
+        m_connection.open( connProperties );
+        assertTrue( m_connection.isOpen() );    
+    }
+    
+    public final void testGetProfileInFileObject() throws OdaException
+    {
+        // specify the profile store file object in a property context
+        HashMap connPropsContext = new HashMap();
+        connPropsContext.put( ConnectionProfileProperty.PROFILE_STORE_FILE_PROP_KEY , 
+                                m_testFileStore );
+        
+        HashMap connAppContext = getAppContextForCPProviderService();
+        connAppContext.put( IPropertyProvider.ODA_CONN_PROP_CONTEXT, connPropsContext );
+
+        m_connection.setAppContext( connAppContext );
+
+        Properties connProperties = new Properties();
+        connProperties.put( ConnectionProfileProperty.PROFILE_NAME_PROP_KEY, 
+                            FlatFileProfileName );
+        connProperties.put( ConnectionProfileProperty.PROFILE_STORE_FILE_PATH_PROP_KEY, 
+                            "dummyFilePath" );
+
+        // open should succeed to load properties from profile file object in context
+        m_connection.open( connProperties );
+        assertTrue( m_connection.isOpen() );    
+    }
+    
+    public final void testGetProfileFallbackToFilePath() throws OdaException
+    {
+        // expects to see warnings in log
+        
+        // specify an invalid profile store file object in the property context
+        HashMap connPropsContext = new HashMap();
+        File nonExistFile = new File( "dummy" );
+        connPropsContext.put( ConnectionProfileProperty.PROFILE_STORE_FILE_PROP_KEY , 
+                            nonExistFile );
+        
+        HashMap connAppContext = getAppContextForCPProviderService();
+        connAppContext.put( IPropertyProvider.ODA_CONN_PROP_CONTEXT, connPropsContext );
+
+        m_connection.setAppContext( connAppContext );
+
+        Properties connProperties = new Properties();
+        connProperties.put( ConnectionProfileProperty.PROFILE_NAME_PROP_KEY, 
+                            FlatFileProfileName );
+        // specify a valid file path to fallback on
+        connProperties.put( ConnectionProfileProperty.PROFILE_STORE_FILE_PATH_PROP_KEY, 
+                            m_testFileStore.toString() );
+
+        // open should succeed to load properties from profile file path
+        m_connection.open( connProperties );
+        assertTrue( m_connection.isOpen() );    
+    }
+    
+    public final void testGetProfileFallbackToDefaultStore() throws OdaException
+    {
+        // expects to see warnings in log
+
+        // specify the default store to fallback to
+        ConnectionProfileMgmt.setStorageLocation( m_testStoreLocation );
+        
+        // specify an invalid profile store file object in the property context
+        HashMap connPropsContext = new HashMap();
+        File nonExistFile = new File( "dummy" );
+        connPropsContext.put( ConnectionProfileProperty.PROFILE_STORE_FILE_PROP_KEY , 
+                            nonExistFile );
+        
+        HashMap connAppContext = getAppContextForCPProviderService();
+        connAppContext.put( IPropertyProvider.ODA_CONN_PROP_CONTEXT, connPropsContext );
+
+        m_connection.setAppContext( connAppContext );
+
+        Properties connProperties = new Properties();
+        connProperties.put( ConnectionProfileProperty.PROFILE_NAME_PROP_KEY, 
+                            FlatFileProfileName );
+        // specify an invalid profile store file path in the property context
+        connProperties.put( ConnectionProfileProperty.PROFILE_STORE_FILE_PATH_PROP_KEY, 
+                            "dummyFilePath" );
+
+        // open should succeed to load properties from profile file in default location
+        m_connection.open( connProperties );
+        assertTrue( m_connection.isOpen() );    
+    }
+    
+    public final void testInvalidProfileStore() throws OdaException
+    {
+        // expects to see warnings in log
+
+        // specify an invalid profile store file object in the property context
+        HashMap connPropsContext = new HashMap();
+        File nonExistFile = new File( "dummy" );
+        connPropsContext.put( ConnectionProfileProperty.PROFILE_STORE_FILE_PROP_KEY , 
+                            nonExistFile );
+        
+        HashMap connAppContext = getAppContextForCPProviderService();
+        connAppContext.put( IPropertyProvider.ODA_CONN_PROP_CONTEXT, connPropsContext );
+
+        m_connection.setAppContext( connAppContext );
+
+        Properties connProperties = new Properties();
+        connProperties.put( ConnectionProfileProperty.PROFILE_NAME_PROP_KEY, 
+                            FlatFileProfileName );
+        // specify an invalid profile store file path in the property context
+        connProperties.put( ConnectionProfileProperty.PROFILE_STORE_FILE_PATH_PROP_KEY, 
+                            "dummyFilePath" );
+
+        // open should fail since no valid profile file object or file path is specified
+        // this would fall back to the default profile store file in workspace
+        try
+        {
+            m_connection.open( connProperties );
+        }
+        catch( OdaException ex )
+        {
+            
+        }
+        assertFalse( m_connection.isOpen() );    
+    }
+    
+    public final void testInvalidProfileName() throws OdaException
+    {
+        // expects to see warnings in log
+
+        // specify the profile store file object in a property context
+        HashMap connPropsContext = new HashMap();
+        connPropsContext.put( ConnectionProfileProperty.PROFILE_STORE_FILE_PROP_KEY , 
+                                m_testFileStore );
+        
+        HashMap connAppContext = getAppContextForCPProviderService();
+        connAppContext.put( IPropertyProvider.ODA_CONN_PROP_CONTEXT, connPropsContext );
+
+        m_connection.setAppContext( connAppContext );
+
+        // specify an invalid profile name
+        Properties connProperties = new Properties();
+        connProperties.put( ConnectionProfileProperty.PROFILE_NAME_PROP_KEY, 
+                            "dummyProfileName" );
+
+        // open should fail since no valid profile name is specified
+        try
+        {
+            m_connection.open( connProperties );
+        }
+        catch( OdaException ex )
+        {
+            
+        }
+        assertFalse( m_connection.isOpen() );    
+    }
+
+}
diff --git a/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/ProfileExplorerPluginTest.java b/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/ProfileExplorerPluginTest.java
index 6519b50..d800f89 100644
--- a/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/ProfileExplorerPluginTest.java
+++ b/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/ProfileExplorerPluginTest.java
@@ -15,25 +15,18 @@
 package org.eclipse.datatools.connectivity.oda.profile.tests;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.net.URL;
-import java.nio.channels.FileChannel;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 
-import org.eclipse.core.runtime.FileLocator;
+import junit.framework.TestCase;
+
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
 import org.eclipse.datatools.connectivity.internal.ConnectionProfileMgmt;
 import org.eclipse.datatools.connectivity.oda.OdaException;
 import org.eclipse.datatools.connectivity.oda.profile.OdaProfileExplorer;
-import org.osgi.framework.Bundle;
-
-import junit.framework.TestCase;
 
 /**
  * Plugin Test cases of the Oda Profile Explorer.
@@ -58,43 +51,18 @@
             m_profileExplorer = OdaProfileExplorer.getInstance();
 
         if( m_testStoreLocation == null )
-            m_testStoreLocation = new Path( getPluginTestDirectory() );
+            m_testStoreLocation = new Path( TestUtil.getPluginTestDirectory() );
         ConnectionProfileMgmt.setStorageLocation( m_testStoreLocation );
 
         if ( getName().equals( "testGetProfilesFromFile" ) )
-            m_testFileStore = copyTestStoreFileFromTemplate( 
+            m_testFileStore = TestUtil.copyTestStoreFileFromTemplate( 
                     m_testStoreLocation, 
                     MixedEntryStoreName );
         else
-            m_testFileStore = copyTestStoreFileFromTemplate( 
+            m_testFileStore = TestUtil.copyTestStoreFileFromTemplate( 
                     m_testStoreLocation, 
                     ConnectionProfileMgmt.FILENAME );
     }
-
-    private File copyTestStoreFileFromTemplate( IPath storeLocation, String storeFilename )
-        throws Exception
-    {
-        // getting profile has the side effect of adding to 
-        // the profiles cache, which updates the profiles store.
-        // So use a temporary store file copied from a template
-        // for use in tests
-        File profileStoreTemplate = storeLocation.append( 
-                "tmplt_" + storeFilename ).toFile();
-        if ( ! profileStoreTemplate.exists() )
-            fail( profileStoreTemplate.getPath() + " template store file does not exist." );
-
-        File testFile = storeLocation.append( storeFilename ).toFile();
-        if ( testFile.exists() )
-            testFile.delete();
-        testFile.createNewFile();
-        
-        FileChannel sourceChan = new FileInputStream( profileStoreTemplate ).getChannel();
-        FileChannel destChan = new FileOutputStream( testFile ).getChannel();
-        destChan.transferFrom( sourceChan, 0, sourceChan.size() );
-        sourceChan.close();
-        destChan.close();
-        return testFile;
-    }
     
     protected void tearDown() throws Exception
     {
@@ -150,9 +118,8 @@
         String profileInstId = getFlatFileProfileInstanceId();
         Properties connProps = m_profileExplorer.getProfileProperties( profileInstId );
         assertNotNull( connProps );
-        // the VersionProviderConnection base class owns 4 properties;
-        // FlatFile adds 3 custom properties
-        assertEquals( 7, connProps.size() );
+        // FlatFile has 5 custom properties
+        assertEquals( 5, connProps.size() );
     }
 
     /*
@@ -203,11 +170,4 @@
         fail( "No Flat File profiles found" );
         return null;
     }
-    
-    private String getPluginTestDirectory() throws Exception
-    {
-        Bundle bundle = Platform.getBundle( getClass().getPackage().getName() );
-        URL url = bundle.getEntry( "src" );
-        return FileLocator.toFileURL( url ).getPath();
-    }
 }
diff --git a/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/TestUtil.java b/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/TestUtil.java
new file mode 100644
index 0000000..fdc0ce8
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/TestUtil.java
@@ -0,0 +1,67 @@
+/*
+ *************************************************************************
+ * Copyright (c) 2007 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.profile.tests;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.channels.FileChannel;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+
+/**
+ * Common test utility methods used in test package.
+ */
+public class TestUtil
+{
+    
+    static String getPluginTestDirectory() throws Exception
+    {
+        Bundle bundle = Platform.getBundle( TestUtil.class.getPackage().getName() );
+        URL url = bundle.getEntry( "src" );
+        return FileLocator.toFileURL( url ).getPath();
+    }
+
+    static File copyTestStoreFileFromTemplate( IPath storeLocation, String storeFilename )
+        throws IOException
+    {
+        // getting profile has the side effect of adding to 
+        // the profiles cache, which updates the profiles store.
+        // So use a temporary store file copied from a template
+        // for use in tests
+        File profileStoreTemplate = storeLocation.append( 
+                "tmplt_" + storeFilename ).toFile();
+        if ( ! profileStoreTemplate.exists() )
+            throw new IOException( profileStoreTemplate.getPath() + " template store file does not exist." );
+
+        File testFile = storeLocation.append( storeFilename ).toFile();
+        if ( testFile.exists() )
+            testFile.delete();
+        testFile.createNewFile();
+        
+        FileChannel sourceChan = new FileInputStream( profileStoreTemplate ).getChannel();
+        FileChannel destChan = new FileOutputStream( testFile ).getChannel();
+        destChan.transferFrom( sourceChan, 0, sourceChan.size() );
+        sourceChan.close();
+        destChan.close();
+        return testFile;
+    }
+
+}