teiid SVN: r1736 - trunk/test-integration/db/src/main/resources.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-01-13 10:06:38 -0500 (Wed, 13 Jan 2010)
New Revision: 1736
Modified:
trunk/test-integration/db/src/main/resources/qe-test.properties
Log:
Teiid 781 - changes and refactoring so the ctc testing can support both the old way (comparing against xml files) and the new way (generating and comparing non-xml files)
Modified: trunk/test-integration/db/src/main/resources/qe-test.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/qe-test.properties 2010-01-13 15:05:12 UTC (rev 1735)
+++ trunk/test-integration/db/src/main/resources/qe-test.properties 2010-01-13 15:06:38 UTC (rev 1736)
@@ -27,7 +27,7 @@
# where to find the vdb's, which is used to define the vdb.definition setting in the deploy.properties
vdb.loc=${vdb.artifacts.dir}
-# turn off the configuration of the datastores (data refresh) and connector bindings (seting the datastore connection info)
+# turn off the configuration of the datastores (data refresh) and connector bindings (setting the datastore connection info)
disable_datastore=true
# the location where newly generated expected results will be created (resultmode = generate)
@@ -41,20 +41,22 @@
# transaction types
# See the TransactionFactory for the list of types
-transaction-type=offwrap
-#transaction-type=local
+transaction-option=autowrap
+#transaction-option=local
# resultmode options:
# - compare : compare actual results to expected results
# - generate : create new expected results
# - none : run the queries, only report when errors occur
+#resultmode=none
resultmode=compare
+#resultmode=generate
# this is the deploy.properties file which will be used to run all the tests
# it will have these properties updated:
# 1 - vdb.definition (which will be based on vdb.loc)
-deployprops.loc=./target/classes/ctc_tests/deploy.properties
+deployprops.loc=${project.loc}/target/classes/ctc_tests/deploy.properties
process-batch = 20
connector-batch = 20
@@ -67,7 +69,7 @@
# properties for Teiid connection
##########################################
-connection-type=driver
+connection-type=datasource
#driver=org.teiid.jdbc.TeiidDataSource
@@ -77,7 +79,7 @@
### driver and url for running in embedded mode
driver=com.metamatrix.jdbc.EmbeddedDataSource
-URL=jdbc:metamatrix:${vdb.name}@target/classes/ctc_tests/deploy.properties;user=admin;password=teiid
+URL=jdbc:metamatrix:${vdb.name}@target/classes/ctc_tests/deploy.properties;version=1;user=admin;password=teiid
User=admin
Password=teiid
15 years
teiid SVN: r1735 - in trunk/test-integration/db/src/main/java/org/teiid/test/client: ctc and 2 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-01-13 10:05:12 -0500 (Wed, 13 Jan 2010)
New Revision: 1735
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/client/ClassFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestProperties.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java
Log:
Teiid 781 - changes and refactoring so the ctc testing can support both the old way (comparing against xml files) and the new way (generating and comparing non-xml files)
Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/ClassFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ClassFactory.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ClassFactory.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -0,0 +1,164 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.test.client;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Properties;
+
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+import com.metamatrix.core.util.ReflectionHelper;
+
+/**
+ * @author vanhalbert
+ *
+ */
+public class ClassFactory {
+
+ /**
+ * The {@link #QUERY_SCENARIO_CLASSNAME} property indicates the implementation of
+ * {@link QueryScenario} to use.
+ */
+ public static final String QUERY_SCENARIO_CLASSNAME = "query.scenario.classname"; //$NON-NLS-1$
+
+ /**
+ * The default scenario class to use when {@link #QUERY_SCENARIO_CLASSNAME} is not defined.
+ */
+
+ public static final String QUERY_SCENARIO_DEFAULT_CLASSNAME = "org.teiid.test.client.impl.QueryScenarioImpl"; //$NON-NLS-1$
+
+
+ /**
+ * The {@link #QUERY_READER_CLASSNAME} property indicates the implementation of
+ * {@link QueryReader} to use.
+ */
+ public static final String QUERY_READER_CLASSNAME = "query.reader.classname"; //$NON-NLS-1$
+
+ /**
+ * The default query reader class to use when {@link #QUERY_READER_CLASSNAME} is not defined.
+ */
+
+ public static final String QUERY_READER_DEFAULT_CLASSNAME = "org.teiid.test.client.ctc.XMLQueryReader"; //$NON-NLS-1$
+
+
+
+ /**
+ * The {@link #RESULTS_GENERATOR_CLASSNAME} property indicates the implementation of
+ * {@link ResultsGenerator} to use.
+ */
+ public static final String RESULTS_GENERATOR_CLASSNAME = "results.generator.classname"; //$NON-NLS-1$
+
+ /**
+ * The default query reader class to use when {@link #QUERY_READER_CLASSNAME} is not defined.
+ */
+
+ public static final String RESULTS_GENERATOR_DEFAULT_CLASSNAME = "org.teiid.test.client.impl.ResultsGeneratorImpl"; //$NON-NLS-1$
+
+
+
+ /**
+ * The {@link #EXPECTED_RESULTS_CLASSNAME} property indicates the implementation of
+ * {@link ExpectedResults} to use.
+ */
+ public static final String EXPECTED_RESULTS_CLASSNAME = "expected.results.classname"; //$NON-NLS-1$
+
+ /**
+ * The default query reader class to use when {@link #EXPECTED_RESULTS_CLASSNAME} is not defined.
+ */
+
+ public static final String EXPECTED_RESULTS_DEFAULT_CLASSNAME = "org.teiid.test.client.impl.ExpectedResultsImpl"; //$NON-NLS-1$
+
+
+
+
+
+ public static QueryScenario createQueryScenario(String scenarioName) {
+
+ String clzzname = ConfigPropertyLoader.getInstance().getProperty(QUERY_SCENARIO_CLASSNAME);
+ if (clzzname == null) {
+ clzzname = QUERY_SCENARIO_DEFAULT_CLASSNAME;
+ }
+
+ Collection<Object> args = new ArrayList<Object>(2);
+ args.add(scenarioName);
+ args.add(ConfigPropertyLoader.getInstance().getProperties());
+
+
+ QueryScenario scenario;
+ try {
+ scenario = (QueryScenario) ReflectionHelper.create(clzzname, args, null);
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e.getMessage());
+ }
+ return scenario;
+ }
+
+ public static QueryReader createQueryReader(Collection<?> args) {
+ String clzzname = ConfigPropertyLoader.getInstance().getProperty(QUERY_READER_CLASSNAME);
+ if (clzzname == null) {
+ clzzname = QUERY_READER_DEFAULT_CLASSNAME;
+ }
+
+ QueryReader reader;
+ try {
+ reader = (QueryReader) ReflectionHelper.create(clzzname, args, null);
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e.getMessage());
+ }
+
+ return reader;
+ }
+
+ public static ResultsGenerator createResultsGenerator(Collection<?> args) {
+ String clzzname = ConfigPropertyLoader.getInstance().getProperty(RESULTS_GENERATOR_CLASSNAME);
+ if (clzzname == null) {
+ clzzname = RESULTS_GENERATOR_DEFAULT_CLASSNAME;
+ }
+
+ ResultsGenerator resultsgen;
+ try {
+ resultsgen = (ResultsGenerator) ReflectionHelper.create(clzzname, args, null);
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e.getMessage());
+ }
+
+ return resultsgen;
+ }
+
+ public static ExpectedResults createExpectedResults(Collection<?> args) {
+ String clzzname = ConfigPropertyLoader.getInstance().getProperty(EXPECTED_RESULTS_CLASSNAME);
+ if (clzzname == null) {
+ clzzname = EXPECTED_RESULTS_DEFAULT_CLASSNAME;
+ }
+
+ ExpectedResults expResults;
+ try {
+ expResults = (ExpectedResults) ReflectionHelper.create(clzzname, args, null);
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e.getMessage());
+ }
+
+ return expResults;
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/ClassFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java 2010-01-13 14:57:32 UTC (rev 1734)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -21,99 +21,240 @@
*/
package org.teiid.test.client;
+import java.io.File;
+import java.io.IOException;
+import java.sql.ResultSet;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Properties;
import org.teiid.test.client.TestProperties.RESULT_MODES;
+import org.teiid.test.framework.TestLogger;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.util.FileUtils;
+
+
/**
- * The QueryScenario manages all the information required to run one scenario of tests.
- * This includes the following:
- * <li>The queryreader and its query sets to be executed as a scenario </li>
- * <li>Provides the expected results that correspond to a query set </li>
- * <li>The results generator that would be used when {@link RESULT_MODES#GENERATE} is specified</li>
+ * The QueryScenario manages all the information required to run one scenario of
+ * tests. This includes the following: <li>The queryreader and its query sets to
+ * be executed as a scenario</li> <li>Provides the expected results that
+ * correspond to a query set</li> <li>The results generator that would be used
+ * when {@link RESULT_MODES#GENERATE} is specified</li>
*
* @author vanhalbert
- *
+ *
*/
-public interface QueryScenario {
-
-
+public abstract class QueryScenario {
+
+ protected QueryReader reader = null;
+ protected ResultsGenerator resultsGen = null;
+
+ private String resultMode = TestProperties.RESULT_MODES.NONE;
+
+ private Properties props = null;
+ private String scenarioName;
+ private String querySetName;
+
+ public QueryScenario(String scenarioName, Properties queryProperties) {
+ this.props = queryProperties;
+ this.scenarioName = scenarioName;
+
+ this.querySetName = props.getProperty(TestProperties.QUERY_SET_NAME,
+ "querysetnamenotdefined");
+
+ setUp();
+
+ }
+
+ protected void setUp() {
+ Collection args = new ArrayList(1);
+ args.add(props);
+
+ reader = ClassFactory.createQueryReader(args);
+
+ args = new ArrayList(2);
+ args.add(this.scenarioName);
+ args.add(this.props);
+
+ resultsGen = ClassFactory.createResultsGenerator(args);
+
+ if (reader.getQuerySetIDs() == null
+ || reader.getQuerySetIDs().isEmpty()) {
+ throw new TransactionRuntimeException(
+ "The queryreader did not return any queryset ID's to process");
+ }
+
+ validateResultsMode(this.props);
+
+ try {
+ setupVDBs(this.getProperties());
+ } catch (IOException e) {
+ throw new TransactionRuntimeException(e.getMessage());
+ }
+
+ }
+
+ protected void setupVDBs(Properties props) throws IOException {
+ // NOTE: this is probably a hack, because the only way I could get all
+ // the vdb's available when running multiple scenarions
+ // was to update the deploy.properties by setting the vdb.definition
+ // property containing the location of
+ // all the vdbs
+
+ String deployPropLoc = props.getProperty("deployprops.loc");
+ Properties deployProperties = PropertiesUtils.load(deployPropLoc);
+
+ // set the vdb.definition property that contains all the vdbs
+ String vdb_loc = props.getProperty("vdb.loc");
+ File vdbfiles[] = FileUtils.findAllFilesInDirectoryHavingExtension(vdb_loc, ".vdb");
+ if (vdbfiles == null || vdbfiles.length == 0) {
+ throw new TransactionRuntimeException((new StringBuilder()).append(
+ "No vdbs found in directory ").append(vdb_loc).toString());
+ }
+ StringBuffer vdbdef = new StringBuffer();
+
+ for (int i = 0; i < vdbfiles.length; i++) {
+ vdbdef.append(vdbfiles[i].getAbsolutePath() + ";");
+ }
+
+ deployProperties.setProperty("vdb.definition", vdbdef.toString());
+ PropertiesUtils.print(deployPropLoc, deployProperties,"Updated for vdb.definition");
+
+ }
+
+
+ protected void validateResultsMode(Properties props) {
+ // Determine from property what to do with query results
+ String resultModeStr = props.getProperty(
+ TestProperties.PROP_RESULT_MODE, "");
+ // No need to check for null prop here since we've just checked for this
+ // required property
+
+ if (resultModeStr.equalsIgnoreCase(TestProperties.RESULT_MODES.NONE)
+ || resultModeStr
+ .equalsIgnoreCase(TestProperties.RESULT_MODES.COMPARE)
+ || resultModeStr
+ .equalsIgnoreCase(TestProperties.RESULT_MODES.GENERATE)) { //$NON-NLS-1$
+ resultMode = resultModeStr;
+ }
+ // otherwise use default of NONE
+
+ TestLogger.log("\nResults mode: " + resultMode); //$NON-NLS-1$
+
+ }
+
/**
- * Return the name that identifies this query set.
- * It should use the {@link TestProperties#QUERY_SET_NAME} property to obtain the name.
+ * Return the name that identifies this query set. It should use the
+ * {@link TestProperties#QUERY_SET_NAME} property to obtain the name.
+ *
* @return String query set name;
*/
- String getQuerySetName();
-
+ public String getQuerySetName() {
+ return this.querySetName;
+ }
+
/**
* Return the identifier for the current scenario
+ *
* @return String name of scenario
*/
- String getQueryScenarioIdentifier() ;
-
+ public String getQueryScenarioIdentifier() {
+ return this.scenarioName;
+ }
+
/**
* Return the properties defined for this scenario
+ *
* @return Properties
*/
- Properties getProperties();
-
+ public Properties getProperties() {
+ return this.props;
+ }
+
/**
* Return a <code>Map</code> containing the query identifier as the key, and
- * the value is the query. In most simple cases, the query will be a <code>String</code>
- * However, complex types (i.e., to execute prepared statements or other arguments), it maybe
- * some other type.
- * @param querySetID identifies a set of queries
+ * the value is the query. In most simple cases, the query will be a
+ * <code>String</code> However, complex types (i.e., to execute prepared
+ * statements or other arguments), it maybe some other type.
+ *
+ * @param querySetID
+ * identifies a set of queries
* @return Map<String, Object>
*/
- Map<String, Object> getQueries(String querySetID);
-
+
+ public Map<String, Object> getQueries(String querySetID) {
+ try {
+ return reader.getQueries(querySetID);
+ } catch (QueryTestFailedException e) {
+ throw new TransactionRuntimeException(e);
+ }
+ }
+
/**
- * Return a <code>Collection</code> of <code>querySetID</code>s that the {@link QueryReader} will be
- * providing. The <code>querySetID</code> can be used to obtain it associated set of queries by
- * call {@link #getQueries(String)}
+ * Return a <code>Collection</code> of <code>querySetID</code>s that the
+ * {@link QueryReader} will be providing. The <code>querySetID</code> can be
+ * used to obtain it associated set of queries by call
+ * {@link #getQueries(String)}
+ *
* @return Collection of querySetIDs
*/
- Collection<String> getQuerySetIDs();
-
+ public Collection<String> getQuerySetIDs() {
+ return reader.getQuerySetIDs();
+ }
+
/**
- * Return the result mode that was defined by the property {@link TestProperties#PROP_RESULT_MODE}
+ * Return the result mode that was defined by the property
+ * {@link TestProperties#PROP_RESULT_MODE}
+ *
* @return String result mode
*/
- String getResultsMode();
-
+ public String getResultsMode() {
+ return this.resultMode;
+ }
+
/**
- * Return the {@link ExpectedResults} for the specified <code>querySetID</code>. These expected
- * results will be used to compare with the actual results in order to determine success or failure.
+ * Return the {@link ExpectedResults} for the specified
+ * <code>querySetID</code>. These expected results will be used to compare
+ * with the actual results in order to determine success or failure.
+ *
* @param querySetID
* @return ExpectedResults
*/
- ExpectedResults getExpectedResults(String querySetID);
-
+ public ExpectedResults getExpectedResults(String querySetID) {
+ Collection args = new ArrayList(2);
+ args.add(querySetID);
+ args.add(props);
+
+ return ClassFactory.createExpectedResults(args);
+
+ }
+
/**
- * Return the {@link ResultsGenerator} that is to be used to create new sets of expected results.
+ * Return the {@link ResultsGenerator} that is to be used to create new sets
+ * of expected results.
+ *
* @return
*/
- ResultsGenerator getResultsGenerator() ;
-
+ public ResultsGenerator getResultsGenerator() {
+ return this.resultsGen;
+ }
+
/**
- * Return the root output directory where comparison reports or newly generated expected results should be located.
- */
- String getOutputDirectory();
-
- /**
- * Add a {@link TestResult} to the query set for tracking and reporting.
- * @param result
- */
- void addTestResult(String querySetID, TestResult result);
-
- /**
- * Call to get a collection of the currently completed {@link TestResult}s
+ * Return the {@link QueryReader} that is to be used to obtain the queries
+ * to process.
+ *
* @return
*/
- Collection<TestResult> getTestResults(String querySetID);
+ public QueryReader getQueryReader() {
+ return this.reader;
+ }
+ public abstract void handleTestResult(TestResult tr, ResultSet resultSet, String sql);
+
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java 2010-01-13 14:57:32 UTC (rev 1734)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -28,7 +28,6 @@
import java.util.Properties;
import org.junit.Assert;
-import org.teiid.test.client.ctc.CTCQueryScenario;
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.ConfigPropertyNames;
import org.teiid.test.framework.TestLogger;
@@ -70,6 +69,10 @@
if (System.getProperty(ConfigPropertyNames.CONFIG_FILE ) == null) {
System.setProperty(ConfigPropertyNames.CONFIG_FILE,"qe-test.properties");
}
+
+ if (System.getProperty("project.loc" ) == null) {
+ System.setProperty("project.loc",".");
+ }
}
@@ -141,8 +144,9 @@
ConfigPropertyLoader.getInstance().setProperty(DriverConnection.DS_URL, url);
- QueryScenario set = new CTCQueryScenario(scenario_name, ConfigPropertyLoader.getInstance().getProperties());
+ QueryScenario set = ClassFactory.createQueryScenario(scenario_name);
+
TransactionContainer tc = getTransactionContainter();
runTestCase(set, tc);
@@ -165,7 +169,7 @@
while (qsetIt.hasNext()) {
querySetID = qsetIt.next();
- TestLogger.logInfo("Start Query Set [" + querySetID + "]");
+ TestLogger.logInfo("Start Test Query ID [" + querySetID + "]");
queryTests = queryset.getQueries(querySetID);
@@ -173,8 +177,11 @@
Iterator<String> queryTestIt = null;
queryTestIt = queryTests.keySet().iterator();
+ ExpectedResults expectedResults = queryset.getExpectedResults(querySetID);
+
+
long beginTS = System.currentTimeMillis();
long endTS = 0;
@@ -184,7 +191,7 @@
Object sqlObject = queryTests.get(queryidentifier);
- userTxn.init(querySetID, queryidentifier, sqlObject);
+ userTxn.init(summary, expectedResults, querySetID, queryidentifier, sqlObject);
// run test
tc.runTransaction(userTxn);
@@ -193,20 +200,21 @@
endTS = System.currentTimeMillis();
- TestLogger.logInfo("End Query Set [" + querySetID + "]");
+ TestLogger.logInfo("End Test Query ID [" + querySetID + "]");
- printResultsForSet(summary, querySetID, queryset, beginTS, endTS);
-
+ summary.printResults(queryset, querySetID,beginTS, endTS);
}
summary.printTotals(queryset);
+ summary.cleanup();
// cleanup all connections created for this test.
userTxn.getConnectionStrategy().shutdown();
ConfigPropertyLoader.reset();
+
}
@@ -223,19 +231,6 @@
}
-
- private void printResultsForSet(final TestResultsSummary summary , final String querySetID, final QueryScenario querySet, final long beginTS, final long endTS) {
- TestLogger.logDebug("Print results for Query Set [" + querySetID
- + "]");
-
- try {
- summary.printResults(querySet, querySetID,beginTS, endTS, 1, 1);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
private Properties getSubstitutedProperties(Properties props) {
Properties or = new Properties();
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2010-01-13 14:57:32 UTC (rev 1734)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -56,6 +56,8 @@
private boolean errorExpected = false;
private String sql = null;
+
+ private TestResultsSummary testResultsSummary;
public TestClientTransaction(QueryScenario querySet) {
super(querySet.getQueryScenarioIdentifier());
@@ -63,12 +65,13 @@
}
- public void init(String querySetID, String queryIdentifier, Object query) {
+ public void init(TestResultsSummary testResultsSummary, ExpectedResults expectedResults, String querySetID, String queryIdentifier, Object query) {
this.querySetID = querySetID;
this.queryIdentifier = queryIdentifier;
this.queryObject = query;
-
- this.expectedResults = null;
+ this.testResultsSummary = testResultsSummary;
+ this.expectedResults = expectedResults;
+
endTS = 0;
beginTS = 0;
@@ -78,14 +81,17 @@
errorExpected = false;
}
+
+ public String getTestName() {
+ return querySetID + ":" + (this.queryIdentifier!=null?this.queryIdentifier:"NA");
+
+ }
@Override
public void before() {
// TODO Auto-generated method stub
super.before();
- this.expectedResults = this.querySet
- .getExpectedResults(this.querySetID);
try {
this.errorExpected = expectedResults
@@ -113,14 +119,11 @@
String sql) throws Exception {
- TestLogger.logDebug("execute: " + sql);
+ TestLogger.logDebug("ID: " + querySetID + "-" + queryidentifier + " execute: " + sql);
- // int expectedRowCount=-1;
TestLogger.logDebug("expected error: " + this.errorExpected);
try {
- System.out.println(this.querySet.getQueryScenarioIdentifier() + ":" + this.querySetID + ":"
- + this.queryIdentifier);
// need to set this so the underlying query execution handles an
// error properly.
@@ -141,92 +144,27 @@
public void after() {
// TODO Auto-generated method stub
super.after();
-
- String errorfile = null;
-
- // TODO: uncomment
- ResultSet erResultSet = null;
TestResult rs = null;
-
- ResultsGenerator genResults = this.querySet.getResultsGenerator();
Throwable resultException = null;
resultException = (this.getLastException() != null ? this
.getLastException() : this.getApplicationException());
-
-
+
if (resultException != null) {
- if (this.exceptionExpected()) {
- testStatus = TestResult.RESULT_STATE.TEST_EXPECTED_EXCEPTION;
- } else {
- testStatus = TestResult.RESULT_STATE.TEST_EXCEPTION;
- }
+ testStatus = TestResult.RESULT_STATE.TEST_EXCEPTION;
+
+ }
- }
-
-
-
-
- if (this.querySet.getResultsMode().equalsIgnoreCase(
- TestProperties.RESULT_MODES.COMPARE)) {
- if (testStatus != TestResult.RESULT_STATE.TEST_EXCEPTION) {
- try {
- this.expectedResults.compareResults(this.queryIdentifier,
- sql, this.internalResultSet, resultException,
- testStatus, isOrdered(sql), this.fetchSize - 1);
- } catch (QueryTestFailedException qtf) {
- resultException = (resultException != null ? resultException
- : qtf);
- testStatus = TestResult.RESULT_STATE.TEST_EXCEPTION;
-
- }
- }
-
- if (testStatus == TestResult.RESULT_STATE.TEST_EXCEPTION) {
- try {
- genResults.generateErrorFile(querySetID,
- this.queryIdentifier, sql, this.internalResultSet,
- resultException, expectedResults
- .getResultsFile(this.queryIdentifier));
-
- } catch (QueryTestFailedException qtfe) {
- throw new TransactionRuntimeException(qtfe.getMessage());
- }
- }
-
- } else if (this.querySet.getResultsMode().equalsIgnoreCase(
- TestProperties.RESULT_MODES.GENERATE)) { //$NON-NLS-1$
-
- try {
- genResults.generateQueryResultFile(querySetID,
- this.queryIdentifier, sql, erResultSet,
- resultException, testStatus);
- } catch (QueryTestFailedException qtfe) {
- throw new TransactionRuntimeException(qtfe.getMessage());
- }
-
- } else {
- // just create the error file for any failures
- if (testStatus == TestResult.RESULT_STATE.TEST_EXCEPTION) {
- try {
- genResults.generateErrorFile(querySetID,
- this.queryIdentifier, sql, this.internalResultSet,
- resultException, expectedResults
- .getResultsFile(this.queryIdentifier));
-
- } catch (QueryTestFailedException qtfe) {
- throw new TransactionRuntimeException(qtfe.getMessage());
- }
- }
- }
-
rs = new TestResultStat(querySetID, this.queryIdentifier, sql,
- testStatus, beginTS, endTS, resultException, errorfile);
+ testStatus, beginTS, endTS, resultException, null);
- this.querySet.addTestResult(this.querySetID, rs);
+ this.querySet.handleTestResult(rs, this.internalResultSet, sql);
+
+ this.testResultsSummary.addTestResult(this.querySetID, rs);
+
}
@@ -244,15 +182,7 @@
return this.errorExpected;
}
- private boolean isOrdered(String sql) {
- if (sql.toLowerCase().indexOf(" order by ") > 0) {
- return true;
- }
- return false;
-
- }
-
/**
* Override the super cleanup() so that the connection to Teiid is not
* cleaned up at this time.
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestProperties.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestProperties.java 2010-01-13 14:57:32 UTC (rev 1734)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestProperties.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -80,8 +80,8 @@
*/
public static final String PROP_OUTPUT_DIR = "outputdir"; //$NON-NLS-1$
+
-
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java 2010-01-13 14:57:32 UTC (rev 1734)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -23,7 +23,8 @@
package org.teiid.test.client;
/**
- * The TestResult represents the results from a single query.
+ * The TestResult represents the results from a single test. A single test can include 1 or more sql commands that
+ * are considered 1 inclusive test.
*
* @author vanhalbert
*
@@ -113,6 +114,19 @@
* @since
*/
int getStatus();
+
+
+ /**
+ * Call to set the status for this test result.
+ * @see TestResult.RESULT_STATE
+ * @param status
+ */
+ void setStatus(int status);
+
+ /**
+ * Return the result status in string format.
+ * @return String
+ */
String getResultStatusString();
@@ -125,6 +139,10 @@
* @since
*/
String getExceptionMsg();
+
+ Throwable getException();
+
+ void setException(Throwable error);
/**
* Return the time (in a long value) that this query started.
@@ -134,6 +152,8 @@
* @since
*/
long getBeginTS();
+
+ void setBeginTS(long beginTS);
/**
* Return the time (in a long value) that this query ended
@@ -143,10 +163,15 @@
* @since
*/
long getEndTS();
+
+ void setEndTS(long endTS);
/**
* @return Returns the name of errorfile where the error results were
* written.
*/
String getErrorfile();
+
+ void setErrorFile(String errorFile);
+
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java 2010-01-13 14:57:32 UTC (rev 1734)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -34,14 +34,12 @@
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.TestLogger;
public class TestResultsSummary {
@@ -58,6 +56,33 @@
private int total_querysets = 0;
private List<String> failed_queries = new ArrayList<String>();
private List<String> query_sets = new ArrayList<String>(10);
+
+ private Map<String, Collection<TestResult>> testResults = Collections.synchronizedMap(new HashMap<String, Collection<TestResult>>());
+
+ public void cleanup() {
+ failed_queries.clear();
+ query_sets.clear();
+ testResults.clear();
+ }
+
+ public synchronized void addTestResult(String querySetID, TestResult result) {
+ Collection<TestResult> results = null;
+ if (this.testResults.containsKey(querySetID)) {
+ results = this.testResults.get(querySetID);
+ } else {
+ results = new ArrayList<TestResult>();
+ this.testResults.put(querySetID, results);
+ }
+ results.add(result);
+
+ }
+
+
+
+ public Collection<TestResult> getTestResults(String querySetID) {
+ return this.testResults.get(querySetID);
+ }
+
private static PrintStream getSummaryStream(String outputDir,
String summaryName) throws IOException {
@@ -213,7 +238,23 @@
total_queries = total_queries + queries;
}
+
+ public void printResults(QueryScenario scenario, String querySetID,
+ long beginTS,
+ long endTS) throws Exception {
+
+ TestLogger.logDebug("Print results for Query Set [" + querySetID
+ + "]");
+
+ try {
+ printResults(scenario, querySetID, beginTS, endTS, 1, 1);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
/**
* Print test results.
*
@@ -228,7 +269,7 @@
long endTS, int numberOfClients, int runNumber) throws Exception {
String testname = scenario.getQueryScenarioIdentifier();
- Collection<TestResult> testResults = scenario.getTestResults(querySetID);
+ Collection<TestResult> testResults = getTestResults(querySetID);
// Properties props = scenario.getProperties();
String outputDir = scenario.getResultsGenerator().getOutputDir();
@@ -460,7 +501,7 @@
addTableData(htmlCode, "QueryId"); //$NON-NLS-1$
addTableData(htmlCode, "Result"); //$NON-NLS-1$
addTableData(htmlCode, "First Response"); //$NON-NLS-1$
- addTableData(htmlCode, "Total Time"); //$NON-NLS-1$
+ addTableData(htmlCode, "Total Seconds"); //$NON-NLS-1$
addTableData(htmlCode, "Exception"); //$NON-NLS-1$
addTableData(htmlCode, "Error File (if any)"); //$NON-NLS-1$
htmlCode.append("</tr>").append(NL); //$NON-NLS-1$
@@ -473,8 +514,11 @@
"show('" + scrub(stat.getQuery()) + "')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
addTableData(htmlCode, stat.getResultStatusString(),
"fail".equalsIgnoreCase(stat.getResultStatusString())); //$NON-NLS-1$
- addTableData(htmlCode, Long.toString(stat.getBeginTS()));
- addTableData(htmlCode, Long.toString(stat.getEndTS()));
+ addTableData(htmlCode, new Date(stat.getBeginTS()).toString());
+
+ // Long.toString(stat.getBeginTS()));
+ addTableData(htmlCode, Long.toString( (stat.getEndTS() - stat.getBeginTS() / 1000 )));
+ //Long.toString(stat.getEndTS()));
if (stat.getStatus() == TestResult.RESULT_STATE.TEST_EXCEPTION) {
addTableData(htmlCode, stat.getExceptionMsg());
if (stat.getErrorfile() != null
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java 2010-01-13 14:57:32 UTC (rev 1734)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -26,11 +26,9 @@
import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import org.teiid.test.framework.transaction.TxnAutoTransaction;
import org.teiid.test.framework.transaction.JNDITransaction;
import org.teiid.test.framework.transaction.LocalTransaction;
-import org.teiid.test.framework.transaction.OffWrapTransaction;
-import org.teiid.test.framework.transaction.OnWrapTransaction;
+import org.teiid.test.framework.transaction.TxnAutoTransaction;
import org.teiid.test.framework.transaction.XATransaction;
@@ -50,7 +48,7 @@
* Transaction Type indicates the type of transaction container to use
* @see TransactionFactory
*/
- public static final String TRANSACTION_TYPE = "transaction-type"; //$NON-NLS-1$
+ public static final String TRANSACTION_TYPE = "transaction-option"; //$NON-NLS-1$
public interface TRANSACTION_TYPES {
public static final String LOCAL_TRANSACTION = "local"; //$NON-NLS-1$
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java 2010-01-13 14:57:32 UTC (rev 1734)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -1,5 +1,4 @@
-/*
- * JBoss, Home of Professional Open Source.
+/* JBoss, Home of Professional Open Source.
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
@@ -23,15 +22,12 @@
import java.io.File;
import java.io.IOException;
+import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Properties;
-import org.junit.Assert;
+import org.teiid.test.client.ClassFactory;
import org.teiid.test.client.ExpectedResults;
import org.teiid.test.client.QueryReader;
import org.teiid.test.client.QueryScenario;
@@ -39,8 +35,6 @@
import org.teiid.test.client.TestProperties;
import org.teiid.test.client.TestResult;
import org.teiid.test.client.TestProperties.RESULT_MODES;
-import org.teiid.test.framework.ConfigPropertyLoader;
-import org.teiid.test.framework.TestLogger;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -48,188 +42,129 @@
import com.metamatrix.core.util.FileUtils;
/**
- * The TestQuerySet contains all the information required to run one set of tests.
- * This includes the following:
- * <li>The queryreader and its query sets to be executed as a scenario </li>
- * <li>Provides the expected results that correspond to a query set </li>
- * <li>The results generator that would be used when {@link RESULT_MODES#GENERATE} is specified</li>
- *
+ * The CTCQueryScenario represents the tests that were created using the old xml file formats.
+ *
* @author vanhalbert
*
*/
-public class CTCQueryScenario implements QueryScenario {
+public class CTCQueryScenario extends QueryScenario {
- private String resultMode = TestProperties.RESULT_MODES.NONE;
-
- private QueryReader reader = null;
- private ResultsGenerator genResults = null;
- private Map<String, Collection<TestResult>> testResults = Collections.synchronizedMap(new HashMap<String, Collection<TestResult>>());
-
-
- private Properties props;
- private String outputDir = null;
- private String querySetName = null;
-
- private String scenario_test_name;
-
+
public CTCQueryScenario(String scenarioName, Properties querySetProperties) {
- this.props = querySetProperties;
- this.scenario_test_name = scenarioName;
- setup();
+ super(scenarioName, querySetProperties);
}
+ protected void setUp() {
-
- public String getQueryScenarioIdentifier() {
- return this.scenario_test_name;
- }
-
- public String getQuerySetName() {
- return this.querySetName;
- }
-
-
- private void setup() {
-
- TestLogger.logDebug("Perform TestClient Setup");
- Properties props = ConfigPropertyLoader.getInstance().getProperties();
-
- this.querySetName = props.getProperty(TestProperties.QUERY_SET_NAME, "querysetnamenotdefined");
-
- outputDir = props.getProperty(TestProperties.PROP_OUTPUT_DIR, ".");
-
- Assert.assertNotNull("Property " + TestProperties.PROP_OUTPUT_DIR
- + " was not specified", outputDir);
-
- outputDir = outputDir + "/" + scenario_test_name;
-
-
try {
-
-
- validateResultsMode(props);
-
- setupVDBs(props);
-
- reader = new XMLQueryReader(props);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- throw new TransactionRuntimeException(e.getMessage());
+ reader = new XMLQueryReader(this.getProperties());
+ } catch (QueryTestFailedException e1) {
+ throw new TransactionRuntimeException(e1);
}
-
- genResults = new XMLGenerateResults(this.props, scenario_test_name, outputDir);
+ resultsGen = new XMLGenerateResults(this.getQueryScenarioIdentifier(), this.getProperties());
- if (reader.getQuerySetIDs() == null || reader.getQuerySetIDs().isEmpty()) {
- throw new TransactionRuntimeException("No query set ID's were returned");
+ if (reader.getQuerySetIDs() == null
+ || reader.getQuerySetIDs().isEmpty()) {
+ throw new TransactionRuntimeException(
+ "The queryreader did not return any queryset ID's to process");
}
- }
-
- private void setupVDBs(Properties props) throws IOException {
- // NOTE: this is probably a hack, because the only way I could get all
- // the vdb's available when running multiple scenarions
- // was to update the deploy.properties by setting the vdb.definition
- // property containing the location of
- // all the vdbs
-
- String deployPropLoc = props.getProperty("deployprops.loc");
- Properties deployProperties = PropertiesUtils.load(deployPropLoc);
-
- // set the vdb.definition property that contains all the vdbs
- String vdb_loc = props.getProperty("vdb.loc");
- File vdbfiles[] = FileUtils.findAllFilesInDirectoryHavingExtension(vdb_loc, ".vdb");
- if (vdbfiles == null || vdbfiles.length == 0) {
- throw new TransactionRuntimeException((new StringBuilder()).append(
- "No vdbs found in directory ").append(vdb_loc).toString());
+ validateResultsMode(this.getProperties());
+
+ try {
+ setupVDBs(this.getProperties());
+ } catch (IOException e) {
+ throw new TransactionRuntimeException(e.getMessage());
}
- StringBuffer vdbdef = new StringBuffer();
- for (int i = 0; i < vdbfiles.length; i++) {
- vdbdef.append(vdbfiles[i].getAbsolutePath() + ";");
- }
-
- deployProperties.setProperty("vdb.definition", vdbdef.toString());
- PropertiesUtils.print(deployPropLoc, deployProperties,"Updated for vdb.definition");
-
}
+
+
+ public ExpectedResults getExpectedResults(String querySetID) {
+ return new XMLExpectedResults( querySetID, this.getProperties());
+ }
- private void validateResultsMode(Properties props) {
- // Determine from property what to do with query results
- String resultModeStr = props.getProperty(TestProperties.PROP_RESULT_MODE, "");
- // No need to check for null prop here since we've just checked for this
- // required property
- if (resultModeStr.equalsIgnoreCase(TestProperties.RESULT_MODES.NONE) ||
- resultModeStr.equalsIgnoreCase(TestProperties.RESULT_MODES.COMPARE) ||
- resultModeStr.equalsIgnoreCase(TestProperties.RESULT_MODES.GENERATE)) { //$NON-NLS-1$
- resultMode = resultModeStr;
- }
- // otherwise use default of NONE
+ /* (non-Javadoc)
+ * @see org.teiid.test.client.QueryScenario#handleTestResult(org.teiid.test.client.TestResult, java.lang.String)
+ */
+ @Override
+ public void handleTestResult(TestResult tr, ResultSet resultSet, String sql) {
- TestLogger.log("\nResults mode: " + resultMode); //$NON-NLS-1$
+ Throwable resultException = tr.getException();
+ if (getResultsMode().equalsIgnoreCase(
+ TestProperties.RESULT_MODES.COMPARE)) {
+ if (tr.getStatus() != TestResult.RESULT_STATE.TEST_EXCEPTION) {
+ try {
+ this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(),
+ sql,
+ resultSet,
+ resultException,
+ tr.getStatus(), isOrdered(sql), -1);
- }
-
- public Properties getProperties() {
- return this.props;
- }
-
- public Map<String, Object> getQueries(String querySetID) {
- try {
- return reader.getQueries(querySetID);
- } catch (QueryTestFailedException e) {
- throw new TransactionRuntimeException(e);
- }
- }
-
- public Collection<String> getQuerySetIDs() {
- return reader.getQuerySetIDs();
- }
-
- public String getResultsMode() {
- return this.resultMode;
- }
-
- public ExpectedResults getExpectedResults(String querySetID) {
- XMLExpectedResults expectedResults = new XMLExpectedResults(this.props, querySetID);
- return expectedResults;
- }
-
-
- public ResultsGenerator getResultsGenerator() {
- return this.genResults;
- }
+ } catch (QueryTestFailedException qtf) {
+ resultException = (resultException != null ? resultException
+ : qtf);
+ tr.setException(resultException);
+ tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
+ }
+ }
+ if (tr.getStatus() == TestResult.RESULT_STATE.TEST_EXCEPTION) {
+ try {
+
+ this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
+ tr.getQueryID(), sql, resultSet, resultException,
+ this.getExpectedResults(tr.getQuerySetID()).getResultsFile(tr.getQueryID()) );
+
- @Override
- public String getOutputDirectory() {
- return outputDir;
- }
+ } catch (QueryTestFailedException qtfe) {
+ throw new TransactionRuntimeException(qtfe.getMessage());
+ }
+ }
+ } else if (getResultsMode().equalsIgnoreCase(
+ TestProperties.RESULT_MODES.GENERATE)) { //$NON-NLS-1$
+ try {
+
+ this.getResultsGenerator().generateQueryResultFile(tr.getQuerySetID(),
+ tr.getQueryID(), sql, resultSet, resultException, tr.getStatus());
+
+ } catch (QueryTestFailedException qtfe) {
+ throw new TransactionRuntimeException(qtfe.getMessage());
+ }
- @Override
- public synchronized void addTestResult(String querySetID, TestResult result) {
- Collection<TestResult> results = null;
- if (this.testResults.containsKey(querySetID)) {
- results = this.testResults.get(querySetID);
} else {
- results = new ArrayList<TestResult>();
- this.testResults.put(querySetID, results);
+ // just create the error file for any failures
+ if (tr.getStatus() == TestResult.RESULT_STATE.TEST_EXCEPTION) {
+ try {
+ this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
+ tr.getQueryID(), sql, resultSet, resultException,
+ this.getExpectedResults(tr.getQuerySetID()).getResultsFile(tr.getQueryID()) );
+
+ } catch (QueryTestFailedException qtfe) {
+ throw new TransactionRuntimeException(qtfe.getMessage());
+ }
+ }
}
- results.add(result);
+
+
}
+
+ private boolean isOrdered(String sql) {
+ if (sql.toLowerCase().indexOf(" order by ") > 0) {
+ return true;
+ }
+ return false;
- @Override
- public Collection<TestResult> getTestResults(String querySetID) {
- return this.testResults.get(querySetID);
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2010-01-13 14:57:32 UTC (rev 1734)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -40,6 +40,7 @@
import java.util.Properties;
import org.jdom.JDOMException;
+import org.teiid.test.client.ClassFactory;
import org.teiid.test.client.ExpectedResults;
import org.teiid.test.client.QueryScenario;
import org.teiid.test.client.ResultsGenerator;
@@ -65,7 +66,7 @@
protected Map<String, ResultsHolder> loadedResults = new HashMap<String, ResultsHolder>();
- public XMLExpectedResults(Properties properties, String querySetIdentifier) {
+ public XMLExpectedResults(String querySetIdentifier, Properties properties) {
this.props = properties;
this.querySetIdentifier = querySetIdentifier;
@@ -698,7 +699,7 @@
}
- QueryScenario set = new CTCQueryScenario("testscenario", ConfigPropertyLoader.getInstance().getProperties());
+ QueryScenario set = ClassFactory.createQueryScenario("testscenario");
_instance.setProperty(XMLQueryReader.PROP_QUERY_FILES_ROOT_DIR, new File("target/classes/").getAbsolutePath() );
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-01-13 14:57:32 UTC (rev 1734)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -54,13 +54,15 @@
private String outputDir = "";
private String generateDir = "";
- public XMLGenerateResults(Properties props, String testname, String outputDirectory) {
+ public XMLGenerateResults( String testname, Properties props) {
+
+ outputDir = props.getProperty(TestProperties.PROP_OUTPUT_DIR, ".");
Assert.assertNotNull("Property " + TestProperties.PROP_OUTPUT_DIR
- + " was not passed in", outputDirectory);
-
- this.outputDir = outputDirectory;
+ + " was not specified", outputDir);
+ outputDir = outputDir + "/" + testname;
+
File d = new File(this.outputDir);
this.outputDir = d.getAbsolutePath();
d = new File(this.outputDir);
@@ -74,7 +76,7 @@
generateDir = props.getProperty(PROP_GENERATE_DIR, ".");
Assert.assertNotNull("Property " + PROP_GENERATE_DIR
- + " was not specified", this.outputDir);
+ + " was not specified", this.generateDir);
d = new File(generateDir, testname);
generateDir = d.getAbsolutePath();
@@ -248,7 +250,7 @@
//
// }
- public String generateErrorFileName(String queryID, String querySetID) {
+ private String generateErrorFileName(String queryID, String querySetID) {
String errorFileName = "ERROR_"
// configID + "_" //$NON-NLS-1$ //$NON-NLS-2$
// + querySetID + "_" //$NON-NLS-1$
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java 2010-01-13 14:57:32 UTC (rev 1734)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -46,9 +46,6 @@
private Properties props = null;
-// private Map<String, Map<String, String>> querySet = new HashMap<String, Map<String, String>>();
-// private Map<String, String> queryToFileMap = new HashMap<String, String>();
-
private Map<String, String> querySetIDToFileMap = new HashMap<String, String>();
public XMLQueryReader(Properties properties)
Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client.impl;
+
+import java.io.File;
+import java.sql.ResultSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.teiid.test.client.ExpectedResults;
+import org.teiid.test.client.ctc.ResultsHolder;
+import org.teiid.test.framework.TestLogger;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+import com.metamatrix.jdbc.util.ResultSetUtil;
+
+public class ExpectedResultsImpl implements ExpectedResults {
+
+ private static final int MAX_COL_WIDTH = 65;
+
+
+ protected Properties props;
+ protected int resultMode = -1;
+ protected String generateDir = null;
+ protected String querySetIdentifier = null;
+ protected String results_dir_loc = null;
+
+ protected Map<String, ResultsHolder> loadedResults = new HashMap<String, ResultsHolder>();
+
+
+ public ExpectedResultsImpl(String querySetIdentifier, Properties properties) {
+ this.props = properties;
+ this.querySetIdentifier = querySetIdentifier;
+
+ this.results_dir_loc = props.getProperty(
+ PROP_EXPECTED_RESULTS_DIR_LOC, "");
+
+ String expected_root_loc = this.props
+ .getProperty(PROP_EXPECTED_RESULTS_ROOT_DIR);
+
+ if (expected_root_loc != null) {
+ File dir = new File(expected_root_loc, results_dir_loc);
+ this.results_dir_loc = dir.getAbsolutePath();
+ }
+
+
+ TestLogger.logInfo("Expected results loc: " + this.results_dir_loc);
+ }
+
+
+ @Override
+ public boolean isExceptionExpected(String queryidentifier) throws QueryTestFailedException {
+ return false;
+ }
+
+
+
+ @Override
+ public String getQuerySetID() {
+ return this.querySetIdentifier;
+ }
+
+
+
+ @Override
+ public synchronized File getResultsFile(String queryidentifier) throws QueryTestFailedException {
+ return findExpectedResultsFile(queryidentifier, this.querySetIdentifier);
+
+ }
+
+
+ /**
+ * Compare the results of a query with those that were expected.
+ *
+ * @param expectedResults
+ * The expected results.
+ * @param results
+ * The actual results - may be null if <code>actualException</code>.
+ * @param actualException
+ * The actual exception recieved durring query execution - may be null if <code>results</code>.
+ * @param isOrdered
+ * Are the actual results ordered?
+ * @param batchSize
+ * Size of the batch(es) used in determining when the first batch of results were read.
+ * @return The response time for comparing the first batch (sizes) of resutls.
+ * @throws QueryTestFailedException
+ * If comparison fails.
+ */
+ public void compareResults( final String queryIdentifier,
+ final String sql,
+ final ResultSet resultSet,
+ final Throwable actualException,
+ final int testStatus,
+ final boolean isOrdered,
+ final int batchSize) throws QueryTestFailedException {
+
+ File expectedResultsFile = getResultsFile(queryIdentifier);
+
+// File temp = new File("ERROR_" + queryIdentifier + ".txt");
+// temp.deleteOnExit();
+
+ List<?> results = null;
+ if (actualException != null) {
+
+ try {
+ results = ResultSetUtil.writeAndCompareThrowable(actualException, null, expectedResultsFile, false);
+
+ } catch (Exception e1) {
+ throw new TransactionRuntimeException(e1);
+ }
+
+ if (results != null && results.size() >0) {
+ throw new QueryTestFailedException("Comparison resulted in unequal lines");
+ }
+ } else {
+
+ try {
+ results = ResultSetUtil.writeAndCompareResultSet(resultSet, MAX_COL_WIDTH, false, null, expectedResultsFile, false);
+
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e);
+ }
+
+ if (results != null && results.size() >0) {
+ throw new QueryTestFailedException("Comparison resulted in unequal lines");
+ }
+ }
+
+
+ }
+
+ @Override
+ public Object getMetaData(String queryidentifier) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ private File findExpectedResultsFile(String queryIdentifier,
+ String querySetIdentifier) throws QueryTestFailedException {
+ String resultFileName = queryIdentifier + ".txt"; //$NON-NLS-1$
+ File file = new File(results_dir_loc + "/" + querySetIdentifier, resultFileName);
+ if (!file.exists()) {
+ throw new QueryTestFailedException("Query results file " + file.getAbsolutePath() + " cannot be found");
+ }
+
+ return file;
+
+ }
+
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.test.client.impl;
+
+import java.sql.ResultSet;
+import java.util.Properties;
+
+import org.teiid.test.client.QueryScenario;
+import org.teiid.test.client.TestProperties;
+import org.teiid.test.client.TestResult;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+/**
+ * The QueryScenarioImpl extends the QueryScenerio handle the testresults for defaults settings.
+ *
+ * @author vanhalbert
+ *
+ */
+public class QueryScenarioImpl extends QueryScenario {
+
+
+
+ public QueryScenarioImpl(String scenarioName, Properties queryProperties) {
+ super(scenarioName, queryProperties);
+
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.teiid.test.client.QueryScenario#handleTestResult(org.teiid.test.client.TestResult, java.lang.String)
+ */
+ @Override
+ public void handleTestResult(TestResult tr, ResultSet resultSet, String sql) {
+
+ Throwable resultException = tr.getException();
+ if (getResultsMode().equalsIgnoreCase(
+ TestProperties.RESULT_MODES.COMPARE)) {
+ try {
+ this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(),
+ sql,
+ resultSet,
+ resultException,
+ tr.getStatus(), isOrdered(sql), -1);
+
+ tr.setStatus(TestResult.RESULT_STATE.TEST_SUCCESS);
+
+ } catch (QueryTestFailedException qtf) {
+ resultException = (resultException != null ? resultException
+ : qtf);
+ tr.setException(resultException);
+ tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
+ try {
+ this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
+ tr.getQueryID(), sql, resultSet, resultException,
+ this.getExpectedResults(tr.getQuerySetID()).getResultsFile(tr.getQueryID()) );
+ } catch (QueryTestFailedException qtfe) {
+ throw new TransactionRuntimeException(qtfe.getMessage());
+ }
+
+ }
+
+
+ } else if (getResultsMode().equalsIgnoreCase(
+ TestProperties.RESULT_MODES.GENERATE)) { //$NON-NLS-1$
+
+ try {
+
+ this.getResultsGenerator().generateQueryResultFile(tr.getQuerySetID(),
+ tr.getQueryID(), sql, resultSet, resultException, tr.getStatus());
+
+ } catch (QueryTestFailedException qtfe) {
+ throw new TransactionRuntimeException(qtfe.getMessage());
+ }
+
+ } else {
+ // just create the error file for any failures
+ if (tr.getException() != null) {
+ try {
+ this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
+ tr.getQueryID(), sql, resultSet, resultException,
+ this.getExpectedResults(tr.getQuerySetID()).getResultsFile(tr.getQueryID()) );
+
+ } catch (QueryTestFailedException qtfe) {
+ throw new TransactionRuntimeException(qtfe.getMessage());
+ }
+ }
+ }
+
+
+
+ }
+
+
+ private boolean isOrdered(String sql) {
+
+ if (sql.toLowerCase().indexOf(" order by ") > 0) {
+ return true;
+ }
+ return false;
+
+ }
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -0,0 +1,270 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client.impl;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.sql.ResultSet;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+
+import org.junit.Assert;
+import org.teiid.test.client.ResultsGenerator;
+import org.teiid.test.client.TestProperties;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.jdbc.util.ResultSetUtil;
+
+public class ResultsGeneratorImpl implements ResultsGenerator {
+ private static final SimpleDateFormat FILE_NAME_DATE_FORMATER = new SimpleDateFormat(
+ "yyyyMMdd_HHmmss"); //$NON-NLS-1$
+ private String outputDir = "";
+ private String generateDir = "";
+
+ private static final int MAX_COL_WIDTH = 65;
+
+
+ public ResultsGeneratorImpl( String testname, Properties props) {
+
+ outputDir = props.getProperty(TestProperties.PROP_OUTPUT_DIR, ".");
+
+ Assert.assertNotNull("Property " + TestProperties.PROP_OUTPUT_DIR
+ + " was not specified", outputDir);
+
+ outputDir = outputDir + "/" + testname;
+
+
+ generateDir = props.getProperty(PROP_GENERATE_DIR, ".");
+ Assert.assertNotNull("Property " + PROP_GENERATE_DIR
+ + " was not specified", this.generateDir);
+
+
+ File d = new File(this.outputDir);
+ this.outputDir = d.getAbsolutePath();
+ d = new File(this.outputDir);
+ if (d.exists()) {
+ FileUtils.removeDirectoryAndChildren(d);
+
+ }
+ if (!d.exists()) {
+ d.mkdirs();
+ }
+
+
+ d = new File(generateDir, testname);
+ generateDir = d.getAbsolutePath();
+ d = new File(generateDir);
+ if (d.exists()) {
+ FileUtils.removeDirectoryAndChildren(d);
+ }
+ if (!d.exists()) {
+ d.mkdirs();
+ }
+
+ }
+
+
+ @Override
+ public String getGenerateDir() {
+ // TODO Auto-generated method stub
+ return this.generateDir;
+ }
+
+ @Override
+ public String getOutputDir() {
+ // TODO Auto-generated method stub
+ return outputDir;
+ }
+
+ /**
+ * Generate query results. These are actual results from the server and may
+ * be used for comparing to results from a later test run.
+ *
+ * @param queryID
+ * @param resultsFile
+ * @param result
+ * @param ex
+ * @throws QueryTestFailedException
+ */
+
+ public void generateQueryResultFile(String querySetID, String queryID,
+ String query, ResultSet result, Throwable ex, int testStatus)
+ throws QueryTestFailedException {
+
+ File fos = createNewResultsFile(queryID, querySetID,
+ getGenerateDir());
+
+
+ FileOutputStream actualOut = null;
+ try {
+ actualOut = new FileOutputStream(fos);
+ PrintStream filePrintStream = new PrintStream(actualOut);
+
+ if (ex != null) {
+ ResultSetUtil.printThrowable(ex, filePrintStream);
+ } else if (result != null ){
+
+ ResultSetUtil.printResultSet(result, MAX_COL_WIDTH, true, filePrintStream);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new TransactionRuntimeException(e);
+ } finally {
+ if (actualOut != null) {
+ try {
+ actualOut.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ }
+
+ public String generateErrorFile(final String querySetID,
+ final String queryID, final String sql, final ResultSet resultSet,
+ final Throwable queryError, final File expectedResultsFile)
+ throws QueryTestFailedException {
+
+ String errorFileName = null;
+ try {
+ // write actual results to error file
+ errorFileName = generateErrorFileName(queryID, querySetID);
+ // configID, queryID, Integer.toString(clientID));
+ // CombinedTestClient.log("\t" + this.clientID + ": Writing error file with actual results: " + errorFileName); //$NON-NLS-1$ //$NON-NLS-2$
+ File errorFile = new File(getOutputDir(), errorFileName);
+
+ // the resultset will be passed in as null when
+ // the error was due to a thrown exception, and not based comparison issues
+ if (resultSet == null) {
+ FileOutputStream actualOut = null;
+ try {
+ actualOut = new FileOutputStream(errorFile);
+ PrintStream filePrintStream = new PrintStream(actualOut);
+
+
+ ResultSetUtil.printThrowable(queryError, filePrintStream);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new TransactionRuntimeException(e);
+ } finally {
+ if (actualOut != null) {
+ try {
+ actualOut.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ return errorFileName;
+
+ }
+
+ // rewind resultset
+
+ resultSet.beforeFirst();
+
+ generateErrorResults(querySetID, queryID, sql, errorFile,
+ resultSet, expectedResultsFile, queryError);
+
+ } catch (Throwable e) {
+ throw new QueryTestFailedException(e.getMessage());
+ // CombinedTestClient.logError("Error writing error file \"" + outputDir + "\"/" + errorFileName + ": " + e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ return errorFileName;
+ }
+
+ private File createNewResultsFile(String queryID, String querySetID,
+ String genDir) {
+ String resultFileName = queryID + ".txt"; //$NON-NLS-1$
+
+ String targetDirname = genDir + File.separator + querySetID; //$NON-NLS-1$
+ File targetDir = new File(targetDirname);
+ targetDir.mkdirs();
+
+ return new File(targetDir, resultFileName);
+ }
+
+
+ private String generateErrorFileName(String queryID, String querySetID) {
+ String errorFileName = "ERROR_"
+ // configID + "_" //$NON-NLS-1$ //$NON-NLS-2$
+ // + querySetID + "_" //$NON-NLS-1$
+ + queryID
+ + "_" //$NON-NLS-1$
+ + FILE_NAME_DATE_FORMATER.format(new Date(System
+ .currentTimeMillis())) + ".txt"; //$NON-NLS-1$
+ return errorFileName;
+ }
+
+ /**
+ * Generate an error file for a query that failed comparison. File should
+ * have the SQL, the actual results returned from the server and the results
+ * that were expected.
+ *
+ * @param queryID
+ * @param sql
+ * @param resultsFile
+ * @param actualResult
+ * @param expectedResultFile
+ * @param ex
+ * @throws QueryTestFailedException
+ */
+ private void generateErrorResults(String querySetID, String queryID,
+ String sql, File resultsFile, ResultSet actualResult,
+ File expectedResultFile, Throwable ex)
+ throws QueryTestFailedException {
+
+ FileOutputStream actualOut = null;
+ try {
+ actualOut = new FileOutputStream(resultsFile);
+ PrintStream filePrintStream = new PrintStream(actualOut);
+
+ ResultSetUtil.printResultSet(actualResult, MAX_COL_WIDTH, true, filePrintStream);
+
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new TransactionRuntimeException(e);
+ } finally {
+ if (actualOut != null) {
+ try {
+ actualOut.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java 2010-01-13 14:57:32 UTC (rev 1734)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java 2010-01-13 15:05:12 UTC (rev 1735)
@@ -41,20 +41,29 @@
protected String querySetID;
protected String errorMsg;
protected String query;
+ protected Throwable error=null;
private long beginTS;
private long endTS;
private String errorFile;
+
+ public TestResultStat(final String querySetID, final String queryID, String query) {
+ this.querySetID = querySetID;
+ this.queryID = queryID;
+ this.query = query;
+ }
+
public TestResultStat(final String querySetID, final String queryID, String query, final int resultStatus, long beginTS, long endTS, final Throwable error) {
this.querySetID = querySetID;
this.queryID = queryID;
this.resultStatus = resultStatus;
this.beginTS = beginTS;
this.endTS = endTS;
- this.errorMsg = (error != null ? error.getMessage() : ""); //$NON-NLS-1$
+ this.error = error;
+
}
public TestResultStat(final String querySetID, final String queryID, String query, final int resultStatus, long beginTS, long endTS, final Throwable error, String errorFile) {
@@ -63,7 +72,7 @@
this.resultStatus = resultStatus;
this.beginTS = beginTS;
this.endTS = endTS;
- this.errorMsg = (error != null ? error.getMessage() : ""); //$NON-NLS-1$
+ this.error = error;
this.errorFile = errorFile;
}
@@ -99,24 +108,53 @@
public int getStatus() {
return resultStatus;
}
+
+ public void setStatus(int endStatus) {
+ resultStatus = endStatus;
+ }
public String getExceptionMsg() {
- return errorMsg;
+ return (error != null ? error.getMessage() : "");
}
+ public void setException(Throwable error){
+ this.error = error;
+ }
+
+ public Throwable getException() {
+ return this.error;
+ }
+
public long getBeginTS() {
return beginTS;
}
+ public void setBeginTS(long beginTS) {
+ this.beginTS = beginTS;
+ }
+
public long getEndTS() {
return endTS;
}
+ public void setEndTS(long endts) {
+ this.endTS = endts;
+ }
+
/**
* @return Returns the errorfile.
*/
public String getErrorfile() {
return errorFile;
}
+
+ public void setErrorFile(String errorfile) {
+ this.errorFile = errorfile;
+ }
+
+
+
+
+
}
15 years
teiid SVN: r1734 - in trunk: engine/src/test/java/org/teiid/dqp/internal/pooling/connector and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-01-13 09:57:32 -0500 (Wed, 13 Jan 2010)
New Revision: 1734
Modified:
trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java
Log:
Teiid-931
TestSocketServerInstanceImpl - added logic to check the array bounds
TestConnectionWrapper - increased the Thread.sleep to 50
Modified: trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java
===================================================================
--- trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java 2010-01-13 06:06:07 UTC (rev 1733)
+++ trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java 2010-01-13 14:57:32 UTC (rev 1734)
@@ -84,6 +84,10 @@
//## JDBC4.0-end ##
public Object read() throws IOException,
ClassNotFoundException {
+ if (readCount >= readMsgs.size()) {
+ return "";
+ }
+
Object msg = readMsgs.get(readCount++);
if (msg instanceof IOException) {
if (msg instanceof SocketTimeoutException) {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java 2010-01-13 06:06:07 UTC (rev 1733)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java 2010-01-13 14:57:32 UTC (rev 1734)
@@ -35,7 +35,7 @@
public void testIdleTime() throws Exception {
ConnectionWrapper wrapper = new ConnectionWrapper(Mockito.mock(BasicConnection.class), Mockito.mock(ConnectionPool.class), 1);
long time = wrapper.getTimeReturnedToPool();
- Thread.sleep(5);
+ Thread.sleep(50);
wrapper.close();
assertTrue(wrapper.getTimeReturnedToPool() - time > 0);
}
15 years
teiid SVN: r1733 - trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-01-13 01:06:07 -0500 (Wed, 13 Jan 2010)
New Revision: 1733
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
Log:
removing system.out
Modified: trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2010-01-13 06:03:53 UTC (rev 1732)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2010-01-13 06:06:07 UTC (rev 1733)
@@ -325,7 +325,6 @@
receivedMessage(socketChannel.read());
}
} catch (SocketTimeoutException e) {
- System.out.println("here");
} catch (Exception e) {
exceptionOccurred(e);
} finally {
15 years
teiid SVN: r1732 - in trunk: client/src/main/java/org/teiid/netty/handler/codec/serialization and 13 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-01-13 01:03:53 -0500 (Wed, 13 Jan 2010)
New Revision: 1732
Added:
trunk/client/src/test/java/org/
trunk/client/src/test/java/org/teiid/
trunk/client/src/test/java/org/teiid/netty/
trunk/client/src/test/java/org/teiid/netty/handler/
trunk/client/src/test/java/org/teiid/netty/handler/codec/
trunk/client/src/test/java/org/teiid/netty/handler/codec/serialization/
trunk/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java
trunk/common-core/src/main/java/com/metamatrix/core/util/AccessibleByteArrayOutputStream.java
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java
trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java
trunk/common-core/src/main/java/com/metamatrix/common/types/BlobType.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PartitionedSortJoin.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java
trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
Log:
TEIID-916 TEIID-925 fix for stream corruption during a timeout. Also further refining the dup remove strategy for performance.
Modified: trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java 2010-01-12 21:02:10 UTC (rev 1731)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java 2010-01-13 06:03:53 UTC (rev 1732)
@@ -58,7 +58,6 @@
private final Socket socket;
private ObjectOutputStream outputStream;
private ObjectInputStream inputStream;
- private Object readLock = new Object();
private OioObjectChannel(Socket socket) throws IOException {
log.fine("creating new OioObjectChannel"); //$NON-NLS-1$
@@ -119,15 +118,13 @@
//## JDBC4.0-end ##
public Object read() throws IOException, ClassNotFoundException {
log.finer("reading message from socket"); //$NON-NLS-1$
- synchronized (readLock) {
- try {
- return inputStream.readObject();
- } catch (SocketTimeoutException e) {
- throw e;
- } catch (IOException e) {
- close();
- throw e;
- }
+ try {
+ return inputStream.readObject();
+ } catch (SocketTimeoutException e) {
+ throw e;
+ } catch (IOException e) {
+ close();
+ throw e;
}
}
Modified: trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2010-01-12 21:02:10 UTC (rev 1731)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2010-01-13 06:03:53 UTC (rev 1732)
@@ -41,6 +41,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -83,6 +84,8 @@
private Map<Serializable, ResultsReceiver<Object>> asynchronousListeners = new ConcurrentHashMap<Serializable, ResultsReceiver<Object>>();
+ private ReentrantLock readLock = new ReentrantLock();
+
public SocketServerInstanceImpl() {
}
@@ -173,7 +176,7 @@
return socketChannel.isOpen();
}
- public void send(Message message, ResultsReceiver<Object> listener, Serializable messageKey)
+ protected void send(Message message, ResultsReceiver<Object> listener, Serializable messageKey)
throws CommunicationException, InterruptedException {
if (listener != null) {
asynchronousListeners.put(messageKey, listener);
@@ -197,7 +200,7 @@
* Send an exception to all clients that are currently waiting for a
* response.
*/
- public void exceptionOccurred(Throwable e) {
+ private void exceptionOccurred(Throwable e) {
if (e instanceof CommunicationException) {
if (e.getCause() instanceof InvalidClassException) {
log.log(Level.SEVERE, "Unknown class or incorrect class version:", e); //$NON-NLS-1$
@@ -222,7 +225,7 @@
}
}
- public void receivedMessage(Object packet) {
+ private void receivedMessage(Object packet) {
log.log(Level.FINE, "reading packet"); //$NON-NLS-1$
if (packet instanceof Message) {
Message messagePacket = (Message)packet;
@@ -313,25 +316,31 @@
public Object get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException,
TimeoutException {
- int timeoutMillis = (int)Math.min(unit.toMillis(timeout), Integer.MAX_VALUE);
- synchronized (SocketServerInstanceImpl.this) {
- while (!isDone()) {
- if (timeoutMillis <= 0) {
- throw new TimeoutException();
- }
- long start = System.currentTimeMillis();
- try {
+ long timeoutMillis = (int)Math.min(unit.toMillis(timeout), Integer.MAX_VALUE);
+ long start = System.currentTimeMillis();
+ boolean reading = false;
+ while (!isDone()) {
+ try {
+ if ((reading = readLock.tryLock(timeoutMillis, TimeUnit.MILLISECONDS)) == true && !isDone()) {
receivedMessage(socketChannel.read());
- } catch (SocketTimeoutException e) {
- } catch (IOException e) {
- exceptionOccurred(e);
- } catch (ClassNotFoundException e) {
- exceptionOccurred(e);
}
- if (!isDone()) {
- timeoutMillis -= (System.currentTimeMillis() - start);
+ } catch (SocketTimeoutException e) {
+ System.out.println("here");
+ } catch (Exception e) {
+ exceptionOccurred(e);
+ } finally {
+ if (reading) {
+ readLock.unlock();
}
}
+ if (!isDone()) {
+ long now = System.currentTimeMillis();
+ timeoutMillis -= now - start;
+ start = now;
+ if (timeoutMillis <= 0) {
+ throw new TimeoutException();
+ }
+ }
}
return super.get(timeout, unit);
}
Modified: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java
===================================================================
--- trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java 2010-01-12 21:02:10 UTC (rev 1731)
+++ trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java 2010-01-13 06:03:53 UTC (rev 1732)
@@ -22,8 +22,10 @@
*/
package org.teiid.netty.handler.codec.serialization;
-import java.io.DataInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.EOFException;
import java.io.IOException;
+import java.io.InputStream;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.StreamCorruptedException;
@@ -40,11 +42,15 @@
*/
public class ObjectDecoderInputStream extends ObjectInputStream {
- private final DataInputStream in;
+ private final InputStream in;
private final ClassLoader classLoader;
private final int maxObjectSize;
+
+ private boolean foundLength;
+ private byte[] buffer;
+ private int count;
- public ObjectDecoderInputStream(DataInputStream in, ClassLoader classLoader, int maxObjectSize) throws SecurityException, IOException {
+ public ObjectDecoderInputStream(InputStream in, ClassLoader classLoader, int maxObjectSize) throws SecurityException, IOException {
super();
this.in = in;
this.classLoader = classLoader;
@@ -54,17 +60,43 @@
@Override
protected final Object readObjectOverride() throws IOException,
ClassNotFoundException {
- int dataLen = in.readInt();
- if (dataLen <= 0) {
- throw new StreamCorruptedException("invalid data length: " + dataLen); //$NON-NLS-1$
+ if (!foundLength) {
+ if (buffer == null) {
+ buffer = new byte[4];
+ }
+ fillBuffer();
+ int dataLen = ((buffer[0] & 0xff << 24) + (buffer[1] & 0xff << 16) + (buffer[2] & 0xff << 8) + (buffer[3] & 0xff << 0));
+ if (dataLen <= 0) {
+ throw new StreamCorruptedException("invalid data length: " + dataLen); //$NON-NLS-1$
+ }
+ if (dataLen > maxObjectSize) {
+ throw new StreamCorruptedException(
+ "data length too big: " + dataLen + " (max: " + maxObjectSize + ')'); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ //check if the underlying buffer can be used
+ if (in.available() >= dataLen) {
+ return new CompactObjectInputStream(in, classLoader).readObject();
+ }
+ buffer = new byte[dataLen];
+ foundLength = true;
}
- if (dataLen > maxObjectSize) {
- throw new StreamCorruptedException(
- "data length too big: " + dataLen + " (max: " + maxObjectSize + ')'); //$NON-NLS-1$ //$NON-NLS-2$
+ fillBuffer();
+ foundLength = false;
+ ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
+ buffer = null;
+ return new CompactObjectInputStream(bais, classLoader).readObject();
+ }
+
+ private void fillBuffer() throws IOException, EOFException {
+ while (count < buffer.length) {
+ int read = in.read(buffer, count, buffer.length - count);
+ if (read == -1) {
+ throw new EOFException();
+ }
+ count += read;
}
-
- return new CompactObjectInputStream(in, classLoader).readObject();
- }
+ count = 0;
+ }
@Override
public void close() throws IOException {
Modified: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java
===================================================================
--- trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java 2010-01-12 21:02:10 UTC (rev 1731)
+++ trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java 2010-01-13 06:03:53 UTC (rev 1732)
@@ -22,12 +22,13 @@
*/
package org.teiid.netty.handler.codec.serialization;
-import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
+import com.metamatrix.core.util.AccessibleByteArrayOutputStream;
+
/**
* An {@link ObjectOutput} which is interoperable with {@link ObjectDecoder}
* and {@link ObjectDecoderInputStream}.
@@ -42,7 +43,7 @@
private final DataOutputStream out;
private final int estimatedLength;
-
+
public ObjectEncoderOutputStream(DataOutputStream out, int estimatedLength) throws SecurityException, IOException {
super();
this.out = out;
@@ -51,14 +52,14 @@
@Override
final protected void writeObjectOverride(Object obj) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(estimatedLength);
+ AccessibleByteArrayOutputStream baos = new AccessibleByteArrayOutputStream(estimatedLength);
ObjectOutputStream oout = new CompactObjectOutputStream(baos);
oout.writeObject(obj);
oout.flush();
oout.close();
- out.writeInt(baos.size());
- out.write(baos.toByteArray());
+ out.writeInt(baos.getCount());
+ out.write(baos.getBuffer(), 0, baos.getCount());
}
@Override
Modified: trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java
===================================================================
--- trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java 2010-01-12 21:02:10 UTC (rev 1731)
+++ trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java 2010-01-13 06:03:53 UTC (rev 1732)
@@ -22,6 +22,8 @@
package com.metamatrix.common.comm.platform.socket.client;
+import static org.junit.Assert.*;
+
import java.io.IOException;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
@@ -32,7 +34,7 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeoutException;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.api.HostInfo;
@@ -42,7 +44,7 @@
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.platform.security.api.ILogon;
-public class TestSocketServerInstanceImpl extends TestCase {
+public class TestSocketServerInstanceImpl {
private static class FakeObjectChannel implements ObjectChannel, ObjectChannelFactory {
List<Object> msgs = new ArrayList<Object>();
@@ -119,7 +121,7 @@
}
- public void testHandshakeTimeout() throws Exception {
+ @Test public void testHandshakeTimeout() throws Exception {
SocketTimeoutException[] exs = new SocketTimeoutException[SocketServerInstanceImpl.HANDSHAKE_RETRIES];
Arrays.fill(exs, new SocketTimeoutException());
final FakeObjectChannel channel = new FakeObjectChannel(Arrays.asList(exs));
@@ -139,7 +141,7 @@
return ssii;
}
- public void testSuccessfulHandshake() throws Exception {
+ @Test public void testSuccessfulHandshake() throws Exception {
final FakeObjectChannel channel = new FakeObjectChannel(Arrays.asList(new Handshake(), new SocketTimeoutException()));
SocketServerInstanceImpl instance = createInstance(channel);
@@ -154,7 +156,7 @@
}
}
- public void testVersionMismatch() throws Exception {
+ @Test public void testVersionMismatch() throws Exception {
Handshake h = new Handshake();
h.setVersion("foo"); //$NON-NLS-1$
final FakeObjectChannel channel = new FakeObjectChannel(Arrays.asList(h));
Added: trunk/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java
===================================================================
--- trunk/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java (rev 0)
+++ trunk/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java 2010-01-13 06:03:53 UTC (rev 1732)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.netty.handler.codec.serialization;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.SocketTimeoutException;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class TestObjectDecoderInputStream {
+
+ @Test public void testTimeoutException() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectEncoderOutputStream oeos = new ObjectEncoderOutputStream(new DataOutputStream(baos), 512);
+ List<Integer> obj = Arrays.asList(1, 2, 3);
+ oeos.writeObject(obj);
+ oeos.close();
+ final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ InputStream is = new InputStream() {
+ int count;
+ @Override
+ public int read() throws IOException {
+ if (count++%2==0) {
+ throw new SocketTimeoutException();
+ }
+ return bais.read();
+ }
+ };
+ ObjectDecoderInputStream odis = new ObjectDecoderInputStream(new DataInputStream(is), Thread.currentThread().getContextClassLoader(), 1024);
+ Object result = null;
+ do {
+ try {
+ result = odis.readObject();
+ } catch (IOException e) {
+
+ }
+ } while (result == null);
+ assertEquals(obj, result);
+ }
+
+}
Property changes on: trunk/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/BlobType.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/BlobType.java 2010-01-12 21:02:10 UTC (rev 1731)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/BlobType.java 2010-01-13 06:03:53 UTC (rev 1732)
@@ -22,8 +22,6 @@
package com.metamatrix.common.types;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
@@ -130,24 +128,6 @@
this.reference.truncate(len);
}
- /**
- * Utility Method to convert blob into byte array
- * @param blob
- * @return byte array
- */
- public static byte[] getByteArray(Blob blob) throws SQLException, IOException {
- InputStream reader = blob.getBinaryStream();
- ByteArrayOutputStream writer = new ByteArrayOutputStream();
- int c = reader.read();
- while (c != -1) {
- writer.write((byte)c);
- c = reader.read();
- }
- reader.close();
- byte[] data = writer.toByteArray();
- writer.close();
- return data;
- }
//## JDBC4.0-begin ##
public void free() throws SQLException {
this.reference.free();
Added: trunk/common-core/src/main/java/com/metamatrix/core/util/AccessibleByteArrayOutputStream.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/util/AccessibleByteArrayOutputStream.java (rev 0)
+++ trunk/common-core/src/main/java/com/metamatrix/core/util/AccessibleByteArrayOutputStream.java 2010-01-13 06:03:53 UTC (rev 1732)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.core.util;
+
+import java.io.ByteArrayOutputStream;
+
+public class AccessibleByteArrayOutputStream extends ByteArrayOutputStream {
+
+ public AccessibleByteArrayOutputStream() {
+ super();
+ }
+
+ public AccessibleByteArrayOutputStream(int size) {
+ super(size);
+ }
+
+ public byte[] getBuffer() {
+ return this.buf;
+ }
+
+ public int getCount() {
+ return this.count;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/common-core/src/main/java/com/metamatrix/core/util/AccessibleByteArrayOutputStream.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java 2010-01-12 21:02:10 UTC (rev 1731)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java 2010-01-13 06:03:53 UTC (rev 1732)
@@ -23,7 +23,6 @@
package com.metamatrix.common.buffer;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -40,6 +39,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.Streamable;
+import com.metamatrix.core.util.AccessibleByteArrayOutputStream;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.query.execution.QueryExecPlugin;
@@ -228,40 +228,22 @@
this.store = this.manager.createFileStore(this.tupleSourceID);
this.store.setCleanupReference(this);
}
- byte[] bytes = convertToBytes(writeBatch);
- mbatch.setLength(bytes.length);
- mbatch.setOffset(this.store.write(bytes));
- this.batches.put(mbatch.getBeginRow(), mbatch);
- batchBuffer = null;
- }
-
- /**
- * Convert from an object to a byte array
- * @param object Object to convert
- * @return Byte array
- */
- private byte[] convertToBytes(TupleBatch batch) throws MetaMatrixComponentException {
- ObjectOutputStream oos = null;
+ AccessibleByteArrayOutputStream baos = null;
try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- oos = new ObjectOutputStream(baos);
-
- batch.setDataTypes(types);
- batch.writeExternal(oos);
+ baos = new AccessibleByteArrayOutputStream(1024);
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ writeBatch.setDataTypes(types);
+ writeBatch.writeExternal(oos);
oos.flush();
- return baos.toByteArray();
-
+ oos.close();
} catch(IOException e) {
throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("FileStorageManager.batch_error")); //$NON-NLS-1$
- } finally {
- if(oos != null) {
- try {
- oos.close();
- } catch(IOException e) {
- }
- }
}
- }
+ mbatch.setLength(baos.getCount());
+ mbatch.setOffset(this.store.write(baos.getBuffer(), 0, baos.getCount()));
+ this.batches.put(mbatch.getBeginRow(), mbatch);
+ batchBuffer = null;
+ }
public void close() throws MetaMatrixComponentException {
//if there is only a single batch, let it stay in memory
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PartitionedSortJoin.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PartitionedSortJoin.java 2010-01-12 21:02:10 UTC (rev 1731)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PartitionedSortJoin.java 2010-01-13 06:03:53 UTC (rev 1732)
@@ -51,7 +51,7 @@
* for buffermanager reserve/release of memory
* (would also help the sort utility)
*/
- public static final int MAX_PARTITIONS = 8;
+ public static final int MAX_PARTITIONS = 16;
private List[] endTuples;
private List<Boolean> overlap = new ArrayList<Boolean>();
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2010-01-12 21:02:10 UTC (rev 1731)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2010-01-13 06:03:53 UTC (rev 1732)
@@ -23,9 +23,11 @@
package com.metamatrix.query.processor.relational;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
+import java.util.TreeSet;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
@@ -69,7 +71,8 @@
@Override
public int compareTo(SortedSublist o) {
- return comparator.compare(this.tuple, o.tuple);
+ //reverse the comparison, so that removal of the lowest is a low cost operation
+ return -comparator.compare(this.tuple, o.tuple);
}
@Override
@@ -92,12 +95,13 @@
private List<TupleBuffer> activeTupleBuffers = new ArrayList<TupleBuffer>();
private int masterSortIndex;
- private int initialSortPass = 1; //used to track the number of times through the initial sort method
+ private int dupRemoveSublists = 1; //used to control the number of sublists needed for dup remove
// Phase constants for readability
private static final int INITIAL_SORT = 1;
private static final int MERGE = 2;
private static final int DONE = 3;
+ private Collection<List<?>> workingTuples;
public SortUtility(TupleSource sourceID, List sortElements, List<Boolean> sortTypes, Mode mode, BufferManager bufferMgr,
String groupName) {
@@ -162,7 +166,14 @@
*/
protected void initialSort() throws MetaMatrixComponentException, MetaMatrixProcessingException {
while(!doneReading) {
- List<List<?>> workingTuples = new ArrayList<List<?>>();
+ if (workingTuples == null) {
+ if (mode == Mode.SORT) {
+ workingTuples = new ArrayList<List<?>>();
+ } else {
+ workingTuples = new TreeSet<List<?>>(comparator);
+ }
+ }
+
int maxRows = bufferManager.getMaxProcessingBatches() * bufferManager.getProcessorBatchSize();
while(!doneReading && workingTuples.size() < maxRows) {
try {
@@ -173,9 +184,10 @@
break;
}
- addTuple(workingTuples, tuple);
+ workingTuples.add(tuple);
} catch(BlockedException e) {
- if (workingTuples.isEmpty() && (mode != Mode.DUP_REMOVE || activeTupleBuffers.size() < initialSortPass)) {
+ if ((workingTuples.size() < maxRows/2 && mode != Mode.DUP_REMOVE)
+ || (workingTuples.size() < (dupRemoveSublists/4)*bufferManager.getProcessorBatchSize() && activeTupleBuffers.size() < dupRemoveSublists)) {
throw e; //block if no work can be performed
}
break;
@@ -190,33 +202,22 @@
activeTupleBuffers.add(sublist);
if (this.mode == Mode.SORT) {
//perform a stable sort
- Collections.sort(workingTuples, comparator);
+ Collections.sort((List<List<?>>)workingTuples, comparator);
}
for (List<?> list : workingTuples) {
sublist.addTuple(list);
}
+ workingTuples = null;
sublist.saveBatch();
}
if (this.activeTupleBuffers.isEmpty()) {
activeTupleBuffers.add(createTupleBuffer());
}
- this.initialSortPass = Math.min(initialSortPass + 1, bufferManager.getMaxProcessingBatches() * 2);
+ this.dupRemoveSublists = Math.min(dupRemoveSublists * 2, bufferManager.getMaxProcessingBatches() * 2);
this.phase = MERGE;
}
- protected void addTuple(List<List<?>> workingTuples, List<?> tuple) {
- if (this.mode == Mode.SORT) {
- workingTuples.add(tuple);
- return;
- }
- int index = Collections.binarySearch(workingTuples, tuple, comparator);
- if (index >= 0) {
- return; //it's already there
- }
- workingTuples.add(-index - 1, tuple);
- }
-
protected void mergePhase() throws MetaMatrixComponentException, MetaMatrixProcessingException {
while(this.activeTupleBuffers.size() > 1) {
ArrayList<SortedSublist> sublists = new ArrayList<SortedSublist>(activeTupleBuffers.size());
@@ -227,7 +228,6 @@
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.TRACE)) {
LogManager.logTrace(LogConstants.CTX_DQP, "Merging", maxSortIndex, "sublists out of", activeTupleBuffers.size()); //$NON-NLS-1$ //$NON-NLS-2$
}
-
// initialize the sublists with the min value
for(int i = 0; i<maxSortIndex; i++) {
TupleBuffer activeID = activeTupleBuffers.get(i);
@@ -242,7 +242,7 @@
// iteratively process the lowest tuple
while (sublists.size() > 0) {
- SortedSublist sortedSublist = sublists.remove(0);
+ SortedSublist sortedSublist = sublists.remove(sublists.size() - 1);
merged.addTuple(sortedSublist.tuple);
if (this.output != null && sortedSublist.index > masterSortIndex) {
this.output.addTuple(sortedSublist.tuple); //a new distinct row
Modified: trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2010-01-12 21:02:10 UTC (rev 1731)
+++ trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2010-01-13 06:03:53 UTC (rev 1732)
@@ -286,6 +286,9 @@
private MetaMatrixSessionInfo getSessionInfo(MetaMatrixSessionID sessionID)
throws InvalidSessionException {
+ if (sessionID == null) {
+ throw new InvalidSessionException(DQPEmbeddedPlugin.Util.getString("SessionServiceImpl.invalid_session", new Object[] {null})); //$NON-NLS-1$
+ }
MetaMatrixSessionInfo info = this.sessionCache.get(sessionID);
if (info == null) {
throw new InvalidSessionException(DQPEmbeddedPlugin.Util.getString("SessionServiceImpl.invalid_session", sessionID)); //$NON-NLS-1$
15 years
teiid SVN: r1731 - in branches/JCA: build/kit-jboss-container/deploy and 16 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-01-12 16:02:10 -0500 (Tue, 12 Jan 2010)
New Revision: 1731
Added:
branches/JCA/build/kit-jboss-container/conf/jboss-log4j.xml
branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java
branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java
Removed:
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
branches/JCA/runtime/src/main/java/org/teiid/WrappedTeiidConnection.java
Modified:
branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml
branches/JCA/build/kit-jboss-container/deploy/teiid-runtime.rar
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java
branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java
branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
branches/JCA/client/src/main/java/com/metamatrix/common/api/MMURL.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java
branches/JCA/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
branches/JCA/runtime/src/main/java/org/teiid/Server.java
branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java
branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java
branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java
branches/JCA/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
Log:
TEIID-833: adding embedded connection which currenly works only in JBoss container
Added: branches/JCA/build/kit-jboss-container/conf/jboss-log4j.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/conf/jboss-log4j.xml (rev 0)
+++ branches/JCA/build/kit-jboss-container/conf/jboss-log4j.xml 2010-01-12 21:02:10 UTC (rev 1731)
@@ -0,0 +1,417 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: jboss-log4j.xml 87678 2009-04-22 16:47:08Z bstansberry(a)jboss.com $ -->
+
+<!--
+ | For more configuration information and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/server.log"/>
+ <param name="Append" value="true"/>
+ <!-- In AS 5.0.x the server log threshold was set by a system
+ property. In 5.1 and later we are instead using the system
+ property to set the priority on the root logger (see <root/> below)
+ <param name="Threshold" value="${jboss.server.log.threshold}"/>
+ -->
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] (Thread) Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- A size based file rolling appender
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/server.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ====================== -->
+ <!-- More Appender examples -->
+ <!-- ====================== -->
+
+ <!-- Buffer events and log them asynchronously
+ <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="SMTP"/>
+ </appender>
+ -->
+
+ <!-- EMail events to an administrator
+ <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="To" value="admin(a)myhost.domain.com"/>
+ <param name="From" value="nobody(a)myhost.domain.com"/>
+ <param name="Subject" value="JBoss Sever Errors"/>
+ <param name="SMTPHost" value="localhost"/>
+ <param name="BufferSize" value="10"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Syslog events
+ <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Facility" value="LOCAL7"/>
+ <param name="FacilityPrinting" value="true"/>
+ <param name="SyslogHost" value="localhost"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Log events to JMS (requires a topic to be created)
+ <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
+ <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
+ </appender>
+ -->
+
+ <!-- Log events through SNMP
+ <appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="ImplementationClassName" value="org.apache.log4j.ext.JoeSNMPTrapSender"/>
+ <param name="ManagementHost" value="127.0.0.1"/>
+ <param name="ManagementHostTrapListenPort" value="162"/>
+ <param name="EnterpriseOID" value="1.3.6.1.4.1.24.0"/>
+ <param name="LocalIPAddress" value="127.0.0.1"/>
+ <param name="LocalTrapSendPort" value="161"/>
+ <param name="GenericTrapType" value="6"/>
+ <param name="SpecificTrapType" value="12345678"/>
+ <param name="CommunityString" value="public"/>
+ <param name="ForwardStackTraceWithTrap" value="true"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="ApplicationTrapOID" value="1.3.6.1.4.1.24.12.10.22.64"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d,%p,[%t],[%c],%m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Emit events as JMX notifications
+ <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+
+ <param name="Threshold" value="WARN"/>
+ <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Security AUDIT Appender
+ <appender name="AUDIT" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/audit.log"/>
+ <param name="Append" value="true"/>
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t:%x) %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- un-comment to enable Teiid COMMAND log
+ <appender name="COMMAND" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="${jboss.server.log.dir}/teiid-command.log"/>
+ <param name="MaxFileSize" value="1000KB"/>
+ <param name="MaxBackupIndex" value="25"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t:%x) %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Un-comment to enable Teiid AUDIT log
+ <appender name="AUDIT" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="${jboss.server.log.dir}/teiid-audit.log"/>
+ <param name="MaxFileSize" value="1000KB"/>
+ <param name="MaxBackupIndex" value="25"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t:%x) %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
+ <category name="org.apache">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the jacorb category to WARN as its INFO is verbose -->
+ <category name="jacorb">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Set the logging level of the JSF implementation that uses
+ | java.util.logging. The jdk logging levels can be controlled
+ | through the org.jboss.logging.log4j.JDKLevel class that
+ | in addition to the standard log4j levels it adds support for
+ | SEVERE, WARNING, CONFIG, FINE, FINER, FINEST
+ -->
+ <category name="javax.enterprise.resource.webcontainer.jsf">
+ <priority value="INFO" class="org.jboss.logging.log4j.JDKLevel"/>
+ </category>
+
+ <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
+ <category name="org.jgroups">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit the org.quartz category to INFO as its DEBUG is verbose -->
+ <category name="org.quartz">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the com.sun category to INFO as its FINE is verbose -->
+ <category name="com.sun">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the sun category to INFO as its FINE is verbose -->
+ <category name="sun">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the javax.xml.bind category to INFO as its FINE is verbose -->
+ <category name="javax.xml.bind">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit JBoss categories
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+ -->
+
+ <!-- Limit the JSR77 categories -->
+ <category name="org.jboss.management">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the verbose facelets compiler -->
+ <category name="facelets.compiler">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit the verbose ajax4jsf cache initialization -->
+ <category name="org.ajax4jsf.cache">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit the verbose embedded jopr categories -->
+ <category name="org.rhq">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit the verbose seam categories -->
+ <category name="org.jboss.seam">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
+ <category name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
+ <priority value="TRACE"/>
+ </category>
+ -->
+
+ <!-- Category specifically for Security Audit Provider
+ <category name="org.jboss.security.audit.providers.LogAuditProvider" additivity="false">
+ <priority value="TRACE"/>
+ <appender-ref ref="AUDIT"/>
+ </category>
+ -->
+
+ <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
+ <category name="org.jboss.serial">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Decrease the priority threshold for the org.jboss.varia category
+ <category name="org.jboss.varia">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
+ <!-- Enable JBossWS message tracing
+ <category name="org.jboss.ws.core.MessageTrace">
+ <priority value="TRACE"/>
+ </category>
+ -->
+
+ <!--
+ | An example of enabling the custom TRACE level priority that is used
+ | by the JBoss internals to diagnose low level details. This example
+ | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
+ | subpackages. This will produce A LOT of logging output.
+ |
+ | Note: since jboss AS 4.2.x, the trace level is supported natively by
+ | log4j, so although the custom org.jboss.logging.XLevel priority will
+ | still work, there is no need to use it. The two examples that follow
+ | will both enable trace logging.
+ <category name="org.jboss.system">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ <category name="org.jboss.ejb.plugins">
+ <priority value="TRACE"/>
+ </category>
+ -->
+
+ <!--
+ | Logs these events to SNMP:
+ - server starts/stops
+ - cluster evolution (node death/startup)
+ - When an EJB archive is deployed (and associated verified messages)
+ - When an EAR archive is deployed
+
+ <category name="org.jboss.system.server.Server">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.deployment.MainDeployer">
+ <priority value="ERROR" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.ejb.EJBDeployer">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.deployment.EARDeployer">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+ -->
+
+ <!-- Clustering logging -->
+ <!-- Uncomment the following to redirect the org.jgroups and
+ org.jboss.ha categories to a cluster.log file.
+
+ <appender name="CLUSTER" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/cluster.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ <category name="org.jgroups">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ <category name="org.jboss.ha">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ -->
+
+ <!-- Teiid specific categoryies -->
+ <logger name="org.teiid">
+ <level value="WARN" />
+ </logger>
+
+ <!-- un-comment to enable COMMAND log
+ <logger name="org.teiid.COMMAND_LOG" additivity="false">
+ <level value="INFO"/>
+ <appender-ref ref="COMMAND"/>
+ </logger>
+ -->
+
+ <!-- Un-comment to enable AUDIT log
+ <logger name="org.teiid.AUDIT_LOG" additivity="false">
+ <level value="INFO"/>
+ <appender-ref ref="AUDIT"/>
+ </logger>
+ -->
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <!--
+ Set the root logger priority via a system property. Note this is parsed by log4j,
+ so the full JBoss system property format is not supported; e.g.
+ setting a default via ${jboss.server.log.threshold:WARN} will not work.
+ -->
+ <priority value="${jboss.server.log.threshold}"/>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml 2010-01-12 21:02:10 UTC (rev 1731)
@@ -10,7 +10,6 @@
<config-property name="TeiidHome" type="java.lang.String">/home/rareddy/teiid/teiid-6.3.0/</config-property>
<max-pool-size>20</max-pool-size>
- <security-domain-and-application>teiid-security</security-domain-and-application>
</no-tx-connection-factory>
</connection-factories>
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid-runtime.rar
===================================================================
(Binary files differ)
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/api/MMURL.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/api/MMURL.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/api/MMURL.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -61,11 +61,6 @@
*/
public static final String DISCOVERY_STRATEGY = "discoveryStategy"; //$NON-NLS-1$
- /**
- * if "true" in the embedded mode if there is a active instance that instance will be shutdown.
- */
- public static final String SHUTDOWN = "shutdown"; //$NON-NLS-1$
-
public static final String SERVER_URL = "serverURL"; //$NON-NLS-1$
/**
* Non-secure MetaMatrix Protocol.
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -33,6 +33,8 @@
void close();
+ void reallyClose();
+
boolean isOpen();
LogonResult getLogonResult();
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -26,12 +26,9 @@
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
-import com.metamatrix.core.MetaMatrixCoreException;
public interface ServerConnectionFactory {
- void initialize(Properties info) throws MetaMatrixCoreException;
-
/**
* Establish a connection to the server.
* @param connProps The properties used by the transport to find a connection. These
@@ -42,13 +39,5 @@
* problems with the connection properties (bad user name, bad password, bad host name, etc)
*/
ServerConnection getConnection(Properties connectionProperties) throws CommunicationException, ConnectionException;
-
- /**
- * Is the connection factory alive
- * @return true if alive; false otherwise.
- */
- boolean isAlive();
-
- void shutdown();
}
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -317,4 +317,9 @@
this.failOver = failOver;
}
+ @Override
+ public void reallyClose() {
+ close();
+ }
+
}
\ No newline at end of file
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -179,7 +179,6 @@
}
- @Override
public void initialize(Properties info) {
PropertiesUtils.setBeanProperties(this, info, "org.teiid.sockets"); //$NON-NLS-1$
this.pingTimer = new Timer("SocketPing", true); //$NON-NLS-1$
@@ -287,17 +286,4 @@
public void setMaxCachedInstances(int maxCachedInstances) {
this.maxCachedInstances = maxCachedInstances;
}
-
-
- @Override
- public void shutdown() {
- // only applies in the Embedded scenario.
- }
-
- @Override
- public boolean isAlive() {
- // only applies in the Embedded scenario.
- return false;
- }
-
}
Modified: branches/JCA/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -66,7 +66,6 @@
public static final String BOOTURL = "bootURL"; //$NON-NLS-1$
public static final String ENABLE_SOCKETS = "sockets.enabled"; //$NON-NLS-1$
public static final String HOST_ADDRESS = "hostAddress"; //$NON-NLS-1$
- public static final String DQP_BOOTSTRAP_FILE = "bootstrapFile"; //$NON-NLS-1$
public static final String TEIID_HOME = "teiid.home"; //$NON-NLS-1$
public static final String TEIID_LOGDIR = "teiid.logdir"; //$NON-NLS-1$
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -25,7 +25,6 @@
import java.io.Serializable;
import java.util.Date;
-import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.metatype.api.annotations.MetaMapping;
import org.teiid.adminapi.Request;
@@ -33,7 +32,6 @@
import com.metamatrix.dqp.message.RequestID;
-@ManagementObject
@MetaMapping(RequestMetadataMapper.class)
public class RequestMetadata extends AdminObjectImpl implements Request, Serializable {
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -23,7 +23,6 @@
import java.util.Date;
-import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementObjectID;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.metatype.api.annotations.MetaMapping;
@@ -33,7 +32,6 @@
/**
* Add and delete properties also in the Mapper class for correct wrapping for profile service.
*/
-@ManagementObject
@MetaMapping(SessionMetadataMapper.class)
public class SessionMetadata extends AdminObjectImpl implements Session {
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -24,14 +24,12 @@
import java.util.Date;
-import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.metatype.api.annotations.MetaMapping;
import org.teiid.adminapi.Transaction;
import com.metamatrix.admin.AdminPlugin;
-@ManagementObject
@MetaMapping(TransactionMetadataMapper.class)
public class TransactionMetadata extends AdminObjectImpl implements Transaction {
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -22,14 +22,12 @@
package org.teiid.adminapi.impl;
-import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.teiid.adminapi.WorkerPoolStatistics;
/**
* This class is a holder for all the statistics gathered about a worker pool.
*/
-@ManagementObject
public class WorkerPoolStatisticsMetadata extends AdminObjectImpl implements WorkerPoolStatistics {
private static final long serialVersionUID = -4917902925523802295L;
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -33,23 +33,4 @@
}
- /**
- * Returns the path and file name from which embedded DQP configuration information will be read.
- *
- * @return the name of the config file for this data source; may be null
- */
- public String getBootstrapFile() {
- return getEmbeddedBootstrapFile();
- }
-
- /**
- * Sets file name from which embedded DQP configuration information * will be read.
- *
- * @param configFile
- * The name of the config file name to set
- */
- public void setBootstrapFile(final String configFile) {
- setEmbeddedBootstrapFile(configFile);
- }
-
}
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -287,7 +287,7 @@
} catch (SQLException se) {
firstException = se;
} finally {
- this.serverConn.close();
+ this.serverConn.reallyClose();
if ( firstException != null )
throw (SQLException)firstException;
}
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -59,8 +59,7 @@
ExecutionProperties.PROP_XML_VALIDATION,
ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS,
MMURL.CONNECTION.AUTO_FAILOVER,
- MMURL.CONNECTION.DISCOVERY_STRATEGY,
- MMURL.CONNECTION.SHUTDOWN
+ MMURL.CONNECTION.DISCOVERY_STRATEGY
};
private String vdbName;
@@ -74,8 +73,7 @@
}
public MMJDBCURL(String vdbName, String connectionURL, Properties props) {
- if (vdbName == null || vdbName.trim().length() == 0 ||
- connectionURL == null || connectionURL.trim().length() == 0) {
+ if (vdbName == null || vdbName.trim().length() == 0) {
throw new IllegalArgumentException();
}
this.vdbName = vdbName;
@@ -198,9 +196,10 @@
public String getJDBCURL() {
if (urlString == null) {
StringBuffer buf = new StringBuffer(JDBC_PROTOCOL)
- .append(vdbName)
- .append('@')
- .append(connectionURL);
+ .append(vdbName);
+ if (this.connectionURL != null) {
+ buf.append('@').append(connectionURL);
+ }
for (Iterator i = properties.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry)i.next();
if (entry.getValue() instanceof String) {
Modified: branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -22,70 +22,43 @@
package org.teiid.jdbc;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Enumeration;
-import java.util.List;
import java.util.Properties;
import java.util.ResourceBundle;
-import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
-import com.metamatrix.common.api.MMURL;
-import com.metamatrix.common.classloader.PostDelegatingClassLoader;
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
-import com.metamatrix.common.protocol.MMURLConnection;
-import com.metamatrix.common.protocol.MetaMatrixURLStreamHandlerFactory;
-import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.ReflectionHelper;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.jdbc.BaseDataSource;
import com.metamatrix.jdbc.JDBCPlugin;
import com.metamatrix.jdbc.MMConnection;
-import com.metamatrix.jdbc.MMSQLException;
-import com.metamatrix.jdbc.api.SQLStates;
import com.metamatrix.jdbc.util.MMJDBCURL;
final class EmbeddedProfile {
- /**
+ private static final String TEIID_RUNTIME = "java:teiid/runtime-engine";
+ private static final String BUNDLE_NAME = "com.metamatrix.jdbc.basic_i18n"; //$NON-NLS-1$
+
+ /**
* Match URL like
- * - jdbc:metamatrix:BQT@c:/foo.properties;version=1..
- * - jdbc:metamatrix:BQT@c:\\foo.properties;version=1..
- * - jdbc:metamatrix:BQT@\\foo.properties;version=1..
- * - jdbc:metamatrix:BQT@/foo.properties;version=1..
- * - jdbc:metamatrix:BQT@../foo.properties;version=1..
- * - jdbc:metamatrix:BQT@./foo.properties;version=1..
- * - jdbc:metamatrix:BQT@file:///c:/foo.properties;version=1..
- * - jdbc:metamatrix:BQT
- * - jdbc:metamatrix:BQT;verson=1
+ * - jdbc:teiid:BQT
+ * - jdbc:teiid:BQT;verson=1
*/
- static final String URL_PATTERN = "jdbc:(teiid|metamatrix):(\\w+)@(([^;]*)[;]?)((.*)*)"; //$NON-NLS-1$
- static final String BASE_PATTERN = "jdbc:(teiid|metamatrix):((\\w+)[;]?)(;([^@])+)*"; //$NON-NLS-1$
+ static final String BASE_PATTERN = "jdbc:teiid:((\\w+)[;]?)(;([^@])+)*"; //$NON-NLS-1$
private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
- private static EmbeddedTransport currentTransport = null;
- static Pattern urlPattern = Pattern.compile(URL_PATTERN);
static Pattern basePattern = Pattern.compile(BASE_PATTERN);
/**
@@ -106,79 +79,37 @@
// parse the URL to add it's properties to properties object
parseURL(url, info);
- MMConnection conn = createConnection(info);
- boolean shutdown = Boolean.parseBoolean(info.getProperty(MMURL.CONNECTION.SHUTDOWN, "false")); //$NON-NLS-1$
- if (shutdown) {
- Admin admin = conn.getAdminAPI();
- try {
- // this will make sure the user has permissions to do the shutdown.
- admin.shutdown(0);
- shutdown();
- throw new MMSQLException(getResourceMessage("EmbeddedDriver.shutdown_sucessful"), SQLStates.SUCESS); //$NON-NLS-1$
- } catch (AdminException e) {
- conn.close();
- throw new MMSQLException(e, getResourceMessage("EmbeddedDriver.shutdown_failure"), SQLStates.DEFAULT); //$NON-NLS-1$
- }
- }
-
- // logging
- String logMsg = JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess"); //$NON-NLS-1$
- logger.fine(logMsg);
-
+ MMConnection conn = createConnection(url, info);
+ logger.fine(JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess")); //$NON-NLS-1$
return conn;
-
}
- static MMConnection createConnection(Properties info) throws SQLException{
+ static MMConnection createConnection(String url, Properties info) throws SQLException{
// first validate the properties as this may called from the EmbeddedDataSource
// and make sure we have all the properties we need.
validateProperties(info);
-
- URL dqpURL;
- try {
- dqpURL = URLHelper.buildURL(info.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE));
- } catch (MalformedURLException e) {
- throw MMSQLException.create(e);
+ try {
+ InitialContext ic = new InitialContext();
+ ServerConnectionFactory scf = (ServerConnectionFactory)ic.lookup(TEIID_RUNTIME);
+ ServerConnection conn = scf.getConnection(info);
+ // this close has no effect; it only closes the managed connection of server connection
+ conn.close();
+ return new MMConnection(conn, info, url);
+ } catch (NamingException e) {
+ throw new SQLException(e);
+ } catch (ConnectionException e) {
+ throw new SQLException(e);
+ } catch (CommunicationException e) {
+ throw new SQLException(e);
}
-
- // now create the connection
- EmbeddedTransport transport = getDQPTransport(dqpURL);
-
- MMConnection conn = transport.createConnection(info);
-
- return conn;
}
/**
- * Get the DQP transport or build the transport if one not available from the
- * DQP URL supplied. DQP transport contains all the details about DQP.
- * @param dqpURL - URL to the DQP.properties file
- * @return EmbeddedTransport
- * @throws SQLException
- * @since 4.4
- */
- private synchronized static EmbeddedTransport getDQPTransport(URL dqpURL) throws SQLException {
- EmbeddedTransport transport = currentTransport;
- if (transport == null || !transport.isAlive() || !currentTransport.getURL().equals(dqpURL)) {
- // shutdown any previous instance; we do encourage single instance in a given VM
- shutdown();
- try {
- transport = new EmbeddedTransport(dqpURL);
- } catch (SQLException e) {
- logger.log(Level.SEVERE, "Could not start the embedded engine", e); //$NON-NLS-1$
- throw e;
- }
- }
- currentTransport = transport;
- return transport;
- }
-
- /**
* This method parses the URL and adds properties to the the properties object. These include required and any optional
* properties specified in the URL.
* Expected URL format --
- * jdbc:metamatrix:local:VDB@<pathToConfigFile>logFile=<logFile.log>; logLevel=<logLevel>;credentials=mycredentials;
+ * jdbc:teiid:VDB;[name=value]*;
*
* @param The URL needed to be parsed.
* @param The properties object which is to be updated with properties in the URL.
@@ -195,16 +126,6 @@
// Set the VDB Name
info.setProperty(BaseDataSource.VDB_NAME, jdbcURL.getVDBName());
-
- // Need to resolve the URL fully, if we are using the default URL like
- // jdbc:metamatrix:<vdbName>.., where as this fully qualifies to
- // jdbc:metamatrix:<vdbName>@classpath:<vdbName>/mm.properties;...
- String connectionURL = jdbcURL.getConnectionURL();
- if (connectionURL == null) {
- connectionURL = getDefaultConnectionURL();
- info.setProperty(DQPEmbeddedProperties.VDB_DEFINITION, jdbcURL.getVDBName()+".vdb"); //$NON-NLS-1$
- }
- info.setProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE, connectionURL);
Properties optionalParams = jdbcURL.getProperties();
MMJDBCURL.normalizeProperties(info);
@@ -231,15 +152,6 @@
}
/**
- * Create the default connection URL, if one is not supplied
- * @param jdbcURL
- * @return default connection URL
- */
- static String getDefaultConnectionURL() {
- return "classpath:/deploy.properties"; //$NON-NLS-1$
- }
-
- /**
* validate some required properties
* @param info the connection properties to be validated
* @throws SQLException
@@ -257,226 +169,12 @@
}
public static boolean acceptsURL(String url) {
- Matcher m = urlPattern.matcher(url);
- boolean matched = m.matches();
- if (matched) {
- // make sure the group (2) which is the name of the file
- // does not start with mm:// or mms://
- String name = m.group(3).toLowerCase();
- return (!name.startsWith("mm://") && !name.startsWith("mms://") && (name.endsWith(".properties")||name.endsWith(".properties;"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
// Check if this can match our default one, then allow it.
- m = basePattern.matcher(url);
- matched = m.matches();
+ Matcher m = basePattern.matcher(url);
+ boolean matched = m.matches();
return matched;
}
-
-
- /**
- * Shutdown the DQP instance which has been started using the given URL
- * @param dqpURL
- */
- public static synchronized void shutdown() {
- if (currentTransport != null) {
- currentTransport.shutdown();
- currentTransport = null;
- }
- }
-
- /**
- * inner class to hold DQP tansportMap object
- * @since 4.3
- */
- static class EmbeddedTransport {
- private ServerConnectionFactory connectionFactory;
- private ClassLoader classLoader;
- private URL url;
-
- public EmbeddedTransport(URL dqpURL) throws SQLException {
- this.url = dqpURL;
-
- //Load the properties from dqp.properties file
- Properties props = loadDQPProperties(dqpURL);
-
- props = PropertiesUtils.resolveNestedProperties(props);
-
- // a non-delegating class loader will be created from where all third party dependent jars can be loaded
- ArrayList<URL> runtimeClasspathList = new ArrayList<URL>();
- String libLocation = props.getProperty(DQPEmbeddedProperties.DQP_LIBDIR, "./lib/"); //$NON-NLS-1$
- if (!libLocation.endsWith("/")) { //$NON-NLS-1$
- libLocation = libLocation + "/"; //$NON-NLS-1$
- }
-
- // find jars in the "lib" directory; patches is reverse alpaha and not case sensitive so small letters then capitals
- if (!EmbeddedProfile.getDefaultConnectionURL().equals(dqpURL.toString())) {
- runtimeClasspathList.addAll(libClassPath(dqpURL, libLocation+"patches/", MMURLConnection.REVERSEALPHA)); //$NON-NLS-1$
- runtimeClasspathList.addAll(libClassPath(dqpURL, libLocation, MMURLConnection.DATE));
-
- try {
- String configLocation = props.getProperty(DQPEmbeddedProperties.DQP_DEPLOYDIR, "./deploy/"); //$NON-NLS-1$
- if (!configLocation.endsWith("/")) { //$NON-NLS-1$
- configLocation = configLocation + "/"; //$NON-NLS-1$
- }
- runtimeClasspathList.add(URLHelper.buildURL(dqpURL, configLocation));
- } catch(IOException e) {
- // ignore..
- }
- }
-
- URL[] dqpClassPath = runtimeClasspathList.toArray(new URL[runtimeClasspathList.size()]);
- this.classLoader = new PostDelegatingClassLoader(dqpClassPath, this.getClass().getClassLoader(), new MetaMatrixURLStreamHandlerFactory());
-
- String logMsg = getResourceMessage("EmbeddedDriver.use_classpath"); //$NON-NLS-1$
- logger.log(Level.FINER, logMsg + " " + Arrays.toString(dqpClassPath)); //$NON-NLS-1$
-
- props.setProperty(DQPEmbeddedProperties.BOOTURL, url.toExternalForm());
- props.setProperty(DQPEmbeddedProperties.TEIID_HOME, getHomeDirectory(props));
- // Now using this class loader create the connection factory to the dqp.
- ClassLoader current = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(this.classLoader);
- String className = "com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl"; //$NON-NLS-1$
- try {
- this.connectionFactory = (ServerConnectionFactory)ReflectionHelper.create(className, null, this.classLoader);
- } catch (MetaMatrixCoreException e) {
- throw MMSQLException.create(e, "Could not load the embedded server, please ensure that your classpath is set correctly."); //$NON-NLS-1$
- }
- try {
- this.connectionFactory.initialize(props);
- } catch (MetaMatrixCoreException e) {
- throw MMSQLException.create(e);
- }
- } finally {
- Thread.currentThread().setContextClassLoader(current);
- }
- }
-
- URL getURL() {
- return this.url;
- }
-
- /**
- * Note that this only works when embedded loaded with "mmfile" protocol in the URL.
- * @param dqpURL
- * @return
- */
- private List<URL> libClassPath (URL dqpURL, String directory, String sortStyle) {
- ObjectInputStream in = null;
- ArrayList<URL> urlList = new ArrayList<URL>();
- try {
- urlList.add(URLHelper.buildURL(dqpURL, directory));
- dqpURL = URLHelper.buildURL(dqpURL, directory+"?action=list&filter=.jar&sort="+sortStyle); //$NON-NLS-1$
- in = new ObjectInputStream(dqpURL.openStream());
- String[] urls = (String[])in.readObject();
- for (int i = 0; i < urls.length; i++) {
- urlList.add(URLHelper.buildURL(urls[i]));
- }
- } catch(IOException e) {
- //ignore, treat as if lib does not exist
- } catch(ClassNotFoundException e) {
- //ignore, treat as if lib does not exist
- } finally {
- if (in != null) {
- try{in.close();}catch(IOException e) {}
- }
- }
- return urlList;
- }
-
- /**
- * Load DQP Properties from the URL supplied.
- * @param dqpURL - URL to the "dqp.properties" object
- * @return Properties loaded
- * @throws SQLException
- */
- Properties loadDQPProperties(URL dqpURL) throws SQLException {
- InputStream in = null;
- try{
- in = dqpURL.openStream();
- Properties props = new Properties(System.getProperties());
- props.load(in);
-
- String logMsg = getResourceMessage("EmbeddedDriver.use_properties"); //$NON-NLS-1$
- logger.log(Level.FINER, logMsg + props);
- return props;
- }catch(IOException e) {
- String logMsg = getResourceMessage("EmbeddedTransport.invalid_dqpproperties_path", new Object[] {dqpURL}); //$NON-NLS-1$
- throw MMSQLException.create(e, logMsg);
- }finally {
- if (in != null) {
- try{in.close();}catch(IOException e) {}
- }
- }
- }
-
- /**
- * Shutdown the current transport
- */
- void shutdown() {
- this.connectionFactory.shutdown();
- }
-
- boolean isAlive() {
- return this.connectionFactory.isAlive();
- }
-
- /**
- * Create a connection to the DQP defined by this transport object based on
- * properties supplied
- * @param info
- * @return Connection
- */
- MMConnection createConnection(Properties info) throws SQLException {
- ClassLoader current = null;
- try {
- current = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(classLoader);
- try {
- ServerConnection conn = connectionFactory.getConnection(info);
- return new MMConnection(conn, info, url.toExternalForm());
- } catch (CommunicationException e) {
- throw MMSQLException.create(e);
- } catch (ConnectionException e) {
- throw MMSQLException.create(e);
- }
- } finally {
- Thread.currentThread().setContextClassLoader(current);
- }
- }
-
- String getHomeDirectory(Properties props) throws SQLException {
- try {
- String teiidHome = props.getProperty(DQPEmbeddedProperties.TEIID_HOME);
-
- if (teiidHome == null) {
- if (EmbeddedProfile.getDefaultConnectionURL().equals(url.toString())) {
- teiidHome = System.getProperty("user.dir")+"/teiid"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
- URL installDirectory = URLHelper.buildURL(url, "."); //$NON-NLS-1$
- teiidHome = installDirectory.getPath();
- }
- }
- File f = new File(teiidHome);
- return f.getCanonicalPath();
- } catch(IOException e) {
- throw MMSQLException.create(e);
- }
- }
-
- }
- private static final String BUNDLE_NAME = "com.metamatrix.jdbc.basic_i18n"; //$NON-NLS-1$
-
-
- static String getResourceMessage(String key, Object[] args) {
- ResourceBundle messages = ResourceBundle.getBundle(BUNDLE_NAME);
- String messageTemplate = messages.getString(key);
- return MessageFormat.format(messageTemplate, args);
- }
-
-
static String getResourceMessage(String key) {
ResourceBundle messages = ResourceBundle.getBundle(BUNDLE_NAME);
String messageTemplate = messages.getString(key);
Modified: branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -22,21 +22,17 @@
package org.teiid.jdbc;
-import java.net.URL;
import java.sql.Connection;
-import java.sql.SQLException;
import java.util.Properties;
import com.metamatrix.common.api.MMURL;
-import com.metamatrix.common.protocol.URLHelper;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.jdbc.BaseDataSource;
import com.metamatrix.jdbc.JDBCPlugin;
import com.metamatrix.jdbc.MMSQLException;
import com.metamatrix.jdbc.util.MMJDBCURL;
/**
- * The MetaMatrix JDBC DataSource implementation class of {@link javax.sql.DataSource} and
+ * The Teiid JDBC DataSource implementation class of {@link javax.sql.DataSource} and
* {@link javax.sql.XADataSource}.
* <p>
* The {@link javax.sql.DataSource} interface follows the JavaBean design pattern,
@@ -52,10 +48,11 @@
* The following are the properties for this DataSource:
* <table cellspacing="0" cellpadding="0" border="1" width="100%">
* <tr><td><b>Property Name</b></td><td><b>Type</b></td><td><b>Description</b></td></tr>
- * <tr><td>portNumber </td><td><code>int </code></td><td>The port number where a MetaMatrix Server is listening
+ * <tr><td>portNumber </td><td><code>int </code></td><td>The port number where a Teiid Server is listening
* for requests.</td></tr>
- * <tr><td>serverName </td><td><code>String</code></td><td>The hostname or IP address of the MetaMatrix Server.</td></tr>
- * <table>
+ * <tr><td>serverName </td><td><code>String</code></td><td>The hostname or IP address of the Teiid Server.</td></tr>
+ * <table>
+ * If "serverName" property is not set then data source will try to create a embedded connection to the Teiid server.
* </p>
*/
public class TeiidDataSource extends BaseDataSource {
@@ -96,8 +93,6 @@
private String discoveryStrategy;
- private String bootstrapFile;
-
/**
* Constructor for MMDataSource.
*/
@@ -217,10 +212,9 @@
final TeiidDriver driver = new TeiidDriver();
// check if this is embedded connection
- if (getEmbeddedBootstrapFile() != null) {
- validateEmbeddedProperties(userName,password);
+ if (getServerName() == null) {
final Properties props = buildEmbeddedProperties(userName, password);
- String url = new MMJDBCURL(getDatabaseName(), getEmbeddedBootstrapFile(), props).getJDBCURL();
+ String url = new MMJDBCURL(getDatabaseName(), null, props).getJDBCURL();
return driver.connect(url, props);
}
@@ -233,20 +227,7 @@
private Properties buildEmbeddedProperties(final String userName, final String password) {
Properties props = buildProperties(userName, password);
-
- if (this.getEmbeddedBootstrapFile().equals(EmbeddedProfile.getDefaultConnectionURL())) {
- props.put(DQPEmbeddedProperties.VDB_DEFINITION, getDatabaseName() + ".vdb"); //$NON-NLS-1$
- }
- props.put(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE, this.bootstrapFile);
return props;
- }
-
- private void validateEmbeddedProperties(final String userName, final String password) throws java.sql.SQLException {
- super.validateProperties(userName, password);
- String reason = reasonWhyInvalidConfigFile(this.bootstrapFile);
- if (reason != null) {
- throw new SQLException(reason);
- }
}
/**
@@ -495,46 +476,5 @@
public void setDiscoveryStrategy(String discoveryStrategy) {
this.discoveryStrategy = discoveryStrategy;
}
-
- /**
- * Returns the path and file name from which embedded DQP configuration information will be read.
- *
- * @return the name of the config file for this data source; may be null
- */
- public String getEmbeddedBootstrapFile() {
- return bootstrapFile;
- }
-
- /**
- * Sets file name from which embedded DQP configuration information * will be read.
- *
- * @param configFile
- * The name of the config file name to set
- */
- public void setEmbeddedBootstrapFile(final String configFile) {
- this.bootstrapFile = configFile;
- }
-
- /**
- * Return the reason why the supplied config file may be invalid, or null if it is considered valid.
- *
- * @param configFile
- * a possible value for the property
- * @return the reason why the property is invalid, or null if it is considered valid
- * @see #setEmbeddedBootstrapFile(String)
- */
- public static String reasonWhyInvalidConfigFile(final String configFile) {
- if(configFile == null) {
- return getResourceMessage("EmbeddedDataSource.The_configFile_property_is_null"); //$NON-NLS-1$
- }
-
- try {
- URL url = URLHelper.buildURL(configFile);
- url.openStream();
- } catch (Exception e) {
- return getResourceMessage("EmbeddedDataSource.The_configFile_does_not_exist_or_cant_be_read"); //$NON-NLS-1$
- }
- return null;
- }
}
Modified: branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -242,13 +242,8 @@
} catch (Exception e) {
}
+
try {
- new MMJDBCURL("myVDB", null, null); //$NON-NLS-1$
- fail("Should have failed."); //$NON-NLS-1$
- } catch (Exception e) {
-
- }
- try {
new MMJDBCURL("myVDB", " ", null); //$NON-NLS-1$ //$NON-NLS-2$
fail("Should have failed."); //$NON-NLS-1$
} catch (Exception e) {
Modified: branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -45,112 +45,81 @@
* // (\\w:[\\\\,\\/]|file:\\/\\/|\\/|\\\\|(\\.){1,2}){1}
*/
@Test public void testAcceptsURL() {
-// // Windows Path
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
- // Alternative windows path
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
-
- // Abosolute path (Unix or windows)
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
-
- // relative path
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
-
- // File URL should be supported (not sure)
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@file:///c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@testdata/dqp/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
-
// ClassPath based URL
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@classpath:/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT@classpath:/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
// These are specific to the MMorg.teiid.jdbc.EmbeddedProfile and should not be suported
- assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@mm://host:7001;version=1")); //$NON-NLS-1$
- assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@mms://host:7001;version=1")); //$NON-NLS-1$
- //assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@http://host:7001;version=1"));
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT@mm://host:7001;version=1")); //$NON-NLS-1$
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT@mms://host:7001;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT")); //$NON-NLS-1$
- assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT!/path/foo.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT;")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT;version=1;logFile=foo.txt")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT")); //$NON-NLS-1$
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT!/path/foo.properties")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT;")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT;version=1;logFile=foo.txt")); //$NON-NLS-1$
}
@Test public void testParseURL() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertEquals("c:\\metamatrix\\dqp\\dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
- assertEquals(3, p.size());
+ assertEquals(2, p.size());
}
@Test public void testParseURL2() throws SQLException {
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@\\metamatrix\\dqp\\dqp.properties;version=3", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;version=3", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertEquals("\\metamatrix\\dqp\\dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("3")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VERSION).equals("3")); //$NON-NLS-1$
- assertEquals(5, p.size());
+ assertEquals(4, p.size());
}
@Test public void testParseURL3() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=4;autoCommitTxn=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT@/metamatrix/dqp/dqp.properties;version=4;autoCommitTxn=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("YES")); //$NON-NLS-1$
- assertEquals(7, p.size());
+ assertEquals(6, p.size());
}
@Test public void testParseURL4() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@testdata/dqp/dqp.properties;partialResultsMode=true", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;partialResultsMode=true", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertEquals("testdata/dqp/dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true")); //$NON-NLS-1$
- assertEquals(4, p.size());
+ assertEquals(3, p.size());
}
@Test public void testParseURL5() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
}
@Test public void testParseURL55() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT;", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
}
@Test public void testParseURL6() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT;partialResultsMode=true;version=1", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;partialResultsMode=true;version=1", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("1")); //$NON-NLS-1$
- assertTrue(p.getProperty("vdb.definition").equals("BQT.vdb")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(7, p.size());
+ assertEquals(5, p.size());
}
@Test public void test() throws Exception {
try {
Class.forName("org.teiid.jdbc.TeiidDriver"); //$NON-NLS-1$
- DriverManager.getConnection("jdbc:metamatrix:Parts@invalidConfig.properties;version=1"); //$NON-NLS-1$
+ DriverManager.getConnection("jdbc:teiid:Parts@invalidConfig.properties;version=1"); //$NON-NLS-1$
fail();
} catch (SQLException e) {
}
Modified: branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -24,6 +24,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import java.sql.DriverPropertyInfo;
@@ -35,19 +36,19 @@
@Test public void testGetPropertyInfo1() throws Exception {
DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:teiid:vdb@mm://localhost:12345", null); //$NON-NLS-1$
- assertEquals(18, info.length);
+ assertEquals(17, info.length);
}
@Test public void testAccepts() throws Exception {
assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:12345")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:teiid:vdb")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
+ assertFalse(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:12345")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:12345")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb")); //$NON-NLS-1$
+ assertFalse(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
}
Modified: branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
--- branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -111,6 +111,7 @@
@Test public void testSessions() throws Exception{
Collection<Session> sessions = admin.getSessions();
+ System.out.println(sessions);
assertTrue(sessions.size() >= 1);
for (Session s: sessions) {
assertEquals("ramesh@teiid-security", s.getUserName());
Deleted: branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -1,283 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.jdbc;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Date;
-import java.util.Properties;
-
-import javax.resource.ResourceException;
-import javax.resource.spi.ConnectionManager;
-
-import org.teiid.ConnectionInfo;
-import org.teiid.ContainerHelper;
-import org.teiid.ContainerUtil;
-import org.teiid.TeiidManagedConnectionFactory;
-import org.teiid.TeiidResourceAdapter;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.impl.BaseAdmin;
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DQPManagementView;
-import org.teiid.dqp.internal.transaction.ContainerTransactionProvider;
-import org.teiid.dqp.internal.transaction.TransactionServerImpl;
-import org.teiid.dqp.internal.transaction.XidFactory;
-import org.teiid.transport.AdminAuthorizationInterceptor;
-import org.teiid.transport.LogonImpl;
-import org.teiid.transport.SocketListenerStats;
-import org.teiid.transport.SocketTransport;
-
-import com.metamatrix.admin.objects.MMProcess;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.comm.ClientServiceRegistry;
-import com.metamatrix.common.comm.ClientServiceRegistryImpl;
-import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
-import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.common.comm.exception.ConnectionException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.NetUtils;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.dqp.client.ClientSideDQP;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.platform.security.api.ILogon;
-import com.metamatrix.platform.security.api.service.SessionService;
-
-
-/**
- * A factory class which creates the connections to the embedded DQP instance.
- * This is also responsible for initializing the DQP if the DQP instance is not
- * already alive.
- */
-public class EmbeddedConnectionFactoryImpl implements ServerConnectionFactory {
- private DQPCore dqp;
-
- private TeiidResourceAdapter ra;
- private TeiidManagedConnectionFactory mcf;
- private ConnectionManager cxManager;
- private Properties bootProperties;
- private SocketTransport socketTransport;
- private long starttime = -1L;
- private InetAddress address;
-
- public EmbeddedConnectionFactoryImpl(TeiidResourceAdapter ra, TeiidManagedConnectionFactory mcf, ConnectionManager cxmanager) {
- this.ra = ra;
- this.mcf = mcf;
- this.cxManager = cxmanager;
- LogManager.setLogConfiguration(new LogConfigurationProvider().get());
- LogManager.setLogListener(new LogListernerProvider().get());
- }
-
- @Override
- public ServerConnection getConnection(Properties connectionProperties) throws CommunicationException, ConnectionException {
- // unfortunately we can only offer the managed connections for the Embedded, for socket connections those requests come
- // directly to this class and will not be managed
- try {
- return (ServerConnection)cxManager.allocateConnection(this.mcf, new ConnectionInfo(connectionProperties, createClientServices(), this.dqp.getSessionService()));
- } catch (ResourceException e) {
- throw new ConnectionException(e);
- }
- }
-
- /**
- * When the DQP is restarted using the admin API, it only shuts it down, it gets
- * restarted when the next time connection is made, however this factory may be
- * holding on to a previous transport handler, so we need to check if the DQP is
- * still alive and create a new one if necessary.
- * @param props
- * @throws ApplicationInitializationException
- * @since 4.3
- */
- public void initialize(Properties props) throws MetaMatrixCoreException {
- this.bootProperties = props;
- this.address = resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
-
- // Since the loading of the engine connection factory and all required services can not tied to load
- // in a dependent manner, provide a proxy until such time.
- ClientServiceRegistry clientServices = (ClientServiceRegistry)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {ClientServiceRegistry.class}, new InvocationHandler() {
- ClientServiceRegistry clientServices = null;
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- if (clientServices == null) {
- clientServices = createClientServices();
- }
- return method.invoke(clientServices, args);
- }
- });
-
- // start socket transport
- boolean enableSocketTransport = PropertiesUtils.getBooleanProperty(this.bootProperties, DQPEmbeddedProperties.ENABLE_SOCKETS, false);
- if (enableSocketTransport) {
- this.socketTransport = new SocketTransport(this.bootProperties, clientServices, this.ra.getWorkManager(), this.address);
- this.socketTransport.start();
- }
-
- this.starttime = System.currentTimeMillis();
- DQPEmbeddedPlugin.logInfo("DQPEmbeddedManager.start_dqp", new Object[] {new Date(System.currentTimeMillis()).toString()}); //$NON-NLS-1$
-
- }
-
- private TransactionService getTransactionService(String processName) {
- TransactionServerImpl txnService = new TransactionServerImpl();
- txnService.setTransactionProvider(new ContainerTransactionProvider(this.ra.getXATerminator()));
- txnService.setProcessName(processName);
- txnService.setXidFactory(new XidFactory());
- return (TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, txnService, new Class[] {TransactionService.class}, MessageLevel.DETAIL);
- }
-
- public synchronized boolean isAlive() {
- return (dqp != null);
- }
-
- public synchronized DQPCore getDQP() {
- if (!isAlive()) {
- throw new MetaMatrixRuntimeException(JDBCPlugin.Util.getString("LocalTransportHandler.Transport_shutdown")); //$NON-NLS-1$
- }
- return this.dqp;
- }
-
- public void shutdown() {
- // shutdown the socket transport.
- if (this.socketTransport != null) {
- this.socketTransport.stop();
- this.socketTransport = null;
- }
- }
-
- /**
- * ConnectionFactory and DQPCore lifecycles can be tied together, however by the time a user
- * logs in all the services will be up. So, send a proxy if this service starts first then during
- * the connection fe
- * @param clusterName
- * @return
- */
- private ClientServiceRegistry createClientServices() {
- // start the DQP
- String processName = bootProperties.getProperty(DQPEmbeddedProperties.PROCESSNAME, "embedded"); //$NON-NLS-1$
- String clusterName = this.bootProperties.getProperty(DQPEmbeddedProperties.CLUSTERNAME, "teiid-cluster"); //$NON-NLS-1$
- ContainerHelper helper = ContainerUtil.lookup("teiid/container-helper");
-
- DQPManagementView holder = helper.getService(DQPManagementView.class);
- this.dqp = new DQPCore();
- this.dqp.setTransactionService(getTransactionService(processName));
- this.dqp.setWorkManager(this.ra.getWorkManager());
- this.dqp.setAuthorizationService(helper.getService(AuthorizationService.class));
- this.dqp.setBufferService(helper.getService(BufferService.class));
- this.dqp.setSessionService(helper.getService(SessionService.class));
- this.dqp.setConnectorManagerRepository(helper.getService(ConnectorManagerRepository.class));
- this.dqp.start(bootProperties);
- holder.setDQP(this.dqp);
-
- ClientServiceRegistry services = new ClientServiceRegistryImpl();
- services.registerClientService(ILogon.class, new LogonImpl(this.dqp.getSessionService(), this.dqp, clusterName), com.metamatrix.common.util.LogConstants.CTX_SERVER);
-
- Admin roleCheckedServerAdmin = wrapAdminService(Admin.class, getAdminAPI(), this.dqp.getAuthorizationService());
- services.registerClientService(Admin.class, roleCheckedServerAdmin, com.metamatrix.common.util.LogConstants.CTX_ADMIN);
-
- services.registerClientService(ClientSideDQP.class, this.dqp, LogConstants.CTX_QUERY_SERVICE);
-
- return services;
- }
-
- private Admin getAdminAPI() {
- Admin admin = ContainerUtil.lookup("teiid/admin");
- if (admin instanceof BaseAdmin) {
- ((BaseAdmin) admin).setManager(this);
- }
- return admin;
- }
-
- @SuppressWarnings("unchecked")
- private <T> T wrapAdminService(Class<T> iface, T impl, AuthorizationService authService) {
- return (T)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {iface}, new AdminAuthorizationInterceptor(authService, impl));
- }
-
- private InetAddress resolveHostAddress(String bindAddress) {
- try {
- if (bindAddress == null) {
- return NetUtils.getInstance().getInetAddress();
- }
- return NetUtils.resolveHostByName(bindAddress);
- } catch (UnknownHostException e) {
- throw new MetaMatrixRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
- }
- }
-
- public InetAddress getAddress() {
- return address;
- }
-
- public long getStartTime() {
- return this.starttime;
- }
-
- public MMProcess getProcess() {
-
- Properties props = this.bootProperties;
-
- String hostName = getAddress().getHostName();
- String processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
-
- String[] identifierParts = new String[] {hostName, processName};
- MMProcess process = new MMProcess(identifierParts);
-
- Runtime rt = Runtime.getRuntime();
-
- process.setEnabled(true);
- process.setCreated(new Date(getStartTime()));
- process.setInetAddress(getAddress());
- process.setFreeMemory(rt.freeMemory());
- process.setTotalMemory(rt.totalMemory());
- process.setProperties(PropertiesUtils.clone(props));
- process.setStartTime(new Date(this.starttime));
-
- if (this.socketTransport != null) {
- SocketListenerStats socketStats = this.socketTransport.getStats();
- if (socketStats != null) {
- process.setSockets(socketStats.sockets);
- process.setMaxSockets(socketStats.maxSockets);
- process.setObjectsRead(socketStats.objectsRead);
- process.setObjectsWritten(socketStats.objectsWritten);
- }
-
- WorkerPoolStatisticsMetadata workerStats = this.socketTransport.getProcessPoolStats();
- process.setQueueWorkerPool(workerStats);
-
- process.setPort(this.socketTransport.getPort());
- }
- return process;
- }
-}
Modified: branches/JCA/runtime/src/main/java/org/teiid/Server.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/Server.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/Server.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -36,9 +36,8 @@
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-public class Server extends EmbeddedConnectionFactoryImpl implements ServerMBean {
+public class Server extends TeiidConnectionFactory implements ServerMBean {
private Properties props;
Copied: branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java (from rev 1721, branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java)
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -0,0 +1,282 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Date;
+import java.util.Properties;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.impl.BaseAdmin;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.internal.process.DQPManagementView;
+import org.teiid.dqp.internal.transaction.ContainerTransactionProvider;
+import org.teiid.dqp.internal.transaction.TransactionServerImpl;
+import org.teiid.dqp.internal.transaction.XidFactory;
+import org.teiid.transport.AdminAuthorizationInterceptor;
+import org.teiid.transport.LogonImpl;
+import org.teiid.transport.SocketListenerStats;
+import org.teiid.transport.SocketTransport;
+
+import com.metamatrix.admin.objects.MMProcess;
+import com.metamatrix.common.application.exception.ApplicationInitializationException;
+import com.metamatrix.common.comm.ClientServiceRegistry;
+import com.metamatrix.common.comm.ClientServiceRegistryImpl;
+import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.api.ServerConnectionFactory;
+import com.metamatrix.common.comm.exception.CommunicationException;
+import com.metamatrix.common.comm.exception.ConnectionException;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.NetUtils;
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
+import com.metamatrix.dqp.service.AuthorizationService;
+import com.metamatrix.dqp.service.BufferService;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.jdbc.JDBCPlugin;
+import com.metamatrix.jdbc.LogConfigurationProvider;
+import com.metamatrix.jdbc.LogListernerProvider;
+import com.metamatrix.platform.security.api.ILogon;
+import com.metamatrix.platform.security.api.service.SessionService;
+
+
+/**
+ * A factory class which creates the connections to the embedded DQP instance.
+ * This is also responsible for initializing the DQP if the DQP instance is not
+ * already alive.
+ */
+public class TeiidConnectionFactory implements ServerConnectionFactory {
+ private DQPCore dqp;
+
+ private TeiidResourceAdapter ra;
+ private TeiidManagedConnectionFactory mcf;
+ private ConnectionManager cxManager;
+ private Properties bootProperties;
+ private SocketTransport socketTransport;
+ private long starttime = -1L;
+ private InetAddress address;
+ ClientServiceRegistry clientServices = null;
+
+
+ public TeiidConnectionFactory(TeiidResourceAdapter ra, TeiidManagedConnectionFactory mcf, ConnectionManager cxmanager) {
+ this.ra = ra;
+ this.mcf = mcf;
+ this.cxManager = cxmanager;
+ LogManager.setLogConfiguration(new LogConfigurationProvider().get());
+ LogManager.setLogListener(new LogListernerProvider().get());
+ }
+
+ @Override
+ public ServerConnection getConnection(Properties connectionProperties) throws CommunicationException, ConnectionException {
+ // unfortunately we can only offer the managed connections for the Embedded, for socket connections those requests come
+ // directly to this class and will not be managed
+ try {
+ if (clientServices == null) {
+ clientServices = createClientServices();
+ }
+ return (ServerConnection)cxManager.allocateConnection(this.mcf, new ConnectionInfo(connectionProperties, clientServices, this.dqp.getSessionService()));
+ } catch (ResourceException e) {
+ throw new ConnectionException(e);
+ }
+ }
+
+ /**
+ * When the DQP is restarted using the admin API, it only shuts it down, it gets
+ * restarted when the next time connection is made, however this factory may be
+ * holding on to a previous transport handler, so we need to check if the DQP is
+ * still alive and create a new one if necessary.
+ * @param props
+ * @throws ApplicationInitializationException
+ * @since 4.3
+ */
+ public void initialize(Properties props) {
+ this.bootProperties = props;
+ this.address = resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
+
+ // Since the loading of the engine connection factory and all required services can not tied to load
+ // in a dependent manner, provide a proxy until such time.
+ ClientServiceRegistry clientServicesProxy = (ClientServiceRegistry)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {ClientServiceRegistry.class}, new InvocationHandler() {
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (clientServices == null) {
+ clientServices = createClientServices();
+ }
+ return method.invoke(clientServices, args);
+ }
+ });
+
+ // start socket transport
+ boolean enableSocketTransport = PropertiesUtils.getBooleanProperty(this.bootProperties, DQPEmbeddedProperties.ENABLE_SOCKETS, false);
+ if (enableSocketTransport) {
+ this.socketTransport = new SocketTransport(this.bootProperties, clientServicesProxy, this.ra.getWorkManager(), this.address);
+ this.socketTransport.start();
+ }
+
+ this.starttime = System.currentTimeMillis();
+ DQPEmbeddedPlugin.logInfo("DQPEmbeddedManager.start_dqp", new Object[] {new Date(System.currentTimeMillis()).toString()}); //$NON-NLS-1$
+
+ }
+
+ private TransactionService getTransactionService(String processName) {
+ TransactionServerImpl txnService = new TransactionServerImpl();
+ txnService.setTransactionProvider(new ContainerTransactionProvider(this.ra.getXATerminator()));
+ txnService.setProcessName(processName);
+ txnService.setXidFactory(new XidFactory());
+ return (TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, txnService, new Class[] {TransactionService.class}, MessageLevel.DETAIL);
+ }
+
+ public synchronized boolean isAlive() {
+ return (dqp != null);
+ }
+
+ public synchronized DQPCore getDQP() {
+ if (!isAlive()) {
+ throw new MetaMatrixRuntimeException(JDBCPlugin.Util.getString("LocalTransportHandler.Transport_shutdown")); //$NON-NLS-1$
+ }
+ return this.dqp;
+ }
+
+ public void shutdown() {
+ // shutdown the socket transport.
+ if (this.socketTransport != null) {
+ this.socketTransport.stop();
+ this.socketTransport = null;
+ }
+ }
+
+ /**
+ * ConnectionFactory and DQPCore lifecycles need to be tied together, but when this class starts
+ * all services may not be up, however by the time a user logs in for a connection all the services will be up.
+ * So, send a proxy of this service first and replace with actual one later.
+ */
+ private ClientServiceRegistry createClientServices() {
+ // start the DQP
+ String processName = bootProperties.getProperty(DQPEmbeddedProperties.PROCESSNAME, "embedded"); //$NON-NLS-1$
+ String clusterName = this.bootProperties.getProperty(DQPEmbeddedProperties.CLUSTERNAME, "teiid-cluster"); //$NON-NLS-1$
+ ContainerHelper helper = ContainerUtil.lookup("teiid/container-helper");
+
+ DQPManagementView holder = helper.getService(DQPManagementView.class);
+ this.dqp = new DQPCore();
+ this.dqp.setTransactionService(getTransactionService(processName));
+ this.dqp.setWorkManager(this.ra.getWorkManager());
+ this.dqp.setAuthorizationService(helper.getService(AuthorizationService.class));
+ this.dqp.setBufferService(helper.getService(BufferService.class));
+ this.dqp.setSessionService(helper.getService(SessionService.class));
+ this.dqp.setConnectorManagerRepository(helper.getService(ConnectorManagerRepository.class));
+ this.dqp.start(bootProperties);
+ holder.setDQP(this.dqp);
+
+ ClientServiceRegistry services = new ClientServiceRegistryImpl();
+ services.registerClientService(ILogon.class, new LogonImpl(this.dqp.getSessionService(), clusterName), com.metamatrix.common.util.LogConstants.CTX_SERVER);
+
+ Admin roleCheckedServerAdmin = wrapAdminService(Admin.class, getAdminAPI(), this.dqp.getAuthorizationService());
+ services.registerClientService(Admin.class, roleCheckedServerAdmin, com.metamatrix.common.util.LogConstants.CTX_ADMIN);
+
+ services.registerClientService(ClientSideDQP.class, this.dqp, LogConstants.CTX_QUERY_SERVICE);
+
+ return services;
+ }
+
+ private Admin getAdminAPI() {
+ Admin admin = ContainerUtil.lookup("teiid/admin");
+ if (admin instanceof BaseAdmin) {
+ ((BaseAdmin) admin).setManager(this);
+ }
+ return admin;
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> T wrapAdminService(Class<T> iface, T impl, AuthorizationService authService) {
+ return (T)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {iface}, new AdminAuthorizationInterceptor(authService, impl));
+ }
+
+ private InetAddress resolveHostAddress(String bindAddress) {
+ try {
+ if (bindAddress == null) {
+ return NetUtils.getInstance().getInetAddress();
+ }
+ return NetUtils.resolveHostByName(bindAddress);
+ } catch (UnknownHostException e) {
+ throw new MetaMatrixRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
+ }
+ }
+
+ public InetAddress getAddress() {
+ return address;
+ }
+
+ public long getStartTime() {
+ return this.starttime;
+ }
+
+ public MMProcess getProcess() {
+
+ Properties props = this.bootProperties;
+
+ String hostName = getAddress().getHostName();
+ String processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
+
+ String[] identifierParts = new String[] {hostName, processName};
+ MMProcess process = new MMProcess(identifierParts);
+
+ Runtime rt = Runtime.getRuntime();
+
+ process.setEnabled(true);
+ process.setCreated(new Date(getStartTime()));
+ process.setInetAddress(getAddress());
+ process.setFreeMemory(rt.freeMemory());
+ process.setTotalMemory(rt.totalMemory());
+ process.setProperties(PropertiesUtils.clone(props));
+ process.setStartTime(new Date(this.starttime));
+
+ if (this.socketTransport != null) {
+ SocketListenerStats socketStats = this.socketTransport.getStats();
+ if (socketStats != null) {
+ process.setSockets(socketStats.sockets);
+ process.setMaxSockets(socketStats.maxSockets);
+ process.setObjectsRead(socketStats.objectsRead);
+ process.setObjectsWritten(socketStats.objectsWritten);
+ }
+
+ WorkerPoolStatisticsMetadata workerStats = this.socketTransport.getProcessPoolStats();
+ process.setQueueWorkerPool(workerStats);
+
+ process.setPort(this.socketTransport.getPort());
+ }
+ return process;
+ }
+}
Modified: branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -37,7 +37,6 @@
import javax.transaction.xa.XAResource;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.basic.WrappedConnection;
import org.teiid.transport.LocalServerConnection;
import com.metamatrix.common.comm.exception.CommunicationException;
@@ -46,7 +45,7 @@
public class TeiidManagedConnection implements ManagedConnection {
protected final Collection<ConnectionEventListener> listeners = new ArrayList<ConnectionEventListener>();
private PrintWriter log;
- private WrappedTeiidConnection conn;
+ private WrappedConnection conn;
public TeiidManagedConnection() {
@@ -57,25 +56,30 @@
if (!(handle instanceof WrappedConnection)) {
throw new ConnectorException("Wrong connection supplied to assosiate");
}
- conn = (WrappedTeiidConnection)handle;
+ conn = (WrappedConnection)handle;
conn.setManagedConnection(this);
}
@Override
public void cleanup() throws ResourceException {
+ if (this.conn != null) {
+ this.conn.close();
+ this.conn = null;
+ }
}
@Override
public void destroy() throws ResourceException {
+ cleanup();
}
@Override
public Object getConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
ConnectionInfo ci = (ConnectionInfo)arg1;
try {
- this.conn = new WrappedTeiidConnection(new LocalServerConnection(ci.properties, ci.clientServices, ci.sessionService));
+ this.conn = new WrappedConnection(new LocalServerConnection(ci.properties, ci.clientServices, ci.sessionService));
this.conn.setManagedConnection(this);
- return this;
+ return this.conn;
} catch (CommunicationException e) {
throw new ResourceException(e);
} catch (ConnectionException e) {
@@ -130,12 +134,6 @@
* remove the managed connection from the pool
*/
void connectionClosed() {
- synchronized (listeners) {
- for (ConnectionEventListener ce: listeners) {
- ce.connectionClosed(new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED));
- }
- }
-
ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
ce.setConnectionHandle(this.conn);
Modified: branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -40,16 +40,14 @@
import javax.security.auth.Subject;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
public class TeiidManagedConnectionFactory implements ManagedConnectionFactory,ResourceAdapterAssociation {
- TeiidResourceAdapter ra;
- PrintWriter log;
- String deployPropertiesFile;
- EmbeddedConnectionFactoryImpl connFactory;
- String teiidHome;
+ private TeiidResourceAdapter ra;
+ private PrintWriter log;
+ private String deployPropertiesFile;
+ private TeiidConnectionFactory connFactory;
+ private String teiidHome;
@Override
public Object createConnectionFactory() throws ResourceException {
@@ -59,13 +57,11 @@
@Override
public Object createConnectionFactory(ConnectionManager arg0) throws ResourceException {
try {
- connFactory = new EmbeddedConnectionFactoryImpl(this.ra, this, arg0);
+ connFactory = new TeiidConnectionFactory(this.ra, this, arg0);
connFactory.initialize(getDeployProperties());
return connFactory;
- } catch (MetaMatrixCoreException e) {
+ } catch (IOException e) {
throw new ResourceException(e);
- } catch (IOException e) {
- throw new ResourceException(e);
}
}
Copied: branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java (from rev 1684, branches/JCA/runtime/src/main/java/org/teiid/WrappedTeiidConnection.java)
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid;
+
+import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.exception.CommunicationException;
+import com.metamatrix.platform.security.api.LogonResult;
+
+public class WrappedConnection implements ServerConnection {
+
+ private ServerConnection delegate;
+ private TeiidManagedConnection mc;
+ private boolean closed = false;
+
+ public WrappedConnection(ServerConnection conn) {
+ this.delegate = conn;
+ }
+
+ @Override
+ public LogonResult getLogonResult() {
+ return delegate.getLogonResult();
+ }
+
+ @Override
+ public <T> T getService(Class<T> iface) {
+ return delegate.getService(iface);
+ }
+
+ @Override
+ public boolean isOpen() {
+ return delegate.isOpen();
+ }
+
+ @Override
+ public boolean isSameInstance(ServerConnection conn)
+ throws CommunicationException {
+ return delegate.isSameInstance(conn);
+ }
+
+ @Override
+ public void close() {
+ if (!this.closed && this.mc != null) {
+ this.closed = true;
+ this.mc.connectionClosed();
+ this.mc = null;
+ }
+ }
+
+ void setManagedConnection(TeiidManagedConnection teiidManagedConnection) {
+ this.mc = teiidManagedConnection;
+ }
+
+ @Override
+ public void reallyClose() {
+ close();
+ if (this.delegate != null) {
+ delegate.close();
+ delegate = null;
+ }
+ }
+}
Property changes on: branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: branches/JCA/runtime/src/main/java/org/teiid/WrappedTeiidConnection.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/WrappedTeiidConnection.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/WrappedTeiidConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid;
-
-import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.platform.security.api.LogonResult;
-
-public class WrappedTeiidConnection implements ServerConnection {
-
- ServerConnection delegate;
- TeiidManagedConnection mc;
- boolean closed = false;
-
- public WrappedTeiidConnection(ServerConnection conn) {
- this.delegate = conn;
- }
-
- @Override
- public LogonResult getLogonResult() {
- return delegate.getLogonResult();
- }
-
- @Override
- public <T> T getService(Class<T> iface) {
- return delegate.getService(iface);
- }
-
- @Override
- public boolean isOpen() {
- return delegate.isOpen();
- }
-
- @Override
- public boolean isSameInstance(ServerConnection conn)
- throws CommunicationException {
- return delegate.isSameInstance(conn);
- }
-
- @Override
- public void close() {
- if (!this.closed && this.mc != null) {
- this.closed = true;
- delegate.close();
- this.mc.connectionClosed();
- this.mc = null;
- }
- }
-
- void setManagedConnection(TeiidManagedConnection teiidManagedConnection) {
- this.mc = teiidManagedConnection;
- }
-}
Modified: branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -24,16 +24,16 @@
import java.util.ArrayList;
import java.util.Collection;
+import org.teiid.TeiidConnectionFactory;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.ProcessObject;
import org.teiid.adminapi.TeiidAdmin;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
public abstract class BaseAdmin extends TeiidAdmin {
- private EmbeddedConnectionFactoryImpl manager;
+ private TeiidConnectionFactory manager;
- public void setManager(EmbeddedConnectionFactoryImpl manager) {
+ public void setManager(TeiidConnectionFactory manager) {
this.manager = manager;
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -53,7 +53,6 @@
private final LogonResult result;
private boolean shutdown;
private DQPWorkContext workContext;
- private ClassLoader classLoader;
private ClientServiceRegistry clientServices;
private SessionService sessionService;
private ILogon logon;
@@ -61,10 +60,10 @@
public LocalServerConnection(Properties connectionProperties, ClientServiceRegistry clientServices, SessionService sessionService) throws CommunicationException, ConnectionException{
this.clientServices = clientServices;
this.sessionService = sessionService;
- this.classLoader = Thread.currentThread().getContextClassLoader();
+ this.workContext = new DQPWorkContext();
+ DQPWorkContext.setWorkContext(this.workContext);
this.logon = this.getService(ILogon.class);
this.result = authenticate(connectionProperties);
- this.workContext = DQPWorkContext.getWorkContext();
}
public synchronized LogonResult authenticate(Properties connProps) throws ConnectionException, CommunicationException {
@@ -97,11 +96,9 @@
Throwable exception = null;
ClassLoader current = Thread.currentThread().getContextClassLoader();
try {
- Thread.currentThread().setContextClassLoader(classLoader);
DQPWorkContext.setWorkContext(workContext);
-
if (!(iface.equals(ILogon.class))) {
- sessionService.validateSession(workContext.getSessionId());
+ sessionService.validateSession(result.getSessionID());
}
return arg1.invoke(clientServices.getClientService(iface), arg2);
} catch (InvocationTargetException e) {
@@ -122,6 +119,11 @@
}
public void close() {
+ // no-op managed connection close
+ }
+
+ @Override
+ public void reallyClose() {
shutdown(true);
}
@@ -147,6 +149,7 @@
//ignore
}
}
+ this.workContext = null;
this.shutdown = true;
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -40,7 +40,6 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.CoreConstants;
-import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.platform.security.api.Credentials;
import com.metamatrix.platform.security.api.ILogon;
@@ -52,12 +51,10 @@
private SessionService service;
private String clusterName;
- private ClientSideDQP dqpService;
- public LogonImpl(SessionService service, ClientSideDQP dqp, String clusterName) {
+ public LogonImpl(SessionService service, String clusterName) {
this.service = service;
this.clusterName = clusterName;
- this.dqpService = dqp;
}
public LogonResult logon(Properties connProps) throws LogonException,
Modified: branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -72,7 +72,7 @@
@Test public void testFailedConnect() throws Exception {
ClientServiceRegistry csr = new ClientServiceRegistryImpl();
SessionService sessionService = mock(SessionService.class);
- csr.registerClientService(ILogon.class, new LogonImpl(sessionService, null, "fakeCluster"), "foo"); //$NON-NLS-1$ //$NON-NLS-2$
+ csr.registerClientService(ILogon.class, new LogonImpl(sessionService, "fakeCluster"), "foo"); //$NON-NLS-1$ //$NON-NLS-2$
listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(),
csr, 1024, 1024, 1, null, true, new FakeWorkManager());
@@ -143,7 +143,7 @@
if (listener == null) {
SessionService sessionService = mock(SessionService.class);
ClientServiceRegistry csr = new ClientServiceRegistryImpl();
- csr.registerClientService(ILogon.class, new LogonImpl(sessionService, null, "fakeCluster") { //$NON-NLS-1$
+ csr.registerClientService(ILogon.class, new LogonImpl(sessionService, "fakeCluster") { //$NON-NLS-1$
@Override
public LogonResult logon(Properties connProps)
throws LogonException, ComponentNotFoundException {
Modified: branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -55,7 +55,7 @@
Mockito.stub(ssi.createSession(userName, null, applicationName,p)).toReturn(session);
- LogonImpl impl = new LogonImpl(ssi, null, "fakeCluster"); //$NON-NLS-1$
+ LogonImpl impl = new LogonImpl(ssi, "fakeCluster"); //$NON-NLS-1$
LogonResult result = impl.logon(p);
assertEquals(userName, result.getUserName());
15 years
teiid SVN: r1730 - in trunk: connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-01-12 13:22:29 -0500 (Tue, 12 Jan 2010)
New Revision: 1730
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/h2/TestH2Translator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleConvertModifier.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseConvertModifier.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestEscapeSyntaxModifier.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestExtractFunctionModifier.java
trunk/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
Log:
TEIID-923 fix for Oracle exception with multiple escape sequences.
Modified: trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -716,19 +716,19 @@
if(Number.class.isAssignableFrom(type)) {
buffer.append(val);
} else if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
- buffer.append("{b'") //$NON-NLS-1$
+ buffer.append("{b '") //$NON-NLS-1$
.append(val)
.append("'}"); //$NON-NLS-1$
} else if(type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
- buffer.append("{ts'") //$NON-NLS-1$
+ buffer.append("{ts '") //$NON-NLS-1$
.append(val)
.append("'}"); //$NON-NLS-1$
} else if(type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
- buffer.append("{t'") //$NON-NLS-1$
+ buffer.append("{t '") //$NON-NLS-1$
.append(val)
.append("'}"); //$NON-NLS-1$
} else if(type.equals(DataTypeManager.DefaultDataClasses.DATE)) {
- buffer.append("{d'") //$NON-NLS-1$
+ buffer.append("{d '") //$NON-NLS-1$
.append(val)
.append("'}"); //$NON-NLS-1$
} else {
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -283,18 +283,18 @@
/**
* Subclasses should override this method to provide a different sql translation
* of the literal date value. By default, a date literal is represented as:
- * <code>{d'2002-12-31'}</code>
+ * <code>{d '2002-12-31'}</code>
* @param dateValue Date value, never null
* @return Translated string
*/
public String translateLiteralDate(java.sql.Date dateValue) {
- return "{d'" + formatDateValue(dateValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "{d '" + formatDateValue(dateValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Subclasses should override this method to provide a different sql translation
* of the literal time value. By default, a time literal is represented as:
- * <code>{t'23:59:59'}</code>
+ * <code>{t '23:59:59'}</code>
*
* See {@link Translator#hasTimeType()} to represent literal times as timestamps.
*
@@ -303,15 +303,15 @@
*/
public String translateLiteralTime(Time timeValue) {
if (!hasTimeType()) {
- return "{ts'1970-01-01 " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "{ts '1970-01-01 " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
}
- return "{t'" + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "{t '" + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Subclasses should override this method to provide a different sql translation
* of the literal timestamp value. By default, a timestamp literal is
- * represented as: <code>{ts'2002-12-31 23:59:59'}</code>.
+ * represented as: <code>{ts '2002-12-31 23:59:59'}</code>.
*
* See {@link Translator#getTimestampNanoPrecision()} to control the literal
* precision.
@@ -320,7 +320,7 @@
* @return Translated string
*/
public String translateLiteralTimestamp(Timestamp timestampValue) {
- return "{ts'" + formatDateValue(timestampValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "{ts '" + formatDateValue(timestampValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
}
/**
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -478,38 +478,38 @@
// Source = DATE
public void testDateToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "string", "char({d'2003-11-01'})"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "string", "char({d '2003-11-01'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testDateToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "timestamp({d'2003-11-01'}, '00:00:00')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "timestamp({d '2003-11-01'}, '00:00:00')"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Source = TIME
public void testTimeToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "char({t'23:59:59'})"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "char({t '23:59:59'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testTimeToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "timestamp('1970-01-01', {t'23:59:59'})"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "timestamp('1970-01-01', {t '23:59:59'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Source = TIMESTAMP
public void testTimestampToString() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "char({ts'2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "char({ts '2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testTimestampToDate() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "date({ts'2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "date({ts '2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testTimestampToTime() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "time({ts'2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "time({ts '2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/h2/TestH2Translator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/h2/TestH2Translator.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/h2/TestH2Translator.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -42,7 +42,7 @@
}
@Test public void testTimestampDiff() throws Exception {
- String input = "select timestampdiff(SQL_TSI_FRAC_SECOND, timestampvalue, {d'1970-01-01'}) from BQT1.Smalla"; //$NON-NLS-1$
+ String input = "select timestampdiff(SQL_TSI_FRAC_SECOND, timestampvalue, {d '1970-01-01'}) from BQT1.Smalla"; //$NON-NLS-1$
String output = "SELECT datediff('MILLISECOND', SmallA.TimestampValue, TIMESTAMP '1970-01-01 00:00:00.0') * 1000000 FROM SmallA"; //$NON-NLS-1$
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
@@ -56,7 +56,7 @@
}
@Test public void testTimestampAdd1() throws Exception {
- String input = "select timestampadd(SQL_TSI_HOUR, intnum, {t'00:00:00'}) from BQT1.Smalla"; //$NON-NLS-1$
+ String input = "select timestampadd(SQL_TSI_HOUR, intnum, {t '00:00:00'}) from BQT1.Smalla"; //$NON-NLS-1$
String output = "SELECT cast(dateadd('HOUR', SmallA.IntNum, TIMESTAMP '1970-01-01 00:00:00.0') AS time) FROM SmallA"; //$NON-NLS-1$
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -68,24 +68,24 @@
public void test1() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
helpTestMod(arg1, SourceSystemFunctions.DAYOFYEAR,
- "to_number(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'DDD'))"); //$NON-NLS-1$
+ "to_number(TO_CHAR({ts '2004-01-21 10:05:00.0'}, 'DDD'))"); //$NON-NLS-1$
}
public void test2() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
helpTestMod(arg1, SourceSystemFunctions.DAYOFYEAR,
- "to_number(TO_CHAR({d'2004-01-21'}, 'DDD'))"); //$NON-NLS-1$
+ "to_number(TO_CHAR({d '2004-01-21'}, 'DDD'))"); //$NON-NLS-1$
}
public void test9() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
helpTestMod(arg1, SourceSystemFunctions.QUARTER,
- "to_number(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'Q'))"); //$NON-NLS-1$
+ "to_number(TO_CHAR({ts '2004-01-21 10:05:00.0'}, 'Q'))"); //$NON-NLS-1$
}
public void test10() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
helpTestMod(arg1, SourceSystemFunctions.QUARTER,
- "to_number(TO_CHAR({d'2004-01-21'}, 'Q'))"); //$NON-NLS-1$
+ "to_number(TO_CHAR({d '2004-01-21'}, 'Q'))"); //$NON-NLS-1$
}
}
\ No newline at end of file
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -67,24 +67,24 @@
public void test1() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
helpTestMod(arg1, "Month", //$NON-NLS-1$
- "rtrim(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'Month'))"); //$NON-NLS-1$
+ "rtrim(TO_CHAR({ts '2004-01-21 10:05:00.0'}, 'Month'))"); //$NON-NLS-1$
}
public void test2() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
helpTestMod(arg1, "Month", //$NON-NLS-1$
- "rtrim(TO_CHAR({d'2004-01-21'}, 'Month'))"); //$NON-NLS-1$
+ "rtrim(TO_CHAR({d '2004-01-21'}, 'Month'))"); //$NON-NLS-1$
}
public void test3() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
helpTestMod(arg1, "Day", //$NON-NLS-1$
- "rtrim(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'Day'))"); //$NON-NLS-1$
+ "rtrim(TO_CHAR({ts '2004-01-21 10:05:00.0'}, 'Day'))"); //$NON-NLS-1$
}
public void test4() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
helpTestMod(arg1, "Day", //$NON-NLS-1$
- "rtrim(TO_CHAR({d'2004-01-21'}, 'Day'))"); //$NON-NLS-1$
+ "rtrim(TO_CHAR({d '2004-01-21'}, 'Day'))"); //$NON-NLS-1$
}
}
\ No newline at end of file
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleConvertModifier.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleConvertModifier.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -480,38 +480,38 @@
// Source = DATE
@Test public void testDateToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "string", "to_char({d'2003-11-01'}, 'YYYY-MM-DD')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "string", "to_char({d '2003-11-01'}, 'YYYY-MM-DD')"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDateToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "cast({d'2003-11-01'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "cast({d '2003-11-01'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Source = TIME
@Test public void testTimeToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "to_char({ts'1970-01-01 23:59:59'}, 'HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "to_char({ts '1970-01-01 23:59:59'}, 'HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testTimeToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "cast({ts'1970-01-01 23:59:59'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "cast({ts '1970-01-01 23:59:59'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Source = TIMESTAMP
@Test public void testTimestampToString() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "to_char({ts'2003-11-01 12:05:02.0'}, 'YYYY-MM-DD HH24:MI:SS.FF')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "to_char({ts '2003-11-01 12:05:02.0'}, 'YYYY-MM-DD HH24:MI:SS.FF')"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testTimestampToDate() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "trunc(cast({ts'2003-11-01 12:05:02.0'} AS date))"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "trunc(cast({ts '2003-11-01 12:05:02.0'} AS date))"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testTimestampToTime() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "case when {ts'2003-11-01 12:05:02.0'} is null then null else to_date('1970-01-01 ' || to_char({ts'2003-11-01 12:05:02.0'}, 'HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') end"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "case when {ts '2003-11-01 12:05:02.0'} is null then null else to_date('1970-01-01 ' || to_char({ts '2003-11-01 12:05:02.0'}, 'HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') end"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -116,23 +116,23 @@
@Test public void testDateLiteral() throws Exception {
helpTestVisitor(getTestVDB(),
- "select {d'2002-12-31'} FROM parts", //$NON-NLS-1$
+ "select {d '2002-12-31'} FROM parts", //$NON-NLS-1$
null,
- "SELECT {d'2002-12-31'} FROM PARTS"); //$NON-NLS-1$
+ "SELECT {d '2002-12-31'} FROM PARTS"); //$NON-NLS-1$
}
@Test public void testTimeLiteral() throws Exception {
helpTestVisitor(getTestVDB(),
- "select {t'13:59:59'} FROM parts", //$NON-NLS-1$
+ "select {t '13:59:59'} FROM parts", //$NON-NLS-1$
null,
- "SELECT {ts'1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
+ "SELECT {ts '1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
}
@Test public void testTimestampLiteral() throws Exception {
helpTestVisitor(getTestVDB(),
- "select {ts'2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
+ "select {ts '2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
null,
- "SELECT {ts'2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
+ "SELECT {ts '2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
}
@Test public void testUnionOrderByWithThreeBranches() throws Exception {
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseConvertModifier.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseConvertModifier.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -108,7 +108,7 @@
LANG_FACTORY.createLiteral("date", String.class)}, //$NON-NLS-1$
java.sql.Date.class);
- helpGetString1(func, "cast(stuff(stuff(convert(varchar, {ts'1989-03-03 07:08:12.0'}, 102), 5, 1, '-'), 8, 1, '-') AS datetime)"); //$NON-NLS-1$
+ helpGetString1(func, "cast(stuff(stuff(convert(varchar, {ts '1989-03-03 07:08:12.0'}, 102), 5, 1, '-'), 8, 1, '-') AS datetime)"); //$NON-NLS-1$
}
/********************END of cast(date AS INPUT) ******************/
@@ -132,7 +132,7 @@
LANG_FACTORY.createLiteral("time", String.class)}, //$NON-NLS-1$
java.sql.Time.class);
- helpGetString1(func, "cast('1970-01-01 ' + convert(varchar, {ts'1989-03-03 07:08:12.0'}, 8) AS datetime)"); //$NON-NLS-1$
+ helpGetString1(func, "cast('1970-01-01 ' + convert(varchar, {ts '1989-03-03 07:08:12.0'}, 8) AS datetime)"); //$NON-NLS-1$
}
/********************END of cast(time AS INPUT) ******************/
@@ -155,7 +155,7 @@
LANG_FACTORY.createLiteral("timestamp", String.class)}, //$NON-NLS-1$
java.sql.Timestamp.class);
- helpGetString1(func, "{ts'1970-01-01 12:02:03'}"); //$NON-NLS-1$
+ helpGetString1(func, "{ts '1970-01-01 12:02:03'}"); //$NON-NLS-1$
}
@Test public void testDateToTimestamp() throws Exception {
@@ -165,7 +165,7 @@
LANG_FACTORY.createLiteral("timestamp", String.class)}, //$NON-NLS-1$
java.sql.Timestamp.class);
- helpGetString1(func, "{d'1989-03-03'}"); //$NON-NLS-1$
+ helpGetString1(func, "{d '1989-03-03'}"); //$NON-NLS-1$
}
/********************END of cast(timestamp AS INPUT) ******************/
@@ -188,7 +188,7 @@
LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
String.class);
- helpGetString1(func, "stuff(convert(varchar, {ts'2003-11-01 12:05:02.0'}, 123), 11, 1, ' ')"); //$NON-NLS-1$
+ helpGetString1(func, "stuff(convert(varchar, {ts '2003-11-01 12:05:02.0'}, 123), 11, 1, ' ')"); //$NON-NLS-1$
}
@Test public void testDateToString() throws Exception {
@@ -199,7 +199,7 @@
LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
String.class);
- helpGetString1(func, "stuff(stuff(convert(varchar, {d'2003-11-01'}, 102), 5, 1, '-'), 8, 1, '-')"); //$NON-NLS-1$
+ helpGetString1(func, "stuff(stuff(convert(varchar, {d '2003-11-01'}, 102), 5, 1, '-'), 8, 1, '-')"); //$NON-NLS-1$
}
@Test public void testTimeToString() throws Exception {
@@ -210,7 +210,7 @@
LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
String.class);
- helpGetString1(func, "convert(varchar, {ts'1970-01-01 03:10:01'}, 8)"); //$NON-NLS-1$
+ helpGetString1(func, "convert(varchar, {ts '1970-01-01 03:10:01'}, 8)"); //$NON-NLS-1$
}
@Test public void testBigDecimalToString() throws Exception {
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -180,22 +180,22 @@
@Test
public void testDateLiteral() {
helpTestVisitor(getTestVDB(),
- "select {d'2002-12-31'} FROM parts", //$NON-NLS-1$
- "SELECT {d'2002-12-31'} FROM PARTS"); //$NON-NLS-1$
+ "select {d '2002-12-31'} FROM parts", //$NON-NLS-1$
+ "SELECT {d '2002-12-31'} FROM PARTS"); //$NON-NLS-1$
}
@Test
public void testTimeLiteral() {
helpTestVisitor(getTestVDB(),
- "select {t'13:59:59'} FROM parts", //$NON-NLS-1$
- "SELECT {ts'1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
+ "select {t '13:59:59'} FROM parts", //$NON-NLS-1$
+ "SELECT {ts '1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
}
@Test
public void testTimestampLiteral() {
helpTestVisitor(getTestVDB(),
- "select {ts'2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
- "SELECT {ts'2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
+ "select {ts '2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
+ "SELECT {ts '2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
}
@Test
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestEscapeSyntaxModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestEscapeSyntaxModifier.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestEscapeSyntaxModifier.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -62,7 +62,7 @@
ILiteral arg3 = CommandBuilder.getLanuageFactory().createLiteral(TimestampUtil.createTimestamp(0, 0, 0, 0, 0, 0, 0), Timestamp.class);
IFunction func = CommandBuilder.getLanuageFactory().createFunction("timestampadd", Arrays.asList( arg1, arg2, arg3), Timestamp.class); //$NON-NLS-1$
- helpTest(func, "{fn timestampadd(SQL_TSI_HOUR, 1, {ts'1899-12-31 00:00:00.0'})}");
+ helpTest(func, "{fn timestampadd(SQL_TSI_HOUR, 1, {ts '1899-12-31 00:00:00.0'})}");
}
private void helpTest(IFunction func, String expected) {
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestExtractFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestExtractFunctionModifier.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestExtractFunctionModifier.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -72,32 +72,32 @@
}
public void test1() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
- helpTestMod(arg1, "EXTRACT(MONTH FROM {d'2004-01-21'})" , "month"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(MONTH FROM {d '2004-01-21'})" , "month"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test2() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 17, 5, 0, 0), Timestamp.class);
- helpTestMod(arg1, "EXTRACT(MONTH FROM {ts'2004-01-21 17:05:00.0'})", "month"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(MONTH FROM {ts '2004-01-21 17:05:00.0'})", "month"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test3() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
- helpTestMod(arg1, "EXTRACT(YEAR FROM {d'2004-01-21'})", "year"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(YEAR FROM {d '2004-01-21'})", "year"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test4() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 17, 5, 0, 0), Timestamp.class);
- helpTestMod(arg1, "EXTRACT(YEAR FROM {ts'2004-01-21 17:05:00.0'})", "year"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(YEAR FROM {ts '2004-01-21 17:05:00.0'})", "year"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test5() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
- helpTestMod(arg1, "EXTRACT(DAY FROM {d'2004-01-21'})", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(DAY FROM {d '2004-01-21'})", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test6() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 17, 5, 0, 0), Timestamp.class);
- helpTestMod(arg1, "EXTRACT(DAY FROM {ts'2004-01-21 17:05:00.0'})", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(DAY FROM {ts '2004-01-21 17:05:00.0'})", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test11() throws Exception {
Modified: trunk/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
===================================================================
--- trunk/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -173,14 +173,14 @@
public void testLiteralDate() {
helpTestVisitor(getTestVDB(),
- "select {d'2003-12-31'} from parts", //$NON-NLS-1$
- "SELECT {d'2003-12-31'} FROM PARTS"); //$NON-NLS-1$
+ "select {d '2003-12-31'} from parts", //$NON-NLS-1$
+ "SELECT {d '2003-12-31'} FROM PARTS"); //$NON-NLS-1$
}
public void testLiteralTime() {
helpTestVisitor(getTestVDB(),
- "select {t'23:59:59'} from parts", //$NON-NLS-1$
- "SELECT {t'23:59:59'} FROM PARTS"); //$NON-NLS-1$
+ "select {t '23:59:59'} from parts", //$NON-NLS-1$
+ "SELECT {t '23:59:59'} FROM PARTS"); //$NON-NLS-1$
}
public void testLiteralNull() {
@@ -191,8 +191,8 @@
public void testLiteralTimestamp() {
helpTestVisitor(getTestVDB(),
- "select {ts'2003-12-31 23:59:59.123'} from parts", //$NON-NLS-1$
- "SELECT {ts'2003-12-31 23:59:59.123'} FROM PARTS"); //$NON-NLS-1$
+ "select {ts '2003-12-31 23:59:59.123'} from parts", //$NON-NLS-1$
+ "SELECT {ts '2003-12-31 23:59:59.123'} FROM PARTS"); //$NON-NLS-1$
}
public void testSQL89Join() {
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2010-01-11 19:00:14 UTC (rev 1729)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2010-01-12 18:22:29 UTC (rev 1730)
@@ -312,17 +312,17 @@
assertEquals(expected, getString(TestLiteralImpl.example("string'Literal"))); //$NON-NLS-1$
expected = "1000"; //$NON-NLS-1$
assertEquals(expected, getString(TestLiteralImpl.example(new Integer(1000))));
- expected = "{b'true'}"; //$NON-NLS-1$
+ expected = "{b 'true'}"; //$NON-NLS-1$
assertEquals(expected, getString(TestLiteralImpl.example(Boolean.TRUE)));
long now = System.currentTimeMillis();
Date date = new Date(now);
- expected = "{d'" + date.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ expected = "{d '" + date.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(expected, getString(TestLiteralImpl.example(date)));
Timestamp ts = new Timestamp(now);
- expected = "{ts'" + ts.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ expected = "{ts '" + ts.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(expected, getString(TestLiteralImpl.example(ts)));
Time t = new Time(now);
- expected = "{t'" + t.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ expected = "{t '" + t.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(expected, getString(TestLiteralImpl.example(t)));
}
15 years