summaryrefslogtreecommitdiffstats
path: root/tags/java/das/1.0-incubating-beta1-rc4/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/TestData.java
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/das/1.0-incubating-beta1-rc4/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/TestData.java')
-rw-r--r--tags/java/das/1.0-incubating-beta1-rc4/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/TestData.java126
1 files changed, 0 insertions, 126 deletions
diff --git a/tags/java/das/1.0-incubating-beta1-rc4/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/TestData.java b/tags/java/das/1.0-incubating-beta1-rc4/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/TestData.java
deleted file mode 100644
index 4b91cde06b..0000000000
--- a/tags/java/das/1.0-incubating-beta1-rc4/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/TestData.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public abstract class TestData {
-
- protected static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd hh:ss:mm.SSS");
-
- protected static final Timestamp TIMESTAMP = getTimestamp();
-
- protected Object[][] data;
-
- protected Connection connection;
-
- private int currentRow = -1;
-
-
- public TestData(Connection c, Object[][] customerData) {
- this.connection = c;
- this.data = customerData;
- }
-
- public int size() {
- return data[0].length;
- }
-
- public int numberOfRows() {
- return data.length;
- }
-
- public boolean next() {
- ++currentRow;
- return currentRow < numberOfRows();
- }
-
- public abstract String getTableName();
-
- public Object getObject(int i) {
- return data[currentRow][i - 1];
- }
-
- public void refresh() throws SQLException {
- deleteRowsFromTable();
- insertRows();
- }
-
- protected void deleteRowsFromTable() throws SQLException {
- PreparedStatement ps = connection.prepareStatement("delete from " + getTableName());
- ps.execute();
- ps.close();
- }
-
- protected void insertRows() throws SQLException {
- StringBuffer sql = new StringBuffer();
- sql.append("insert into ");
- sql.append(getTableName());
- sql.append(" values (");
- for (int i = 1; i < size(); i++) {
- sql.append("?,");
- }
- sql.append("?)");
- PreparedStatement ps = connection.prepareStatement(sql.toString());
-
- while (next()) {
- for (int i = 1; i <= size(); i++) {
- ps.setObject(i, getObject(i));
- }
- ps.execute();
- ps.clearParameters();
- }
- ps.close();
- }
-
- // Utilities
- protected static Date getDate() {
-
- try {
- return DATE_FORMAT.parse("1966-12-20 00:00:00.0");
- } catch (ParseException e) {
- throw new RuntimeException(e);
- }
- }
-
- protected static Date getDate(String timeStamp) {
-
- try {
- return DATE_FORMAT.parse(timeStamp);
- } catch (ParseException e) {
- throw new RuntimeException(e);
- }
- }
-
- public static Timestamp getTimestamp() {
- return new Timestamp(getDate().getTime());
- }
-
- public static Timestamp getTimestamp(String timeStamp) {
- return new Timestamp(getDate(timeStamp).getTime());
- }
-
-}