[210171] Utility to save or load an ODA Design Session to/from an URI resource
diff --git a/tests/org.eclipse.datatools.connectivity.oda.design.tests/.classpath b/tests/org.eclipse.datatools.connectivity.oda.design.tests/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.design.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.datatools.connectivity.oda.design.tests/.cvsignore b/tests/org.eclipse.datatools.connectivity.oda.design.tests/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.design.tests/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/tests/org.eclipse.datatools.connectivity.oda.design.tests/.project b/tests/org.eclipse.datatools.connectivity.oda.design.tests/.project
new file mode 100644
index 0000000..279752c
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.design.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.eclipse.datatools.connectivity.oda.design.tests</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.pde.PluginNature</nature>
+	</natures>
+</projectDescription>
diff --git a/tests/org.eclipse.datatools.connectivity.oda.design.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.datatools.connectivity.oda.design.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..c88471c
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.design.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: DTP ODA Design Tests Suite
+Bundle-SymbolicName: org.eclipse.datatools.connectivity.oda.design.tests; singleton:=true
+Bundle-Version: 3.0.6.200711191
+Bundle-ClassPath: org.eclipse.datatools.connectivity.oda.design.tests.jar
+Bundle-Vendor: Eclipse.org
+Export-Package: org.eclipse.datatools.connectivity.oda.design.tests
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.datatools.connectivity.oda.design;visibility:=reexport,
+ org.eclipse.emf.ecore.xmi;visibility:=reexport,
+ org.junit;visibility:=reexport
+Eclipse-LazyStart: true
diff --git a/tests/org.eclipse.datatools.connectivity.oda.design.tests/about.html b/tests/org.eclipse.datatools.connectivity.oda.design.tests/about.html
new file mode 100644
index 0000000..1b7d275
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.design.tests/about.html
@@ -0,0 +1,28 @@
+<html>
+<head>
+<title>About This Content</title>
+</head>
+<body>
+<div>
+<h3>About This Content</h3>
+<p>May 2, 2006</p>
+<h3>License</h3>
+<p>The Eclipse Foundation makes available all content in this plug-in
+(&quot;Content&quot;). Unless otherwise indicated below, the Content is
+provided to you under the terms and conditions of the Eclipse Public License
+Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available at <a
+href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation,
+the Content is being redistributed by another party (&quot;Redistributor&quot;)
+and different terms and conditions may apply to your use of any object code in
+the Content. Check the Redistributor’s license that was provided with the
+Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source
+code in the Content and such source code may be obtained at <a
+href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+<p>&nbsp;</p>
+</div>
+</body>
+</html>
diff --git a/tests/org.eclipse.datatools.connectivity.oda.design.tests/build.properties b/tests/org.eclipse.datatools.connectivity.oda.design.tests/build.properties
new file mode 100644
index 0000000..1392450
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.design.tests/build.properties
@@ -0,0 +1,23 @@
+# <copyright>
+# *************************************************************************
+# * 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
+# *  
+# *************************************************************************
+# </copyright>
+#
+# $Id$
+
+bin.includes = org.eclipse.datatools.connectivity.oda.design.tests.jar,\
+               META-INF/,\
+               plugin.xml,\
+               testFiles/
+jars.compile.order = org.eclipse.datatools.connectivity.oda.design.tests.jar
+source.org.eclipse.datatools.connectivity.oda.design.tests.jar = src/
+output.org.eclipse.datatools.connectivity.oda.design.tests.jar = bin/
diff --git a/tests/org.eclipse.datatools.connectivity.oda.design.tests/plugin.xml b/tests/org.eclipse.datatools.connectivity.oda.design.tests/plugin.xml
new file mode 100644
index 0000000..823ccb0
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.design.tests/plugin.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ <copyright>
+ *************************************************************************
+ * 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
+ *  
+ *************************************************************************
+ </copyright>
+
+ $Id$
+-->
+
+<plugin>
+</plugin>
+
diff --git a/tests/org.eclipse.datatools.connectivity.oda.design.tests/src/org/eclipse/datatools/connectivity/oda/design/tests/DesignUtilLoadSaveTest.java b/tests/org.eclipse.datatools.connectivity.oda.design.tests/src/org/eclipse/datatools/connectivity/oda/design/tests/DesignUtilLoadSaveTest.java
new file mode 100644
index 0000000..5eede90
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.design.tests/src/org/eclipse/datatools/connectivity/oda/design/tests/DesignUtilLoadSaveTest.java
@@ -0,0 +1,176 @@
+/*
+ *************************************************************************
+ * 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.design.tests;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.datatools.connectivity.oda.design.OdaDesignSession;
+import org.eclipse.datatools.connectivity.oda.design.util.DesignUtil;
+
+/**
+ * Test cases for loading and saving OdaDesignSession utility in DesignUtil.  
+ */
+public class DesignUtilLoadSaveTest extends TestCase
+{
+    private String m_testFilePath;
+    
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        if( m_testFilePath == null )
+        {
+            try
+            {
+                m_testFilePath = TestUtil.getPluginTestFilePath();
+            }
+            catch( IOException ex )
+            {
+                ex.printStackTrace();
+                fail();
+            }
+        }
+    }
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    public void testLoadOdaDesignSession()
+    {
+        OdaDesignSession design = loadOdaDesignSession( new File( getSampleDbTestFile() ));
+        assertEquals( "sampledb Data Set", design.getResponseDataSetDesign().getName() );
+        assertNotNull( design.getRequestDataSetDesign() );
+        assertNotNull( design.getResponseDataSetDesign() );
+    }
+    
+    private OdaDesignSession loadOdaDesignSession( File testFile )
+    {
+        OdaDesignSession design = null;
+        try
+        {
+            design = DesignUtil.loadOdaDesignSession( testFile );
+        }
+        catch( Exception ex )
+        {
+            fail();
+        }
+        assertNotNull( design );
+        return design;
+    }
+    
+    private String getGoldenTestFilePath()
+    {
+        return m_testFilePath + "/golden";
+    }
+    
+    private String getSampleDbTestFile()
+    {
+        return getGoldenTestFilePath() + "/jdbcBirtSampleSession.xml";
+    }
+    
+    private String getTempOutFile()
+    {
+        return m_testFilePath + "/tempOut.xml";
+    }
+
+    public void testSaveDesignSession()
+    {
+        File goldenFile = new File( getSampleDbTestFile() );
+        OdaDesignSession design = loadOdaDesignSession( goldenFile );
+
+        File tempOut = new File( getTempOutFile() );
+        saveDesignSession( design, tempOut );
+        assertTrue( compareFileContent( goldenFile, tempOut ) );
+        
+        // modify the design and test nonEqual output
+        design.getResponseDataSetDesign().setName( "test change in name" );
+        saveDesignSession( design, tempOut );
+        assertFalse( compareFileContent( goldenFile, tempOut ) );
+        
+        cleanupFile( tempOut );
+    }
+    
+    private void saveDesignSession( OdaDesignSession design, File tempOut )
+    {
+        try
+        {
+            DesignUtil.saveOdaDesignSession( design, tempOut );
+        }
+        catch( Exception ex )
+        {
+            cleanupFile( tempOut );
+            fail();
+        }
+    }
+    
+    private boolean compareFileContent( File file1, File file2 )
+    {
+        boolean match = true;
+        BufferedReader file1BufReader = null;
+        BufferedReader file2BufReader = null;
+        try
+        {
+            file1BufReader = new BufferedReader( new FileReader( file1 ) ); 
+            file2BufReader = new BufferedReader( new FileReader( file2 ) );
+        }
+        catch( FileNotFoundException ex )
+        {
+            match = false;
+            ex.printStackTrace();
+        } 
+        
+        try
+        {
+            String file1Line, file2Line;
+            while( match && (file1Line = file1BufReader.readLine() ) != null )
+            {
+                file2Line = file2BufReader.readLine();
+                match = file1Line.equals( file2Line );
+            }
+        }
+        catch( IOException ex )
+        {
+            match = false;
+            ex.printStackTrace();
+        }
+
+        try
+        {
+            file1BufReader.close();
+            file2BufReader.close();
+        }
+        catch( IOException ex )
+        {
+            ex.printStackTrace();
+        }
+        
+        return match;
+    }
+    
+    private void cleanupFile( File file )
+    {
+        if( file != null && file.exists() )
+            file.delete();
+    }
+    
+}
+
diff --git a/tests/org.eclipse.datatools.connectivity.oda.design.tests/src/org/eclipse/datatools/connectivity/oda/design/tests/TestUtil.java b/tests/org.eclipse.datatools.connectivity.oda.design.tests/src/org/eclipse/datatools/connectivity/oda/design/tests/TestUtil.java
new file mode 100644
index 0000000..7815558
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.design.tests/src/org/eclipse/datatools/connectivity/oda/design/tests/TestUtil.java
@@ -0,0 +1,34 @@
+/*
+ *************************************************************************
+ * 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.design.tests;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+
+public class TestUtil
+{
+
+    static String getPluginTestFilePath()
+        throws IOException
+    {       
+        Bundle bundle = Platform.getBundle( TestUtil.class.getPackage().getName() );
+        String testFilePath = FileLocator.toFileURL( bundle.getEntry( "/testFiles" ) ).getFile();
+        return testFilePath;
+    }
+    
+}
diff --git a/tests/org.eclipse.datatools.connectivity.oda.design.tests/testFiles/golden/jdbcBirtSampleSession.xml b/tests/org.eclipse.datatools.connectivity.oda.design.tests/testFiles/golden/jdbcBirtSampleSession.xml
new file mode 100644
index 0000000..9e8c511
--- /dev/null
+++ b/tests/org.eclipse.datatools.connectivity.oda.design.tests/testFiles/golden/jdbcBirtSampleSession.xml
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="ASCII"?>
+<design:odaDesignSession xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design" xsi:schemaLocation="http://www.eclipse.org/datatools/connectivity/oda/design java://org.eclipse.datatools.connectivity.oda.design.DesignPackage">
+  <design:request>
+    <design:dataAccessDesign>
+      <design:dataSetDesign>
+        <design:name>sampledb Data Set</design:name>
+        <design:odaExtensionDataSetId>org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet</design:odaExtensionDataSetId>
+        <design:dataSourceDesign>
+          <design:name>sampledb Data Source</design:name>
+          <design:odaExtensionId>org.eclipse.birt.report.data.oda.jdbc</design:odaExtensionId>
+          <design:publicProperties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>odaDriverClass</design:name>
+                <design:value>org.eclipse.birt.report.data.oda.sampledb.Driver</design:value>
+              </design:nameValue>
+            </design:properties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>odaURL</design:name>
+                <design:value>jdbc:classicmodels:sampledb</design:value>
+              </design:nameValue>
+            </design:properties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>odaUser</design:name>
+                <design:value>ClassicModels</design:value>
+              </design:nameValue>
+            </design:properties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>odaPassword</design:name>
+              </design:nameValue>
+            </design:properties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>odaJndiName</design:name>
+              </design:nameValue>
+            </design:properties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>OdaConnProfileName</design:name>
+              </design:nameValue>
+            </design:properties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>OdaConnProfileStorePath</design:name>
+              </design:nameValue>
+            </design:properties>
+          </design:publicProperties>
+        </design:dataSourceDesign>
+        <design:query>
+          <design:queryText>select city
+from CLASSICMODELS.OFFICES
+where officecode like ?</design:queryText>
+        </design:query>
+        <design:resultSets>
+          <design:resultSetDefinitions>
+            <design:resultSetColumns>
+              <design:resultColumnDefinitions>
+                <design:attributes>
+                  <design:name>CITY</design:name>
+                  <design:position>1</design:position>
+                  <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
+                  <design:uiHints>
+                    <design:displayName>CITY</design:displayName>
+                  </design:uiHints>
+                </design:attributes>
+              </design:resultColumnDefinitions>
+            </design:resultSetColumns>
+          </design:resultSetDefinitions>
+        </design:resultSets>
+        <design:parameters>
+          <design:parameterDefinitions>
+            <design:inOutMode>In</design:inOutMode>
+            <design:attributes>
+              <design:name></design:name>
+              <design:position>1</design:position>
+              <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
+              <design:nullability>Nullable</design:nullability>
+              <design:uiHints/>
+            </design:attributes>
+            <design:inputAttributes>
+              <design:elementAttributes>
+                <design:optional>true</design:optional>
+                <design:masksValue>false</design:masksValue>
+                <design:uiHints>
+                  <design:promptStyle>SelectableListWithTextField</design:promptStyle>
+                </design:uiHints>
+              </design:elementAttributes>
+            </design:inputAttributes>
+          </design:parameterDefinitions>
+        </design:parameters>
+      </design:dataSetDesign>
+    </design:dataAccessDesign>
+    <design:sessionLocale>
+      <design:language>en</design:language>
+      <design:country>US</design:country>
+    </design:sessionLocale>
+  </design:request>
+  <design:response>
+    <design:sessionStatus>Ok</design:sessionStatus>
+    <design:dataAccessDesign>
+      <design:dataSetDesign>
+        <design:name>sampledb Data Set</design:name>
+        <design:odaExtensionDataSetId>org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet</design:odaExtensionDataSetId>
+        <design:dataSourceDesign>
+          <design:name>sampledb Data Source</design:name>
+          <design:odaExtensionId>org.eclipse.birt.report.data.oda.jdbc</design:odaExtensionId>
+          <design:publicProperties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>odaDriverClass</design:name>
+                <design:value>org.eclipse.birt.report.data.oda.sampledb.Driver</design:value>
+              </design:nameValue>
+            </design:properties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>odaURL</design:name>
+                <design:value>jdbc:classicmodels:sampledb</design:value>
+              </design:nameValue>
+            </design:properties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>odaUser</design:name>
+                <design:value>ClassicModels</design:value>
+              </design:nameValue>
+            </design:properties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>odaPassword</design:name>
+              </design:nameValue>
+            </design:properties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>odaJndiName</design:name>
+              </design:nameValue>
+            </design:properties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>OdaConnProfileName</design:name>
+              </design:nameValue>
+            </design:properties>
+            <design:properties>
+              <design:nameValue>
+                <design:name>OdaConnProfileStorePath</design:name>
+              </design:nameValue>
+            </design:properties>
+          </design:publicProperties>
+        </design:dataSourceDesign>
+        <design:query>
+          <design:queryText>select city
+from CLASSICMODELS.OFFICES
+where officecode like ?</design:queryText>
+        </design:query>
+        <design:resultSets>
+          <design:resultSetDefinitions>
+            <design:resultSetColumns>
+              <design:resultColumnDefinitions>
+                <design:attributes>
+                  <design:name>CITY</design:name>
+                  <design:position>1</design:position>
+                  <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
+                  <design:uiHints>
+                    <design:displayName>CITY</design:displayName>
+                  </design:uiHints>
+                </design:attributes>
+              </design:resultColumnDefinitions>
+            </design:resultSetColumns>
+          </design:resultSetDefinitions>
+        </design:resultSets>
+        <design:parameters>
+          <design:parameterDefinitions>
+            <design:inOutMode>In</design:inOutMode>
+            <design:attributes>
+              <design:name></design:name>
+              <design:position>1</design:position>
+              <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
+              <design:nullability>Nullable</design:nullability>
+              <design:uiHints/>
+            </design:attributes>
+            <design:inputAttributes>
+              <design:elementAttributes>
+                <design:optional>true</design:optional>
+                <design:masksValue>false</design:masksValue>
+                <design:uiHints>
+                  <design:promptStyle>SelectableListWithTextField</design:promptStyle>
+                </design:uiHints>
+              </design:elementAttributes>
+            </design:inputAttributes>
+          </design:parameterDefinitions>
+        </design:parameters>
+      </design:dataSetDesign>
+    </design:dataAccessDesign>
+  </design:response>
+</design:odaDesignSession>
\ No newline at end of file