diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-21 07:55:07 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-21 07:55:07 +0000 |
commit | e1539a531da3192dac843520d77c8c76e407a402 (patch) | |
tree | bb6d189a5e334edd77b4b4f201aba409231becad /tags/java-M1-20060522/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DasTest.java | |
parent | 0f72626e59d77f0365c1e6bbb9420f6693ffc67d (diff) |
Moving 1.x tags
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@882849 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tags/java-M1-20060522/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DasTest.java')
-rw-r--r-- | tags/java-M1-20060522/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DasTest.java | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/tags/java-M1-20060522/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DasTest.java b/tags/java-M1-20060522/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DasTest.java deleted file mode 100644 index c4e75d20a8..0000000000 --- a/tags/java-M1-20060522/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DasTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.das.rdb.test.framework; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.util.Iterator; -import java.util.List; - -import junit.framework.TestCase; - -import commonj.sdo.DataObject; -import commonj.sdo.Property; - -/** - * - */ -public class DasTest extends TestCase { - - public static Connection connection = null; - private boolean usingDefaultSetup = false; - - /** - * Tears down the fixture, for example, close a network connection. This - * method is called after a test is executed. - */ - protected void tearDown() throws Exception { -// if (usingDefaultSetup) -// connection = null; - } - - protected Connection getAutoConnection() throws SQLException { - - Connection c = primGetConnection(); - c.setAutoCommit(true); - return connection; - - } - - protected Connection getConnection() throws SQLException { - - Connection c = primGetConnection(); - c.setAutoCommit(false); - return connection; - } - - /** - * This provides the default connection for runing single test cases on a - * chosen platform. - */ - private Connection primGetConnection() { - if (connection == null) - defaultSetup(); - return connection; - } - - - - /** - * This is a bit of a hack since it counts on constructor initialization of the - * DatabaseSet up class and also calls its setUp method directly. This is a misuse - * of this JUnit TestSetup subclass . - * - * TODO - refactor to avoid this hackiness ... could move this logic to its own - * class that is then invoked by DatabaseSetUp - */ - private void defaultSetup() { - - usingDefaultSetup = true; - -// DatabaseSetup setUp = new DB2Setup(this); - DatabaseSetup setUp = new DerbySetup(this); - try { - setUp.setUp(); - } catch (Exception e) { - throw new RuntimeException(e); - } - - } - - - //Utilities - protected InputStream getConfig(String fileName) throws FileNotFoundException { - return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); - } - - protected void write(String label, ResultSet rs) throws IOException, SQLException { - - ResultSetMetaData md = rs.getMetaData(); - int count = md.getColumnCount(); - System.out.println("Contents of ResultSet from " + label); - for (int i = 1; i <= count; i++) { - System.out.print("\t"); - System.out.println (md.getColumnLabel(i)); - } - System.out.println(""); - while (rs.next()) { - for (int i = 1; i <= count; i++) { - System.out.print("\t"); - System.out.print(rs.getString(i)); - } - System.out.println("\t"); - } - System.out.println("done"); - } - - - protected void printList(List data) { - Iterator i = data.iterator(); - while ( i.hasNext()) { - System.out.println(); - DataObject obj = (DataObject) i.next(); - Iterator props = obj.getType().getProperties().iterator(); - while ( props.hasNext()) { - Property p = (Property) props.next(); - if ( p.isMany() ) { - System.out.print("[ " + p.getName() + " ] "); - Iterator children = obj.getList(p).iterator(); - while ( children.hasNext()) { - DataObject child = (DataObject) children.next(); - System.out.print("[ " + child.get("ID") + " ]"); - } - System.out.println(); - } else if ( !p.getType().isDataType()) { - DataObject child = obj.getDataObject(p); - if ( child != null ) - System.out.println("[ " + p.getName() + " ] " + "[ " + child.get("ID") + " ]"); - } else { - System.out.println("[ " + p.getName() + " ] " + obj.get(p)); - } - } - } - } - - -} |