teiid SVN: r1220 - in trunk/common-core/src: test/java/com/metamatrix/common/util and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-08-06 22:36:41 -0400 (Thu, 06 Aug 2009)
New Revision: 1220
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java
Log:
TEIID-743 fixing bean setting logic to use all properties including defaults
Modified: trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2009-08-07 02:33:46 UTC (rev 1219)
+++ trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2009-08-07 02:36:41 UTC (rev 1220)
@@ -997,15 +997,11 @@
private static Properties lowerCaseAllPropNames(final Properties connectionProps) {
final Properties lcProps = new Properties();
- final Iterator itr = connectionProps.keySet().iterator();
- while ( itr.hasNext() ) {
- final String name = (String) itr.next();
- Object propValue = connectionProps.get(name);
- if (propValue instanceof String) {
- // we're only interested in prop values of type String
- // here since we'll be looking for params to reflected methods
- lcProps.setProperty(name.toLowerCase(), (String)propValue);
- } // if
+ final Enumeration<?> itr = connectionProps.propertyNames();
+ while ( itr.hasMoreElements() ) {
+ final String name = (String) itr.nextElement();
+ String propValue = connectionProps.getProperty(name);
+ lcProps.setProperty(name.toLowerCase(), propValue);
}
return lcProps;
}
Modified: trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java 2009-08-07 02:33:46 UTC (rev 1219)
+++ trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java 2009-08-07 02:36:41 UTC (rev 1220)
@@ -722,6 +722,8 @@
p.setProperty("prop2", "2"); //$NON-NLS-1$ //$NON-NLS-2$
p.setProperty("prop3", "3"); //$NON-NLS-1$ //$NON-NLS-2$
+ p = new Properties(p);
+
PropertiesUtils.setBeanProperties(bean, p, null);
assertEquals(0, bean.getProp());
16 years, 8 months
teiid SVN: r1219 - in trunk/engine/src: main/java/com/metamatrix/query/validator and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-08-06 22:33:46 -0400 (Thu, 06 Aug 2009)
New Revision: 1219
Removed:
trunk/engine/src/main/java/com/metamatrix/query/validator/ValueValidationVisitor.java
Modified:
trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java
trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
Log:
TEIID-496 removing valuevalidationvisitor and instead adding constraints to references
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java 2009-08-06 20:11:11 UTC (rev 1218)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java 2009-08-07 02:33:46 UTC (rev 1219)
@@ -22,6 +22,7 @@
package com.metamatrix.query.sql.symbol;
+import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.metadata.TempMetadataID;
import com.metamatrix.query.sql.LanguageVisitor;
@@ -34,13 +35,19 @@
*/
public class Reference implements Expression, ContextReference {
+ public interface Constraint {
+ public void validate(Object value) throws QueryValidatorException;
+ }
+
private boolean positional;
private int refIndex;
private Class<?> type;
private ElementSymbol expression;
-
+
+ private Constraint constraint;
+
/**
* Constructor for a positional Reference.
*/
@@ -49,6 +56,14 @@
this.positional = true;
}
+ public Constraint getConstraint() {
+ return constraint;
+ }
+
+ public void setConstraint(Constraint constraint) {
+ this.constraint = constraint;
+ }
+
/**
* Constructor for an element Reference.
*/
@@ -64,6 +79,7 @@
if (ref.expression != null) {
this.expression = (ElementSymbol)ref.expression.clone();
}
+ this.constraint = ref.constraint;
}
public boolean isResolved() {
Modified: trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2009-08-06 20:11:11 UTC (rev 1218)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2009-08-07 02:33:46 UTC (rev 1219)
@@ -35,6 +35,7 @@
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.eval.Evaluator;
@@ -58,6 +59,7 @@
import com.metamatrix.query.sql.lang.Insert;
import com.metamatrix.query.sql.lang.Into;
import com.metamatrix.query.sql.lang.IsNullCriteria;
+import com.metamatrix.query.sql.lang.Limit;
import com.metamatrix.query.sql.lang.MatchCriteria;
import com.metamatrix.query.sql.lang.NotCriteria;
import com.metamatrix.query.sql.lang.Option;
@@ -90,6 +92,7 @@
import com.metamatrix.query.sql.symbol.ExpressionSymbol;
import com.metamatrix.query.sql.symbol.Function;
import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
@@ -104,7 +107,24 @@
public class ValidationVisitor extends AbstractValidationVisitor {
- // State during validation
+ private final class PositiveIntegerConstraint implements
+ Reference.Constraint {
+
+ private String msgKey;
+
+ public PositiveIntegerConstraint(String msgKey) {
+ this.msgKey = msgKey;
+ }
+
+ @Override
+ public void validate(Object value) throws QueryValidatorException {
+ if (((Integer)value).intValue() < 0) {
+ throw new QueryValidatorException(QueryPlugin.Util.getString(msgKey)); //$NON-NLS-1$
+ }
+ }
+ }
+
+ // State during validation
private boolean isXML = false; // only used for Query commands
// update procedure being validated
@@ -1033,6 +1053,78 @@
if (isNonComparable(obj.getLeftExpression())) {
handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0027, obj),obj);
}
+
+ // Validate use of 'rowlimit' and 'rowlimitexception' pseudo-functions - they cannot be nested within another
+ // function, and their operands must be a nonnegative integers
+
+ // Collect all occurrances of rowlimit function
+ List rowLimitFunctions = new ArrayList();
+ FunctionCollectorVisitor visitor = new FunctionCollectorVisitor(rowLimitFunctions, FunctionLibrary.ROWLIMIT);
+ PreOrderNavigator.doVisit(obj, visitor);
+ visitor = new FunctionCollectorVisitor(rowLimitFunctions, FunctionLibrary.ROWLIMITEXCEPTION);
+ PreOrderNavigator.doVisit(obj, visitor);
+ final int functionCount = rowLimitFunctions.size();
+ if (functionCount > 0) {
+ Function function = null;
+ Expression expr = null;
+ if (obj.getLeftExpression() instanceof Function) {
+ Function leftExpr = (Function)obj.getLeftExpression();
+ if (leftExpr.getFunctionDescriptor().getName().equalsIgnoreCase(FunctionLibrary.ROWLIMIT) ||
+ leftExpr.getFunctionDescriptor().getName().equalsIgnoreCase(FunctionLibrary.ROWLIMITEXCEPTION)) {
+ function = leftExpr;
+ expr = obj.getRightExpression();
+ }
+ }
+ if (function == null && obj.getRightExpression() instanceof Function) {
+ Function rightExpr = (Function)obj.getRightExpression();
+ if (rightExpr.getFunctionDescriptor().getName().equalsIgnoreCase(FunctionLibrary.ROWLIMIT) ||
+ rightExpr.getFunctionDescriptor().getName().equalsIgnoreCase(FunctionLibrary.ROWLIMITEXCEPTION)) {
+ function = rightExpr;
+ expr = obj.getLeftExpression();
+ }
+ }
+ if (function == null) {
+ // must be nested, which is invalid
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.0"), obj); //$NON-NLS-1$
+ } else {
+ if (expr instanceof Constant) {
+ Constant constant = (Constant)expr;
+ if (constant.getValue() instanceof Integer) {
+ Integer integer = (Integer)constant.getValue();
+ if (integer.intValue() < 0) {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.1"), obj); //$NON-NLS-1$
+ }
+ } else {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.1"), obj); //$NON-NLS-1$
+ }
+ } else if (expr instanceof Reference) {
+ ((Reference)expr).setConstraint(new PositiveIntegerConstraint("ValidationVisitor.1")); //$NON-NLS-1$
+ } else {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.1"), obj); //$NON-NLS-1$
+ }
+ }
+ }
}
+
+ public void visit(Limit obj) {
+ Expression offsetExpr = obj.getOffset();
+ if (offsetExpr instanceof Constant) {
+ Integer offset = (Integer)((Constant)offsetExpr).getValue();
+ if (offset.intValue() < 0) {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.badoffset2"), obj); //$NON-NLS-1$
+ }
+ } else if (offsetExpr instanceof Reference) {
+ ((Reference)offsetExpr).setConstraint(new PositiveIntegerConstraint("ValidationVisitor.badoffset2")); //$NON-NLS-1$
+ }
+ Expression limitExpr = obj.getRowLimit();
+ if (limitExpr instanceof Constant) {
+ Integer limit = (Integer)((Constant)limitExpr).getValue();
+ if (limit.intValue() < 0) {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.badlimit2"), obj); //$NON-NLS-1$
+ }
+ } else if (limitExpr instanceof Reference) {
+ ((Reference)limitExpr).setConstraint(new PositiveIntegerConstraint("ValidationVisitor.badlimit2")); //$NON-NLS-1$
+ }
+ }
}
Deleted: trunk/engine/src/main/java/com/metamatrix/query/validator/ValueValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValueValidationVisitor.java 2009-08-06 20:11:11 UTC (rev 1218)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/ValueValidationVisitor.java 2009-08-07 02:33:46 UTC (rev 1219)
@@ -1,122 +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.query.validator;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.visitor.FunctionCollectorVisitor;
-
-public class ValueValidationVisitor extends AbstractValidationVisitor {
-
- public void visit(CompareCriteria obj) {
- // Validate use of 'rowlimit' and 'rowlimitexception' pseudo-functions - they cannot be nested within another
- // function, and their operands must be a nonnegative integers
-
- // Collect all occurrances of rowlimit function
- List rowLimitFunctions = new ArrayList();
- FunctionCollectorVisitor visitor = new FunctionCollectorVisitor(rowLimitFunctions, FunctionLibrary.ROWLIMIT);
- PreOrderNavigator.doVisit(obj, visitor);
- visitor = new FunctionCollectorVisitor(rowLimitFunctions, FunctionLibrary.ROWLIMITEXCEPTION);
- PreOrderNavigator.doVisit(obj, visitor);
- final int functionCount = rowLimitFunctions.size();
- if (functionCount > 0) {
- Function function = null;
- Expression expr = null;
- if (obj.getLeftExpression() instanceof Function) {
- Function leftExpr = (Function)obj.getLeftExpression();
- if (leftExpr.getFunctionDescriptor().getName().equalsIgnoreCase(FunctionLibrary.ROWLIMIT) ||
- leftExpr.getFunctionDescriptor().getName().equalsIgnoreCase(FunctionLibrary.ROWLIMITEXCEPTION)) {
- function = leftExpr;
- expr = obj.getRightExpression();
- }
- }
- if (function == null && obj.getRightExpression() instanceof Function) {
- Function rightExpr = (Function)obj.getRightExpression();
- if (rightExpr.getFunctionDescriptor().getName().equalsIgnoreCase(FunctionLibrary.ROWLIMIT) ||
- rightExpr.getFunctionDescriptor().getName().equalsIgnoreCase(FunctionLibrary.ROWLIMITEXCEPTION)) {
- function = rightExpr;
- expr = obj.getLeftExpression();
- }
- }
- if (function == null) {
- // must be nested, which is invalid
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.0"), obj); //$NON-NLS-1$
- } else {
- if (expr instanceof Reference) {
- expr = ((Reference)expr).getExpression();
- }
- if (expr instanceof Constant) {
- Constant constant = (Constant)expr;
- if (constant.getValue() instanceof Integer) {
- Integer integer = (Integer)constant.getValue();
- if (integer.intValue() < 0) {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.1"), obj); //$NON-NLS-1$
- }
- } else {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.1"), obj); //$NON-NLS-1$
- }
- } else {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.1"), obj); //$NON-NLS-1$
- }
- }
- }
- }
-
- public void visit(Limit obj) {
- Expression offsetExpr = obj.getOffset();
- if (offsetExpr instanceof Reference) {
- offsetExpr = ((Reference)offsetExpr).getExpression();
- }
- if (offsetExpr instanceof Constant) {
- Integer offset = (Integer)((Constant)offsetExpr).getValue();
- if (offset == null) {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.badoffset1"), obj); //$NON-NLS-1$
- } else if (offset.intValue() < 0) {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.badoffset2"), obj); //$NON-NLS-1$
- }
- }
- Expression limitExpr = obj.getRowLimit();
- if (limitExpr instanceof Reference) {
- limitExpr = ((Reference)limitExpr).getExpression();
- }
- if (limitExpr instanceof Constant) {
- Integer limit = (Integer)((Constant)limitExpr).getValue();
- if (limit == null) {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.badlimit1"), obj); //$NON-NLS-1$
- } else if (limit.intValue() < 0) {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.badlimit2"), obj); //$NON-NLS-1$
- }
- }
- }
-
-}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2009-08-06 20:11:11 UTC (rev 1218)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2009-08-07 02:33:46 UTC (rev 1219)
@@ -123,12 +123,6 @@
}
}
- @Override
- protected void validateQueryValues(Command command)
- throws QueryValidatorException, MetaMatrixComponentException {
- //do nothing initially - check after parameter values have been set
- }
-
/**
* @throws MetaMatrixComponentException
* @throws QueryValidatorException
@@ -174,7 +168,7 @@
List<Reference> params = prepPlan.getReferences();
List<?> values = requestMsg.getParameterValues();
- resolveAndValidateParameters(this.userCommand, params, values);
+ PreparedStatementRequest.resolveParameterValues(params, values, this.context);
}
return prepPlan.getRewritenCommand();
}
@@ -213,7 +207,7 @@
List<VariableContext> contexts = new LinkedList<VariableContext>();
List<List<Object>> multiValues = new ArrayList<List<Object>>(this.prepPlan.getReferences().size());
for (List<?> values : paramValues) {
- resolveAndValidateParameters(this.userCommand, this.prepPlan.getReferences(), values);
+ PreparedStatementRequest.resolveParameterValues(this.prepPlan.getReferences(), values, this.context);
contexts.add(this.context.getVariableContext());
if(supportPreparedBatchUpdate){
if (multiValues.isEmpty()) {
@@ -259,22 +253,14 @@
this.processPlan = planner.optimize(ctn, idGenerator, metadata, capabilitiesFinder, analysisRecord, context);
}
- private void resolveAndValidateParameters(Command command, List<Reference> params,
- List<?> values) throws QueryResolverException,
- MetaMatrixComponentException, QueryValidatorException {
- // validate parameters values - right number and right type
- PreparedStatementRequest.resolveParameterValues(params, values, this.context);
- // call back to Request.validateQueryValues to ensure that bound references are valid
- super.validateQueryValues(command);
- }
-
/**
* @param params
* @param values
* @throws QueryResolverException
+ * @throws QueryValidatorException
*/
public static void resolveParameterValues(List<Reference> params,
- List values, CommandContext context) throws QueryResolverException, MetaMatrixComponentException {
+ List values, CommandContext context) throws QueryResolverException, MetaMatrixComponentException, QueryValidatorException {
VariableContext result = new VariableContext();
//the size of the values must be the same as that of the parameters
if (params.size() != values.size()) {
@@ -303,6 +289,9 @@
}
}
+ if (param.getConstraint() != null) {
+ param.getConstraint().validate(value);
+ }
//bind variable
result.setGlobalValue(param.getContextSymbol(), value);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-08-06 20:11:11 UTC (rev 1218)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-08-07 02:33:46 UTC (rev 1219)
@@ -105,7 +105,6 @@
import com.metamatrix.query.validator.Validator;
import com.metamatrix.query.validator.ValidatorFailure;
import com.metamatrix.query.validator.ValidatorReport;
-import com.metamatrix.query.validator.ValueValidationVisitor;
/**
* Server side representation of the RequestMessage. Knows how to process itself.
@@ -326,13 +325,6 @@
}
}
- protected void validateQueryValues(Command command)
- throws QueryValidatorException, MetaMatrixComponentException {
-
- AbstractValidationVisitor visitor = new ValueValidationVisitor();
- validateWithVisitor(visitor, metadata, command, false);
- }
-
private Command parseCommand() throws QueryParserException {
String[] commands = requestMsg.getCommands();
ParseInfo parseInfo = createParseInfo(this.requestMsg);
@@ -471,8 +463,6 @@
validateQuery(command, true);
- validateQueryValues(command);
-
command = QueryRewriter.rewrite(command, null, metadata, context);
/*
@@ -615,8 +605,6 @@
validateQuery(newCommand, isRootXQuery);
- validateQueryValues(newCommand);
-
if (isRootXQuery) {
validateEntitlement(newCommand);
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java 2009-08-06 20:11:11 UTC (rev 1218)
+++ trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java 2009-08-07 02:33:46 UTC (rev 1219)
@@ -354,12 +354,9 @@
try {
ValidatorReport report = Validator.validate(command, metadata);
- ValidatorReport report3 = Validator.validate(command, metadata, new ValueValidationVisitor(), true);
-
// Get invalid objects from report
Collection actualObjs = new ArrayList();
report.collectInvalidObjects(actualObjs);
- report3.collectInvalidObjects(actualObjs);
// Compare expected and actual objects
Set expectedStrings = new HashSet(Arrays.asList(expectedStringArray));
@@ -371,7 +368,7 @@
}
if(expectedStrings.size() == 0 && actualStrings.size() > 0) {
- fail("Expected no failures but got some: " + report.getFailureMessage() + ", " + report3.getFailureMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ fail("Expected no failures but got some: " + report.getFailureMessage()); //$NON-NLS-1$
} else if(actualStrings.size() == 0 && expectedStrings.size() > 0) {
fail("Expected some failures but got none for sql = " + command); //$NON-NLS-1$
} else {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-08-06 20:11:11 UTC (rev 1218)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-08-07 02:33:46 UTC (rev 1219)
@@ -391,5 +391,13 @@
TestProcessor.sampleData2b(dataManager);
helpTestProcessing(preparedSql, values, expected, dataManager, FakeMetadataFactory.example1Cached(), false, false);
}
+
+ @Test(expected=QueryValidatorException.class) public void testLimitValidation() throws Exception {
+ String preparedSql = "select pm1.g1.e1 from pm1.g1 limit ?"; //$NON-NLS-1$
+
+ List values = Arrays.asList(-1);
+ FakeDataManager dataManager = new FakeDataManager();
+ helpTestProcessing(preparedSql, values, null, dataManager, FakeMetadataFactory.example1Cached(), false, false);
+ }
}
16 years, 8 months
teiid SVN: r1218 - in trunk/connectors/connector-jdbc/src: test/java/org/teiid/connector/jdbc/postgresql and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-08-06 16:11:11 -0400 (Thu, 06 Aug 2009)
New Revision: 1218
Added:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLCapabilities.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java
Log:
TEIID-758 adding support for locate to postgresql.
Added: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java 2009-08-06 20:11:11 UTC (rev 1218)
@@ -0,0 +1,58 @@
+/*
+ * 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.connector.jdbc.postgresql;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.connector.api.TypeFacility;
+import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
+import org.teiid.connector.language.IExpression;
+import org.teiid.connector.language.IFunction;
+import org.teiid.connector.language.ILanguageFactory;
+
+public class LocateFunctionModifier extends BasicFunctionModifier {
+
+ private ILanguageFactory factory;
+
+ public LocateFunctionModifier(ILanguageFactory factory) {
+ this.factory = factory;
+ }
+
+ @Override
+ public List<?> translate(IFunction function) {
+ List<Object> parts = new ArrayList<Object>();
+ List<IExpression> params = function.getParameters();
+ parts.add("position("); //$NON-NLS-1$
+ parts.add(params.get(0));
+ parts.add(" in "); //$NON-NLS-1$
+ if (params.size() == 3) {
+ parts.add(factory.createFunction("substr", params.subList(1, 3), TypeFacility.RUNTIME_TYPES.STRING)); //$NON-NLS-1$
+ } else {
+ parts.add(params.get(1));
+ }
+ parts.add(")"); //$NON-NLS-1$
+ return parts;
+ }
+
+}
Property changes on: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLCapabilities.java 2009-08-06 16:47:07 UTC (rev 1217)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLCapabilities.java 2009-08-06 20:11:11 UTC (rev 1218)
@@ -89,8 +89,7 @@
supportedFunctions.add("LCASE"); //$NON-NLS-1$
supportedFunctions.add("LEFT"); //$NON-NLS-1$
supportedFunctions.add("LENGTH"); //$NON-NLS-1$
- // Doesn't support both forms exposed by MM
-// supportedFunctions.add("LOCATE"); //$NON-NLS-1$
+ supportedFunctions.add("LOCATE"); //$NON-NLS-1$
supportedFunctions.add("LOWER"); //$NON-NLS-1$
supportedFunctions.add("LPAD"); //$NON-NLS-1$
supportedFunctions.add("LTRIM"); //$NON-NLS-1$
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java 2009-08-06 16:47:07 UTC (rev 1217)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java 2009-08-06 20:11:11 UTC (rev 1218)
@@ -93,7 +93,9 @@
registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.CONVERT, new PostgreSQLConvertModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, new PostgreSQLConvertModifier(getLanguageFactory()));
+
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
}
@Override
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java 2009-08-06 16:47:07 UTC (rev 1217)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java 2009-08-06 20:11:11 UTC (rev 1218)
@@ -22,40 +22,24 @@
package org.teiid.connector.jdbc.postgresql;
-import java.util.Map;
import java.util.Properties;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.jdbc.MetadataFactory;
-import org.teiid.connector.jdbc.postgresql.PostgreSQLTranslator;
-import org.teiid.connector.jdbc.translator.TranslatedCommand;
-import org.teiid.connector.language.ICommand;
-import junit.framework.TestCase;
-
import com.metamatrix.cdk.api.EnvironmentUtility;
-/**
- */
-public class TestPostgreSQLTranslator extends TestCase {
+public class TestPostgreSQLTranslator {
- private static Map MODIFIERS;
private static PostgreSQLTranslator TRANSLATOR;
-
- static {
- try {
- TRANSLATOR = new PostgreSQLTranslator();
- TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
- MODIFIERS = TRANSLATOR.getFunctionModifiers();
- } catch(ConnectorException e) {
- e.printStackTrace();
- }
- }
-
- public TestPostgreSQLTranslator(String name) {
- super(name);
- }
-
+
+ @BeforeClass public static void setupOnce() throws Exception {
+ TRANSLATOR = new PostgreSQLTranslator();
+ TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
+ }
+
public String getTestVDB() {
return MetadataFactory.PARTS_VDB;
}
@@ -64,401 +48,359 @@
return MetadataFactory.BQT_VDB;
}
- public void helpTestVisitor(String vdb, String input, Map modifiers, String expectedOutput) throws ConnectorException {
- // Convert from sql to objects
- ICommand obj = MetadataFactory.helpTranslate(vdb, input);
-
- TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), TRANSLATOR);
- tc.translateCommand(obj);
-
-
- // Check stuff
- assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
+ public void helpTestVisitor(String vdb, String input, String expectedOutput) throws ConnectorException {
+ MetadataFactory.helpTestVisitor(vdb, input, expectedOutput, TRANSLATOR);
}
- public void testRewriteConversion1() throws Exception {
+ @Test public void testRewriteConversion1() throws Exception {
String input = "SELECT char(convert(PART_WEIGHT, integer) + 100) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT chr((cast(PARTS.PART_WEIGHT AS integer) + 100)) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion2() throws Exception {
+ @Test public void testRewriteConversion2() throws Exception {
String input = "SELECT convert(PART_WEIGHT, long) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT cast(PARTS.PART_WEIGHT AS bigint) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion3() throws Exception {
+ @Test public void testRewriteConversion3() throws Exception {
String input = "SELECT convert(PART_WEIGHT, short) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT cast(PARTS.PART_WEIGHT AS smallint) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion4() throws Exception {
+ @Test public void testRewriteConversion4() throws Exception {
String input = "SELECT convert(PART_WEIGHT, float) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT cast(PARTS.PART_WEIGHT AS real) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion5() throws Exception {
+ @Test public void testRewriteConversion5() throws Exception {
String input = "SELECT convert(PART_WEIGHT, double) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT cast(PARTS.PART_WEIGHT AS float8) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion6() throws Exception {
+ @Test public void testRewriteConversion6() throws Exception {
String input = "SELECT convert(PART_WEIGHT, biginteger) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT cast(PARTS.PART_WEIGHT AS numeric) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion7() throws Exception {
+ @Test public void testRewriteConversion7() throws Exception {
String input = "SELECT convert(PART_WEIGHT, bigdecimal) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT cast(PARTS.PART_WEIGHT AS decimal) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion8() throws Exception {
+ @Test public void testRewriteConversion8() throws Exception {
String input = "SELECT convert(PART_WEIGHT, boolean) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT cast(PARTS.PART_WEIGHT AS boolean) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion9() throws Exception {
+ @Test public void testRewriteConversion9() throws Exception {
String input = "SELECT convert(PART_WEIGHT, date) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT to_date(PARTS.PART_WEIGHT, 'YYYY-MM-DD') FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion10() throws Exception {
+ @Test public void testRewriteConversion10() throws Exception {
String input = "SELECT convert(PART_WEIGHT, time) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT to_timestamp(('1970-01-01 ' || PARTS.PART_WEIGHT), 'YYYY-MM-DD HH24:MI:SS') FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion11() throws Exception {
+ @Test public void testRewriteConversion11() throws Exception {
String input = "SELECT convert(PART_WEIGHT, timestamp) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF') FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion12() throws Exception {
+ @Test public void testRewriteConversion12() throws Exception {
String input = "SELECT convert(convert(PART_WEIGHT, time), string) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT to_char(to_timestamp(('1970-01-01 ' || PARTS.PART_WEIGHT), 'YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS') FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion13() throws Exception {
+ @Test public void testRewriteConversion13() throws Exception {
String input = "SELECT convert(convert(PART_WEIGHT, timestamp), string) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT to_char(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF'), 'YYYY-MM-DD HH24:MI:SS.US') FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion14() throws Exception {
+ @Test public void testRewriteConversion14() throws Exception {
String input = "SELECT convert(convert(PART_WEIGHT, date), string) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT to_char(to_date(PARTS.PART_WEIGHT, 'YYYY-MM-DD'), 'YYYY-MM-DD') FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion15() throws Exception {
+ @Test public void testRewriteConversion15() throws Exception {
String input = "SELECT convert(convert(PART_WEIGHT, timestamp), date) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT cast(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF') AS date) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion16() throws Exception {
+ @Test public void testRewriteConversion16() throws Exception {
String input = "SELECT convert(convert(PART_WEIGHT, timestamp), time) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT cast(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF') AS time) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion17() throws Exception {
+ @Test public void testRewriteConversion17() throws Exception {
String input = "SELECT convert(convert(PART_WEIGHT, time), timestamp) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT to_timestamp(to_char(to_timestamp(('1970-01-01 ' || PARTS.PART_WEIGHT), 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion18() throws Exception {
+ @Test public void testRewriteConversion18() throws Exception {
String input = "SELECT convert(convert(PART_WEIGHT, date), timestamp) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT to_timestamp(to_char(to_date(PARTS.PART_WEIGHT, 'YYYY-MM-DD'), 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteConversion19() throws Exception {
+ @Test public void testRewriteConversion19() throws Exception {
String input = "SELECT convert(convert(PART_WEIGHT, boolean), string) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT CASE WHEN cast(PARTS.PART_WEIGHT AS boolean) = TRUE THEN '1' ELSE '0' END FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteLog() throws Exception {
+ @Test public void testRewriteLog() throws Exception {
String input = "SELECT log(convert(PART_WEIGHT, double)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT ln(cast(PARTS.PART_WEIGHT AS float8)) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
input = "SELECT log10(convert(PART_WEIGHT, double)) FROM PARTS"; //$NON-NLS-1$
output = "SELECT log(cast(PARTS.PART_WEIGHT AS float8)) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteLeft() throws Exception {
+ @Test public void testRewriteLeft() throws Exception {
String input = "SELECT left(PART_WEIGHT, 2) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT SUBSTR(PARTS.PART_WEIGHT, 1, 2) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRewriteRight() throws Exception {
+ @Test public void testRewriteRight() throws Exception {
String input = "SELECT right(PART_WEIGHT, 2) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT SUBSTR(PARTS.PART_WEIGHT, (-1 * 2)) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testDayOfWeek() throws Exception {
+ @Test public void testDayOfWeek() throws Exception {
String input = "SELECT dayofweek(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT (EXTRACT(DOW FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) + 1) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testDayOfMonth() throws Exception {
+ @Test public void testDayOfMonth() throws Exception {
String input = "SELECT dayofmonth(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT EXTRACT(DAY FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testDayOfYear() throws Exception {
+ @Test public void testDayOfYear() throws Exception {
String input = "SELECT dayofyear(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT EXTRACT(DOY FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testHour() throws Exception {
+ @Test public void testHour() throws Exception {
String input = "SELECT hour(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT EXTRACT(HOUR FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testMinute() throws Exception {
+ @Test public void testMinute() throws Exception {
String input = "SELECT minute(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT EXTRACT(MINUTE FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testMonth() throws Exception {
+ @Test public void testMonth() throws Exception {
String input = "SELECT month(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT EXTRACT(MONTH FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testQuarter() throws Exception {
+ @Test public void testQuarter() throws Exception {
String input = "SELECT quarter(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT EXTRACT(QUARTER FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testSecond() throws Exception {
+ @Test public void testSecond() throws Exception {
String input = "SELECT second(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT EXTRACT(SECOND FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testWeek() throws Exception {
+ @Test public void testWeek() throws Exception {
String input = "SELECT week(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT EXTRACT(WEEK FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testYear() throws Exception {
+ @Test public void testYear() throws Exception {
String input = "SELECT year(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT EXTRACT(YEAR FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testDayName() throws Exception {
+ @Test public void testDayName() throws Exception {
String input = "SELECT dayname(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT RTRIM(TO_CHAR(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF'), 'Day')) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testMonthName() throws Exception {
+ @Test public void testMonthName() throws Exception {
String input = "SELECT monthname(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT RTRIM(TO_CHAR(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF'), 'Month')) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testIfnull() throws Exception {
+ @Test public void testIfnull() throws Exception {
String input = "SELECT ifnull(PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
String output = "SELECT coalesce(PARTS.PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testSubstring1() throws Exception {
+ @Test public void testSubstring1() throws Exception {
String input = "SELECT substring(PART_WEIGHT, 1) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT substr(PARTS.PART_WEIGHT, 1) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testSubstring2() throws Exception {
+ @Test public void testSubstring2() throws Exception {
String input = "SELECT substring(PART_WEIGHT, 1, 5) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT substr(PARTS.PART_WEIGHT, 1, 5) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testBooleanAggregate() throws Exception {
+ @Test public void testBooleanAggregate() throws Exception {
String input = "SELECT MIN(convert(PART_WEIGHT, boolean)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT bool_and(cast(PARTS.PART_WEIGHT AS boolean)) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
output);
}
- public void testRowLimit2() throws Exception {
+ @Test public void testRowLimit2() throws Exception {
String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
String output = "SELECT SmallA.IntKey FROM SmallA LIMIT 100"; //$NON-NLS-1$
helpTestVisitor(getTestBQTVDB(),
input,
- MODIFIERS,
output);
}
- public void testRowLimit3() throws Exception {
+ @Test public void testRowLimit3() throws Exception {
String input = "select intkey from bqt1.smalla limit 50, 100"; //$NON-NLS-1$
String output = "SELECT SmallA.IntKey FROM SmallA LIMIT 100 OFFSET 50"; //$NON-NLS-1$
helpTestVisitor(getTestBQTVDB(),
input,
- MODIFIERS,
output);
}
- public void testBitFunctions() throws Exception {
+ @Test public void testBitFunctions() throws Exception {
String input = "select bitand(intkey, intnum), bitnot(intkey), bitor(intnum, intkey), bitxor(intnum, intkey) from bqt1.smalla"; //$NON-NLS-1$
String output = "SELECT (SmallA.IntKey & SmallA.IntNum), ~(SmallA.IntKey), (SmallA.IntNum | SmallA.IntKey), (SmallA.IntNum # SmallA.IntKey) FROM SmallA"; //$NON-NLS-1$
helpTestVisitor(getTestBQTVDB(),
input,
- MODIFIERS,
output);
}
+
+ @Test public void testLocate() throws Exception {
+ String input = "select locate('a', stringkey), locate('b', stringkey, 2) from bqt1.smalla"; //$NON-NLS-1$
+ String output = "SELECT position('a' in SmallA.StringKey), position('b' in substr(SmallA.StringKey, 2)) FROM SmallA"; //$NON-NLS-1$
+
+ helpTestVisitor(getTestBQTVDB(),
+ input,
+ output);
+ }
-
}
16 years, 8 months
teiid SVN: r1217 - trunk/runtime/src/main/java/com/metamatrix/jdbc.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-08-06 12:47:07 -0400 (Thu, 06 Aug 2009)
New Revision: 1217
Modified:
trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
Log:
removing unneeded shutdowninprogress variable
Modified: trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-08-06 16:34:42 UTC (rev 1216)
+++ trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-08-06 16:47:07 UTC (rev 1217)
@@ -84,7 +84,6 @@
* already alive.
*/
public class EmbeddedConnectionFactoryImpl implements ServerConnectionFactory {
- private volatile boolean shutdownInProgress = false;
private DQPCore dqp;
private long starttime = -1L;
private Thread shutdownThread;
@@ -315,45 +314,34 @@
Runtime.getRuntime().removeShutdownHook(this.shutdownThread);
}
- // Make sure shutdown is not already in progress; as call to shutdown will close
- // connections; and after the last connection closes, the listener also calls shutdown
- // for normal route.
- if (!this.shutdownInProgress) {
-
- // this will by pass, and only let shutdown called once.
- this.shutdownInProgress = true;
-
- try {
- this.dqp.stop();
- } catch (ApplicationLifecycleException e) {
- LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
- }
-
- // remove any artifacts which are not cleaned-up
- if (this.workspaceDirectory != null) {
- File file = new File(this.workspaceDirectory);
- if (file.exists()) {
- delete(file);
- }
+ try {
+ this.dqp.stop();
+ } catch (ApplicationLifecycleException e) {
+ LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
+ }
+
+ // remove any artifacts which are not cleaned-up
+ if (this.workspaceDirectory != null) {
+ File file = new File(this.workspaceDirectory);
+ if (file.exists()) {
+ delete(file);
}
-
- this.dqp = null;
-
- // shutdown the socket transport.
- if (this.socketTransport != null) {
- this.socketTransport.stop();
- this.socketTransport = null;
- }
-
- // shutdown the cache.
- ResourceFinder.getCacheFactory().destroy();
-
- this.shutdownInProgress = false;
-
- this.init = false;
-
- this.restart = restart;
- }
+ }
+
+ this.dqp = null;
+
+ // shutdown the socket transport.
+ if (this.socketTransport != null) {
+ this.socketTransport.stop();
+ this.socketTransport = null;
+ }
+
+ // shutdown the cache.
+ ResourceFinder.getCacheFactory().destroy();
+
+ this.init = false;
+
+ this.restart = restart;
}
private Admin getAdminAPI() {
16 years, 8 months
teiid SVN: r1216 - in trunk: connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2 and 10 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-08-06 12:34:42 -0400 (Thu, 06 Aug 2009)
New Revision: 1216
Added:
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCBaseExecution.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCUpdateExecution.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2/DB2SQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbyCapabilities.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbySQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLCapabilities.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
trunk/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbyCapabilities.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
Log:
TEIID-715 TEIID-752 TEIID-753 adding some consistency to null ordering, addressing issues with mysql translator and with bulk updates
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCBaseExecution.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCBaseExecution.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCBaseExecution.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -97,7 +97,7 @@
* Return true if this is a batched update
*/
protected void bindPreparedStatementValues(PreparedStatement stmt, TranslatedCommand tc, int rowCount) throws SQLException {
- List params = tc.getPreparedValues();
+ List<?> params = tc.getPreparedValues();
for (int row = 0; row < rowCount; row++) {
for (int i = 0; i< params.size(); i++) {
@@ -106,12 +106,12 @@
if (paramValue.isMultiValued()) {
value = ((List<?>)value).get(row);
}
- Class paramType = paramValue.getType();
+ Class<?> paramType = paramValue.getType();
sqlTranslator.bindValue(stmt, value, paramType, i+1);
- if (rowCount > 1) {
- stmt.addBatch();
- }
- }
+ }
+ if (rowCount > 1) {
+ stmt.addBatch();
+ }
}
}
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -122,9 +122,11 @@
} catch (MetaMatrixCoreException e) {
throw new ConnectorException(e);
}
+ PropertiesUtils.setBeanProperties(sqlTranslator, environment.getProperties(), null);
sqlTranslator.initialize(environment);
capabilities = sqlTranslator.getConnectorCapabilities();
+ PropertiesUtils.setBeanProperties(capabilities, environment.getProperties(), null);
createDataSources(dataSourceClassName, connectionProps);
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCUpdateExecution.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCUpdateExecution.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCUpdateExecution.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -89,10 +89,10 @@
boolean succeeded = false;
boolean commitType = getAutoCommit(null);
- ICommand[] commands = (ICommand[])batchedCommand.getUpdateCommands().toArray(new ICommand[batchedCommand.getUpdateCommands().size()]);
+ ICommand[] commands = batchedCommand.getUpdateCommands().toArray(new ICommand[batchedCommand.getUpdateCommands().size()]);
int[] results = new int[commands.length];
- TranslatedCommand command = null;
+ TranslatedCommand tCommand = null;
try {
// temporarily turn the auto commit off, and set it back to what it was
@@ -106,18 +106,18 @@
TranslatedCommand previousCommand = null;
for (int i = 0; i < commands.length; i++) {
- command = translateCommand(commands[i]);
- if (command.isPrepared()) {
+ tCommand = translateCommand(commands[i]);
+ if (tCommand.isPrepared()) {
PreparedStatement pstmt = null;
- if (previousCommand != null && previousCommand.isPrepared() && previousCommand.getSql().equals(command.getSql())) {
+ if (previousCommand != null && previousCommand.isPrepared() && previousCommand.getSql().equals(tCommand.getSql())) {
pstmt = (PreparedStatement)statement;
} else {
if (!executedCmds.isEmpty()) {
executeBatch(i, results, executedCmds);
}
- pstmt = getPreparedStatement(command.getSql());
+ pstmt = getPreparedStatement(tCommand.getSql());
}
- bindPreparedStatementValues(pstmt, command, 1);
+ bindPreparedStatementValues(pstmt, tCommand, 1);
pstmt.addBatch();
} else {
if (previousCommand != null && previousCommand.isPrepared()) {
@@ -127,17 +127,17 @@
if (statement == null) {
getStatement();
}
- statement.addBatch(command.getSql());
+ statement.addBatch(tCommand.getSql());
}
- executedCmds.add(command);
- previousCommand = command;
+ executedCmds.add(tCommand);
+ previousCommand = tCommand;
}
if (!executedCmds.isEmpty()) {
executeBatch(commands.length, results, executedCmds);
}
succeeded = true;
} catch (SQLException e) {
- throw new JDBCExecutionException(e, command);
+ throw new JDBCExecutionException(e, tCommand);
} finally {
if (commitType) {
restoreAutoCommit(!succeeded, null);
@@ -182,7 +182,7 @@
for (int i = 0; i< translatedComm.getPreparedValues().size(); i++) {
ILiteral paramValue = (ILiteral)translatedComm.getPreparedValues().get(i);
if (paramValue.isMultiValued()) {
- rowCount = ((List<?>)paramValue).size();
+ rowCount = ((List<?>)paramValue.getValue()).size();
break;
}
}
@@ -220,11 +220,14 @@
* @return
* @throws ConnectorException
*/
- private boolean getAutoCommit(TranslatedCommand command) throws ConnectorException {
+ private boolean getAutoCommit(TranslatedCommand tCommand) throws ConnectorException {
+ if (this.context.isTransactional()) {
+ return false;
+ }
try {
return connection.getAutoCommit();
} catch (SQLException err) {
- throw new JDBCExecutionException(err, command);
+ throw new JDBCExecutionException(err, tCommand);
}
}
@@ -236,18 +239,18 @@
* @throws ConnectorException
*/
private void restoreAutoCommit(boolean exceptionOccurred,
- TranslatedCommand command) throws ConnectorException {
+ TranslatedCommand tCommand) throws ConnectorException {
try {
if (exceptionOccurred) {
connection.rollback();
}
} catch (SQLException err) {
- throw new JDBCExecutionException(err, command);
+ throw new JDBCExecutionException(err, tCommand);
} finally {
try {
connection.setAutoCommit(true);
} catch (SQLException err) {
- throw new JDBCExecutionException(err, command);
+ throw new JDBCExecutionException(err, tCommand);
}
}
}
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2/DB2SQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2/DB2SQLTranslator.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2/DB2SQLTranslator.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -176,5 +176,8 @@
return expr;
}
-
+ @Override
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.HIGH;
+ }
}
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbyCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbyCapabilities.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbyCapabilities.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -135,7 +135,7 @@
return supportedFunctions;
}
- public void setVersion(String version) {
+ public void setDatabaseVersion(String version) {
this.version = version;
}
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbySQLTranslator.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbySQLTranslator.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -37,8 +37,8 @@
*/
public class DerbySQLTranslator extends DB2SQLTranslator {
- public static final String DATABASE_VERSION = "DatabaseVersion"; //$NON-NLS-1$
-
+ private String version = DerbyCapabilities.TEN_1;
+
@Override
public void initialize(ConnectorEnvironment env) throws ConnectorException {
super.initialize(env);
@@ -68,13 +68,12 @@
}
@Override
- public ConnectorCapabilities getConnectorCapabilities()
- throws ConnectorException {
- ConnectorCapabilities capabilities = super.getConnectorCapabilities();
- if (capabilities instanceof DerbyCapabilities) {
- ((DerbyCapabilities)capabilities).setVersion(getEnvironment().getProperties().getProperty(DATABASE_VERSION, DerbyCapabilities.TEN_1));
- }
- return capabilities;
+ public boolean supportsExplicitNullOrdering() {
+ return version.compareTo(DerbyCapabilities.TEN_4) >= 0;
+ }
+
+ public void setDatabaseVersion(String version) {
+ this.version = version;
}
}
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -64,7 +64,7 @@
@Override
public String translateLiteralTimestamp(Timestamp timestampValue) {
- return "TIMESTAMP('" + formatDateValue(timestampValue) + "')"; //$NON-NLS-1$//$NON-NLS-2$
+ return "{ts '" + formatDateValue(timestampValue) + "'}"; //$NON-NLS-1$//$NON-NLS-2$
}
@Override
@@ -74,7 +74,7 @@
@Override
public int getTimestampNanoPrecision() {
- return 6;
+ return 0;
}
@Override
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSQLTranslator.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSQLTranslator.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -323,6 +323,11 @@
}
@Override
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.HIGH;
+ }
+
+ @Override
public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
return OracleCapabilities.class;
}
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLCapabilities.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLCapabilities.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -33,8 +33,15 @@
* @since 4.3
*/
public class PostgreSQLCapabilities extends JDBCCapabilities {
-
-
+
+ public static final String EIGHT_0 = "8.0"; //$NON-NLS-1$
+ public static final String EIGHT_1 = "8.1"; //$NON-NLS-1$
+ public static final String EIGHT_2 = "8.2"; //$NON-NLS-1$
+ public static final String EIGHT_3 = "8.3"; //$NON-NLS-1$
+ public static final String EIGHT_4 = "8.4"; //$NON-NLS-1$
+
+ private String version = EIGHT_0;
+
public List<String> getSupportedFunctions() {
List<String> supportedFunctions = new ArrayList<String>();
supportedFunctions.addAll(super.getSupportedFunctions());
@@ -117,9 +124,11 @@
// supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
// supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
supportedFunctions.add("QUARTER"); //$NON-NLS-1$
- supportedFunctions.add("SECOND"); //$NON-NLS-1$
-// supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
-// supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
+ supportedFunctions.add("SECOND"); //$NON-NLS-1$
+ if (this.version.compareTo(EIGHT_2) >= 0) {
+ supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
+ supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
+ }
supportedFunctions.add("WEEK"); //$NON-NLS-1$
supportedFunctions.add("YEAR"); //$NON-NLS-1$
@@ -268,5 +277,9 @@
@Override
public boolean supportsIntersect() {
return true;
- }
+ }
+
+ public void setDatabaseVersion(String version) {
+ this.version = version;
+ }
}
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -52,7 +52,9 @@
* Translator class for PostgreSQL. Updated to expect a 8.0+ jdbc client
* @since 4.3
*/
-public class PostgreSQLTranslator extends Translator {
+public class PostgreSQLTranslator extends Translator {
+
+ private String version = PostgreSQLCapabilities.EIGHT_0;
public void initialize(ConnectorEnvironment env) throws ConnectorException {
//TODO: all of the functions (except for convert) can be handled through just the escape syntax
@@ -158,6 +160,16 @@
}
@Override
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.HIGH;
+ }
+
+ @Override
+ public boolean supportsExplicitNullOrdering() {
+ return version.compareTo(PostgreSQLCapabilities.EIGHT_4) >= 0;
+ }
+
+ @Override
public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
return PostgreSQLCapabilities.class;
}
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -37,11 +37,13 @@
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.TypeFacility;
+import org.teiid.connector.jdbc.translator.Translator.NullOrder;
import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IFunction;
import org.teiid.connector.language.ILanguageObject;
import org.teiid.connector.language.ILimit;
import org.teiid.connector.language.ILiteral;
+import org.teiid.connector.language.IOrderByItem;
import org.teiid.connector.language.IParameter;
import org.teiid.connector.language.IProcedure;
import org.teiid.connector.language.IParameter.Direction;
@@ -119,6 +121,22 @@
}
}
}
+
+ @Override
+ public void visit(IOrderByItem obj) {
+ super.visit(obj);
+ if (!this.translator.supportsExplicitNullOrdering()) {
+ return;
+ }
+ NullOrder nullOrder = this.translator.getDefaultNullOrder();
+ if (obj.getDirection() == IOrderByItem.ASC) {
+ if (nullOrder != NullOrder.LOW && nullOrder != NullOrder.FIRST) {
+ buffer.append(" NULLS FIRST"); //$NON-NLS-1$
+ }
+ } else if (nullOrder != NullOrder.HIGH && nullOrder != NullOrder.LAST) {
+ buffer.append(" NULLS LAST"); //$NON-NLS-1$
+ }
+ }
/**
* @param type
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 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -56,6 +56,7 @@
import org.teiid.connector.language.IParameter;
import org.teiid.connector.language.ISetQuery;
import org.teiid.connector.language.IParameter.Direction;
+import org.teiid.connector.visitor.util.SQLReservedWords;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.util.ReflectionHelper;
@@ -65,7 +66,14 @@
* Specific databases should override as necessary.
*/
public class Translator {
-
+
+ public enum NullOrder {
+ HIGH,
+ LOW,
+ FIRST,
+ LAST
+ }
+
// Because the retrieveValue() method will be hit for every value of
// every JDBC result set returned, we do lots of weird special stuff here
// to improve the performance (most importantly to remove big if/else checks
@@ -296,6 +304,8 @@
if (getTimestampNanoPrecision() > 0) {
int mask = 10^(9-getTimestampNanoPrecision());
newTs.setNanos(ts.getNanos()/mask*mask);
+ } else {
+ newTs.setNanos(0);
}
dateObject = newTs;
}
@@ -784,4 +794,16 @@
public boolean useParensForJoins() {
return false;
}
+
+ /**
+ * get the default null ordering
+ * @return
+ */
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.LOW;
+ }
+
+ public boolean supportsExplicitNullOrdering() {
+ return true;
+ }
}
Modified: trunk/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml
===================================================================
--- trunk/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml 2009-08-06 16:34:42 UTC (rev 1216)
@@ -86,6 +86,7 @@
<PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="org.postgresql.Driver" IsRequired="true" />
<PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:postgresql://<host>:5432/<databaseName>" IsRequired="true" PropertyType="String" IsMasked="false" />
<PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.postgresql.PostgreSQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
+ <PropertyDefinition Name="DatabaseVersion" DisplayName="Database Version" ShortDescription="PostgreSQL Version i.e. 8.3" DefaultValue="8.0" PropertyType="String" />
</ComponentType>
<ComponentType Name="PostgreSQL XA JDBC Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
<PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="org.postgresql.xa.PGXADataSource" IsRequired="true" />
@@ -94,6 +95,7 @@
<PropertyDefinition Name="DatabaseName" DisplayName="Database Name" ShortDescription="" IsRequired="true" PropertyType="String" IsMasked="false" />
<PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.postgresql.PostgreSQLTranslator" PropertyType="String" IsExpert="true" IsMasked="false" />
<PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean" />
+ <PropertyDefinition Name="DatabaseVersion" DisplayName="Database Version" ShortDescription="PostgreSQL Version i.e. 8.3" DefaultValue="8.0" PropertyType="String" />
</ComponentType>
<ComponentType Name="Apache Derby Embedded Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
<PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="org.apache.derby.jdbc.EmbeddedDriver" IsRequired="true" />
Added: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -0,0 +1,65 @@
+/*
+ * 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.connector.jdbc;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.util.Arrays;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.connector.api.ConnectorLogger;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.jdbc.translator.Translator;
+import org.teiid.connector.language.ICommand;
+import org.teiid.connector.language.IInsert;
+import org.teiid.connector.language.IInsertExpressionValueSource;
+import org.teiid.connector.language.ILiteral;
+
+import com.metamatrix.cdk.api.EnvironmentUtility;
+
+public class TestJDBCUpdateExecution {
+
+ @Test public void testBulkUpdate() throws Exception {
+ ICommand command = MetadataFactory.helpTranslate(MetadataFactory.BQT_VDB, "insert into bqt1.smalla (intkey, intnum) values (1, 2)"); //$NON-NLS-1$
+ ILiteral value = ((ILiteral)((IInsertExpressionValueSource)((IInsert)command).getValueSource()).getValues().get(0));
+ ILiteral value1 = ((ILiteral)((IInsertExpressionValueSource)((IInsert)command).getValueSource()).getValues().get(1));
+ value.setMultiValued(true);
+ value.setBindValue(true);
+ value.setValue(Arrays.asList(1, 2));
+ value1.setMultiValued(true);
+ value1.setBindValue(true);
+ value1.setValue(Arrays.asList(2, 3));
+ Connection connection = Mockito.mock(Connection.class);
+ PreparedStatement p = Mockito.mock(PreparedStatement.class);
+ Mockito.stub(p.executeBatch()).toReturn(new int [] {1, 1});
+ Mockito.stub(connection.prepareStatement("INSERT INTO SmallA (IntKey, IntNum) VALUES (?, ?)")).toReturn(p); //$NON-NLS-1$
+ Translator sqlTranslator = new Translator();
+ ExecutionContext context = EnvironmentUtility.createSecurityContext("user"); //$NON-NLS-1$
+ JDBCUpdateExecution updateExecution = new JDBCUpdateExecution(command, connection, sqlTranslator, Mockito.mock(ConnectorLogger.class), new Properties(), context);
+ updateExecution.execute();
+ Mockito.verify(p, Mockito.times(2)).addBatch();
+ }
+
+}
Property changes on: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbyCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbyCapabilities.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbyCapabilities.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -31,14 +31,14 @@
@Test public void testLimitSupport() {
DerbyCapabilities derbyCapabilities = new DerbyCapabilities();
assertFalse(derbyCapabilities.supportsRowLimit());
- derbyCapabilities.setVersion(DerbyCapabilities.TEN_5);
+ derbyCapabilities.setDatabaseVersion(DerbyCapabilities.TEN_5);
assertTrue(derbyCapabilities.supportsRowLimit());
}
@Test public void testFunctionSupport() {
DerbyCapabilities derbyCapabilities = new DerbyCapabilities();
assertEquals(27, derbyCapabilities.getSupportedFunctions().size());
- derbyCapabilities.setVersion(DerbyCapabilities.TEN_4);
+ derbyCapabilities.setDatabaseVersion(DerbyCapabilities.TEN_4);
assertEquals(43, derbyCapabilities.getSupportedFunctions().size());
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -192,5 +192,14 @@
MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
input,
output, TRANSLATOR);
+ }
+
+ @Test public void testTimestampLiteral() throws Exception {
+ String input = "select smalla.intkey from bqt1.smalla where smalla.timestampvalue = '2009-08-06 12:23:34.999'"; //$NON-NLS-1$
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE SmallA.TimestampValue = {ts '2009-08-06 12:23:34.0'}"; //$NON-NLS-1$
+
+ MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ input,
+ output, TRANSLATOR);
}
}
Modified: trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2009-08-06 14:43:44 UTC (rev 1215)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2009-08-06 16:34:42 UTC (rev 1216)
@@ -301,7 +301,7 @@
helpTestVisitor(getTestVDB(),
"select part_id id FROM parts UNION ALL select part_name FROM parts UNION ALL select part_id FROM parts ORDER BY id", //$NON-NLS-1$
null,
- "(SELECT g_2.PART_ID AS c_0 FROM PARTS g_2 UNION ALL SELECT g_1.PART_NAME AS c_0 FROM PARTS g_1) UNION ALL SELECT g_0.PART_ID AS c_0 FROM PARTS g_0 ORDER BY c_0", //$NON-NLS-1$
+ "(SELECT g_2.PART_ID AS c_0 FROM PARTS g_2 UNION ALL SELECT g_1.PART_NAME AS c_0 FROM PARTS g_1) UNION ALL SELECT g_0.PART_ID AS c_0 FROM PARTS g_0 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
true);
}
@@ -309,7 +309,7 @@
helpTestVisitor(getTestVDB(),
"select part_id FROM parts UNION ALL select part_name FROM parts ORDER BY part_id", //$NON-NLS-1$
null,
- "SELECT g_1.PART_ID AS c_0 FROM PARTS g_1 UNION ALL SELECT g_0.PART_NAME AS c_0 FROM PARTS g_0 ORDER BY c_0", //$NON-NLS-1$
+ "SELECT g_1.PART_ID AS c_0 FROM PARTS g_1 UNION ALL SELECT g_0.PART_NAME AS c_0 FROM PARTS g_0 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
true);
}
@@ -317,7 +317,7 @@
helpTestVisitor(getTestVDB(),
"select part_id as p FROM parts UNION ALL select part_name FROM parts ORDER BY p", //$NON-NLS-1$
null,
- "SELECT PARTS.PART_ID AS p FROM PARTS UNION ALL SELECT PARTS.PART_NAME FROM PARTS ORDER BY p"); //$NON-NLS-1$
+ "SELECT PARTS.PART_ID AS p FROM PARTS UNION ALL SELECT PARTS.PART_NAME FROM PARTS ORDER BY p NULLS FIRST"); //$NON-NLS-1$
}
@Test public void testUpdateWithFunction() throws Exception {
@@ -458,7 +458,7 @@
@Test public void testLimitWithNestedInlineView() throws Exception {
String input = "select max(intkey), stringkey from (select intkey, stringkey from bqt1.smalla order by intkey limit 100) x group by stringkey"; //$NON-NLS-1$
- String output = "SELECT MAX(x.intkey), x.stringkey FROM (SELECT * FROM (SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA ORDER BY intkey) WHERE ROWNUM <= 100) x GROUP BY x.stringkey"; //$NON-NLS-1$
+ String output = "SELECT MAX(x.intkey), x.stringkey FROM (SELECT * FROM (SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA ORDER BY intkey NULLS FIRST) WHERE ROWNUM <= 100) x GROUP BY x.stringkey"; //$NON-NLS-1$
helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
input,
@@ -500,7 +500,7 @@
@Test public void testRowLimitWithUnionOrderBy() throws Exception {
String input = "(select intkey from bqt1.smalla limit 50, 100) union select intnum from bqt1.smalla order by intkey"; //$NON-NLS-1$
- String output = "SELECT c_0 FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT g_1.IntKey AS c_0 FROM SmallA g_1) VIEW_FOR_LIMIT WHERE ROWNUM <= 150) WHERE ROWNUM_ > 50 UNION SELECT g_0.IntNum AS c_0 FROM SmallA g_0 ORDER BY c_0"; //$NON-NLS-1$
+ String output = "SELECT c_0 FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT g_1.IntKey AS c_0 FROM SmallA g_1) VIEW_FOR_LIMIT WHERE ROWNUM <= 150) WHERE ROWNUM_ > 50 UNION SELECT g_0.IntNum AS c_0 FROM SmallA g_0 ORDER BY c_0 NULLS FIRST"; //$NON-NLS-1$
CommandBuilder commandBuilder = new CommandBuilder(FakeMetadataFactory.exampleBQTCached());
ICommand obj = commandBuilder.getCommand(input, true, true);
16 years, 8 months
teiid SVN: r1215 - trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-08-06 10:43:44 -0400 (Thu, 06 Aug 2009)
New Revision: 1215
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java
Log:
minor fix to clear groups after a raise over a set op
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java 2009-08-05 15:36:27 UTC (rev 1214)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java 2009-08-06 14:43:44 UTC (rev 1215)
@@ -161,9 +161,8 @@
}
NodeEditor.removeChildNode(parentNode, node);
}
- rootNode = performRaise(rootNode, accessNode, parentNode);
-
- return rootNode;
+ accessNode.getGroups().clear();
+ return performRaise(rootNode, accessNode, parentNode);
case NodeConstants.Types.SELECT:
{
if (!parentNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET) && canRaiseOverSelect(accessNode, metadata, capFinder, parentNode)) {
16 years, 8 months
teiid SVN: r1214 - trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http.
by teiid-commits@lists.jboss.org
Author: jdoyle
Date: 2009-08-05 11:36:27 -0400 (Wed, 05 Aug 2009)
New Revision: 1214
Removed:
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http/HTTPTestServer.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http/TestNoArgConnector.java
Log:
TEIID-749
Removing occasionally failing test.
Deleted: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http/HTTPTestServer.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http/HTTPTestServer.java 2009-08-04 17:49:52 UTC (rev 1213)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http/HTTPTestServer.java 2009-08-05 15:36:27 UTC (rev 1214)
@@ -1,52 +0,0 @@
-package com.metamatrix.connector.xml.http;
-
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.DefaultHandler;
-import org.mortbay.jetty.handler.HandlerList;
-import org.mortbay.jetty.handler.ResourceHandler;
-import org.mortbay.jetty.servlet.Context;
-
-import com.metamatrix.connector.xml.base.ProxyObjectFactory;
-
-public class HTTPTestServer {
-
- private static Server server;
-
- public HTTPTestServer() {
- server = initServer();
-
- try {
- server.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private static Server initServer() {
- Server srv = new Server(8673);
- ResourceHandler handler = new ResourceHandler();
- handler.setResourceBase(ProxyObjectFactory.getDocumentsFolder());
-
- Context context = new Context(srv, "/servlets");
- //context.addServlet("com.metamatrix.test.servlet.EchoServlet", "/Echo");
- //context.addServlet("com.metamatrix.test.servlet.MockResponseServlet", "/Mock");
- context.addServlet("com.metamatrix.test.servlet.NameValueServlet", "/requestTest/NameValue");
- //context.addServlet("com.metamatrix.test.servlet.DocNameValueServlet", "/requestTest/docNameValue");
- //context.addServlet("com.metamatrix.test.servlet.DocPostBodyServlet", "/requestTest/docPostBody");
-
- HandlerList hList = new HandlerList();
- hList.setHandlers(new Handler[]{handler, context, new DefaultHandler()});
- srv.setHandler(hList);
- return srv;
- }
-
- public void stop() {
- try {
- server.stop();
- } catch (Exception e) {
- // shutting down.
- }
- }
-
-}
\ No newline at end of file
Deleted: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http/TestNoArgConnector.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http/TestNoArgConnector.java 2009-08-04 17:49:52 UTC (rev 1213)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http/TestNoArgConnector.java 2009-08-05 15:36:27 UTC (rev 1214)
@@ -1,45 +0,0 @@
-package com.metamatrix.connector.xml.http;
-
-
-import java.util.List;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.teiid.connector.api.Connector;
-import org.teiid.connector.api.ConnectorException;
-
-import com.metamatrix.cdk.api.ConnectorHost;
-import com.metamatrix.connector.xml.base.ProxyObjectFactory;
-import com.metamatrix.connector.xml.base.XMLConnector;
-import com.metamatrix.connector.xml.base.XMLConnectorStateImpl;
-
-public class TestNoArgConnector extends TestCase {
-
- Connector connector;
- ConnectorHost host;
- HTTPTestServer server;
-
- @Override
- public void setUp() throws Exception {
- server = new HTTPTestServer();
-
- connector = new XMLConnector();
- Properties props = ProxyObjectFactory.getDefaultHttpProps();
- props.setProperty(HTTPConnectorState.URI, "http://0.0.0.0:8673/purchaseOrdersShort.xml");
- props.setProperty(HTTPConnectorState.PARAMETER_METHOD, HTTPConnectorState.PARAMETER_NONE);
- props.setProperty(XMLConnectorStateImpl.CACHE_ENABLED, "true");
- String vdbPath = ProxyObjectFactory.getDocumentsFolder() + "/purchase_orders.vdb";
- host = new ConnectorHost(connector, props, vdbPath);
- host.setSecurityContext("purchase_orders", "1", "root", null);
- }
-
- public void testSelect() {
- try {
- List result = host.executeCommand("SELECT * FROM po_list_noargs.ITEM");
- assertEquals(2, result.size());
- } catch (ConnectorException e) {
- fail(e.getMessage());
- }
- }
-}
16 years, 8 months
teiid SVN: r1213 - trunk/runtime/src/main/java/org/teiid/transport.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-08-04 13:49:52 -0400 (Tue, 04 Aug 2009)
New Revision: 1213
Modified:
trunk/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java
Log:
TEIID-665: correcting regression of previous code. Also, making the ssl enablement independent of crypto enablement.
Modified: trunk/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java 2009-08-04 16:37:03 UTC (rev 1212)
+++ trunk/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java 2009-08-04 17:49:52 UTC (rev 1213)
@@ -80,11 +80,10 @@
boolean client_encryption_enabled = false;
public void init(Properties props) {
- ssl_enabled = PropertiesUtils.getBooleanProperty(props, SSL_ENABLED, false);
+ ssl_enabled = PropertiesUtils.getBooleanProperty(props, SSL_ENABLED, false);
+ client_encryption_enabled = PropertiesUtils.getBooleanProperty(props, CLIENT_ENCRYPTION_ENABLED, true);
if (ssl_enabled) {
- client_encryption_enabled = PropertiesUtils.getBooleanProperty(props, CLIENT_ENCRYPTION_ENABLED, true);
-
keyStoreFileName = props.getProperty(KEYSTORE_FILENAME);
try {
keyStorePassword = CryptoUtil.stringDecrypt(props.getProperty(KEYSTORE_PASSWORD, "")); //$NON-NLS-1$
@@ -142,11 +141,11 @@
}
public boolean isServerSSLEnabled() {
- return ssl_enabled && CryptoUtil.isEncryptionEnabled();
+ return this.ssl_enabled;
}
public boolean isClientEncryptionEnabled() {
- return CryptoUtil.isEncryptionEnabled() && client_encryption_enabled;
+ return this.client_encryption_enabled;
}
}
16 years, 8 months