teiid SVN: r1582 - in trunk: console and 2 other directories.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2009-11-20 17:26:31 -0500 (Fri, 20 Nov 2009)
New Revision: 1582
Removed:
trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionImpl.java
trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionUtil.java
trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionFactory.java
Modified:
trunk/console/pom.xml
trunk/console/src/resources/embedded/META-INF/rhq-plugin.xml
trunk/pom.xml
Log:
TEIID-807: Initial check-in of console changes to add to teiid build, and create a plugin for embedded Jopr.
Modified: trunk/console/pom.xml
===================================================================
--- trunk/console/pom.xml 2009-11-20 20:30:31 UTC (rev 1581)
+++ trunk/console/pom.xml 2009-11-20 22:26:31 UTC (rev 1582)
@@ -1,19 +1,23 @@
<?xml version="1.0"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <parent>
- <artifactId>teiid</artifactId>
- <groupId>org.jboss.teiid</groupId>
- <version>6.3.0-SNAPSHOT</version>
- </parent>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <parent>
+ <artifactId>teiid</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ <version>6.3.0-SNAPSHOT</version>
+ </parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-console</artifactId>
- <name>TEIID Console</name>
- <description>This project is for the RHQ plugin that supports the TEIID Console </description>
+ <name>Console</name>
+ <description>This project is for the RHQ plugin that supports the
+ TEIID Console </description>
<properties>
- <org.jboss.jopr.as4.version>1.2.0.GA</org.jboss.jopr.as4.version>
+ <!--
+ <org.jboss.jopr.as4.version>1.2.0.GA</org.jboss.jopr.as4.version>
+ -->
<org.jboss.jopr.as5.version>1.2.0.GA</org.jboss.jopr.as5.version>
<org.jboss.jopr.version>1.2.0.GA</org.jboss.jopr.version>
@@ -21,11 +25,14 @@
<apache.ant.version>1.7.0</apache.ant.version>
</properties>
-
+
<build>
<pluginManagement>
<plugins>
- <!-- Fixes how test resources of a project can be used in projects dependent on it -->
+ <!--
+ Fixes how test resources of a project can be used in projects
+ dependent on it
+ -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
@@ -34,7 +41,7 @@
</plugins>
</pluginManagement>
<plugins>
- <!-- Specify the compiler options and settings -->
+ <!-- Specify the compiler options and settings -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -55,7 +62,10 @@
</includes>
<excludes>
<exclude>**/Abstract*TestCase.java</exclude>
- <!-- hack to prevent anonymous inner classes in Tests from being run as tests -->
+ <!--
+ hack to prevent anonymous inner classes in Tests from being run
+ as tests
+ -->
<include>**/Test*$*.java</include>
</excludes>
<systemProperties>
@@ -70,7 +80,7 @@
</systemProperties>
</configuration>
</plugin>
-
+
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-2</version>
@@ -91,74 +101,7 @@
</execution>
</executions>
</plugin>
-
- <!--
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant</artifactId>
- <version>${apache.ant.version}</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>assemble-artifacts</id>
- <phase>package</phase>
- <configuration>
- <tasks>
- <property name="product.version" value="${project.version}" />
- <property name="product.name" value="${project.name}" />
- <ant antfile="src/assembly/assemble-artifacts.xml" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- -->
-
- <!--
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dist-wars</id>
- <phase>process-resources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <outputDirectory>${basedir}/target/</outputDirectory>
- <artifactItems>
- <artifactItem>
- <groupId>org.jboss.jopr</groupId>
- <artifactId>jopr-embedded-jbas4</artifactId>
- <version>${org.jboss.jopr.as4.version}</version>
- <type>war</type>
- <overWrite>true</overWrite>
- </artifactItem>
- <artifactItem>
- <groupId>org.jboss.jopr</groupId>
- <artifactId>jopr-embedded-jbas5</artifactId>
- <version>${org.jboss.jopr.as5.version}</version>
- <type>war</type>
- <overWrite>true</overWrite>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- -->
-<!--
-
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
@@ -171,64 +114,92 @@
</dependencies>
<executions>
<execution>
- <id>assembly-kit-jboss-as4</id>
+ <id>assemble-artifacts</id>
<phase>package</phase>
<configuration>
<tasks>
- <mkdir dir="target/jboss-as4-war"/>
- <unzip src="target/jopr-embedded-jbas4-${org.jboss.jopr.as4.version}.war" dest="target/jboss-as4-war"/>
-
- <mkdir dir="target/plugin-classes"/>
-
-
- <unzip src="../jbedsp-plugin/target/distribution/jbedsp-plugin-${project.version}-binaries.jar" dest="target/jboss-as4-war/WEB-INF/lib"/>
-
- <unzip src="../jbedsp-plugin/target/distribution/jbedsp-embedded-plugin-${project.version}.jar" dest="target/plugin-classes"/>
- <unzip src="target/${project.name}-${project.version}.jar" dest="target/plugin-classes"/>
- <jar destfile="target/jboss-as4-war/plugins/jbedsp-jopr-plugin-${project.version}.jar" basedir="target/plugin-classes"/>
-
- <zip destfile="target/jopr-teiid-embedded-jbas4.war" basedir="target/jboss-as4-war" />
-
+ <property name="product.version" value="${project.version}" />
+ <property name="product.name" value="${project.name}" />
+ <ant antfile="src/assembly/assemble-artifacts.xml" />
</tasks>
-
</configuration>
-
<goals>
<goal>run</goal>
- </goals>
+ </goals>
</execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
<execution>
- <id>assembly-kit-jboss-as5</id>
- <phase>package</phase>
+ <id>copy-dist-wars</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
<configuration>
- <tasks>
- <mkdir dir="target/jboss-as5-war"/>
- <unzip src="target/jopr-embedded-jbas5-${org.jboss.jopr.as5.version}.war" dest="target/jboss-as5-war"/>
+ <outputDirectory>${basedir}/target/</outputDirectory>
- <mkdir dir="target/plugin-classes"/>
+ <artifactItems>
+ <!--
+ <artifactItem> <groupId>org.jboss.jopr</groupId>
+ <artifactId>jopr-embedded-jbas4</artifactId>
+ <version>${org.jboss.jopr.as4.version}</version>
+ <type>war</type> <overWrite>true</overWrite> </artifactItem>
+ -->
+ <artifactItem>
+ <groupId>org.jboss.jopr</groupId>
+ <artifactId>jopr-embedded-jbas5</artifactId>
+ <version>${org.jboss.jopr.as5.version}</version>
+ <type>war</type>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
- <unzip src="../jbedsp-plugin/target/distribution/jbedsp-plugin-${project.version}-binaries.jar" dest="target/jboss-as5-war/WEB-INF/lib"/>
- <unzip src="../jbedsp-plugin/target/distribution/jbedsp-embedded-plugin-${project.version}.jar" dest="target/plugin-classes"/>
- <unzip src="target/${project.name}-${project.version}.jar" dest="target/plugin-classes"/>
- <jar destfile="target/jboss-as5-war/plugins/jbedsp-jopr-plugin-${project.version}.jar" basedir="target/plugin-classes"/>
-
- <zip destfile="target/jopr-teiid-embedded-jbas5.war" basedir="target/jboss-as5-war" />
- </tasks>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>${apache.ant.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <!--
+ <execution> <id>assembly-kit-jboss-as4</id> <phase>package</phase>
+ <configuration> <tasks> <mkdir dir="target/jboss-as4-war"/> <unzip
+ src="target/jopr-embedded-jbas4-${org.jboss.jopr.as4.version}.war"
+ dest="target/jboss-as4-war"/> <mkdir dir="target/plugin-classes"/>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <unzip
+ src="../jbedsp-plugin/target/distribution/jbedsp-plugin-${project.version}-binaries.jar"
+ dest="target/jboss-as4-war/WEB-INF/lib"/> <unzip
+ src="../jbedsp-plugin/target/distribution/jbedsp-embedded-plugin-${project.version}.jar"
+ dest="target/plugin-classes"/> <unzip
+ src="target/${project.name}-${project.version}.jar"
+ dest="target/plugin-classes"/> <jar
+ destfile="target/jboss-as4-war/plugins/jbedsp-jopr-plugin-${project.version}.jar"
+ basedir="target/plugin-classes"/> <zip
+ destfile="target/jopr-teiid-embedded-jbas4.war"
+ basedir="target/jboss-as4-war" /> </tasks> </configuration>
+ <goals> <goal>run</goal> </goals> </execution>
+ -->
+
</executions>
</plugin>
--->
-
-
</plugins>
</build>
@@ -262,6 +233,18 @@
<scope>provided</scope> <!-- provided by the agent/plugin-container -->
</dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-jmx-plugin</artifactId>
+ <version>${org.jboss.jopr.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>mc4j</groupId>
+ <artifactId>org-mc4j-ems</artifactId>
+ <version>1.2.6</version>
+ </dependency>
+
<!--
TODO: This is a fix for the Javac bug requiring annotations to be
available when compiling dependent classes. It is fixed in JDK 6.
@@ -292,56 +275,62 @@
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-client</artifactId>
- </dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client</artifactId>
<type>test-jar</type>
</dependency>
-
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-client-jdbc</artifactId>
- </dependency>
+
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client-jdbc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client-jdbc</artifactId>
<type>test-jar</type>
</dependency>
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-common-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-common-core</artifactId>
- <type>test-jar</type>
- </dependency>
-
<dependency>
- <groupId>org.jboss.jopr</groupId>
- <artifactId>jopr-embedded-jbas4</artifactId>
- <type>war</type>
- <version>${org.jboss.jopr.as4.version}</version>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <type>test-jar</type>
+ </dependency>
+
+ <!--
+ <dependency> <groupId>org.jboss.jopr</groupId>
+ <artifactId>jopr-embedded-jbas4</artifactId> <type>war</type>
+ <version>${org.jboss.jopr.as4.version}</version> </dependency>
+ -->
+ <dependency>
<groupId>org.jboss.jopr</groupId>
<artifactId>jopr-embedded-jbas5</artifactId>
<type>war</type>
<version>${org.jboss.jopr.as5.version}</version>
</dependency>
-
+
<dependency>
+ <groupId>org.jboss.integration</groupId>
+ <artifactId>jboss-profileservice-spi</artifactId>
+ <version>5.1.0.CR2</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
</dependency>
+
</dependencies>
-</project>
+</project>
\ No newline at end of file
Deleted: trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionImpl.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionImpl.java 2009-11-20 20:30:31 UTC (rev 1581)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionImpl.java 2009-11-20 22:26:31 UTC (rev 1582)
@@ -1,1340 +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.rhq.comm.impl;
-
-import java.lang.reflect.Method;
-import java.net.UnknownHostException;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminObject;
-import org.teiid.adminapi.ConnectorBinding;
-import org.teiid.adminapi.Host;
-import org.teiid.adminapi.ProcessObject;
-import org.teiid.adminapi.QueueWorkerPool;
-import org.teiid.adminapi.Request;
-import org.teiid.adminapi.Session;
-import org.teiid.adminapi.SystemObject;
-import org.teiid.rhq.comm.Component;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionConstants;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionPool;
-import org.teiid.rhq.comm.ExecutedResult;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Queries.Query;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.System.Metrics;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.System.Operations;
-import org.teiid.rhq.plugin.HostComponent;
-
-import com.metamatrix.jdbc.MMConnection;
-import com.metamatrix.platform.security.api.MetaMatrixSessionState;
-
-public class ConnectionImpl implements Connection, TeiidConnectionConstants {
-
- // TODO:
- // 1. Change from using LogManager. This writes to the MM Server, the
- // messages should be
- // written to the agent log
- // 2. Need to support connecting via ssl
- // 3. Need to understand the life cycle of a connection
- // a. during discovery
- // b. during monitoring, operations, etc.
- // 4. add post processing for calculated fields in operation results
-
-
- private static final Log log = LogFactory.getLog(ConnectionImpl.class);
-
- public String key = "";
-
- private Properties environmentProps = null;
-
- private Admin adminApi = null;
- private MMConnection mmconn = null;
-
- private ConnectionPool connectionPool = null;
-
- // set when an exception is thrown by the admin api
- // and indicates when close is called, to tell the pool
- // to remove the connection;
- private boolean invalidConnection = false;
-
- protected ConnectionImpl (final String key,
- final Properties envProps,
- final ConnectionPool pool,
- final MMConnection connection) throws SQLException {
- this.connectionPool = pool;
- this.mmconn = connection;
- this.adminApi = this.mmconn.getAdminAPI();
- this.key = key;
- this.environmentProps = envProps;
-
- }
-
- public boolean isValid() {
- return (! this.invalidConnection);
- }
- /**
- * @see org.teiid.rhq.comm.Connection#isAlive()
- */
- public boolean isAlive() {
- try {
- if (adminApi != null) {
- adminApi.getSystem();
- this.invalidConnection=false;
- return true;
- }
- } catch (Throwable e) {
- invalidConnection = true;
- log.error("Error: admin connection for " + key + " is not alive", e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return false;
- }
-
- /**
- * @see org.teiid.rhq.comm.Connection#close()
- */
- public void close() {
- try {
- if (connectionPool != null) {
- connectionPool.close(this);
- }
-
- } catch (Exception e) {
- log.error("Error returning connection to the connection pool", e); //$NON-NLS-1$
- }
-
- invalidConnection = true;
-
- }
-
-
- /**
- * Called by the factory to close the source connection
- *
- */
-
- protected void closeSource() {
- try {
- if (mmconn != null) {
- mmconn.close();
- }
- } catch (Exception e) {
- log.error("Error closing the admin connection", e); //$NON-NLS-1$
- } finally {
- adminApi = null;
- mmconn = null;
- connectionPool = null;
- environmentProps.clear();
- environmentProps = null;
- this.invalidConnection = true;
-
- }
- }
-
-// public Properties getEnvironment() throws ConnectionException {
-// Properties systemProperties = new Properties();
-// try {
-// Collection processCollection = ConnectionUtil.getAllProcesses(
-// getConnection(), this.getHost().getIdentifier());
-//
-// Iterator processIter = processCollection.iterator();
-// String portList = null;
-//
-// boolean first = true;
-// while (processIter.hasNext()) {
-// ProcessObject process = (ProcessObject) processIter.next();
-// if (first) {
-// first = false;
-// portList = String.valueOf(process.getPort());
-// } else {
-// portList += PORT_DELIM + process.getPort(); //$NON-NLS-1$
-// }
-//
-// }
-//
-// systemProperties.setProperty(ConnectionConstants.USERNAME,
-// environmentProps.getProperty(ConnectionConstants.USERNAME));
-// systemProperties.setProperty(ConnectionConstants.PASSWORD,
-// environmentProps.getProperty(ConnectionConstants.PASSWORD));
-// systemProperties.setProperty(ConnectionConstants.PORTS, portList);
-// environmentProps = (Properties) systemProperties.clone();
-//
-// return systemProperties;
-// } catch (AdminException ae) {
-// invalidConnection = true;
-// throw new ConnectionException(ae.getMessage());
-// } finally {
-// this.resetConnection();
-// }
-// }
-
- public Collection<Component> discoverComponents(String componentType,
- String identifier) throws ConnectionException {
- if (componentType
- .equals(Runtime.Connector.TYPE)) {
- return getConnectors(identifier);
-
-// } else if (componentType
-// .equals(Runtime.Service.TYPE)) {
-// return getServices(identifier);
-
- } else if (componentType
- .equals(Runtime.Process.TYPE)) {
- return getVMs(identifier);
-
- } else if (componentType
- .equals(Runtime.Host.TYPE)) {
- return getAllHosts();
-
-// } else if (componentType
-// .equals(ComponentType.Resource.Service.TYPE)) {
-// return getServicesForConfig(identifier);
-//
-// } else if (componentType
-// .equals(ComponentType.Resource.Connector.TYPE)) {
-// return getConnectorsForConfig(identifier);
-
- }
-// else if (componentType
-// .equals(ComponentType.Runtime.Session.TYPE)) {
-// return getConnectorsForConfig(identifier);
-//
-// }
- return Collections.EMPTY_LIST;
- }
-
-
-
- public void executeOperation(ExecutedResult operationResult,
- final Map valueMap) throws ConnectionException {
-
- if (operationResult.getComponentType().equals(Runtime.Connector.TYPE)) {
- executeConnectorOperation(operationResult, operationResult.getOperationName(), valueMap);
- } else if (operationResult.getComponentType().equals(ConnectionConstants.ComponentType.Runtime.System.TYPE)) {
- executeSystemOperation(operationResult, operationResult.getOperationName(), valueMap);
- } else if (operationResult.getComponentType().equals( Runtime.Process.TYPE)) {
- executeProcessOperation(operationResult, operationResult.getOperationName(), valueMap);
- } else if (operationResult.getComponentType().equals(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.TYPE)) {
- executeHostOperation(operationResult, operationResult.getOperationName(), valueMap);
- } else if (operationResult.getComponentType().equals(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session.TYPE)) {
- executeSessionOperation(operationResult, operationResult.getOperationName(), valueMap);
- } else if (operationResult.getComponentType().equals(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Queries.TYPE)) {
- executeQueriesOperation(operationResult, operationResult.getOperationName(), valueMap);
- }
- }
-
-
-
- private void executeSystemOperation(ExecutedResult operationResult, final String operationName, final Map valueMap)
- throws ConnectionException {
- Object resultObject = new Object();
-
- if (operationName.equals(Operations.BOUNCE_SYSTEM)) {
- Boolean waitUntilFinished = (Boolean)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.WAIT_UNTIL_FINISHED);
- bounceSystem(waitUntilFinished);
- }else if (operationName.equals(Operations.GET_LONGRUNNINGQUERIES)) {
- Boolean includeSourceQueries = (Boolean)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.INCLUDE_SOURCE_QUERIES);
- Integer longRunningValue = (Integer)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.LONG_RUNNING_QUERY_LIMIT);
- List fieldNameList = operationResult.getFieldNameList();
- resultObject = getLongRunningQueries(includeSourceQueries, longRunningValue, fieldNameList);
- operationResult.setContent((List)resultObject);
- }else if (operationName.equals(ComponentType.Operation.KILL_REQUEST)) {
- String requestID = (String)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.REQUEST_ID);
- cancelRequest(requestID);
- }else if (operationName.equals(ComponentType.Operation.GET_VDBS)) {
- List fieldNameList = operationResult.getFieldNameList();
- resultObject = getVDBs(fieldNameList);
- operationResult.setContent((List)resultObject);
- }else if (operationName.equals(ComponentType.Operation.GET_PROPERTIES)) {
- String identifier = (String)valueMap.get(ConnectionConstants.IDENTIFIER);
- Properties props = getProperties(ConnectionConstants.ComponentType.Runtime.System.TYPE, identifier);
- resultObject = createReportResultList(props);
- operationResult.setContent((List)resultObject);
- }
-
- }
-
- private void executeProcessOperation(ExecutedResult operationResult, final String operationName, final Map valueMap)
- throws ConnectionException {
- Object resultObject = new Object();
-
- if (operationName.equals(ComponentType.Operation.GET_PROPERTIES)) {
- String identifier = (String)valueMap.get(ConnectionConstants.IDENTIFIER);
- Properties props = getProperties(Runtime.Process.TYPE, identifier);
- resultObject = createReportResultList(props);
- operationResult.setContent((List)resultObject);
- }
- }
-
- private void executeHostOperation(ExecutedResult operationResult, final String operationName, final Map valueMap)
- throws ConnectionException {
- Object resultObject = new Object();
-
- if (operationName.equals(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.Operations.GET_HOSTS)) {
- String identifier = (String)valueMap.get(ConnectionConstants.IDENTIFIER);
- Properties props = getProperties(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.TYPE, identifier);
- resultObject = createReportResultList(props);
- operationResult.setContent((List)resultObject);
- }
- }
-
- private void executeConnectorOperation(ExecutedResult operationResult, final String operationName, final Map valueMap)
- throws ConnectionException {
- Object resultObject = new Object();
- String identifier = (String)valueMap.get(ConnectionConstants.IDENTIFIER);
-
- if (operationName.equals(Runtime.Connector.Operations.RESTART_CONNECTOR)) {
- startConnector(identifier);
- }else if (operationName.equals(Runtime.Connector.Operations.STOP_CONNECTOR)) {
- Boolean stopNow = (Boolean)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.STOP_NOW);
- stopConnector(identifier, stopNow);
- }else if (operationName.equals(ComponentType.Operation.GET_PROPERTIES)) {
- Properties props = getProperties(Runtime.Connector.TYPE, identifier);
- resultObject = createReportResultList(props);
- operationResult.setContent((List)resultObject);
- }
- }
-
- private void executeSessionOperation(ExecutedResult operationResult, final String operationName, final Map valueMap)
- throws ConnectionException {
- if (operationName.equals(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session.Query.GET_SESSIONS)) {
- Object resultObject = new Object();
-
- List fieldNameList = operationResult.getFieldNameList();
- resultObject = getSessions(false, fieldNameList);
- operationResult.setContent((List)resultObject);
- }
-
-
- }
-
- private void executeQueriesOperation(ExecutedResult operationResult, final String operationName, final Map valueMap)
- throws ConnectionException {
-
- if (operationName.equals(Query.GET_QUERIES)) {
- Object resultObject = new Object();
-
- // Boolean includeSourceQueries = (Boolean)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.INCLUDE_SOURCE_QUERIES);
- List fieldNameList = operationResult.getFieldNameList();
- resultObject = getRequests(false, fieldNameList);
- operationResult.setContent((List)resultObject);
- }
- }
-
-
- public Object getMetric(String componentType, String identifier, String metric, Map valueMap)
- throws ConnectionException {
- Object resultObject = new Object();
-
- if (componentType.equals(ComponentType.Runtime.System.TYPE)){
- resultObject = getSystemMetric(componentType, metric, valueMap);
- }else if (componentType.equals(Runtime.Process.TYPE)){
- resultObject = getProcessMetric(componentType, identifier, metric, valueMap);
- }
-
-
- return resultObject;
- }
-
- private Object getSystemMetric(String componentType, String metric,
- Map valueMap) throws ConnectionException {
-
- Object resultObject = new Object();
-
- if (metric.equals(Metrics.QUERY_COUNT)) {
- resultObject = new Double(getQueryCount().doubleValue());
- } else {
- if (metric.equals(Metrics.SESSION_COUNT)) {
- resultObject = new Double(getSessionCount().doubleValue());
- } else {
- if (metric.equals(Metrics.LONG_RUNNING_QUERIES)) {
- Integer longRunningQueryLimit = (Integer)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.LONG_RUNNING_QUERY_LIMIT);
- Collection<Request> longRunningQueries = getLongRunningQueries(false, longRunningQueryLimit, null);
- resultObject = new Double(longRunningQueries.size());
- }
- }
- }
-
- return resultObject;
- }
-
-
- private Object getProcessMetric(String componentType, String identifier, String metric,
- Map valueMap) throws ConnectionException {
-
- Object resultObject = new Object();
-
- if (metric.equals(ComponentType.Metric.HIGH_WATER_MARK)) {
- resultObject = new Double(getHighWatermark(identifier));
- }
-
- return resultObject;
- }
-
- public Boolean isAvailable(String componentType, String identifier)
- throws ConnectionException {
-
- try {
-
- Admin conn = this.getConnection();
- if (componentType
- .equalsIgnoreCase(Runtime.Connector.TYPE)) {
- ConnectorBinding cb = ConnectionUtil.getConnector(conn, identifier);
- if (cb.getState() == ConnectorBinding.STATE_OPEN) {
- return true;
- }
-// } else if (componentType
-// .equalsIgnoreCase(Runtime.Service.TYPE)) {
-// Service svc = ConnectionUtil.getService(conn, identifier);
-// if (svc.getState() == Service.STATE_OPEN) {
-// return true;
-// }
-
- } else if (componentType
- .equalsIgnoreCase(Runtime.Process.TYPE)) {
- ProcessObject vm = ConnectionUtil.getProcess(conn, identifier);
- if (vm.isRunning()) {
- return true;
- }
- } else if (componentType
- .equalsIgnoreCase(Runtime.Host.TYPE)) {
- Host host=ConnectionUtil.getHost(identifier, conn);
- if (host.isRunning()) {
- return true;
- }
- } else if (componentType
- .equalsIgnoreCase(Runtime.System.TYPE)) {
- if (conn.getSystem() != null) {
- return true;
- }
- }
- } catch (AdminException ae) {
- invalidConnection = true;
-
- log.error(ae.getMessage());
- }
-
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.metamatrix.admin.api.rhq.connection.Connection#getProperty(java.lang.String,
- * java.lang.String)
- */
- public String getProperty(final String identifier, final String property)
- throws ConnectionException {
-
- String propertyValue = null;
-
-
-// if (identifier.equals(ConnectionConstants.SYSTEM_NAME_IDENTIFIER)) {
-// Resource mmResource = (Resource) getResource(identifier,
-// getConnection());
-// propertyValue = mmResource.getPropertyValue(property);
-// }
-
- return propertyValue;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.metamatrix.admin.api.rhq.connection.Connection#getInstallationDirectory()
- */
- public String getKey() {
- return key;
- }
-
- /**
- * @see org.teiid.rhq.comm.Connection#getHost()
- */
- public Component getHost(String identifier) throws ConnectionException {
-
- try {
-
- return mapHost( ConnectionUtil.getHost(identifier, getConnection()) );
- } catch (AdminException e) {
- invalidConnection = true;
- throw new ConnectionException(e.getMessage());
- }
-
- }
-
- public Collection getAllHosts() throws ConnectionException {
- Collection<Component> hostObjs = null;
-// try {
-// Collection<Host> hosts = getConnection().getHosts("*");
-// hostObjs = new ArrayList(hosts.size());
-//
-// for (Iterator<Host>it=hosts.iterator(); it.hasNext();) {
-// Host h = it.next();
-//
-// ComponentImpl chost = mapHost(h);
-//
-// hostObjs.add(chost);
-// }
-// } catch (AdminException e) {
-// invalidConnection = true;
-// throw new ConnectionException(e.getMessage());
-// }
-
- return hostObjs;
- }
-
- private ComponentImpl mapHost(Host h) throws ConnectionException {
- ComponentImpl chost = createComponent(h);
-
- chost.addProperty(HostComponent.INSTALL_DIR, h.getPropertyValue(Host.HOST_DIRECTORY));
- return chost;
-
- }
-
-
- /**
- * @see org.teiid.rhq.comm.Connection#getHost()
- */
-// public Collection<Component> getServices(String vmIdentifier) throws ConnectionException {
-//
-// try {
-//
-// Collection<Service> servicesCollection = getConnection().getServices(vmIdentifier +"|*");
-//
-// Iterator<Service> iterSvc = servicesCollection.iterator();
-//
-// Collection<Component> svccomponents = new ArrayList<Component>(servicesCollection.size());
-// while (iterSvc.hasNext()) {
-// Service svc = iterSvc.next();
-//
-// Component comp = mapService(svc);
-//
-// svccomponents.add(comp);
-// }
-// return svccomponents;
-//
-// } catch (AdminException e) {
-// invalidConnection = true;
-// throw new ConnectionException(e.getMessage());
-// }
-//
-// }
-//
-
-// public Collection<Component> getServicesForConfig(String identifier)
-// throws ConnectionException {
-// try {
-//
-// Collection<Service> servicesCollection = getConnection().getServicesToConfigure(identifier);
-//
-// Iterator<Service> iterSvc = servicesCollection.iterator();
-//
-// Collection<Component> svccomponents = new ArrayList<Component>(servicesCollection.size());
-// while (iterSvc.hasNext()) {
-// Service svc = iterSvc.next();
-//
-// Component comp = mapService(svc);
-//
-// svccomponents.add(comp);
-// }
-// return svccomponents;
-//
-// } catch (AdminException e) {
-// invalidConnection = true;
-// throw new ConnectionException(e.getMessage());
-// }
-//
-// }
-
- public Collection<Component> getVMs(String hostIdentifier) throws ConnectionException {
-
- try {
-
- Collection processes = getConnection().getProcesses(hostIdentifier + "|*");
-
- Iterator<ProcessObject> iterVMs = processes.iterator();
- log.info("Processing processes..."); //$NON-NLS-1$
-
- Collection vmcomponents = new ArrayList(processes.size());
- while (iterVMs.hasNext()) {
- // ProcessObject processObject = iterHostProcesses.next();
- ProcessObject vm = iterVMs.next();
-
- Component comp = mapProcess(vm);
-
- vmcomponents.add(comp);
- }
-
- return vmcomponents;
- } catch (AdminException ae) {
- invalidConnection = true;
- throw new ConnectionException(ae.getMessage());
-
- }
- }
-
- private Component mapProcess(ProcessObject vm) throws ConnectionException {
- if (vm == null) return null;
-
- ComponentImpl comp = createComponent(vm);
- comp.setPort(vm.getPropertyValue(ProcessObject.SERVER_PORT));
-
- return comp;
-
- }
-
- /**
- * @see com.metamatrix.rhq.comm.Connection#getVMs()
- */
-// public Collection<Component> getVMs() throws ConnectionException {
-//
-// return getVMs(this.getHost().getIdentifier());
-//
-// }
-
- /**
- * Returns a collection of all VDBs in the system.
- * @param fieldNameList - operaration result fields if required. May be null.
- *
- * @return Collection
- */
- public Collection getVDBs(List fieldNameList)
- throws ConnectionException {
-
- Collection vdbCollection = Collections.EMPTY_LIST;
-
- try {
-
- vdbCollection = getConnection().getVDBs("*");
- } catch (AdminException ae) {
- invalidConnection = true;
- throw new ConnectionException(ae.getMessage());
-
- }
-
- if (fieldNameList != null) {
- Collection reportResultCollection = createReportResultList(
- fieldNameList, vdbCollection.iterator());
- return reportResultCollection;
- } else {
- return vdbCollection;
- }
- }
-
-
-
-// public Collection<Component> getConnectorsForConfig(String identifier)
-// throws ConnectionException {
-//
-// Collection<Component> connectors = Collections.EMPTY_LIST;
-//
-// try {
-// Collection connectorsCollection = getConnection().getConnectorBindingsToConfigure(identifier);
-//
-// Iterator<ConnectorBinding> iterConnectors = connectorsCollection.iterator();
-// log.info("Getting connector bindings for configuration...");//$NON-NLS-1$
-//
-// while (iterConnectors.hasNext()) {
-// // ProcessObject processObject = iterHostProcesses.next();
-// ConnectorBinding connectorBinding = iterConnectors.next();
-//
-// log.debug("Found connector binding " + connectorBinding.getName());//$NON-NLS-1$
-//
-// Component comp = mapConnector(connectorBinding);
-//
-// connectors.add(comp);
-// }
-// return connectors;
-// } catch (AdminException e) {
-// invalidConnection = true;
-// throw new ConnectionException(e.getMessage());
-// }
-//
-// }
-
- public Collection<Component> getConnectors(String vmIdentifier) throws ConnectionException {
-
- Collection<Component> connectors = Collections.EMPTY_LIST;
- try {
-
- Collection mmConnectors = getConnection().getConnectorBindings(vmIdentifier +"|*");
-
- connectors = new ArrayList(mmConnectors != null ? mmConnectors
- .size() : 0);
-
- Iterator<ConnectorBinding> iterConnectors = mmConnectors.iterator();
- log.info("Processing connector bindings...");//$NON-NLS-1$
-
- while (iterConnectors.hasNext()) {
- // ProcessObject processObject = iterHostProcesses.next();
- ConnectorBinding connectorBinding = iterConnectors.next();
-
- log
- .info("Found connector binding " + connectorBinding.getName());//$NON-NLS-1$
-
- Component comp = mapConnector(connectorBinding);
-
- connectors.add(comp);
- }
- } catch (AdminException ae) {
- invalidConnection = true;
- throw new ConnectionException(ae.getMessage());
- }
- return connectors;
- }
-
- private Component getConnector(String connectorIdentifier) throws ConnectionException {
-
-
- try {
- ConnectorBinding connectorBinding = ConnectionUtil.getConnector(getConnection(), connectorIdentifier);
- return mapConnector(connectorBinding);
-
- } catch (AdminException ae) {
- invalidConnection = true;
- throw new ConnectionException(ae.getMessage());
- }
- }
-
-// private Component getService(String svcIdentifier) throws ConnectionException {
-//
-//
-// try {
-// Service svc = ConnectionUtil.getService(getConnection(), svcIdentifier);
-// return mapService(svc);
-//
-// } catch (AdminException ae) {
-// invalidConnection = true;
-// throw new ConnectionException(ae.getMessage());
-// }
-//}
-
- private Component mapConnector(ConnectorBinding connectorBinding) throws ConnectionException {
- ComponentImpl comp = createComponent(connectorBinding);
-
- comp.setDescription(connectorBinding.getDescription());
-
- return comp;
-
- }
-
-// private Component mapService(Service service) throws ConnectionException {
-// ComponentImpl comp = createComponent(service);
-//
-// comp.setDescription(service.getDescription());
-//
-// return comp;
-//
-// }
-
- private Component mapSession(Session session) throws ConnectionException {
- ComponentImpl comp = null;
-
- try {
- Class clzz = Class.forName(ComponentImpl.class.getName(), true, this.connectionPool.getClassLoader());
- comp = (ComponentImpl) clzz.newInstance();
-
- comp.setIdentifier(session.getIdentifier());
- comp.setName(session.getSessionID());
- comp.setSystemKey(getKey());
- comp.setVersion("1.0"); //$NON-NLS-1$
-
- comp.setProperties(session.getProperties());
-
-
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new ConnectionException(e.getMessage());
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new ConnectionException(e.getMessage());
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new ConnectionException(e.getMessage());
- }
- return comp;
-
-
- }
-
- // *******************
- // Support Methods
- // *******************
-
- public Boolean isSystemAvailable() throws ConnectionException {
-
- return this.isAlive();
-
- }
-
- private String getSystemName(final Admin adminApi) throws ConnectionException {
- return "NoSystemName";
-// Resource mmJGroups = (Resource) getResource("JGroups", adminApi); //$NON-NLS-1$
-// return mmJGroups.getPropertyValue(SYSTEM_NAME_PROPERTY);
- }
-
-
- /**
- * @throws Exception
- */
- // static
-// private Integer getQueuedThreadCount(Admin adminApi) throws Exception {
-//
-// ProcessObject process = ConnectionUtil.getProcess(getConnection(), processIdentifier);
-//
-// return process.getQueueWorkerPool().getQueued();
-//
-// }
-
- /**
- * @throws Exception
- */
- private void startConnector(final String connectorBindingIdentifier) throws ConnectionException {
- try {
- (getConnection())
- .startConnectorBinding(connectorBindingIdentifier);
- } catch (AdminException ae) {
- invalidConnection = true;
- throw new ConnectionException(ae.getMessage());
-
- }
- }
-
- /**
- * @throws Exception
- */
- private void bounceSystem(final boolean waitUntilFinished) throws ConnectionException {
- try {
- getConnection().restart();
- } catch (AdminException err) {
- throw new ConnectionException(err.getMessage());
- }
- }
-
- /**
- * @throws Exception
- */
- private void stopConnector(String connectorBindingIdentifier, boolean hardStop)
- throws ConnectionException {
- try {
- getConnection().stopConnectorBinding(
- connectorBindingIdentifier, hardStop);
- } catch (AdminException ae) {
- invalidConnection = true;
- throw new ConnectionException(ae.getMessage());
-
- }
- }
-
- /**
- * @throws Exception
- */
- private static boolean isReachable(final String host, int port)
- throws UnknownHostException {
- return NetUtils.getInstance().isPortAvailable(host, port);
- }
-
- /**
- * @throws Exception
- */
- // static
-// private Integer getThreadPoolThreadCount(final Admin adminApi)
-// throws ConnectionException {
-// Integer threadCount = new Integer(0);
-//
-// ProcessObject process = ConnectionUtil.getProcess(getConnection(), processIdentifier);
-//
-// QueueWorkerPool pool = null;
-// pool = process.getQueueWorkerPool();
-// threadCount = pool.getThreads();
-// return threadCount;
-// }
-
- private Integer getQueryCount() throws ConnectionException {
-
- Integer count = new Integer(0);
-
- Collection<Request> requestsCollection = null;
- requestsCollection = getRequests(false, null);
-
- if (requestsCollection != null && !requestsCollection.isEmpty()) {
- count = requestsCollection.size();
- }
-
- return count;
- }
-
- protected Collection<Request> getRequests(boolean includeSourceQueries, List fieldNameList) throws ConnectionException {
-
- Collection<Request> requestsCollection = null;;
-
- try {
- Admin conn = getConnection();
- requestsCollection = conn.getRequests(WILDCARD);
- if (includeSourceQueries){
- Collection<Request> sourceRequestsCollection = Collections.EMPTY_LIST;
- sourceRequestsCollection = conn.getSourceRequests(WILDCARD);
- requestsCollection.addAll(sourceRequestsCollection);
- }
- } catch (AdminException ae) {
- invalidConnection = true;
- throw new ConnectionException(ae.getMessage());
-
- } catch (Exception e) {
- final String msg = "Exception getting the AdminApi in getRequests: "; //$NON-NLS-1$
- log.error(msg, e);
- throw new ConnectionException(msg);
- }
-
- if (fieldNameList!=null){
- Collection reportResultCollection = createReportResultList(fieldNameList, requestsCollection.iterator());
- return reportResultCollection;
- }else{
- return requestsCollection;
- }
-
- }
-
- protected void cancelRequest(String requestID) throws ConnectionException {
-
- try {
- getConnection().cancelRequest(requestID);
- } catch (AdminException ae) {
- invalidConnection = true;
- throw new ConnectionException(ae.getMessage());
-
- } catch (Exception e) {
- final String msg = "Exception getting the AdminApi in getRequests: "; //$NON-NLS-1$
- log.error(msg, e);
- throw new ConnectionException(msg);
- }
-
- }
-
-// public Collection<Request> postProcessing(String operationName, Collection reportResultCollection) throws ConnectionException {
-//
-// if (operationName.equals(ConnectionConstants.ComponentType.Operation.GET_QUERIES)){
-// Iterator resultIter = reportResultCollection.iterator();
-// while (resultIter.hasNext()){
-// Map row = (Map)resultIter.next();
-// String createDateString = row.get("Createdate");
-// Date createDate = new Date(createDateString);
-//
-// Date current = new Date(System.nanoTime());
-// GregorianCalendar cal = new GregorianCalendar();
-// cal.add()
-// Date elapsedTime = Calendar.getInstance().add( createDate)
-// }
-// String createDateString = reportResultList.
-// }
-// return reportResultList;
-// }
-
- protected Collection<Request> getLongRunningQueries(boolean includeSourceQueries, int longRunningValue, List fieldNameList) throws ConnectionException {
-
- Collection<Request> requestsCollection = null;
-
- double longRunningQueryTimeDouble = new Double(longRunningValue);
-
- try {
- requestsCollection = getRequests(includeSourceQueries, null);
- } catch (Exception e) {
- final String msg = "AdminException getting the AdminApi in getLongRunningQueries: "; //$NON-NLS-1$
- log.error(msg, e);
- throw new ConnectionException(msg);
- }
-
- Iterator<Request> requestsIter = requestsCollection.iterator();
- while (requestsIter.hasNext()) {
- Request request = requestsIter.next();
- Date startTime = request.getProcessingDate();
- // Get msec from each, and subtract.
- long runningTime = Calendar.getInstance().getTimeInMillis() - startTime.getTime();
-
- if (runningTime < longRunningQueryTimeDouble) {
- requestsIter.remove();
- }
- }
-
- if (fieldNameList!=null){
- Collection reportResultCollection = createReportResultList(fieldNameList, requestsCollection.iterator());
- return reportResultCollection;
- }else{
- return requestsCollection;
- }
- }
-
- private Integer getSessionCount() throws ConnectionException {
-
- Collection<Session> activeSessionsCollection = Collections.EMPTY_LIST;
- try {
- activeSessionsCollection = getActiveSessions();
- } catch (AdminException ae) {
- invalidConnection = true;
- throw new ConnectionException(ae.getMessage());
-
- } catch (Exception e) {
- final String msg = "AdminException getting the AdminApi in getSessionCount: "; //$NON-NLS-1$
- log.error(msg, e);
- throw new ConnectionException(e.getMessage());
- }
-
- return activeSessionsCollection.size();
- }
-
- private Collection<Session> getActiveSessions(String identifier) throws AdminException {
- Collection allSessionsCollection = getConnection().getSessions(identifier);
- Collection activeSessionsCollection = new ArrayList();
-
- Iterator<Session> allSessionsIter = allSessionsCollection
- .iterator();
- while (allSessionsIter.hasNext()) {
- Session session = allSessionsIter.next();
- if (session.getState() == MetaMatrixSessionState.ACTIVE) {
- activeSessionsCollection.add(session);
- }
- }
-
- return activeSessionsCollection;
- }
-
- private Collection<Session> getActiveSessions() throws AdminException {
- Collection allSessionsCollection = getConnection().getSessions(WILDCARD);
- Collection activeSessionsCollection = new ArrayList();
-
- Iterator<Session> allSessionsIter = allSessionsCollection
- .iterator();
- while (allSessionsIter.hasNext()) {
- Session session = allSessionsIter.next();
- if (session.getState() == MetaMatrixSessionState.ACTIVE) {
- activeSessionsCollection.add(session);
- }
- }
-
- return activeSessionsCollection;
- }
-
- public Collection getSessions(boolean activeOnly, List fieldNameList) throws ConnectionException {
-
- Collection sessionsCollection = Collections.EMPTY_LIST;
- try {
- if (activeOnly){
- sessionsCollection = getActiveSessions();
- }else{
- sessionsCollection = getConnection().getSessions(WILDCARD);
- }
- } catch (AdminException ae) {
- invalidConnection = true;
- throw new ConnectionException(ae.getMessage());
-
- } catch (Exception e) {
- final String msg = "AdminException getting the AdminApi in getSessions: "; //$NON-NLS-1$
- log.error(msg, e);
- throw new ConnectionException(e.getMessage());
- }
-
- if (sessionsCollection != null && sessionsCollection.size() > 0) {
- Iterator sessionsIter = sessionsCollection.iterator();
-
- return createReportResultList(fieldNameList, sessionsIter);
- }
-
- return Collections.EMPTY_LIST;
- }
-
- private Collection createReportResultList(Properties props) {
- Collection reportResultList = new ArrayList();
-
- //Create list from properties and sort
- Enumeration<Object> keys = props.keys();
- List<String> elementList = new ArrayList();
- while (keys.hasMoreElements()) {
- elementList.add((String) keys.nextElement());
- }
-
- Collections.sort(elementList);
-
- Iterator propsKeySetIter = elementList.iterator();
-
- while (propsKeySetIter.hasNext()) {
- Map reportValueMap = new HashMap();
- String name = (String)propsKeySetIter.next();
- Object value = props.get(name);
- reportValueMap.put(ConnectionConstants.ComponentType.Operation.Value.NAME, name);
- reportValueMap.put(ConnectionConstants.ComponentType.Operation.Value.VALUE, value);
- reportResultList.add(reportValueMap);
- }
- return reportResultList;
- }
-
- private Collection createReportResultList(List fieldNameList, Iterator sessionsIter) {
- Collection reportResultList = new ArrayList();
-
- while (sessionsIter.hasNext()) {
- Object object = sessionsIter.next();
-
- Class cls = null;
- try {
- cls = object.getClass();
- Iterator methodIter = fieldNameList.iterator();
- Map reportValueMap = new HashMap();
- while (methodIter.hasNext()) {
- String fieldName = (String) methodIter.next();
- String methodName = fieldName;
- Method meth = cls.getMethod(methodName, (Class[]) null);
- Object retObj = meth.invoke(object, (Object[]) null);
- reportValueMap.put(fieldName, retObj);
- }
- reportResultList.add(reportValueMap);
- } catch (Throwable e) {
- System.err.println(e);
- }
- }
- return reportResultList;
- }
-
- private Integer getHighWatermark(String processIdentifier) throws ConnectionException {
-
- try {
-
- ProcessObject process = ConnectionUtil.getProcess(getConnection(), processIdentifier);
- QueueWorkerPool pool = null;
- pool = process.getQueueWorkerPool();
- return pool.getTotalHighwaterMark();
-
- } catch (AdminException e) {
- // TODO Auto-generated catch block
- throw new ConnectionException(e.getMessage());
-
- }
-
- }
-
- /**
- * @param resourcePrefix
- * @return
- */
-// private Object getResource(final String resourceIdentifier,
-// final Admin adminApi) throws ConnectionException {
-//
-// Object resource = null;
-// try {
-//
-// Collection<Object> resourceCollection = getConnection()adminApi
-// .getResources(resourceIdentifier);
-// // Collection<Object> processCollection = ((ServerMonitoringAdmin)
-// // adminApi)
-// // .getProcesses(AdminObject.WILDCARD);
-// Iterator<Object> resourceIter = resourceCollection.iterator();
-//
-// while (resourceIter.hasNext()) {
-// resource = resourceIter.next();
-// }
-// } catch (AdminException ae) {
-// invalidConnection = true;
-// throw new ConnectionException(ae.getMessage());
-//
-//
-// } catch (Exception e) {
-// final String msg = "LogonException getting the AdminApi in getResource: "; //$NON-NLS-1$
-// log.error(msg, e);
-// }
-//
-// return resource;
-// }
-
-
- /**
- * @param resourcePrefix
- * @return
- */
- private Component getProcess(final String processIdentifier) throws ConnectionException {
-
- ProcessObject process = null;
- try {
-
- process = ConnectionUtil.getProcess(getConnection(), processIdentifier);
-
- return mapProcess(process);
-
- } catch (Exception e) {
- final String msg = "AdminException in getProcess: "; //$NON-NLS-1$
- log.error(msg, e);
- throw new ConnectionException(e.getMessage());
- }
-
- }
-
- /**
- * Return the properties for component of a specified resource type
- * @param resourceType
- * @param identifier
- * @return
- * @throws ConnectionException
- * @since 5.5.3
- */
-
- public Properties getProperties(String resourceType, String identifier)
- throws ConnectionException {
- String className = null;
- Component ao = null;
- if (resourceType.equalsIgnoreCase(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.TYPE) ) {
- className = Host.class.getName();
- ao = this.getHost(identifier);
-
- } else if (resourceType.equalsIgnoreCase(ConnectionConstants.ComponentType.Runtime.System.TYPE) ) {
- className = SystemObject.class.getName();
-
-
- } else if (resourceType.equalsIgnoreCase(Runtime.Process.TYPE) ) {
- className = ProcessObject.class.getName();
-
- ao = this.getProcess(identifier);
-
- } else if (resourceType.equalsIgnoreCase(Runtime.Connector.TYPE) ) {
- className = ConnectorBinding.class.getName();
-
- ao = this.getConnector(identifier);
-// } else if (resourceType.equalsIgnoreCase(Runtime.Service.TYPE) ) {
-// className = Service.class.getName();
-//
-// ao = this.getService(identifier);
- }
-
- if (ao == null) {
- throw new ConnectionException("Unable to get properties for invalid resource " + identifier + " of resource type " + resourceType); //$NON-NLS-1$
- }
-
- Properties props = null;
- try {
- Map defaults = ConnectionUtil.getPropertiesDefinitions(getConnection(), resourceType, className, identifier);
-
- props = new Properties();
- props.putAll(defaults);
-
- // overlay the defined properties for the component object over the defaults
- props.putAll(ao.getProperties());
- } catch (AdminException ae) {
- invalidConnection = true;
- throw new ConnectionException(ae.getMessage());
-
- }
-
- return props;
-
- }
- /*
-
- /**
- * Returns the system name for the current connection
- *
- * @param componentName
- * @param operationName
- * @param parameters
- * @return systemName
- */
-// private String getProperty() throws Exception {
-//
-// String systemName = "NoSystemName";
-
-
-// Resource mmJGroups = (Resource) getResource("JGroups", getConnection()); //$NON-NLS-1$
-// systemName = mmJGroups.getPropertyValue("metamatrix.cluster.name"); //$NON-NLS-1$
-//
-// return systemName;
-//
-// }
-
- private Admin getConnection() {
- return adminApi;
-
-
- }
-
- private ComponentImpl createComponent(AdminObject object) throws ConnectionException {
- if (object != null) {
- return createComponent(object.getIdentifier(), object.getName(), object.getProperties());
- }
- return createComponent("NOTSET", "NAMENOTSET", null);
-
-
-
- }
-
-
- private ComponentImpl createComponent(String identifier, String name, Properties props) throws ConnectionException {
-
- ComponentImpl comp = null;
- try {
- Class clzz = Class.forName(ComponentImpl.class.getName(), true, this.connectionPool.getClassLoader());
- comp = (ComponentImpl) clzz.newInstance();
-
- comp.setIdentifier(identifier);
- comp.setName(name);
- comp.setSystemKey(getKey());
- comp.setVersion("1.0"); //$NON-NLS-1$
-
- if (props != null) {
- comp.setProperties(props);
- }
-
-
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new ConnectionException(e.getMessage());
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new ConnectionException(e.getMessage());
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new ConnectionException(e.getMessage());
- }
- return comp;
-
- }
-
-
-}
Deleted: trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionUtil.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionUtil.java 2009-11-20 20:30:31 UTC (rev 1581)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionUtil.java 2009-11-20 22:26:31 UTC (rev 1582)
@@ -1,341 +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.rhq.comm.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.ConnectorBinding;
-import org.teiid.adminapi.Host;
-import org.teiid.adminapi.ProcessObject;
-import org.teiid.adminapi.PropertyDefinition;
-import org.teiid.adminapi.Service;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Process;
-
-
-/**
- * @since 4.3
- */
-public class ConnectionUtil implements TeiidConnectionConstants {
-
- private static Map<String, Map<String, Object>> defCache = new HashMap<String, Map<String, Object>>();
-
- /**
- * Call to find a host. The hostName passed in can be any of the
- * the following:
- * <li>The fully qualified host name</li>
- * <li>The short name of the fully qualified host name</li>
- * <li>The IP address of box</li>
- * <li>The bind address defined in the host properties</li>
- * <li>The general reference of localhost</li>
- *
- * The order of resolution will be as follows:
- * 1. Try to match the IPAddress resolved host names to what is configured.
- * <li>hostName matches to configured host name</li>
- * <li>resolve hostName to an InetAddress and use its' full host name to match configured host(s)</li>
- * <li>resolve hostName to an InetAddress and use its' short host name to match configured host(s)</li>
- * <li>In cases where the <code>hostName</code> represents the short name and will not resolve to a longer name,
- * convert the <code>Host</code> full name to the short name to try to match.</li>
- * <li>match hostname to the physical address for a configurated host</li>
- * <li>match hostname to the bindaddress for a configurated host</li>
- * 2. Reverse the match, try matching what's configurated to host name passed
- * <li>try using the short name of configured host to match</li>
- * <li>try using the physical address of the configurated host match</li>
- * <li>try using the bind address of the configured host to match</li>
- *
- * NOTE: This logic is duplicated from the CurrentConfiguration.findHost(). That method could not
- * be used due to the different <code>Host</code> object types that are used.
- *
- * @param hostName
- * @return Host
- * @throws Exception
- * @since 5.5
- */
-// public static Host findHost(String hostName, ServerAdmin adminapi) throws AdminException {
-//
-// Host h = null;
-//
-// try {
-// // first try to match the name pas host by what was passed before
-// // substituting something else
-// h = getHost(hostName, adminapi);
-// if (h != null) {
-// return h;
-// }
-//
-// h = getHost(InetAddress.getLocalHost().getHostName(), adminapi);
-// if (h != null) {
-// return h;
-// }
-//
-//
-// // the hostName could be an IP address that we'll use to try to
-// // resolve back to the actuall host name
-// InetAddress inetAddress = InetAddress.getByName(hostName);
-//
-// // try using the fully qualified host name
-//
-// h = getHost(inetAddress.getCanonicalHostName(), adminapi);
-// if (h != null) {
-// return h;
-// }
-//
-// h = getHost(inetAddress.getHostName(), adminapi);
-// if (h != null) {
-// return h;
-// }
-//
-// // try the address
-// h = getHost(inetAddress.getHostAddress(), adminapi);
-//
-// if (h != null) {
-// return h;
-// }
-// } catch (AdminException ae) {
-// throw ae;
-// } catch (Exception e) {
-// // do nothing
-// }
-//
-//
-//
-// // 2nd try to match
-// try {
-// Collection hosts = getAllHosts(adminapi);
-// // if the host name passed in is the short name,
-// // then try to match to the Host short name
-//
-// Iterator hi = hosts.iterator();
-//
-// while (hi.hasNext()) {
-//
-// String hostAddress = h.getPropertyValue(Host.HOST_PHYSICAL_ADDRESS);
-//
-// if (hostAddress != null && hostAddress.equalsIgnoreCase(hostName)) {
-// return h;
-// }
-// String hostBindAddress = h.getPropertyValue(Host.HOST_BIND_ADDRESS);
-//
-// if (hostBindAddress.equalsIgnoreCase(hostName)) {
-// return h;
-// }
-//
-//
-// }
-//
-// } catch (AdminException ae) {
-// throw ae;
-// } catch (Exception e) {
-// // do nothing
-// }
-//
-//
-// return null;
-//
-// }
-
- /**
- * Called to return only 1 host
- * @param hostName
- * @param adminapi
- * @return
- * @throws AdminException
- * @since 4.3
- */
- public static Host getHost(String hostIdentifier, Admin adminapi) throws AdminException {
- // Configuring and monitoring will no longer be done thru a single connection.
- // each host will be managed seperately
-
-
-// Collection hosts = adminapi.getHosts(hostIdentifier);
-//
-// if (hosts != null && hosts.size() == 1) {
-// // return the unique host by the hostName
-// return (Host) hosts.iterator().next();
-// }
- // return null if no hosts were found or
- // multiple hosts were found by that name.
- return null;
- }
-
- /**
- * Called to return all the currently defined hosts
- * @param adminapi
- * @return
- * @throws AdminException
- * @since 4.3
- */
-// public static Collection getAllHosts(Admin adminapi) throws AdminException {
-//
-// return adminapi.getHosts("*"); //$NON-NLS-1$
-// }
-
-
- /**
- * @param adminApi is the connection to the MM Server
- * @return Collection of MMProcesses
- */
-// public static Collection getAllProcesses(final Admin adminApi, String identifier) throws AdminException {
-//
-// Collection processCollection = Collections.EMPTY_LIST;
-//
-// processCollection = adminApi.getProcesses(identifier + "|*"); //$NON-NLS-1$
-//
-// return processCollection;
-// }
-
- public static ProcessObject getProcess(final Admin adminApi, String processIdentifier) throws AdminException {
-
- Collection processCollection = adminApi.getProcesses(processIdentifier);
-
- if (processCollection != null && processCollection.size() == 1) {
- // return the unique connector binding
- return (ProcessObject) processCollection.iterator().next();
- }
-
- return null;
- }
-
- /**
- * @param adminApi is the connection to the MM Server
- * @return Collection of MMProcesses
- */
-// public static Collection getAllConnectors(final Admin adminApi, String vmIdentifier) throws AdminException {
-//
-// Collection connectorCollection = Collections.EMPTY_LIST;
-//
-// connectorCollection = adminApi.getConnectorBindings(vmIdentifier +"|*");
-//
-//
-// return connectorCollection;
-// }
-
- public static ConnectorBinding getConnector(final Admin adminApi, String cbIdentifier) throws AdminException {
-
- Collection connectorCollection = adminApi.getConnectorBindings(cbIdentifier);
-
- if (connectorCollection != null && connectorCollection.size() == 1) {
- // return the unique connector binding
- return (ConnectorBinding) connectorCollection.iterator().next();
- }
-
- return null;
- }
-
- public static Service getService(final Admin adminApi, String svcIdentifier) throws AdminException {
-
-// Collection svcCollection = adminApi.getServices(svcIdentifier);
-//
-// if (svcCollection != null && svcCollection.size() == 1) {
-// // return the unique connector binding
-// return (Service) svcCollection.iterator().next();
-// }
-
- return null;
- }
-
-
- /**
- * @param adminApi is the connection to the MM Server
- *
- * @return Collection of VDBs
- */
-// public static Collection getAllVDBs(final Admin adminApi) throws AdminException {
-//
-// Collection connectorCollection = Collections.EMPTY_LIST;
-//
-// connectorCollection = adminApi.getVDBs("*"); //$NON-NLS-1$
-//
-// return connectorCollection;
-// }
-
- /*
- * Return the tokens in a string in a list. This is particularly
- * helpful if the tokens need to be processed in reverse order. In that case,
- * a list iterator can be acquired from the list for reverse order traversal.
- *
- * @param str String to be tokenized
- * @param delimiter Characters which are delimit tokens
- * @return List of string tokens contained in the tokenized string
- */
- public static List getTokens(String str, String delimiter) {
- ArrayList l = new ArrayList();
- StringTokenizer tokens = new StringTokenizer(str, delimiter);
- while(tokens.hasMoreTokens()) {
- l.add(tokens.nextToken());
- }
- return l;
- }
-
-
- public static synchronized Map getPropertiesDefinitions(final Admin adminApi, String resourceType, String className, String identifier) throws AdminException, ConnectionException {
- Properties result = new Properties();
-
- boolean cache = false;
- if ( resourceType.equalsIgnoreCase(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.TYPE) ||
- resourceType.equalsIgnoreCase(Process.TYPE) ) {
- cache = true;
-
- if (defCache.containsKey(className)) {
- return defCache.get(className);
- }
- }
-
-
- Collection pdefs = adminApi.getPropertyDefinitions(identifier, className);
-
- Map<String, Object> defMap = new HashMap<String, Object>();
-
- for (Iterator it=pdefs.iterator(); it.hasNext();) {
- PropertyDefinition pdef = (PropertyDefinition)it.next();
- Object value = pdef.getValue() != null ? pdef.getValue() : pdef.getDefaultValue();
- defMap.put(pdef.getName(), (value != null ? value : "")); //$NON-NLS-1$
-
- }
-
- if (cache) {
- defCache.put(className, defMap);
- }
-
-
- return defMap;
- }
-
- static class InvalidAdminException extends Throwable {
-
- public InvalidAdminException(String msg) {
- super(msg);
- }
-
- }
-
-
-}
Deleted: trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionFactory.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionFactory.java 2009-11-20 20:30:31 UTC (rev 1581)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionFactory.java 2009-11-20 22:26:31 UTC (rev 1582)
@@ -1,248 +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.rhq.comm.impl;
-
-/*
- * The connection factory implementation is located here so that a new version
- * of MetaMatrix that has different connection requirements can be dealt
- * with on a per MM Version.
- */
-
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.teiid.adminapi.Admin;
-import org.teiid.jdbc.TeiidDriver;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionConstants;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionFactory;
-import org.teiid.rhq.comm.ConnectionPool;
-
-import com.metamatrix.common.comm.platform.client.ServerAdminFactory;
-import com.metamatrix.common.jdbc.JDBCUtil;
-import com.metamatrix.jdbc.MMConnection;
-
-
-
-public class TeiidConnectionFactory implements
- ConnectionFactory {
- private static final Log LOG = LogFactory.getLog(TeiidConnectionFactory.class);
-
- private Properties connEnv;
- private ConnectionPool pool;
- private String username = null;
- private String password = null;
- private String url = null;
-
- public TeiidConnectionFactory() {
-
- }
-
- public String getURL() {
- return url;
- }
-
- public Connection createConnection() throws ConnectionException {
-
- Thread currentThread = Thread.currentThread();
- ClassLoader threadContextLoader = currentThread.getContextClassLoader();
- try {
- currentThread.setContextClassLoader(pool.getClassLoader());
-
- MMConnection mmconn = getConnection();
-
- if (mmconn != null) {
- ConnectionImpl conn = new ConnectionImpl(url, connEnv, pool, mmconn);
- if (conn.isAlive()) {
- return conn;
- }
-
- conn.closeSource();
- }
-
- return new InvalidConnectionImpl(url, connEnv, pool);
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- throw new ConnectionException(e);
- } finally {
- currentThread.setContextClassLoader(threadContextLoader);
- }
-
-
- }
-
-
- public void initialize( final Properties env, final ConnectionPool connectionPool) throws ConnectionException {
- this.connEnv = (Properties) env.clone();
- this.pool = connectionPool;
-
-
- if (pool == null || connEnv == null || connEnv.isEmpty()) {
- throw new ConnectionException("ConnectionFactory has not been initialized properly"); //$NON-NLS-1$
- }
-
-
- url = connEnv.getProperty(ConnectionConstants.URL);
- username = connEnv
- .getProperty(ConnectionConstants.USERNAME);
- password = connEnv
- .getProperty(ConnectionConstants.PASSWORD);
-
-
- if (url == null ) {
- throw new ConnectionException("URL is not set"); //$NON-NLS-1$
-
- }
- if (username == null ) {
- throw new ConnectionException("USERNAME is not set"); //$NON-NLS-1$
-
- }
- if (password == null ) {
- throw new ConnectionException("PASSWORD is not set"); //$NON-NLS-1$
-
- }
- }
-
-
- /**
- * @see org.teiid.rhq.comm.ConnectionFactory#closeConnection(org.teiid.rhq.comm.Connection)
- */
- public void closeConnection(Connection connection) {
- if (connection instanceof ConnectionImpl) {
- ConnectionImpl conn = (ConnectionImpl) connection;
- conn.closeSource();
- } else {
-
- connection.close();
- }
- }
-
- private MMConnection getConnection() {
- MMConnection conn = null;
- Throwable firstexception = null;
-
- try {
- Properties props = new Properties();
- props.setProperty(JDBCUtil.DATABASE, url);
- props.setProperty(JDBCUtil.DRIVER, TeiidDriver.class.getName());
- props.setProperty(JDBCUtil.USERNAME, username);
- props.setProperty(JDBCUtil.PASSWORD, password);
-
- conn = (MMConnection) JDBCUtil.createJDBCConnection(props);
-
-
- return conn;
- } catch (Throwable ce) {
- if (firstexception == null) {
- firstexception = ce;
- }
- }
-
- if (firstexception != null) {
- firstexception.printStackTrace();
- LOG.error("Unable to connect to JBEDSP System: " + firstexception.getMessage()); //$NON-NLS-1$
- }
-
- return null;
- }
-
- /**
- * @param userName
- * @param password
- * @param servers
- * @return Admin
- * @throws Exception,
- * AdminException
- * @since 5.5.3
- */
-// private Admin getAdminAPI(String pusername, String ppassword, String purl)
-// throws Exception {
-//
-// String servers = null;
-//
-// com.metamatrix.common.comm.platform.client.ServerAdminFactory factory = null;
-//
-// Admin serverAdmin = null;
-//
-// try {
-// factory = ServerAdminFactory.getInstance();
-//
-// serverAdmin = factory.createAdmin(pusername, ppassword.toCharArray(),
-// purl, "RHQ"); //$NON-NLS-1$
-//
-// } catch (Throwable ae) {
-// if (ae instanceof MetaMatrixRuntimeException) {
-// Throwable child = ((MetaMatrixRuntimeException) ae).getChild();
-// if (child.getMessage().indexOf("Read timed out") > 0) { //$NON-NLS-1$
-// try {
-//
-// System.setProperty("com.metamatrix.ssl.trustStore", key + "/client/metamatrix.truststore"); //$NON-NLS-1$ //$NON-NLS-2$
-// servers = MMConnectionConstants.SSL_PROTOCOL + iNetAddress.getHostName() + ":" + pport; //$NON-NLS-1$
-// serverAdmin = factory.createAdmin(pusername, ppassword.toCharArray(),
-// servers, "RHQ");//$NON-NLS-1$
-// } catch (Exception ae2) {
-// throw ae;
-// }
-// } else {
-// throw ae;
-// }
-// } else {
-// throw new Exception(ae.getMessage());
-// }
-
-// }
-// LOG.info("Connected to JBEDSP Server using " + servers); //$NON-NLS-1$
-//
-// this.url = purl;
-//
-// return serverAdmin;
-// }
-
-
-
- /*
- * Return the tokens in a string in a list. This is particularly
- * helpful if the tokens need to be processed in reverse order. In that case,
- * a list iterator can be acquired from the list for reverse order traversal.
- *
- * @param str String to be tokenized
- * @param delimiter Characters which are delimit tokens
- * @return List of string tokens contained in the tokenized string
- */
- private static List getTokens(String str, String delimiter) {
- ArrayList l = new ArrayList();
- StringTokenizer tokens = new StringTokenizer(str, delimiter);
- while(tokens.hasMoreTokens()) {
- l.add(tokens.nextToken());
- }
- return l;
- }
-
-
-
-}
Modified: trunk/console/src/resources/embedded/META-INF/rhq-plugin.xml
===================================================================
--- trunk/console/src/resources/embedded/META-INF/rhq-plugin.xml 2009-11-20 20:30:31 UTC (rev 1581)
+++ trunk/console/src/resources/embedded/META-INF/rhq-plugin.xml 2009-11-20 22:26:31 UTC (rev 1582)
@@ -22,614 +22,17 @@
* 02110-1301 USA.
*/-->
-<plugin name="TeiidPlugin" displayName="Teiid Plugin"
- package="org.teiid.rhq.plugin" version="2.0.0"
- description="Supports management and monitoring of JBoss Teiid"
+<plugin name="TeiidPlugin" displayName="Teiid Plugin" package="org.teiid.rhq.plugin"
+ version="2.0.0" description="Supports management and monitoring of JBoss Teiid"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
- <server name="Teiid Data Services"
- discovery="PlatformDiscoveryComponent"
- class="PlatformComponent"
- description="JBoss Teiid DataServices"
- supportsManualAdd="true"
- singleton="true">
+ <depends plugin="JMX" useClasses="true"/>
- <subcategories>
- <subcategory name="Runtime"/>
- <subcategory name="Resources"/>
- </subcategories>
+ <server name="Teiid Data Services" description="Teiid Datasources" class="PlatformComponent"
+ discovery="PlatformDiscoveryComponent" createDeletePolicy="both">
+ </server>
- <resource-configuration>
- <c:group name="connection" displayName="Connection Info">
- <c:description>Connection</c:description>
- <c:simple-property name="url" displayName="Teiid URL"
- description="The URL with which to connect to the Teiid Data Service instance (e.g. mm://localhost:31000)."
- default="mm://localhost:31000"/>
- <c:simple-property name="username" required="true" description="The name of the administrative principal (i.e. user) to authenticate."/>
- <c:simple-property name="password" type="password" required="true"
- description="The credentials (i.e. password) that should be used to authenticate the administrative principal."/>
- </c:group>
- </resource-configuration>
-
-
- <server name="Sessions"
- subCategory="Runtime"
- discovery="NodeDiscoveryComponent"
- description="Active / Inactive sessions connected to the Teidd Server"
- class="SessionComponent"
- singleton="true">
-
-<!--
- group name = operation name or query name
-
- simple-property name = the method name on the object to get the value
--->
- <resource-configuration>
- <c:group name="getSessions" displayName="Sessions">
-
- <c:list-property name="list"
- displayName="Current Sessions"
- description="Sessions currently connected to the Teiid"
- required="false">
- <c:map-property name="map">
- <c:simple-property displayName="Session ID"
- name="getSessionID" type="string" readOnly="true"
- description="The id for this session" />
- <c:simple-property displayName="User Name"
- name="getUserName" type="string" readOnly="true"
- description="The username for the user of this session" />
- <c:simple-property
- displayName="Application Name" name="getApplicationName"
- type="string" readOnly="true"
- description="The name of the application this user is accessing Teiid through" />
- <c:simple-property displayName="VDB Name"
- name="getVDBName" type="string" readOnly="true"
- description="The name of the VDB the user is connected to" />
- <c:simple-property displayName="VDB Version"
- name="getVDBVersion" type="string" readOnly="true"
- description="The version of the VDB the user is connected to" />
-
- <c:simple-property displayName="State"
- name="getStateAsString" type="string" readOnly="true"
- description="The current state of this session" />
-
- <c:simple-property displayName="IP Address"
- name="getIPAddress" type="string" readOnly="true"
- description="The IP Address for this user's connection" />
- <c:simple-property displayName="Host Name"
- name="getHostName" type="string" readOnly="true"
- description="The host machine from which this user connected" />
- </c:map-property>
- </c:list-property>
-
- </c:group>
- </resource-configuration>
-
- </server>
-
- <server name="Queries"
- subCategory="Runtime"
- discovery="NodeDiscoveryComponent"
- description="Current queries executing against the Teiid Server"
- class="QueriesComponent"
- singleton="true">
-
-<!--
- group name = operation name or query name
-
- simple-property name = the method name on the object to get the value
--->
- <resource-configuration>
- <c:group name="listQueries" displayName="Executing Queries">
-
- <c:list-property name="list"
- displayName="Executing Queries"
- description="Current queries executing in the Teiid system"
- required="false">
- <c:map-property name="map">
- <c:simple-property displayName="User Name"
- name="getUserName" type="string"
- description="The username for the user that submitted this query" />
- <c:simple-property displayName="Session ID"
- name="getSessionID" type="string"
- description="The id for the session" />
- <c:simple-property displayName="Request ID"
- name="getRequestID" type="string"
- description="The id for the request" />
- <c:simple-property displayName="Start Time"
- name="getCreated" type="string"
- description="The time this query has been running" />
- <c:simple-property displayName="Transaction ID"
- name="getTransactionID" type="string"
- description="The version of the VDB the user is connected to" />
- <c:simple-property displayName="SQL String"
- name="getSqlCommand" type="string"
- description="The SQL string for this query" />
- <c:simple-property
- displayName="Connector Binding Name"
- name="getConnectorBindingName" type="string"
- description="The IP Address for this user's connection" />
- <c:simple-property displayName="Node ID"
- name="getNodeID" type="string"
- description="The node ID of this query" />
- <c:simple-property displayName="Source Request"
- name="isSource" type="string"
- description="If false this is the top level query. If true this a physical source query." />
- </c:map-property>
- </c:list-property>
-
- </c:group>
- </resource-configuration>
-
- </server>
-
-
-
-
-
- <server name="System"
- subCategory="Runtime"
- discovery="NodeDiscoveryComponent"
- class="SystemComponent"
- description="Operational System"
- supportsManualAdd="true"
- singleton="true">
-
-
- <operation name="bounceSystem"
- displayName="Bounce System"
- description="Stop and restart the system">
- <parameters>
- <c:simple-property name="waitUntilFinished"
- type="boolean" default="false"
- description="If true, this method waits until the operation is finished before returning. This may take a long time to complete. If false, this method returns immediately, even though the operation may not be finished." />
- </parameters>
- </operation>
-<!--
- <operation name="listUsers"
- displayName="View current user sessions"
- description="List current user sessions connected to this Teiid System">
- <results>
- <c:list-property name="list">
- <c:map-property name="map">
- <c:simple-property displayName="User Name"
- name="getUserName" type="string"
- description="The username for the user of this session" />
- <c:simple-property
- displayName="Application Name" name="getApplicationName"
- type="string"
- description="The name of the application this user is accessing Teiid through" />
- <c:simple-property displayName="Session ID"
- name="getSessionID" type="string"
- description="The id for this session" />
- <c:simple-property displayName="VDB Name"
- name="getVDBName" type="string"
- description="The name of the VDB the user is connected to" />
- <c:simple-property displayName="VDB Version"
- name="getVDBVersion" type="string"
- description="The version of the VDB the user is connected to" />
- <c:simple-property displayName="Product Name"
- name="getProductName" type="string"
- description="The product name" />
- <c:simple-property displayName="IP Address"
- name="getIPAddress" type="string"
- description="The IP Address for this user's connection" />
- <c:simple-property displayName="Host Name"
- name="getHostName" type="string"
- description="The host name for this user's connection" />
- <c:simple-property displayName="Last Ping Time"
- name="getLastPingTime" type="string"
- description="The last time this client was ping'd" />
- <c:simple-property displayName="State"
- name="getStateAsString" type="string"
- description="The current state of this session" />
- </c:map-property>
- </c:list-property>
- </results>
- </operation>
--->
-
-<!--
- <operation name="listQueries" displayName="View current queries"
- description="List current queries executing against the Teiid System">
- <parameters>
- <c:simple-property name="includeSourceQueries"
- type="boolean" default="true"
- description="If true, source queries will be included in the results. If false, only top-level queries will be included in the results." />
- </parameters>
- <results>
- <c:list-property name="list">
- <c:map-property name="map">
- <c:simple-property displayName="User Name"
- name="getUserName" type="string"
- description="The username for the user that submitted this query" />
- <c:simple-property displayName="Session ID"
- name="getSessionID" type="string"
- description="The id for the session" />
- <c:simple-property displayName="Request ID"
- name="getRequestID" type="string"
- description="The id for the request" />
- <c:simple-property displayName="Start Time"
- name="getCreated" type="string"
- description="The time this query has been running" />
- <c:simple-property displayName="Transaction ID"
- name="getTransactionID" type="string"
- description="The version of the VDB the user is connected to" />
- <c:simple-property displayName="SQL String"
- name="getSqlCommand" type="string"
- description="The SQL string for this query" />
- <c:simple-property
- displayName="Connector Binding Name"
- name="getConnectorBindingName" type="string"
- description="The IP Address for this user's connection" />
- <c:simple-property displayName="Node ID"
- name="getNodeID" type="string"
- description="The node ID of this query" />
- <c:simple-property displayName="Source Request"
- name="isSource" type="string"
- description="If false this is the top level query. If true this a physical source query." />
- </c:map-property>
- </c:list-property>
- </results>
- </operation>
--->
- <operation name="listLongRunningQueries"
- displayName="View current long running queries"
- description="List current queries executing against the Teiid System that have surpassed the long running query threshhold">
- <parameters>
- <c:simple-property name="includeSourceQueries"
- type="boolean" default="true"
- description="If true, source queries will be included in the results. If false, only top-level queries will be included in the results." />
- </parameters>
- <results>
- <c:list-property name="list">
- <c:map-property name="map">
- <c:simple-property displayName="User Name"
- name="getUserName" type="string"
- description="The username for the user that submitted this query" />
- <c:simple-property displayName="Session ID"
- name="getSessionID" type="string"
- description="The name of the resource whose availability is being reported" />
- <c:simple-property displayName="Request ID"
- name="getRequestID" type="string"
- description="The id for the request" />
- <c:simple-property displayName="Start Time"
- name="getCreated" type="string"
- description="The time this query has been running" />
- <c:simple-property displayName="Transaction ID"
- name="getTransactionID" type="string"
- description="The version of the VDB the user is connected to" />
- <c:simple-property displayName="SQL String"
- name="getSqlCommand" type="string"
- description="The SQL string for this query" />
- <c:simple-property
- displayName="Connector Binding Name"
- name="getConnectorBindingName" type="string"
- description="The IP Address for this user's connection" />
- <c:simple-property displayName="Node ID"
- name="getNodeID" type="string"
- description="The node ID of this query" />
- <c:simple-property displayName="Source Request"
- name="isSource" type="string"
- description="If false this is the top level query. If true this a physical source query." />
- </c:map-property>
- </c:list-property>
- </results>
- </operation>
-
- <operation name="killRequest" displayName="Terminate query"
- description="Terminate the processing of a query and it's source queries">
- <parameters>
- <c:simple-property displayName="SessionID|RequestID"
- name="requestID" type="string" required="true"
- description="The IDs of the session|request to terminate (use format = sessionID|requestID)" />
- </parameters>
- </operation>
-
-
- <metric displayName="Query Count" defaultOn="true"
- displayType="summary" category="throughput" property="queryCount"
- description="The number of queries for a given point in time" />
-
- <metric displayName="Long Running Queries" defaultOn="true"
- displayType="summary" category="performance"
- property="longRunningQueries"
- description="The number of queries that have been running longer than the limit set for queries. The default is 60 minutes, but this may be overridden by the 'longRunningQueryTime' system variable." />
-
- <metric displayName="Session Count" defaultOn="true"
- displayType="summary" category="throughput" property="sessionCount"
- description="The number of user connections for a given point in time" />
-
- <resource-configuration>
- <c:group name="general" displayName="General" hiddenByDefault="false">
- <c:description>Query Configuration</c:description>
- <c:simple-property name="longRunningQueryLimit" type="integer" activationPolicy="immediate" units="seconds" default="600" displayName="Long Running Query limit" description="The value (in seconds) to use to determine if a query is to be considered 'long running'.">
- <c:constraint>
- <c:integer-constraint minimum="0" maximum="999999" />
- </c:constraint>
- </c:simple-property>
- </c:group>
- </resource-configuration>
-
-
- <server name="Host"
- discovery="HostDiscoveryComponent"
- class="HostComponent"
- description="Teiid Host"
- createDeletePolicy="delete-only">
-
- <resource-configuration>
- <c:group name="hostinfo" displayName="Host Info">
- <c:description>Host configuration information</c:description>
-
- <c:simple-property name="metamatrix.installationDir" readOnly="true" required="false" displayName="Installation Directory"
- description="The physical location of the Teiid server installation"/>
- <c:simple-property name="metamatrix.log.dir" readOnly="true" required="false" displayName="Log Directory"
- description="The physical location of the Host log files"/>
- <c:simple-property name="metamatrix.data.dir" readOnly="true" required="false" displayName="Data Directory"
- description="The physical location of the internal Teiid dynamic data"/>
- <c:simple-property name="metamatrix.host.dir" readOnly="true" required="false" displayName="Host Directory"
- description="The Host directory is where host specific files are located."/>
- <c:simple-property name="metamatrix.host.bind.address" readOnly="true" required="false" displayName="Bind Address"
- description="The bind address determines what interfaces the host machine will be bound to."/>
- <c:simple-property name="metamatrix.host.physical.address" readOnly="true" required="false" displayName="Physical Address"
- description="The physical address indicates what address a client application will use to connect."/>
- </c:group>
- </resource-configuration>
-
-
- <service name="Process"
- discovery="ProcessDiscoveryComponent"
- class="ProcessComponent"
- description="Teiid Process instance"
- createDeletePolicy="both">
-
- <plugin-configuration>
- <c:group name="event" displayName="Process Log Tracking">
- <c:simple-property name="enabled" type="boolean" summary="true" default="true" required="true"
- description="A flag indicating whether of not this log Event source is currently
- enabled (i.e. whether the associated log file should be tailed for
- new entries)."/>
- <c:simple-property name="minimumSeverity" required="true" default="ERROR"
- description="The minimum severity of Events that should be collected for this
- source. The default is ERROR.">
- <c:property-options>
- <c:option name="DEBUG" value="DEBUG"/>
- <c:option name="INFO" value="INFO"/>
- <c:option name="WARNING" value="WARNING"/>
- <c:option name="ERROR" value="ERROR" default="true"/>
- </c:property-options>
- </c:simple-property>
- </c:group>
- </plugin-configuration>
-
- <operation name="restartProcess"
- displayName="Re-start Process"
- description="Start/re-start this process" />
- <operation name="stopProcess"
- displayName="Stop Process"
- description="Stop this process">
- <parameters>
- <c:simple-property name="stopNow" type="boolean"
- default="true"
- description="If true, stop the process forcefully. If false, wait until any pending work is completed." />
- </parameters>
- </operation>
-
-
- <metric displayName="Query High Water Mark" defaultOn="true"
- displayType="summary" category="utilization"
- property="highWatermark"
- description="High water mark for queries in the Socket Worker Queue" />
-
- <event name="errorLogEntry" description="an entry in a log file"/>
- <!-- Ted Jones - 06/19/08
- Commenting out current threads metric until http://jira.jboss.org/jira/browse/JBEDSP-426 is resolved. -->
- <!-- <metric displayName="Current Threads"
- defaultOn="true"
- displayType="summary"
- category="utilization"
- property="threadCount"
- description="The number of active threads in the Socket Worker Queue"/> -->
-
- <resource-configuration>
- <c:group name="processinfo" displayName="Process Info">
- <c:description>Process configuration information</c:description>
- <c:simple-property name="vm.enabled" type="boolean" displayName="Start Enabled Flag"
- description="The enabled flag allows for disabling the VM from starting without have to remove it from deployment."/>
- <c:simple-property name="vm.socketPort" type="integer" displayName="Socket Port"
- description="The port number for the process when socket communications are being used"/>
-
- <c:simple-property name="vm.starter.cmd.java_opts" displayName="Java Options"
- description="These are the java options passed in before the main class"/>
- <c:simple-property name="vm.starter.minHeapSize" displayName="Minimum Heap Size (MB)" required="false"
- description="The bind address, when specified determines what address the vm will be bound to."/>
- <c:simple-property name="vm.starter.maxHeapSize" type="integer" displayName="Maximum Heap Size (MB)" required="false"
- description="The maximum heap size, in megabytes, to be used for this VM. If no value is provided for this property, the default property value from the configuration is used; if no value is specified anywhere, no maximum heap size will be set."/>
- <c:simple-property name="vm.bind.address" type="string" displayName="VM Bind Address" required="false"
- description="The bind address, when specified determines what address the vm will be bound to."/>
- <c:simple-property name="vm.unicast.port" type="integer" displayName="Cluster Port for Unicast"
- description="The port number for the process when unicast based clustering is used."/>
- <c:simple-property name="vm.minPort" type="integer" displayName="Min Port Number"
- description="Min port number"/>
-
- </c:group>
- <c:group name="tuning" displayName="Tuning">
-
- <c:simple-property name="vm.timetolive" type="integer" displayName="Socket Worker Thread Time-To-Live (ms)"
- description="Time-to-live (in milliseconds) for threads used to do work on client requests."/>
- <c:simple-property name="vm.maxThreads" type="integer" displayName="Max Threads" required="false"
- description="Maximum socket listener threads.">
- <c:defaultValueDescription>If nothing is specified, the default of 64 will be used.
- </c:defaultValueDescription>
- </c:simple-property>
- <c:simple-property name="vm.inputBufferSize" type="integer" displayName="Socket Input BufferSize"
- description="The size of socket buffer used when reading."/>
- <c:simple-property name="vm.forced.shutdown.time" type="integer" displayName="VM Forced Shutdown Time (secs)"
- description="The the number of seconds the VM will wait until it will perform a force shutdown."/>
- <c:simple-property name="vm.outputBufferSize" type="integer" displayName="Socket Output BufferSize"
- description="The size of the socket buffer used when writing."/>
-
- </c:group>
- </resource-configuration>
-
-
- <service name="Connectors"
- discovery="ConnectorDiscoveryComponent"
- class="ConnectorComponent">
-
- <resource-configuration>
- <c:group name="advanced" displayName="Advanced">
-
- <c:list-property name="config-property"
- displayName="Config Property"
- description="Configuration Properties"
- required="false">
- <c:map-property name="property-values">
- <c:simple-property name="config-property-name"
- displayName="Name"
- description="Name of the Configuration Property"
- required="true"/>
- <c:simple-property name="config-property-type"
- displayName="Type"
- description="Type of the Configuration Property"
- required="true"/>
- <c:simple-property name="config-property-value"
- displayName="Value"
- description="Value of the Configuration Property"
- required="true"/>
- </c:map-property>
- </c:list-property>
-
- </c:group>
- </resource-configuration>
-
- <operation name="restartConnector"
- displayName="Re-start Connector"
- description="Start/re-start this connector binding" />
- <operation name="stopConnector"
- displayName="Stop Connector"
- description="Stop this connector binding">
- <parameters>
- <c:simple-property name="stopNow" type="boolean"
- default="true"
- description="If true, stop the connector binding forcefully. If false, wait until any pending work is completed." />
- </parameters>
- </operation>
- </service>
-
- <service name="Services"
- discovery="ServiceDiscoveryComponent"
- class="ServiceComponent">
-
- <resource-configuration>
- <c:group name="advanced" displayName="Advanced">
-
- <c:list-property name="config-property"
- displayName="Config Property"
- description="Configuration Properties"
- required="false">
- <c:map-property name="property-values">
- <c:simple-property name="config-property-name"
- displayName="Name"
- description="Name of the Configuration Property"
- required="true"/>
- <c:simple-property name="config-property-type"
- displayName="Type"
- description="Type of the Configuration Property"
- required="true"/>
- <c:simple-property name="config-property-value"
- displayName="Value"
- description="Value of the Configuration Property"
- required="true"/>
- </c:map-property>
- </c:list-property>
-
- </c:group>
- </resource-configuration>
-
- <operation name="restart"
- displayName="Re-start Service"
- description="Start/re-start this service" />
- <operation name="stop"
- displayName="Stop Service"
- description="Stop this service">
- <parameters>
- <c:simple-property name="stopNow" type="boolean"
- default="true"
- description="If true, stop the servie forcefully. If false, wait until any pending work is completed." />
- </parameters>
- </operation>
- </service>
-
- </service> <!-- end of VM -->
-
- </server> <!-- end of Host -->
-
- </server> <!-- end of System -->
-
- <server name="Security"
- discovery="NodeDiscoveryComponent"
- description="Security"
- class="SecurityComponent"
- singleton="true">
-
- <resource-configuration>
- <c:group name="configuration" displayName="Configuration">
- <c:simple-property name="enabled" type="boolean" summary="true" default="false" required="true"
- description="A flag indicating whether or not security is enabled for this system."/>
- <c:simple-property name="username" required="false" description="The name of the administrative principal (i.e. user) to authenticate."/>
- <c:simple-property name="password" type="password" required="false"
- description="The credentials (i.e. password) that should be used to authenticate the administrative principal."/>
- </c:group>
- </resource-configuration>
- </server> <!-- End of security -->
-
- </server> <!-- end of Platform -->
-
-
-
-<!--
-
-
- <service name="Connector Types"
- subCategory="Resources"
- discovery="ResourceDiscoveryComponent"
- class="ResourceComponent"
- description="Connector Types"
- createDeletePolicy="both"
- creationDataType="content">
-
- <operation name="getProperties"
- displayName="View properties"
- description="List the properties">
- <results>
- <c:list-property name="list">
- <c:map-property name="map">
- <c:simple-property name="Name" type="string"
- description="The name of this property" />
- <c:simple-property name="Connector Type" type="string"
- description="The type of connector that defines this data source" />
- <c:simple-property name="Default" type="string"
- description="The default value when not defined by the user" />
- <c:simple-property name="Masked" type="boolean"
- description="Indicates if the property value requires masking after being entered. A password would be a good example of a value needing masking." />
- <c:simple-property name="Descritpion" type="string"
- description="The property description" />
- </c:map-property>
- </c:list-property>
- </results>
- </operation>
-
- <content name="file" displayName="CDK File" category="deployable" isCreationType="true">
- <configuration>
- </configuration>
- </content>
- </service>
--->
-
</plugin>
\ No newline at end of file
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-11-20 20:30:31 UTC (rev 1581)
+++ trunk/pom.xml 2009-11-20 22:26:31 UTC (rev 1582)
@@ -268,6 +268,18 @@
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-console</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-console</artifactId>
+ <type>test-jar</type>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
<version>${project.version}</version>
</dependency>
@@ -447,6 +459,7 @@
<module>client-jdbc</module>
<module>engine</module>
<module>connectors</module>
+ <module>console</module>
<module>metadata</module>
<module>txn-jbossts</module>
<module>connector-sdk</module>
15 years, 1 month
teiid SVN: r1581 - in trunk/test-integration/db/src/main/java/org/teiid/test/framework: datasource and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-20 15:30:31 -0500 (Fri, 20 Nov 2009)
New Revision: 1581
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
Log:
Teiid 773 - added environment variable to enable specifying a different datasources location to use
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-11-20 18:53:09 UTC (rev 1580)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-11-20 20:30:31 UTC (rev 1581)
@@ -1,6 +1,7 @@
package org.teiid.test.framework;
import org.teiid.test.framework.datasource.DataSource;
+import org.teiid.test.framework.datasource.DataSourceMgr;
import com.metamatrix.jdbc.api.ExecutionProperties;
@@ -55,10 +56,16 @@
public static final String EXCLUDE_DATASBASE_TYPES_PROP = "excludedatasourcetypes";
+ /**
+ * The {@link #OVERRIDE_DATASOURCES_LOC}, when specified, will override the default
+ * defined for {@link DataSourceMgr#DEFAULT_DATASOURCES_LOC};
+ *
+ */
+ public static final String OVERRIDE_DATASOURCES_LOC = "datasourceloc";
-
/**
- * Connection Type indicates the type of connection (strategy) to use
+ * Connection Type indicates the type of connection (strategy) to use when
+ * connecting to Teiid.
* Options are {@link CONNECTION_TYPES}
*/
public static final String CONNECTION_TYPE = "connection-type"; //$NON-NLS-1$
@@ -66,6 +73,7 @@
/**
* {@see #CONNECTION_TYPE} regarding setting the specific connection type to use
+ * when connecting to Teiid
* @author vanhalbert
*
*/
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-11-20 18:53:09 UTC (rev 1580)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-11-20 20:30:31 UTC (rev 1581)
@@ -12,9 +12,13 @@
import java.util.Map;
import java.util.Properties;
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.ConfigPropertyNames;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
+import com.metamatrix.common.util.PropertiesUtils;
+
/**
* The DataSourceMgr is responsible for loading and managing the datasources
* defined by the datasource connection properties file. There's only a need to
@@ -28,6 +32,18 @@
public class DataSourceMgr {
private static DataSourceMgr _instance = null;
+
+ /**
+ * Defines the default location where the datasource files will be found.
+ * An override can be specified by setting the property {@link ConfigPropertyNames#OVERRIDE_DATASOURCES_LOC}.
+ */
+ public static final String DEFAULT_DATASOURCES_LOC="./target/classes/datasources/";
+
+ /**
+ * When run from maven, the {@link ConfigPropertyNames#OVERRIDE_DATASOURCES_LOC} will be assigned
+ * to this value because of its a place holder for when a user does set the vm argument.
+ */
+ private static final String UNASSIGNEDDSLOC="${datasourceloc}";
private Map<String, DataSource> allDatasourcesMap = new HashMap<String, DataSource>(); // key
// =
@@ -84,24 +100,32 @@
private void loadDataSourceMappings() throws QueryTestFailedException {
- File[] dirs = findAllChildDirectories("./target/classes/datasources/");
+ String dsloc = ConfigPropertyLoader.createInstance().getProperty(ConfigPropertyNames.OVERRIDE_DATASOURCES_LOC);
+
+ if (dsloc == null || dsloc.equalsIgnoreCase(UNASSIGNEDDSLOC)) {
+ dsloc = DEFAULT_DATASOURCES_LOC;
+ }
+
+ File[] dirs = findAllChildDirectories(dsloc);
if (dirs == null || dirs.length == 0) {
throw new TransactionRuntimeException(
"No datasource directories found at location "
- + "./target/classes/datasources/");
+ + dsloc);
}
for (int i = 0; i < dirs.length; i++) {
File d = dirs[i];
- String dname = d.getName();
+ addDataSource(d, allDatasourcesMap);
- addDataSource(dname, d.getName(), allDatasourcesMap);
-
}
if (allDatasourcesMap == null || allDatasourcesMap.isEmpty()) {
throw new TransactionRuntimeException(
"Error: No Datasources were loaded.");
+ } else if (allDatasourcesMap.size() < 2) {
+ throw new TransactionRuntimeException(
+ "Error: Must load 2 Datasources, only 1 was found.");
+
}
System.out.println("Number of total datasource mappings loaded "
@@ -147,15 +171,23 @@
}
- private void addDataSource(String dirname, String dirloc,
+ private void addDataSource(File datasourcedir, //String dirname, String dirloc,
Map<String, DataSource> datasources) {
+
+// String dirname = datasourcefile.getName();
+
+ File dsfile = new File(datasourcedir, "connection.properties");
+
+ if (!dsfile.exists()) {
+ return;
+ }
- String dsfile = "/datasources/" + dirloc + "/connection.properties";
+// String dsfile = "/datasources/" + dirname + "/connection.properties";
Properties dsprops = loadProperties(dsfile);
if (dsprops != null) {
- DataSource ds = new DataSource(dirname, "dsgroup", dsprops);
+ DataSource ds = new DataSource(datasourcedir.getName(), "dsgroup", dsprops);
datasources.put(ds.getName(), ds);
System.out.println("Loaded datasource " + ds.getName());
@@ -163,20 +195,24 @@
}
- private static Properties loadProperties(String filename) {
+ private static Properties loadProperties(File dsfile) {
Properties props = null;
try {
- InputStream in = DataSourceMgr.class.getResourceAsStream(filename);
- if (in != null) {
- props = new Properties();
- props.load(in);
- return props;
- }
- return null;
+
+ props = PropertiesUtils.load(dsfile.getAbsolutePath());
+ return props;
+
+// InputStream in = DataSourceMgr.class.getResourceAsStream(dsfile.getAbsolutePath());
+// if (in != null) {
+// props = new Properties();
+// props.load(in);
+// return props;
+// }
+// return null;
} catch (IOException e) {
throw new TransactionRuntimeException(
- "Error loading properties from file '" + filename + "'"
+ "Error loading properties from file '" + dsfile.getAbsolutePath() + "'"
+ e.getMessage());
}
}
15 years, 1 month
teiid SVN: r1580 - in trunk: engine/src/main/java/com/metamatrix/query/parser and 4 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-11-20 13:53:09 -0500 (Fri, 20 Nov 2009)
New Revision: 1580
Modified:
trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
trunk/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java
trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/resolver/TestXMLResolver.java
Log:
TEIID-145 changing the client default to ansi mode by default
Modified: trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java 2009-11-20 17:58:23 UTC (rev 1579)
+++ trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java 2009-11-20 18:53:09 UTC (rev 1580)
@@ -66,7 +66,7 @@
private boolean useResultSetCache;
// Treat the double quoted strings as variables in the command
- private boolean dblQuotedVariableAllowed = false;
+ private boolean dblQuotedVariableAllowed = true;
//whether query plan is allowed or not
private boolean queryPlanAllowed = true;
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java 2009-11-20 17:58:23 UTC (rev 1579)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java 2009-11-20 18:53:09 UTC (rev 1580)
@@ -37,17 +37,17 @@
public boolean aggregatesAllowed = false;
// treat a double quoted variable as variable instead of string
- public boolean allowDoubleQuotedVariable=true;
+ public boolean ansiQuotedIdentifiers=true;
public ParseInfo() { }
- public boolean allowDoubleQuotedVariable() {
- return allowDoubleQuotedVariable;
+ public boolean useAnsiQuotedIdentifiers() {
+ return ansiQuotedIdentifiers;
}
@Override
public int hashCode() {
- return allowDoubleQuotedVariable?1:0;
+ return ansiQuotedIdentifiers?1:0;
}
@Override
@@ -59,6 +59,6 @@
return false;
}
ParseInfo other = (ParseInfo)obj;
- return this.allowDoubleQuotedVariable == other.allowDoubleQuotedVariable;
+ return this.ansiQuotedIdentifiers == other.ansiQuotedIdentifiers;
}
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2009-11-20 17:58:23 UTC (rev 1579)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2009-11-20 18:53:09 UTC (rev 1580)
@@ -121,7 +121,7 @@
* @param id Possible string literal
*/
boolean isStringLiteral(String str, ParseInfo info) throws ParseException {
- if (info.allowDoubleQuotedVariable() || str.charAt(0) != '"' || str.charAt(str.length() - 1) != '"') {
+ if (info.useAnsiQuotedIdentifiers() || str.charAt(0) != '"' || str.charAt(str.length() - 1) != '"') {
return false;
}
int index = 1;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2009-11-20 17:58:23 UTC (rev 1579)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2009-11-20 18:53:09 UTC (rev 1580)
@@ -215,7 +215,7 @@
ParseInfo info = new ParseInfo();
// Defect 19747 - the parser needs the following connection property to decide whether to treat double-quoted strings as variable names
- info.allowDoubleQuotedVariable = isDoubleQuotedVariablesAllowed;
+ info.ansiQuotedIdentifiers = isDoubleQuotedVariablesAllowed;
CacheID id = new PreparedPlanCache.CacheID(workContext, info, sql);
PreparedPlanCache.PreparedPlan plan = planCache.getPreparedPlan(id);
if(plan != null) {
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-11-20 17:58:23 UTC (rev 1579)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-11-20 18:53:09 UTC (rev 1580)
@@ -333,7 +333,7 @@
public static ParseInfo createParseInfo(RequestMessage requestMsg) {
ParseInfo parseInfo = new ParseInfo();
- parseInfo.allowDoubleQuotedVariable = requestMsg.isDoubleQuotedVariableAllowed();
+ parseInfo.ansiQuotedIdentifiers = requestMsg.isDoubleQuotedVariableAllowed();
return parseInfo;
}
@@ -584,8 +584,8 @@
boolean isRootXQuery = recursionGroup == null && commandContext.getCallStackDepth() == 0 && userCommand instanceof XQuery;
ParseInfo parseInfo = new ParseInfo();
- if (isRootXQuery && requestMsg.isDoubleQuotedVariableAllowed()) {
- parseInfo.allowDoubleQuotedVariable = true;
+ if (isRootXQuery) {
+ parseInfo.ansiQuotedIdentifiers = requestMsg.isDoubleQuotedVariableAllowed();
}
Command newCommand = QueryParser.getQueryParser().parseCommand(query, parseInfo);
QueryResolver.resolveCommand(newCommand, metadata);
Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-11-20 17:58:23 UTC (rev 1579)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-11-20 18:53:09 UTC (rev 1580)
@@ -2221,7 +2221,7 @@
query.setSelect(select);
query.setFrom(from);
ParseInfo info = new ParseInfo();
- info.allowDoubleQuotedVariable = false;
+ info.ansiQuotedIdentifiers = false;
helpTest("SELECT \"g\"\".\"\"a\" from g", //$NON-NLS-1$
"SELECT 'g\".\"a' FROM g", //$NON-NLS-1$
query, info);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java 2009-11-20 17:58:23 UTC (rev 1579)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java 2009-11-20 18:53:09 UTC (rev 1580)
@@ -67,7 +67,6 @@
import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
import com.metamatrix.query.optimizer.xml.TestXMLPlanner;
-import com.metamatrix.query.parser.ParseInfo;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.processor.FakeDataManager;
import com.metamatrix.query.processor.QueryProcessor;
@@ -2928,9 +2927,7 @@
public static Command helpGetCommand(String sql, QueryMetadataInterface metadata) throws QueryParserException, QueryResolverException, MetaMatrixComponentException, QueryValidatorException {
QueryParser parser = new QueryParser();
- ParseInfo info = new ParseInfo();
- info.allowDoubleQuotedVariable = true;
- Command command = parser.parseCommand(sql, info);
+ Command command = parser.parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
command = QueryRewriter.rewrite(command, null, metadata, null);
return command;
Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestXMLResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestXMLResolver.java 2009-11-20 17:58:23 UTC (rev 1579)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestXMLResolver.java 2009-11-20 18:53:09 UTC (rev 1580)
@@ -31,7 +31,6 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.parser.ParseInfo;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.CompareCriteria;
@@ -442,9 +441,7 @@
expected.setOperator(CompareCriteria.EQ);
expected.setRightExpression(new Constant("yyz")); //$NON-NLS-1$
- ParseInfo info = new ParseInfo();
- info.allowDoubleQuotedVariable = true;
- Query query = (Query) TestResolver.helpResolve(QueryParser.getQueryParser().parseCommand("select \"xml\" from xmltest.doc1 where node1 = 'yyz'", info), FakeMetadataFactory.example1Cached(), null); //$NON-NLS-1$
+ Query query = (Query) TestResolver.helpResolve(QueryParser.getQueryParser().parseCommand("select \"xml\" from xmltest.doc1 where node1 = 'yyz'"), FakeMetadataFactory.example1Cached(), null); //$NON-NLS-1$
Criteria actual = query.getCriteria();
assertEquals("Did not match expected criteria", expected, actual); //$NON-NLS-1$
}
15 years, 1 month
teiid SVN: r1579 - trunk/engine/src/test/java/com/metamatrix/query/processor.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-11-20 12:58:23 -0500 (Fri, 20 Nov 2009)
New Revision: 1579
Modified:
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
Log:
TEIID-251 TEIID-873 added support for order by expressions and removing parsing restrictions that limited quoted identifiers.
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-11-20 17:27:16 UTC (rev 1578)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-11-20 17:58:23 UTC (rev 1579)
@@ -7498,6 +7498,20 @@
helpProcess(plan, dataManager, expected);
}
+ @Test public void testOrderByUnrelatedExpression() {
+ String sql = "SELECT e1, e2 + 1 from pm1.g2 order by e3 || e2 limit 1"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("a", 1),
+ };
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
private static final boolean DEBUG = false;
}
15 years, 1 month
teiid SVN: r1578 - in trunk/engine/src: main/java/com/metamatrix/query/resolver/command and 15 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-11-20 12:27:16 -0500 (Fri, 20 Nov 2009)
New Revision: 1578
Modified:
trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/OrderBy.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java
trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java
Log:
TEIID-251 TEIID-873 added support for order by expressions and removing parsing restrictions that limited quoted identifiers.
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -23,6 +23,8 @@
package com.metamatrix.query.parser;
import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import com.metamatrix.core.util.Assertion;
@@ -37,48 +39,59 @@
import com.metamatrix.query.sql.proc.CriteriaSelector;
public class SQLParserUtil {
-
+
+ String normalizeStringLiteral(String s) {
+ int start = 1;
+ if (s.charAt(0) == 'N') {
+ start++;
+ }
+ char tickChar = s.charAt(start - 1);
+ s = s.substring(start, s.length() - 1);
+ return removeEscapeChars(s, tickChar);
+ }
+
+ String normalizeId(String s) {
+ if (s.indexOf('"') == -1) {
+ return s;
+ }
+ List<String> nameParts = new LinkedList<String>();
+ while (s.length() > 0) {
+ if (s.charAt(0) == '"') {
+ boolean escape = false;
+ for (int i = 1; i < s.length(); i++) {
+ if (s.charAt(i) != '"') {
+ continue;
+ }
+ escape = !escape;
+ boolean end = i == s.length() - 1;
+ if (end || (escape && s.charAt(i + 1) == '.')) {
+ String part = s.substring(1, i);
+ s = s.substring(i + (end?1:2));
+ nameParts.add(removeEscapeChars(part, '"'));
+ break;
+ }
+ }
+ } else {
+ int index = s.indexOf('.');
+ if (index == -1) {
+ nameParts.add(s);
+ break;
+ }
+ nameParts.add(s.substring(0, index));
+ s = s.substring(index + 1);
+ }
+ }
+ StringBuilder sb = new StringBuilder();
+ for (Iterator<String> i = nameParts.iterator(); i.hasNext();) {
+ sb.append(i.next());
+ if (i.hasNext()) {
+ sb.append('.');
+ }
+ }
+ return sb.toString();
+ }
+
/**
- * Check that this is a valid group or element ID
- * @param id Group ID string
- */
- boolean isMetadataID(String id) throws ParseException {
- int length = id.length();
-
- // Validate server forms:
- // group, vdb.group, "group", vdb."group",
- // group.*, vdb.group.*, "group".*, vdb."group".*,
- // group.element, vdb.group.element, "group".element, vdb."group".element
- // tag.tag.tag
- // tag.tag.@attribute
-
- // Check first character - must be letter or "
- char c = id.charAt(0);
- if( ! (c == '\"' || c == '#' || StringUtil.isLetter(c)) ) {
- return false;
- }
-
- // Check middle characters - letter, number, _, "
- if(length > 1) {
- for(int i=1; i<length; i++) {
- c = id.charAt(i);
- if( ! (c == '.' || c == '_' || c == '\"' || c == '/' || c == '@' || StringUtil.isLetterOrDigit(c)) ) {
- // Allow last character to be * as well
- if( i == (length-1) ) {
- if(c != '*') {
- return false;
- }
- } else {
- return false;
- }
- }
- }
- }
-
- return true;
- }
-
- /**
* Check that this is a valid function name
* @param id Function name string
*/
@@ -102,99 +115,30 @@
throw new ParseException(QueryPlugin.Util.getString("SQLParser.Invalid_func", params)); //$NON-NLS-1$
}
- /**
- * Check that this is a valid alias
- * @param alias Alias string
- */
- boolean isAlias(String alias) throws ParseException {
- if((alias.charAt(0) == '\"' && alias.charAt(alias.length()-1) == '\"')
- ||(alias.charAt(0) == '\'' && alias.charAt(alias.length()-1) == '\'')) {
- return isMetadataPart(alias.substring(1, alias.length()-1));
- }
- return isMetadataPart(alias);
- }
/**
- * Check that this is a valid metadata part - starts with a letter and contains alpha, numeric, _
- * @param part Metadata part string
- */
- boolean isMetadataPart(String part) throws ParseException {
- int length = part.length();
-
- // Check first character - must be letter
- char c = part.charAt(0);
- if( ! StringUtil.isLetter(c) ) {
- return false;
- }
-
- // Check other characters - letter, number, _
- if(length > 1) {
- for(int i=1; i<length; i++) {
- c = part.charAt(i);
- if( ! (c == '_' || StringUtil.isLetterOrDigit(c)) ) {
- return false;
- }
- }
- }
-
- return true;
- }
-
- /**
* Check if this is a valid string literal
* @param id Possible string literal
*/
boolean isStringLiteral(String str, ParseInfo info) throws ParseException {
- // Check first last characters first - this is a requirement and should
- // fail quickly in most cases
- if(str.charAt(0) != '\"' || str.charAt(str.length()-1) != '\"') {
- return false;
- }
-
- // Check whether this is a string like "abcdefg" or a variable like "category.group"."element"
-
- // First, tokenize on periods (note that periods may be embedded in quoted parts)
- List tokens = StringUtil.split(str, "."); //$NON-NLS-1$
- if(tokens.size() < 2) {
- // No periods, so this must be a string literal
- return info.allowDoubleQuotedVariable()? false : true;
- }
- // Start at second token (i=1) and look at pairs of this and previous for
- // a pair that ends and begins in ". Also, have to make sure that " is not
- // part of an escaped quote: "abc"".""def" should be a string literal while
- // "abc"."def" should be a variable.
- for(int i=1; i<tokens.size(); i++) {
- String first = (String) tokens.get(i-1);
- String second = (String) tokens.get(i);
- if( second.charAt(0) == '\"' &&
- second.charAt(1) != '\"' &&
- first.charAt(first.length()-1) == '\"' &&
- first.charAt(first.length()-2) != '\"' ) {
-
- return false;
- }
- }
-
- // Didn't find any evidence that this is a dotted variable, so must be a string
- // unless we are allowing double quoted variable, like ODBC metadata tools use.
- return info.allowDoubleQuotedVariable()? false : true;
+ if (info.allowDoubleQuotedVariable() || str.charAt(0) != '"' || str.charAt(str.length() - 1) != '"') {
+ return false;
+ }
+ int index = 1;
+ while (index < str.length() - 1) {
+ index = str.indexOf('"', index);
+ if (index == -1 || index + 1 == str.length()) {
+ return true;
+ }
+ if (str.charAt(index + 1) != '"') {
+ return false;
+ }
+ index += 2;
+ }
+ return true;
}
/**
- * Check that this is a valid metadata ID, remove quotes, and return updated
- * ID string.
- * @param id Metadata ID string
- */
- String validateMetadataID(String id) throws ParseException {
- if(! isMetadataID(id)) {
- Object[] params = new Object[] { id };
- throw new ParseException(QueryPlugin.Util.getString("SQLParser.Invalid_id", params)); //$NON-NLS-1$
- }
- id = id.replaceAll("\"", ""); //$NON-NLS-1$ //$NON-NLS-2$
- return id;
- }
-
- /**
* Check that this is a valid alias, remove quotes, and return updated
* alias string.
* @param id Metadata alias
@@ -204,7 +148,7 @@
}
private String validateName(String id, boolean element) throws ParseException {
- if(! isAlias(id)) {
+ if(id.indexOf('.') != -1) {
Object[] params = new Object[] { id };
String key = "SQLParser.Invalid_alias"; //$NON-NLS-1$
if (element) {
@@ -212,9 +156,7 @@
}
throw new ParseException(QueryPlugin.Util.getString(key, params));
}
- // Remove Quotes and Single Tick
- id = removeCharacter(id, '"');
- return removeCharacter(id, '\'');
+ return id;
}
/**
@@ -225,28 +167,6 @@
return validateName(id, true);
}
- /**
- * Remove all quotes from the specified id string
- * @param id Input string
- * @param remove character to be removed from id
- * @return string from which remove character is removed,
- * if no instances of remove character is found original string returned
- */
- String removeCharacter(String id, char remove) {
- if(id.indexOf(remove) >= 0) {
- StringBuffer newStr = new StringBuffer();
- int length = id.length();
- for(int i=0; i<length; i++) {
- char c = id.charAt(i);
- if(c != remove) {
- newStr.append(c);
- }
- }
- return newStr.toString();
- }
- return id;
- }
-
String removeEscapeChars(String str, char tickChar) {
String doubleTick = "" + tickChar + tickChar; //$NON-NLS-1$
int index = str.indexOf(doubleTick);
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -35,12 +35,15 @@
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.TempMetadataAdapter;
+import com.metamatrix.query.metadata.TempMetadataID;
import com.metamatrix.query.resolver.CommandResolver;
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.lang.QueryCommand;
import com.metamatrix.query.sql.lang.SetQuery;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.util.ErrorMessageKeys;
@@ -90,9 +93,8 @@
// ORDER BY clause
if(setQuery.getOrderBy() != null) {
- List validGroups = Collections.EMPTY_LIST;
//order by elements must use the short name of the projected symbols
- ResolverUtil.resolveOrderBy(setQuery.getOrderBy(), validGroups, setQuery.getProjectedSymbols(), metadata, false);
+ ResolverUtil.resolveOrderBy(setQuery.getOrderBy(), setQuery, metadata);
}
setProjectedTypes(setQuery, firstProjectTypes);
@@ -116,7 +118,7 @@
for (int j = 0; j < projectedSymbols.size(); j++) {
SingleElementSymbol ses = (SingleElementSymbol)projectedSymbols.get(j);
Class targetType = (Class)firstProjectTypes.get(j);
- if (ses.getType() != targetType && ResolverUtil.orderByContainsVariable(child.getOrderBy(), ses, j)) {
+ if (ses.getType() != targetType && orderByContainsVariable(child.getOrderBy(), ses, j)) {
String sourceTypeName = DataTypeManager.getDataTypeName(ses.getType());
String targetTypeName = DataTypeManager.getDataTypeName(targetType);
throw new QueryResolverException(QueryPlugin.Util.getString("UnionQueryResolver.type_conversion", //$NON-NLS-1$
@@ -129,6 +131,21 @@
}
}
+ /**
+ * Checks if a variable is in the ORDER BY
+ * @param position 0-based index of the variable
+ * @return True if the ORDER BY contains the element
+ */
+ public static boolean orderByContainsVariable(OrderBy orderBy, SingleElementSymbol ses, int position) {
+ for (final Iterator iterator = orderBy.getVariables().iterator(); iterator.hasNext();) {
+ final ElementSymbol element = (ElementSymbol)iterator.next();
+ if (position == ((TempMetadataID)element.getMetadataID()).getPosition()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
static void checkSymbolTypes(List firstProjectTypes, List projSymbols) {
for(int j=0; j<projSymbols.size(); j++){
Class firstProjType = (Class)firstProjectTypes.get(j);
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -612,7 +612,7 @@
public void visit(OrderBy obj) {
try {
- ResolverUtil.resolveOrderBy(obj, new ArrayList(currentGroups), query.getSelect().getProjectedSymbols(), metadata, query.getGroupBy() == null && !query.getSelect().isDistinct());
+ ResolverUtil.resolveOrderBy(obj, query, metadata);
} catch(QueryResolverException e) {
throw new MetaMatrixRuntimeException(e);
} catch(MetaMatrixComponentException e) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -39,7 +40,6 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.TransformationException;
import com.metamatrix.common.types.DataTypeManager.DefaultDataTypes;
-import com.metamatrix.core.util.StringUtil;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.function.FunctionDescriptor;
import com.metamatrix.query.function.FunctionLibrary;
@@ -54,6 +54,9 @@
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.lang.Limit;
import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.lang.QueryCommand;
+import com.metamatrix.query.sql.lang.SetQuery;
import com.metamatrix.query.sql.lang.SubqueryContainer;
import com.metamatrix.query.sql.symbol.AbstractCaseExpression;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
@@ -68,6 +71,8 @@
import com.metamatrix.query.sql.symbol.ScalarSubquery;
import com.metamatrix.query.sql.symbol.SelectSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import com.metamatrix.query.sql.util.SymbolMap;
+import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
import com.metamatrix.query.util.ErrorMessageKeys;
/**
@@ -292,164 +297,159 @@
}
}
- /**
- * Attempt to resolve the order by
- * throws QueryResolverException if the symbol is not of SingleElementSymbol type
- * @param orderBy
- * @param fromClauseGroups groups of the FROM clause of the query (for
- * resolving ambiguous unqualified element names), or empty List if a Set Query
- * Order By is being resolved
- * @param knownElements resolved elements from SELECT clause, which are only
- * ones allowed to be in ORDER BY
- * @param metadata QueryMetadataInterface
- * @param isSimpleQuery
- */
- public static void resolveOrderBy(OrderBy orderBy, List fromClauseGroups, List knownElements, QueryMetadataInterface metadata, boolean isSimpleQuery)
+ /**
+ * Attempt to resolve the order by throws QueryResolverException if the
+ * symbol is not of SingleElementSymbol type
+ *
+ * @param orderBy
+ * @param fromClauseGroups
+ * groups of the FROM clause of the query (for resolving
+ * ambiguous unqualified element names), or empty List if a Set
+ * Query Order By is being resolved
+ * @param knownElements
+ * resolved elements from SELECT clause, which are only ones
+ * allowed to be in ORDER BY
+ * @param metadata
+ * QueryMetadataInterface
+ * @param isSimpleQuery
+ */
+ public static void resolveOrderBy(OrderBy orderBy, QueryCommand command, QueryMetadataInterface metadata)
throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
- orderBy.setInPlanForm(false);
+ List<SingleElementSymbol> knownElements = command.getProjectedQuery().getSelect().getProjectedSymbols();
+
+ boolean isSimpleQuery = false;
+ List fromClauseGroups = Collections.emptyList();
+ if (command instanceof Query) {
+ Query query = (Query)command;
+ isSimpleQuery = !query.getSelect().isDistinct() && query.getGroupBy() == null;
+ if (query.getFrom() != null) {
+ fromClauseGroups = query.getFrom().getGroups();
+ }
+ }
+
// Cached state, if needed
String[] knownShortNames = new String[knownElements.size()];
+ List<Expression> expressions = new ArrayList<Expression>(knownElements.size());
for(int i=0; i<knownElements.size(); i++) {
- SingleElementSymbol knownSymbol = (SingleElementSymbol) knownElements.get(i);
+ SingleElementSymbol knownSymbol = knownElements.get(i);
+ expressions.add(SymbolMap.getExpression(knownSymbol));
if (knownSymbol instanceof ExpressionSymbol) {
continue;
}
String name = knownSymbol.getShortName();
- //special check for uuid element symbols
- if (knownSymbol instanceof ElementSymbol && knownSymbol.getShortName().equalsIgnoreCase(knownSymbol.getName())) {
- name = metadata.getShortElementName(metadata.getFullName((((ElementSymbol)knownSymbol).getMetadataID())));
- }
knownShortNames[i] = name;
}
- // Collect all elements from order by
- List elements = orderBy.getVariables();
- Iterator elementIter = elements.iterator();
-
- // Walk through elements of order by
- while(elementIter.hasNext()){
- ElementSymbol symbol = (ElementSymbol) elementIter.next();
- SingleElementSymbol matchedSymbol = null;
- String symbolName = symbol.getName();
- String groupPart = metadata.getGroupName(symbolName);
- String shortName = symbol.getShortName();
-
- //check for union order by (allow uuids to skip this check)
- if (fromClauseGroups.isEmpty() && groupPart != null && !shortName.equals(symbolName)) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0043, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0043, symbolName));
- }
-
- // walk the SELECT col short names, looking for a match on the current ORDER BY 'short name'
- for(int i=0; i<knownShortNames.length; i++) {
- if( shortName.equalsIgnoreCase( knownShortNames[i] )) {
- if (groupPart != null) {
- Object knownSymbol = knownElements.get(i);
- if(knownSymbol instanceof ElementSymbol) {
- ElementSymbol knownElement = (ElementSymbol) knownSymbol;
- GroupSymbol group = knownElement.getGroupSymbol();
-
- // skip this one if the two short names are not from the same group
- if (!nameMatchesGroup(groupPart.toUpperCase(), group.getCanonicalName())) {
- continue;
- }
- }
- }
-
- // if we already have a matched symbol, matching again here means it is duplicate/ambiguous
- if(matchedSymbol != null) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0042, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0042, symbolName));
- }
- matchedSymbol = (SingleElementSymbol)knownElements.get(i);
+ for (int i = 0; i < orderBy.getVariableCount(); i++) {
+ SingleElementSymbol sortKey = orderBy.getVariable(i);
+ if (sortKey instanceof ElementSymbol) {
+ int index = resolveSortKey(orderBy, fromClauseGroups, knownElements, metadata,
+ isSimpleQuery, knownShortNames, (ElementSymbol)sortKey);
+ if (index == -1) {
+ index = expressions.indexOf(SymbolMap.getExpression(sortKey));
}
- }
-
- // this clause handles the order by clause like
- // select foo from bar order by "1"; where 1 is foo.
- if (matchedSymbol == null && StringUtil.isDigits(symbolName)) {
- int elementOrder = Integer.valueOf(symbolName).intValue() - 1;
- // adjust for the 1 based index.
- if (elementOrder < knownElements.size() && elementOrder >= 0) {
- matchedSymbol = (SingleElementSymbol)knownElements.get(elementOrder);
-
- for(int i=0; i<knownShortNames.length; i++) {
- if (i == elementOrder) {
- continue;
- }
- if (matchedSymbol.getShortCanonicalName().equalsIgnoreCase(knownShortNames[i])) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0042, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0042, knownShortNames[i]));
- }
- }
+ orderBy.setExpressionPosition(i, index);
+ if (index == -1) {
+ orderBy.addUnrelated((ElementSymbol)sortKey);
}
- }
-
- if(matchedSymbol == null) {
- // Didn't find it by full name or short name, so try resolving
- // and retrying by full name - this will work for uuid case
- try {
- ResolverVisitor.resolveLanguageObject(symbol, fromClauseGroups, metadata);
- } catch(QueryResolverException e) {
- throw new QueryResolverException(e, ErrorMessageKeys.RESOLVER_0043, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0043, symbol.getName()) );
- }
-
- matchedSymbol = findMatchingElementByID(symbol, knownElements);
- }
-
- if (matchedSymbol == null) {
- if (!isSimpleQuery) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0043, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0043, symbol.getName()));
- }
- orderBy.setUnrelated(true);
- } else {
- TempMetadataID tempMetadataID = new TempMetadataID(symbol.getName(), matchedSymbol.getType());
- tempMetadataID.setPosition(knownElements.indexOf(matchedSymbol));
- symbol.setMetadataID(tempMetadataID);
- symbol.setType(matchedSymbol.getType());
- }
+ continue;
+ } else if (sortKey instanceof ExpressionSymbol) {
+ // check for legacy positional
+ ExpressionSymbol es = (ExpressionSymbol)sortKey;
+ if (es.getExpression() instanceof Constant) {
+ Constant c = (Constant)es.getExpression();
+ int elementOrder = Integer.valueOf(c.getValue().toString()).intValue();
+ // adjust for the 1 based index.
+ if (elementOrder > knownElements.size() || elementOrder < 1) {
+ throw new QueryResolverException(QueryPlugin.Util.getString("SQLParser.non_position_constant", c)); //$NON-NLS-1$
+ }
+ orderBy.setExpressionPosition(i, elementOrder - 1);
+ }
+ }
+ //handle order by expressions
+ if (command instanceof SetQuery) {
+ throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.setquery_order_expression", sortKey)); //$NON-NLS-1$
+ }
+ for (ElementSymbol symbol : ElementCollectorVisitor.getElements(sortKey, false)) {
+ resolveSortKey(orderBy, fromClauseGroups, knownElements, metadata,
+ isSimpleQuery, knownShortNames, symbol);
+ }
+ ResolverVisitor.resolveLanguageObject(sortKey, metadata);
+ int index = expressions.indexOf(SymbolMap.getExpression(sortKey));
+
+ if (index != -1) {
+ //the query is using an derived column, but not through an alias
+ orderBy.setExpressionPosition(i, index);
+ }
+ //must be an unrelated sort expression
}
}
+
+ private static int resolveSortKey(OrderBy orderBy, List fromClauseGroups,
+ List knownElements, QueryMetadataInterface metadata,
+ boolean isSimpleQuery, String[] knownShortNames,
+ ElementSymbol symbol) throws MetaMatrixComponentException,
+ QueryMetadataException, QueryResolverException {
+ SingleElementSymbol matchedSymbol = null;
+ String symbolName = symbol.getName();
+ String groupPart = metadata.getGroupName(symbolName);
+ String shortName = symbol.getShortName();
+
+ //check for union order by
+ if (fromClauseGroups.isEmpty() && groupPart != null && !shortName.equals(symbolName)) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0043, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0043, symbolName));
+ }
- /**
- * Helper for resolveOrderBy to find a matching fully-qualified element in a list of
- * projected SELECT symbols.
- * @throws QueryResolverException
- */
- private static SingleElementSymbol findMatchingElementByID(ElementSymbol symbol, List knownElements) throws QueryResolverException {
- Object elementID = symbol.getMetadataID();
-
- if(elementID == null) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0043, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0043, symbol.getName()));
- }
-
- Object groupID = symbol.getGroupSymbol().getMetadataID();
+ // walk the SELECT col short names, looking for a match on the current ORDER BY 'short name'
+ for(int i=0; i<knownShortNames.length; i++) {
+ if( shortName.equalsIgnoreCase( knownShortNames[i] )) {
+ if (groupPart != null) {
+ Object knownSymbol = knownElements.get(i);
+ if(knownSymbol instanceof ElementSymbol) {
+ ElementSymbol knownElement = (ElementSymbol) knownSymbol;
+ GroupSymbol group = knownElement.getGroupSymbol();
+
+ // skip this one if the two short names are not from the same group
+ if (!nameMatchesGroup(groupPart.toUpperCase(), group.getCanonicalName())) {
+ continue;
+ }
+ }
+ }
+
+ // if we already have a matched symbol, matching again here means it is duplicate/ambiguous
+ if(matchedSymbol != null) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0042, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0042, symbolName));
+ }
+ matchedSymbol = (SingleElementSymbol)knownElements.get(i);
+ }
+ }
+
+ if (matchedSymbol != null) {
+ TempMetadataID tempMetadataID = new TempMetadataID(symbol.getName(), matchedSymbol.getType());
+ int position = knownElements.indexOf(matchedSymbol);
+ tempMetadataID.setPosition(position);
+ symbol.setMetadataID(tempMetadataID);
+ symbol.setType(matchedSymbol.getType());
+ return position;
+ }
+ if (!isSimpleQuery) {
+ throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.invalid_unrelated", symbol.getName())); //$NON-NLS-1$
+ }
+ // Didn't find it by full name or short name, so try resolving
+ try {
+ ResolverVisitor.resolveLanguageObject(symbol, fromClauseGroups, metadata);
+ } catch(QueryResolverException e) {
+ throw new QueryResolverException(e, ErrorMessageKeys.RESOLVER_0043, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0043, symbol.getName()) );
+ }
+ return -1;
+ }
- for(int i=0; i<knownElements.size(); i++) {
- SingleElementSymbol selectSymbol = (SingleElementSymbol)knownElements.get(i);
- SingleElementSymbol knownSymbol = null;
- if(selectSymbol instanceof AliasSymbol) {
- knownSymbol = ((AliasSymbol)selectSymbol).getSymbol();
- }
- if(knownSymbol instanceof ElementSymbol) {
- ElementSymbol knownElement = (ElementSymbol) knownSymbol;
- Object knownElementID = knownElement.getMetadataID();
-
- if(elementID.equals(knownElementID)) {
- Object knownGroupID = knownElement.getGroupSymbol().getMetadataID();
- if(groupID.equals(knownGroupID)) {
- return selectSymbol;
- }
- }
- }
- }
-
- return null;
- }
-
/**
* Get the default value for the parameter, which could be null
* if the parameter is set to NULLABLE. If no default is available,
@@ -776,25 +776,6 @@
}
return false;
}
-
- /**
- * Checks if a variable is in the ORDER BY
- * @param position 0-based index of the variable
- * @return True if the ORDER BY contains the element
- */
- public static boolean orderByContainsVariable(OrderBy orderBy, SingleElementSymbol ses, int position) {
- if (!orderBy.isInPlanForm()) {
- for (final Iterator iterator = orderBy.getVariables().iterator(); iterator.hasNext();) {
- final ElementSymbol element = (ElementSymbol)iterator.next();
- if (position == ((TempMetadataID)element.getMetadataID()).getPosition()) {
- return true;
- }
- }
- } else {
- return orderBy.getVariables().contains(ses);
- }
- return false;
- }
/**
* Check the type of the (left) expression and the type of the single
Modified: trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -66,7 +66,6 @@
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.SupportConstants;
import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
import com.metamatrix.query.metadata.TempMetadataStore;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.relational.DependentValueSource;
@@ -143,6 +142,7 @@
import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.symbol.ScalarSubquery;
import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
+import com.metamatrix.query.sql.symbol.SelectSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.util.ValueIterator;
@@ -729,79 +729,7 @@
}
}
- if (query.getGroupBy() != null) {
- // we check for group by expressions here to create an ANSI SQL plan
- boolean hasExpression = false;
- for (final Iterator iterator = query.getGroupBy().getSymbols().iterator(); !hasExpression && iterator.hasNext();) {
- hasExpression = iterator.next() instanceof ExpressionSymbol;
- }
- if (hasExpression) {
- Select select = query.getSelect();
- GroupBy groupBy = query.getGroupBy();
- query.setGroupBy(null);
- Criteria having = query.getHaving();
- query.setHaving(null);
- OrderBy orderBy = query.getOrderBy();
- query.setOrderBy(null);
- Limit limit = query.getLimit();
- query.setLimit(null);
- Into into = query.getInto();
- query.setInto(null);
- Set<Expression> newSelectColumns = new HashSet<Expression>();
- for (final Iterator iterator = groupBy.getSymbols().iterator(); iterator.hasNext();) {
- newSelectColumns.add(SymbolMap.getExpression((SingleElementSymbol)iterator.next()));
- }
- Set<AggregateSymbol> aggs = new HashSet<AggregateSymbol>();
- aggs.addAll(AggregateSymbolCollectorVisitor.getAggregates(select, true));
- if (having != null) {
- aggs.addAll(AggregateSymbolCollectorVisitor.getAggregates(having, true));
- }
- for (AggregateSymbol aggregateSymbol : aggs) {
- if (aggregateSymbol.getExpression() != null) {
- Expression expr = aggregateSymbol.getExpression();
- newSelectColumns.add(SymbolMap.getExpression(expr));
- }
- }
- Select innerSelect = new Select();
- int index = 0;
- for (Expression expr : newSelectColumns) {
- if (expr instanceof SingleElementSymbol) {
- innerSelect.addSymbol((SingleElementSymbol)expr);
- } else {
- innerSelect.addSymbol(new ExpressionSymbol("EXPR" + index++ , expr)); //$NON-NLS-1$
- }
- }
- query.setSelect(innerSelect);
- Query outerQuery = null;
- try {
- outerQuery = QueryRewriter.createInlineViewQuery(new GroupSymbol("X"), query, metadata, query.getSelect().getProjectedSymbols()); //$NON-NLS-1$
- } catch (QueryMetadataException err) {
- throw new QueryValidatorException(err, err.getMessage());
- } catch (QueryResolverException err) {
- throw new QueryValidatorException(err, err.getMessage());
- } catch (MetaMatrixComponentException err) {
- throw new MetaMatrixRuntimeException(err);
- }
- Iterator iter = outerQuery.getSelect().getProjectedSymbols().iterator();
- HashMap<Expression, SingleElementSymbol> expressionMap = new HashMap<Expression, SingleElementSymbol>();
- for (SingleElementSymbol symbol : (List<SingleElementSymbol>)query.getSelect().getProjectedSymbols()) {
- expressionMap.put((Expression)SymbolMap.getExpression(symbol).clone(), (SingleElementSymbol)iter.next());
- }
- ExpressionMappingVisitor.mapExpressions(groupBy, expressionMap);
- outerQuery.setGroupBy(groupBy);
- ExpressionMappingVisitor.mapExpressions(having, expressionMap);
- outerQuery.setHaving(having);
- ExpressionMappingVisitor.mapExpressions(orderBy, expressionMap);
- outerQuery.setOrderBy(orderBy);
- outerQuery.setLimit(limit);
- ExpressionMappingVisitor.mapExpressions(select, expressionMap);
- outerQuery.setSelect(select);
- outerQuery.setInto(into);
- outerQuery.setOption(query.getOption());
- query = outerQuery;
- rewriteExpressions(innerSelect);
- }
- }
+ query = rewriteGroupBy(query);
// Rewrite having
Criteria having = query.getHaving();
@@ -812,7 +740,7 @@
rewriteExpressions(query.getSelect());
if (!query.getIsXML()) {
- rewriteOrderBy(query);
+ query = (Query)rewriteOrderBy(query);
}
if (query.getLimit() != null) {
@@ -825,6 +753,91 @@
return query;
}
+
+ /**
+ * Converts a group by with expressions into a group by with only element symbols and an inline view
+ * @param query
+ * @return
+ * @throws QueryValidatorException
+ */
+ private Query rewriteGroupBy(Query query) throws QueryValidatorException {
+ if (query.getGroupBy() == null) {
+ return query;
+ }
+ // we check for group by expressions here to create an ANSI SQL plan
+ boolean hasExpression = false;
+ for (final Iterator iterator = query.getGroupBy().getSymbols().iterator(); !hasExpression && iterator.hasNext();) {
+ hasExpression = iterator.next() instanceof ExpressionSymbol;
+ }
+ if (!hasExpression) {
+ return query;
+ }
+ Select select = query.getSelect();
+ GroupBy groupBy = query.getGroupBy();
+ query.setGroupBy(null);
+ Criteria having = query.getHaving();
+ query.setHaving(null);
+ OrderBy orderBy = query.getOrderBy();
+ query.setOrderBy(null);
+ Limit limit = query.getLimit();
+ query.setLimit(null);
+ Into into = query.getInto();
+ query.setInto(null);
+ Set<Expression> newSelectColumns = new HashSet<Expression>();
+ for (final Iterator iterator = groupBy.getSymbols().iterator(); iterator.hasNext();) {
+ newSelectColumns.add(SymbolMap.getExpression((SingleElementSymbol)iterator.next()));
+ }
+ Set<AggregateSymbol> aggs = new HashSet<AggregateSymbol>();
+ aggs.addAll(AggregateSymbolCollectorVisitor.getAggregates(select, true));
+ if (having != null) {
+ aggs.addAll(AggregateSymbolCollectorVisitor.getAggregates(having, true));
+ }
+ for (AggregateSymbol aggregateSymbol : aggs) {
+ if (aggregateSymbol.getExpression() != null) {
+ Expression expr = aggregateSymbol.getExpression();
+ newSelectColumns.add(SymbolMap.getExpression(expr));
+ }
+ }
+ Select innerSelect = new Select();
+ int index = 0;
+ for (Expression expr : newSelectColumns) {
+ if (expr instanceof SingleElementSymbol) {
+ innerSelect.addSymbol((SingleElementSymbol)expr);
+ } else {
+ innerSelect.addSymbol(new ExpressionSymbol("EXPR" + index++ , expr)); //$NON-NLS-1$
+ }
+ }
+ query.setSelect(innerSelect);
+ Query outerQuery = null;
+ try {
+ outerQuery = QueryRewriter.createInlineViewQuery(new GroupSymbol("X"), query, metadata, query.getSelect().getProjectedSymbols()); //$NON-NLS-1$
+ } catch (QueryMetadataException err) {
+ throw new QueryValidatorException(err, err.getMessage());
+ } catch (QueryResolverException err) {
+ throw new QueryValidatorException(err, err.getMessage());
+ } catch (MetaMatrixComponentException err) {
+ throw new MetaMatrixRuntimeException(err);
+ }
+ Iterator iter = outerQuery.getSelect().getProjectedSymbols().iterator();
+ HashMap<Expression, SingleElementSymbol> expressionMap = new HashMap<Expression, SingleElementSymbol>();
+ for (SingleElementSymbol symbol : (List<SingleElementSymbol>)query.getSelect().getProjectedSymbols()) {
+ expressionMap.put((Expression)SymbolMap.getExpression(symbol).clone(), (SingleElementSymbol)iter.next());
+ }
+ ExpressionMappingVisitor.mapExpressions(groupBy, expressionMap);
+ outerQuery.setGroupBy(groupBy);
+ ExpressionMappingVisitor.mapExpressions(having, expressionMap);
+ outerQuery.setHaving(having);
+ ExpressionMappingVisitor.mapExpressions(orderBy, expressionMap);
+ outerQuery.setOrderBy(orderBy);
+ outerQuery.setLimit(limit);
+ ExpressionMappingVisitor.mapExpressions(select, expressionMap);
+ outerQuery.setSelect(select);
+ outerQuery.setInto(into);
+ outerQuery.setOption(query.getOption());
+ query = outerQuery;
+ rewriteExpressions(innerSelect);
+ return query;
+ }
private void rewriteExpressions(LanguageObject obj) throws QueryValidatorException {
if (obj == null) {
@@ -855,55 +868,108 @@
/**
* Rewrite the order by clause.
+ * Unrelated order by expressions will cause the creation of nested inline views.
*
* @param query
* @throws QueryValidatorException
*/
- private void rewriteOrderBy(QueryCommand query) throws QueryValidatorException {
- OrderBy orderBy = query.getOrderBy();
+ public QueryCommand rewriteOrderBy(QueryCommand queryCommand) throws QueryValidatorException {
+ final OrderBy orderBy = queryCommand.getOrderBy();
if (orderBy == null) {
- return;
+ return queryCommand;
}
- makeSelectUnique(query.getProjectedQuery().getSelect(), true);
- List projectedSymbols = query.getProjectedQuery().getSelect().getProjectedSymbols();
- if (orderBy.isInPlanForm()) {
- rewriteExpressions(orderBy);
- }
-
- OrderBy newOrderBy = new OrderBy();
- newOrderBy.setUnrelated(orderBy.hasUnrelated());
+ Select select = queryCommand.getProjectedQuery().getSelect();
+ final List projectedSymbols = select.getProjectedSymbols();
HashSet<Expression> previousExpressions = new HashSet<Expression>();
+ boolean hasUnrelatedExpression = false;
+
for (int i = 0; i < orderBy.getVariableCount(); i++) {
- SingleElementSymbol querySymbol = orderBy.getVariable(i);
- if (!orderBy.isInPlanForm()) {
- //get the order by item from the select clause, the variable must be an element symbol
- //however we have a hack to determine the position...
- Object id = ((ElementSymbol)querySymbol).getMetadataID();
- if (id instanceof TempMetadataID) {
- int index = ((TempMetadataID)((ElementSymbol)querySymbol).getMetadataID()).getPosition();
- if (index != -1) {
- querySymbol = (SingleElementSymbol)((SingleElementSymbol)projectedSymbols.get(index)).clone();
- }
- } // else not a projected symbol
- }
- Expression expr = SymbolMap.getExpression(querySymbol);
- if (!previousExpressions.add(expr)) {
- continue;
- }
-
- if (query instanceof Query && EvaluatableVisitor.isFullyEvaluatable(expr, true)) {
- continue;
- }
- newOrderBy.addVariable((SingleElementSymbol)querySymbol.clone(), orderBy.getOrderType(i).booleanValue());
+ SingleElementSymbol querySymbol = orderBy.getVariable(i);
+ int index = orderBy.getExpressionPosition(i);
+ if (index == -1) {
+ hasUnrelatedExpression |= (querySymbol instanceof ExpressionSymbol);
+ continue; // must be unrelated - but potentially contains references to the select clause
+ }
+ querySymbol = (SingleElementSymbol)projectedSymbols.get(index);
+ Expression expr = SymbolMap.getExpression(querySymbol);
+ if (!previousExpressions.add(expr) || (queryCommand instanceof Query && EvaluatableVisitor.isFullyEvaluatable(expr, true))) {
+ orderBy.removeOrderByItem(i--);
+ } else {
+ orderBy.getVariables().set(i, querySymbol.clone());
+ }
}
- if (newOrderBy.getVariableCount() == 0) {
- query.setOrderBy(null);
- } else {
- newOrderBy.setInPlanForm(true);
- query.setOrderBy(newOrderBy);
- }
+ if (orderBy.getVariableCount() == 0) {
+ queryCommand.setOrderBy(null);
+ return queryCommand;
+ }
+
+ if (!hasUnrelatedExpression) {
+ return queryCommand;
+ }
+
+ int originalSymbolCount = select.getProjectedSymbols().size();
+
+ //add unrelated to select
+ select.addSymbols(orderBy.getUnrelated());
+ makeSelectUnique(select, false);
+
+ Query query = queryCommand.getProjectedQuery();
+
+ Into into = query.getInto();
+ query.setInto(null);
+ Limit limit = query.getLimit();
+ query.setLimit(null);
+ query.setOrderBy(null);
+
+ Query top = null;
+
+ try {
+ Query intermediate = createInlineViewQuery(new GroupSymbol("X"), query, metadata, select.getProjectedSymbols()); //$NON-NLS-1$
+ Iterator iter = intermediate.getSelect().getProjectedSymbols().iterator();
+ HashMap<Expression, SingleElementSymbol> expressionMap = new HashMap<Expression, SingleElementSymbol>();
+ for (SingleElementSymbol symbol : (List<SingleElementSymbol>)select.getProjectedSymbols()) {
+ SingleElementSymbol ses = (SingleElementSymbol)iter.next();
+ expressionMap.put(SymbolMap.getExpression(symbol), ses);
+ expressionMap.put(new ElementSymbol(symbol.getName()), ses);
+ }
+ ExpressionMappingVisitor.mapExpressions(orderBy, expressionMap);
+ for (int i = 0; i < orderBy.getVariableCount(); i++) {
+ int index = orderBy.getExpressionPosition(i);
+ SingleElementSymbol ss = orderBy.getVariable(i);
+ if (index == -1 && !(ss instanceof ElementSymbol)) {
+ intermediate.getSelect().addSymbol((SelectSymbol)ss.clone());
+ }
+ }
+ makeSelectUnique(intermediate.getSelect(), true);
+
+ top = createInlineViewQuery(new GroupSymbol("Y"), intermediate, metadata, intermediate.getSelect().getProjectedSymbols()); //$NON-NLS-1$
+ iter = top.getSelect().getProjectedSymbols().iterator();
+ expressionMap = new HashMap<Expression, SingleElementSymbol>();
+ for (SingleElementSymbol symbol : (List<SingleElementSymbol>)intermediate.getSelect().getProjectedSymbols()) {
+ expressionMap.put(SymbolMap.getExpression(symbol), (SingleElementSymbol)iter.next());
+ }
+ ExpressionMappingVisitor.mapExpressions(orderBy, expressionMap);
+ //now the order by should only contain element symbols
+ } catch (QueryResolverException e) {
+ throw new QueryValidatorException(e, e.getMessage());
+ } catch (QueryMetadataException e) {
+ throw new QueryValidatorException(e, e.getMessage());
+ } catch (MetaMatrixComponentException e) {
+ throw new QueryValidatorException(e, e.getMessage());
+ }
+ //filter back out the unrelated
+ orderBy.getUnrelated().clear();
+ List symbols = top.getSelect().getSymbols();
+ for (ElementSymbol symbol : (List<ElementSymbol>)symbols.subList(originalSymbolCount, symbols.size())) {
+ orderBy.addUnrelated(symbol);
+ }
+ top.getSelect().setSymbols(symbols.subList(0, originalSymbolCount));
+ top.setInto(into);
+ top.setLimit(limit);
+ top.setOrderBy(orderBy);
+ return top;
}
/**
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/OrderBy.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/OrderBy.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/OrderBy.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -24,14 +24,18 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.core.util.HashCodeUtil;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.LanguageVisitor;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.visitor.SQLStringVisitor;
import com.metamatrix.query.util.ErrorMessageKeys;
@@ -46,17 +50,20 @@
public class OrderBy implements LanguageObject {
/** Constant for the ascending value */
- public static final boolean ASC = Boolean.TRUE.booleanValue();
+ public static final boolean ASC = true;
/** Constant for the descending value */
- public static final boolean DESC = Boolean.FALSE.booleanValue();
+ public static final boolean DESC = false;
private List sortOrder;
private List orderTypes;
- private boolean inPlanForm = true;
- private boolean hasUnrelated;
-
/**
+ * set by the resolver to contain element symbol references
+ * outside of the select clause
+ */
+ private Set<ElementSymbol> unrelated;
+ private List<Integer> expressionPositions;
+ /**
* Constructs a default instance of this class.
*/
public OrderBy() {
@@ -192,8 +199,16 @@
copySymbols.add(ses.clone());
}
OrderBy result = new OrderBy(copySymbols, getTypes());
- result.setInPlanForm(this.inPlanForm);
- result.setUnrelated(this.hasUnrelated);
+ if (this.unrelated != null) {
+ HashSet<ElementSymbol> copyUnrelated = new HashSet<ElementSymbol>();
+ for (ElementSymbol elementSymbol : this.unrelated) {
+ copyUnrelated.add((ElementSymbol)elementSymbol.clone());
+ }
+ result.unrelated = copyUnrelated;
+ }
+ if (this.expressionPositions != null) {
+ result.expressionPositions = new ArrayList<Integer>(expressionPositions);
+ }
return result;
}
@@ -239,20 +254,42 @@
return SQLStringVisitor.getSQLString(this);
}
- public boolean isInPlanForm() {
- return this.inPlanForm;
+ public boolean hasUnrelated() {
+ return this.unrelated != null;
+ }
+
+ public void addUnrelated(ElementSymbol symbol) {
+ if (this.unrelated == null) {
+ this.unrelated = new HashSet<ElementSymbol>();
+ }
+ this.unrelated.add(symbol);
+ }
+
+ public Set<ElementSymbol> getUnrelated() {
+ if (this.unrelated == null) {
+ return Collections.emptySet();
+ }
+ return unrelated;
+ }
+
+ public void setExpressionPosition(int orderIndex, int selectIndex) {
+ if (this.expressionPositions == null) {
+ this.expressionPositions = new ArrayList<Integer>(Collections.nCopies(sortOrder.size(), -1));
+ }
+ this.expressionPositions.set(orderIndex, selectIndex);
}
-
- public void setInPlanForm(boolean inPlanForm) {
- this.inPlanForm = inPlanForm;
- }
- public boolean hasUnrelated() {
- return hasUnrelated;
+ public int getExpressionPosition(int orderIndex) {
+ if (expressionPositions == null) {
+ return -1;
+ }
+ return expressionPositions.get(orderIndex);
}
- public void setUnrelated(boolean hasUnrelated) {
- this.hasUnrelated = hasUnrelated;
- }
-
+ public void removeOrderByItem(int index) {
+ sortOrder.remove(index);
+ orderTypes.remove(index);
+ expressionPositions.remove(index);
+ }
+
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -30,6 +30,7 @@
import java.util.List;
import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.core.util.StringUtil;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.ReservedWords;
@@ -114,6 +115,7 @@
private static final String SPACE = " "; //$NON-NLS-1$
private static final String BEGIN_COMMENT = "/*"; //$NON-NLS-1$
private static final String END_COMMENT = "*/"; //$NON-NLS-1$
+ private static final char ID_ESCAPE_CHAR = '\"';
private LinkedList<Object> parts = new LinkedList<Object>();
@@ -618,87 +620,77 @@
}
public void visit(Option obj) {
- boolean anOption = false;
- List parts = new ArrayList();
-
parts.add(ReservedWords.OPTION);
if(obj.getShowPlan()) {
- anOption = true;
parts.add(" "); //$NON-NLS-1$
parts.add(ReservedWords.SHOWPLAN);
}
if(obj.getPlanOnly()) {
- anOption = true;
parts.add(" "); //$NON-NLS-1$
parts.add(ReservedWords.PLANONLY);
}
if(obj.getDebug()) {
- anOption = true;
parts.add(" "); //$NON-NLS-1$
parts.add(ReservedWords.DEBUG);
}
Collection groups = obj.getDependentGroups();
if(groups != null && groups.size() > 0) {
- anOption = true;
parts.add(" "); //$NON-NLS-1$
parts.add(ReservedWords.MAKEDEP);
parts.add(" "); //$NON-NLS-1$
Iterator iter = groups.iterator();
- parts.add(iter.next());
while(iter.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
- parts.add(iter.next());
+ outputDisplayName((String)iter.next());
+
+ if (iter.hasNext()) {
+ parts.add(", ");
+ }
}
}
groups = obj.getNotDependentGroups();
if(groups != null && groups.size() > 0) {
- anOption = true;
parts.add(" "); //$NON-NLS-1$
parts.add(ReservedWords.MAKENOTDEP);
parts.add(" "); //$NON-NLS-1$
Iterator iter = groups.iterator();
- parts.add(iter.next());
while(iter.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
- parts.add(iter.next());
+ outputDisplayName((String)iter.next());
+
+ if (iter.hasNext()) {
+ parts.add(", ");
+ }
}
}
groups = obj.getNoCacheGroups();
if(groups != null && groups.size() > 0) {
- anOption = true;
parts.add(" "); //$NON-NLS-1$
parts.add(ReservedWords.NOCACHE);
parts.add(" "); //$NON-NLS-1$
Iterator iter = groups.iterator();
- parts.add(iter.next());
while(iter.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
- parts.add(iter.next());
+ outputDisplayName((String)iter.next());
+
+ if (iter.hasNext()) {
+ parts.add(", ");
+ }
}
}else if(obj.isNoCache()){
- anOption = true;
parts.add(" "); //$NON-NLS-1$
parts.add(ReservedWords.NOCACHE);
}
- // Only add this if any option was set to true - otherwise omit
- if(anOption) {
- replaceStringParts(parts.toArray());
- } else {
- replaceStringParts(new Object[0]);
- }
}
public void visit(OrderBy obj) {
@@ -713,11 +705,12 @@
Iterator typeIter = types.iterator();
while ( iter.hasNext() ) {
SingleElementSymbol ses = (SingleElementSymbol)iter.next();
- if (ses instanceof ElementSymbol && ((ElementSymbol)ses).getDisplayMode().equals(ElementSymbol.DisplayMode.SHORT_OUTPUT_NAME)) {
- parts.add(registerNode(ses));
- } else {
- outputDisplayName(ses.getOutputName());
- }
+ if (ses instanceof AliasSymbol) {
+ AliasSymbol as = (AliasSymbol)ses;
+ outputDisplayName(as.getOutputName());
+ } else {
+ parts.add(registerNode(ses));
+ }
Boolean type = (Boolean) typeIter.next();
if( type.booleanValue() == OrderBy.DESC ) {
parts.add(SPACE);
@@ -1000,7 +993,7 @@
if(param.getExpression() == null) {
if(param.getName() != null) {
- parts.add(escapeSinglePart(obj.getParamFullName(param)));
+ outputDisplayName(obj.getParamFullName(param));
} else {
parts.add("?"); //$NON-NLS-1$
}
@@ -1151,7 +1144,7 @@
constantParts = new Object[] { "{d'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
} else {
String strValue = obj.getValue().toString();
- strValue = escapeStringValue(strValue);
+ strValue = escapeStringValue(strValue, '\'');
constantParts = new Object[] { getStringQuoteBegin(), strValue, getStringQuoteEnd() };
}
}
@@ -1180,8 +1173,8 @@
* @param str String literal value (unquoted), never null
* @return Escaped string literal value
*/
- protected String escapeStringValue(String str) {
- int index = str.indexOf('\'');
+ protected String escapeStringValue(String str, char tick) {
+ int index = str.indexOf(tick);
if(index < 0) {
return str;
}
@@ -1189,9 +1182,9 @@
StringBuffer temp = new StringBuffer();
while(index >= 0) {
temp.append(str.substring(last, index));
- temp.append("''"); //$NON-NLS-1$
+ temp.append(tick).append(tick);
last = index+1;
- index = str.indexOf('\'', last);
+ index = str.indexOf(tick, last);
}
if(last <= (str.length()-1)) {
@@ -1591,13 +1584,23 @@
parts.add(registerNode(obj.getRowLimit()));
}
- private static final char ID_ESCAPE_CHAR = '\"';
-
private String escapeSinglePart(String part) {
if(isReservedWord(part)) {
return ID_ESCAPE_CHAR + part + ID_ESCAPE_CHAR;
}
- return part;
+ boolean escape = true;
+ char start = part.charAt(0);
+ if (start == '#' || start == '@' || StringUtil.isLetter(start)) {
+ escape = false;
+ for (int i = 1; !escape && i < part.length(); i++) {
+ char c = part.charAt(i);
+ escape = !StringUtil.isLetterOrDigit(c) && c != '_';
+ }
+ }
+ if (escape) {
+ return ID_ESCAPE_CHAR + escapeStringValue(part, '"') + ID_ESCAPE_CHAR;
+ }
+ return part;
}
/**
Modified: trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -644,6 +644,17 @@
if(obj.getLimit() != null) {
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.limit_not_valid_for_xml"), obj); //$NON-NLS-1$
}
+ if (obj.getOrderBy() != null) {
+ OrderBy orderBy = obj.getOrderBy();
+ if (orderBy.hasUnrelated()) {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.unrelated_orderby_xml"), obj); //$NON-NLS-1$
+ }
+ for (SingleElementSymbol ses : (List<SingleElementSymbol>)orderBy.getVariables()) {
+ if (!(ses instanceof ElementSymbol)) {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.orderby_expression_xml"), obj); //$NON-NLS-1$
+ }
+ }
+ }
}
protected void validateGroupSupportsUpdate(GroupSymbol groupSymbol) {
Modified: trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2009-11-20 17:27:16 UTC (rev 1578)
@@ -194,22 +194,14 @@
| <SQL_TSI_YEAR: "SQL_TSI_YEAR">
}
-TOKEN : /* User variables and literals
- - NOTE IDs are not spec compliant. We allow for
- - any number of name parts to appear and restrict quoted
- - IDs to continaing regular identifiers
- */
+TOKEN : /* User variables and literals */
{
- < ALL_IN_GROUP: <GROUP_PART> <PERIOD> <STAR> >
+ < ALL_IN_GROUP: <ID> <PERIOD> <STAR> >
-| < ID: <GROUP_PART> ( <PERIOD> <QUOTED_ID> )? >
+| < ID: <QUOTED_ID> (<PERIOD> <QUOTED_ID>)* >
+| < #QUOTED_ID: <ID_PART> | ("\"" (("\"\"") | ~["\""] )+ "\"") >
+| < #ID_PART: (("@" | "#" | <LETTER>) (<LETTER> | "_" | <DIGIT>)*) >
-| < #GROUP_PART: ("#")? (<QUOTED_ID> <PERIOD>)? <QUOTED_ID> >
-| < #QUOTED_ID: <DOTTED_ID> | ("\"" <DOTTED_ID> "\"") >
-| < #DOTTED_ID: <ID_PART> (<PERIOD> <ID_PART>)* >
-| < #ID_PART: ("@")? <LETTER> (<ID_CHAR>)* >
-| < #ID_CHAR: (<LETTER> | "_" | <DIGIT>) >
-
| < DATETYPE: "{" "d" >
| < TIMETYPE: "{" "t" >
| < TIMESTAMPTYPE: "{" "ts" >
@@ -218,12 +210,9 @@
| < INTEGERVAL: (<MINUS>)?(<DIGIT>)+ >
| < FLOATVAL: (<MINUS>)? (<DIGIT>)* <PERIOD> (<DIGIT>)+
( ["e", "E"] (["+","-"])? (<DIGIT>)+ )? >
-| < STRINGVAL: (("N")? (<STRINGA> | <STRINGB>)) >
-| < #STRINGA: "'" (~["'"])* ( "''" (~["'"])* )* "'" >
-| < #STRINGB: "\"" (~["\""])* ( "\"\"" (~["\""])* )* "\"" >
+| < STRINGVAL: (("N")? "'" ( ("''") | ~["'"] )* "'") >
| < #LETTER: (["a"-"z","A"-"Z"] | ["\u0153"-"\ufffd"]) >
| < #DIGIT: ["0"-"9"] >
-| < #COLON: ":">
}
@@ -256,6 +245,28 @@
//----------------------------------------------------
//----------------------------------------------------
+String stringVal() :
+{
+ Token t = null;
+}
+{
+ (t = <STRINGVAL>)
+ {
+ return normalizeStringLiteral(t.image);
+ }
+}
+
+String id() :
+{
+ Token t = null;
+}
+{
+ (t = <ID>)
+ {
+ return normalizeId(t.image);
+ }
+}
+
/**
* Parse any of several command types - this is the main parser entry point.
* @param info instructions to parse the command
@@ -305,13 +316,13 @@
Command dropTable(ParseInfo info) :
{
Drop drop = new Drop();
- Token tableToken = null;
+ String table = null;
}
{
<DROP> <TABLE>
- tableToken = <ID>
+ table = id()
{
- drop.setTable(new GroupSymbol(validateMetadataID(tableToken.image)));
+ drop.setTable(new GroupSymbol(table));
return drop;
}
}
@@ -325,15 +336,15 @@
Command createTempTable(ParseInfo info) :
{
Create create = new Create();
- Token tableToken = null;
+ String table = null;
List columns = null;
}
{
<CREATE> <LOCAL> <TEMPORARY> <TABLE>
- tableToken = <ID>
+ table = id()
<LPAREN>
{
- create.setTable(new GroupSymbol(validateMetadataID(tableToken.image)));
+ create.setTable(new GroupSymbol(table));
}
columns = createElementsWithTypes(info)
{
@@ -496,7 +507,7 @@
LoopStatement loopStatement(ParseInfo info) :
{
LoopStatement loopStmt = null;
- Token cursor = null;
+ String cursor = null;
QueryCommand query = null;
Block block = null;
}
@@ -507,12 +518,11 @@
query = queryExpression(info)
<RPAREN>
<AS>
- cursor = <ID>
+ cursor = id()
block = block(info)
{
- String cursorName = cursor.image;
- loopStmt = new LoopStatement(block, query, cursorName);
+ loopStmt = new LoopStatement(block, query, cursor);
return loopStmt;
}
@@ -553,7 +563,7 @@
{
CriteriaSelector critSelector = new CriteriaSelector();
- Token elementToken = null;
+ String element = null;
List elements = new ArrayList();
Token operator = null;
}
@@ -579,18 +589,18 @@
[LOOKAHEAD(4)<ON>
<LPAREN>
- elementToken = <ID>
+ element = id()
{
- elements.add(new ElementSymbol(validateMetadataID(elementToken.image)));
+ elements.add(new ElementSymbol(element));
}
(<COMMA>
- elementToken = <ID>
-
- {
- elements.add(new ElementSymbol(validateMetadataID(elementToken.image)));
- }
+ element = id()
+
+ {
+ elements.add(new ElementSymbol(element));
+ }
)*
<RPAREN>
@@ -631,7 +641,7 @@
DeclareStatement declareStatement(ParseInfo info) :
{
DeclareStatement declStmt = null;
- Token varToken = null;
+ String var = null;
Constant type = null;
ElementSymbol variableID = null;
LanguageObject value = null;
@@ -639,9 +649,9 @@
{
<DECLARE>
type = dataType()
- varToken = <ID>
+ var = id()
{
- variableID = new ElementSymbol(validateMetadataID(varToken.image));
+ variableID = new ElementSymbol(var);
}
[<EQ>
value = assignStatementOperand(info)
@@ -660,14 +670,14 @@
AssignmentStatement assignStatement(ParseInfo info) :
{
LanguageObject value = null;
- Token varToken = null;
+ String var = null;
ElementSymbol elementID = null;
}
{
- varToken = <ID>
+ var = id()
{
- elementID = new ElementSymbol(validateMetadataID(varToken.image));
+ elementID = new ElementSymbol(var);
}
<EQ>
value = assignStatementOperand(info)
@@ -725,7 +735,7 @@
TranslateCriteria translateCriteria(ParseInfo info) :
{
- Token elementToken = null;
+ String element = null;
Expression value = null;
ElementSymbol leftSymbol = null;
@@ -746,12 +756,12 @@
critList = new ArrayList();
}
<LPAREN>
- elementToken = <ID>
+ element = id()
<EQ>
value = expression(info)
{
compCrit = new CompareCriteria();
- leftSymbol = new ElementSymbol(elementToken.image);
+ leftSymbol = new ElementSymbol(element);
compCrit.setLeftExpression(leftSymbol);
compCrit.setRightExpression(value);
compCrit.setOperator(CompareCriteria.EQ);
@@ -759,12 +769,12 @@
compCrit = null;
}
( <COMMA>
- elementToken = <ID>
+ element = id()
<EQ>
value = expression(info)
{
compCrit = new CompareCriteria();
- leftSymbol = new ElementSymbol(elementToken.image);
+ leftSymbol = new ElementSymbol(element);
compCrit.setLeftExpression(leftSymbol);
compCrit.setRightExpression(value);
compCrit.setOperator(CompareCriteria.EQ);
@@ -815,7 +825,7 @@
DynamicCommand dynamicCommand(ParseInfo info) :
{
Expression sql = null;
- Token groupToken = null;
+ String groupID = null;
GroupSymbol group = null;
int updateCount = 0;
Token updateToken = null;
@@ -834,9 +844,8 @@
elements = createElementsWithTypes(info)
[<INTO>
- groupToken = <ID>
+ groupID = id()
{
- String groupID = validateMetadataID(groupToken.image);
group = new GroupSymbol(groupID);
}
]
@@ -872,22 +881,22 @@
SetClauseList setClauseList(boolean shortName, ParseInfo info) :
{
SetClauseList using = new SetClauseList();
- Token elementToken = null;
+ String element = null;
}
{
- elementToken = <ID>
+ element = id()
<EQ>
{
- String symbolName = shortName?validateElementName(elementToken.image):validateMetadataID(elementToken.image);
+ String symbolName = shortName?validateElementName(element):element;
ElementSymbol symbol = new ElementSymbol(symbolName);
Expression value = expression(info);
using.addClause(symbol, value);
}
(<COMMA>
- elementToken = <ID>
+ element = id()
<EQ>
{
- symbolName = shortName?validateElementName(elementToken.image):validateMetadataID(elementToken.image);
+ symbolName = shortName?validateElementName(element):element;
symbol = new ElementSymbol(symbolName);
value = expression(info);
using.addClause(symbol, value);
@@ -899,28 +908,28 @@
}
/**
- * * Create elementes with datatypes
+ * Create elements with datatypes
* @throws ParseException if parsing failed
*/
List createElementsWithTypes(ParseInfo info) :
{
- Token elementToken = null;
+ String element = null;
Constant type = null;
List elements = new ArrayList();
}
{
- elementToken = <ID>
+ element = id()
type = dataType()
{
- ElementSymbol symbol = new ElementSymbol(validateElementName(elementToken.image));
+ ElementSymbol symbol = new ElementSymbol(validateElementName(element));
symbol.setType(DataTypeManager.getDataTypeClass(type.getValue().toString()));
elements.add(symbol);
}
(<COMMA>
- elementToken = <ID>
+ element = id()
type = dataType()
{
- symbol = new ElementSymbol(validateElementName(elementToken.image));
+ symbol = new ElementSymbol(validateElementName(element));
symbol.setType(DataTypeManager.getDataTypeClass(type.getValue().toString()));
elements.add(symbol);
}
@@ -935,7 +944,7 @@
StoredProcedure storedProcedure = new StoredProcedure();
storedProcedure.setCallableStatement(true);
Token call = null;
- Token procNameToken = null;
+ String procName = null;
Option option = null;
SPParameter parameter = null;
int parameterIndex = 1;
@@ -954,9 +963,9 @@
throw new ParseException(QueryPlugin.Util.getString("SQLParser.call_expected")); //$NON-NLS-1$
}
}
- procNameToken = <ID>
+ procName = id()
{
- storedProcedure.setProcedureName(procNameToken.image);
+ storedProcedure.setProcedureName(procName);
}
//parameters
@@ -988,15 +997,15 @@
StoredProcedure storedProcedure(ParseInfo info) :
{
StoredProcedure storedProcedure = new StoredProcedure();
- Token procNameToken = null;
+ String procName = null;
Option option = null;
}
{
(
(<EXEC> | <EXECUTE>)
- procNameToken = <ID>
+ procName = id()
{
- storedProcedure.setProcedureName(procNameToken.image);
+ storedProcedure.setProcedureName(procName);
}
//parameters
@@ -1067,7 +1076,7 @@
{
storedProcedure.setDisplayNamedParameters(true);
}
- (name=paramName(info)
+ (name=id()
<EQ>
value = expression(info)
{
@@ -1078,7 +1087,7 @@
parameter = null;
}
( <COMMA>
- name=paramName(info)
+ name=id()
<EQ>
value = expression(info)
{
@@ -1097,29 +1106,6 @@
}
/**
- * Parse an execute statement parameter name (must not be
- * enclosed in single or double ticks)
- * @return Parsed insert statement
- * @throws ParseException if parsing failed
- */
-String paramName(ParseInfo info) :
-{
- Token t = null;
- String parameterName = null;
-
-}
-{
- t=<ID>
- {
- parameterName = t.image;
-
- parameterName = validateMetadataID(parameterName);
-
- return parameterName;
- }
-}
-
-/**
* Parse an INSERT command
* @return Parsed insert statement
* @throws ParseException if parsing failed
@@ -1127,26 +1113,26 @@
Insert insert(ParseInfo info) :
{
Insert insert = new Insert();
- Token groupToken = null;
- Token elementToken = null;
+ String group = null;
+ String element = null;
List values = null;
Option option = null;
QueryCommand query = null;
}
{
<INSERT> <INTO>
- groupToken = <ID>
+ group = id()
[LOOKAHEAD(<LPAREN><ID>)
<LPAREN>
- elementToken = <ID>
+ element = id()
{
- insert.addVariable(new ElementSymbol(validateMetadataID(elementToken.image)));
+ insert.addVariable(new ElementSymbol(element));
}
( <COMMA>
- elementToken = <ID>
+ element = id()
{
- insert.addVariable(new ElementSymbol(validateMetadataID(elementToken.image)));
+ insert.addVariable(new ElementSymbol(element));
}
)*
<RPAREN>
@@ -1176,7 +1162,7 @@
{
// Store group
- insert.setGroup(new GroupSymbol(validateMetadataID(groupToken.image)) );
+ insert.setGroup(new GroupSymbol(group) );
return insert;
}
@@ -1219,7 +1205,7 @@
Update update(ParseInfo info) :
{
Update update = new Update();
- Token groupToken = null;
+ String group = null;
SetClauseList setClauseList = null;
Criteria criteria = null;
ElementSymbol elementID = null;
@@ -1227,7 +1213,7 @@
}
{
<UPDATE>
- groupToken = <ID>
+ group = id()
<SET>
setClauseList = setClauseList(false, info)
{
@@ -1241,7 +1227,7 @@
]
{
// Store group
- update.setGroup(new GroupSymbol( validateMetadataID(groupToken.image)) );
+ update.setGroup(new GroupSymbol( group) );
// Store optional criteria
if(criteria != null) {
@@ -1260,14 +1246,14 @@
*/
Delete delete(ParseInfo info) :
{
- Token groupToken = null;
+ String group = null;
Criteria criteria = null;
Delete delete = new Delete();
Option option = null;
}
{
<DELETE> <FROM>
- groupToken = <ID>
+ group = id()
[criteria = where(info)]
[option = option(info)
{
@@ -1275,7 +1261,7 @@
}
]
{
- delete.setGroup(new GroupSymbol(validateMetadataID(groupToken.image)));
+ delete.setGroup(new GroupSymbol(group));
delete.setCriteria(criteria);
return delete;
@@ -1398,14 +1384,14 @@
Into into(ParseInfo info) :
{
- Token groupID = null;
+ String groupID = null;
Into into = null;
}
{
<INTO>
- (groupID=<ID>)
+ (groupID=id())
{
- into = new Into(new GroupSymbol(groupID.image));
+ into = new Into(new GroupSymbol(groupID));
return into;
}
}
@@ -1454,7 +1440,7 @@
SelectSymbol selectSymbol(ParseInfo info) :
{
Expression expression = null;
- Token aliasToken = null;
+ String alias = null;
Token allInGroupToken = null;
}
{
@@ -1468,50 +1454,32 @@
// Expression
expression=expression(info)
)
- [[<AS>] ( aliasToken=<ID> |
- aliasToken=<STRINGVAL>
- )
+ [[<AS>] ( alias=id() )
]
)
{
// Validate alias
- String alias = null;
- if(aliasToken != null) {
- alias = validateAlias(aliasToken.image);
+ if(alias != null) {
+ alias = validateAlias(alias);
}
if(allInGroupToken != null) {
- if(aliasToken == null) {
- // Group.*
- return new AllInGroupSymbol(validateMetadataID(allInGroupToken.image));
- } else {
- Object[] params = new Object[] { allInGroupToken.image };
- throw new ParseException(QueryPlugin.Util.getString("SQLParser.Cant_alias_star", params)); //$NON-NLS-1$
- }
- } else if(expression instanceof ElementSymbol) {
- SingleElementSymbol es = (ElementSymbol) expression;
- if(aliasToken != null) {
- // Aliased element
- es = new AliasSymbol(alias, es);
- }
- return es;
+ // Group.*
+ return new AllInGroupSymbol(normalizeId(allInGroupToken.image));
+ }
+ SingleElementSymbol es = null;
+ if(expression instanceof ElementSymbol) {
+ es = (ElementSymbol) expression;
} else if(expression instanceof AggregateSymbol) {
- // This can happen if the aggregate symbol is surrounded by ( ), which
- // can happen when queries are generated in ODBC
- AggregateSymbol aggSymbol = (AggregateSymbol) expression;
- if(aliasToken != null) {
- return new AliasSymbol(alias, aggSymbol);
- } else {
- return aggSymbol;
- }
+ es = (AggregateSymbol)expression;
} else {
String functionName = generateFunctionName(info, null);
- SingleElementSymbol expSymbol = new ExpressionSymbol(functionName, expression);
- if(aliasToken != null) {
- expSymbol = new AliasSymbol(alias, expSymbol);
- }
- return expSymbol;
+ es = new ExpressionSymbol(functionName, expression);
}
+ if(alias != null) {
+ return new AliasSymbol(alias, es);
+ }
+ return es;
}
}
@@ -1729,7 +1697,7 @@
*/
SubqueryFromClause subqueryFromClause(ParseInfo info) :
{
- Token aliasID = null;
+ String aliasID = null;
Command command = null;
SubqueryFromClause clause = null;
Token lparen = null;
@@ -1740,10 +1708,10 @@
command = storedProcedure(info) )
<RPAREN>
[<AS>]
- aliasID = <ID>
+ aliasID = id()
{
- clause = new SubqueryFromClause(validateAlias(aliasID.image), command);
+ clause = new SubqueryFromClause(validateAlias(aliasID), command);
setFromClauseOptions(lparen, clause);
return clause;
}
@@ -1758,16 +1726,16 @@
{
GroupSymbol group = null;
Token groupID = null;
- Token aliasID = null;
+ String aliasID = null;
UnaryFromClause clause = null;
}
{
- (groupID=<ID> [[<AS>] aliasID=<ID>])
+ (groupID=<ID> [[<AS>] aliasID=id()])
{
if(aliasID != null) {
- group = new GroupSymbol(validateAlias(aliasID.image), validateMetadataID(groupID.image));
+ group = new GroupSymbol(validateAlias(aliasID), normalizeId(groupID.image));
} else {
- group = new GroupSymbol(validateMetadataID(groupID.image));
+ group = new GroupSymbol(normalizeId(groupID.image));
}
clause = new UnaryFromClause(group);
setFromClauseOptions(groupID, clause);
@@ -2063,15 +2031,15 @@
Character escapeChar(ParseInfo info) :
{
- Token escStr = null;
+ String escStr = null;
}
{
- <ESCAPE> escStr=<STRINGVAL>
+ <ESCAPE> escStr=stringVal()
{
- if (escStr.image.length() != 3) {
- throw new ParseException(QueryPlugin.Util.getString("SQLParser.Invalid_escape_char", escStr.image)); //$NON-NLS-1$
+ if (escStr.length() != 1) {
+ throw new ParseException(QueryPlugin.Util.getString("SQLParser.Invalid_escape_char", escStr)); //$NON-NLS-1$
}
- return Character.valueOf(escStr.image.charAt(1));
+ return Character.valueOf(escStr.charAt(0));
}
}
@@ -2276,41 +2244,31 @@
*/
OrderBy orderby(ParseInfo info) :
{
- Token id = null;
+ SingleElementSymbol ex = null;
Token type = null;
OrderBy orderby = new OrderBy();
boolean ascending = true;
}
{
<ORDER> <BY>
- (id=<ID> | id=<STRINGVAL> | id=<INTEGERVAL>) [<ASC> | type=<DESC>]
+ ex=sortKey(info) [<ASC> | type=<DESC>]
{
ascending = true;
if(type != null) {
ascending = false;
type=null;
}
- if (StringUtil.isDigits(id.image)){
- orderby.addVariable(new ElementSymbol(id.image), ascending);
- }
- else{
- orderby.addVariable(new ElementSymbol(validateMetadataID(id.image)), ascending);
- }
+ orderby.addVariable(ex, ascending);
}
(<COMMA>
- (id=<ID> | id=<STRINGVAL> | id=<INTEGERVAL>) [<ASC> | type=<DESC>]
+ ex=sortKey(info) [<ASC> | type=<DESC>]
{
ascending = true;
if(type != null) {
ascending = false;
type=null;
}
- if (StringUtil.isDigits(id.image)){
- orderby.addVariable(new ElementSymbol(id.image), ascending);
- }
- else{
- orderby.addVariable(new ElementSymbol(validateMetadataID(id.image)), ascending);
- }
+ orderby.addVariable(ex, ascending);
}
)*
{
@@ -2318,6 +2276,33 @@
}
}
+SingleElementSymbol sortKey(ParseInfo info) :
+{
+ Expression ex = null;
+}
+{
+ ex=expression(info)
+ {
+ //legacy support check for positional constants
+ if (ex instanceof Constant) {
+ boolean valid = false;
+ Constant c = (Constant)ex;
+ if (c.getValue() instanceof Integer) {
+ Integer val = (Integer)c.getValue();
+ valid = val.intValue() > 0;
+ }
+ if (!valid) {
+ throw new ParseException(QueryPlugin.Util.getString("SQLParser.non_position_constant", ex)); //$NON-NLS-1$
+ }
+ }
+ if(ex instanceof ElementSymbol) {
+ return (ElementSymbol)ex;
+ }
+ String exprName = generateFunctionName(info, null);
+ return new ExpressionSymbol(exprName, ex);
+ }
+}
+
/**
* <p>Parse an LIMIT clause.</p>
* @return Parsed LIMIT
@@ -2363,7 +2348,7 @@
Token plan = null;
Token debug = null;
Token planOnly = null;
- Token id = null;
+ String id = null;
Token nocache = null;
Option option = new Option();
}
@@ -2375,37 +2360,37 @@
debug = <DEBUG> |
<MAKEDEP>
- id=<ID>
+ id=id()
{
- option.addDependentGroup(validateMetadataID(id.image));
+ option.addDependentGroup(id);
}
(<COMMA>
- id=<ID>
+ id=id()
{
- option.addDependentGroup(validateMetadataID(id.image));
+ option.addDependentGroup(id);
}
)* |
<MAKENOTDEP>
- id=<ID>
+ id=id()
{
- option.addNotDependentGroup(validateMetadataID(id.image));
+ option.addNotDependentGroup(id);
}
(<COMMA>
- id=<ID>
+ id=id()
{
- option.addNotDependentGroup(validateMetadataID(id.image));
+ option.addNotDependentGroup(id);
}
)* |
nocache = <NOCACHE>
- [id=<ID>
+ [id=id()
{
- option.addNoCacheGroup(validateMetadataID(id.image));
+ option.addNoCacheGroup(id);
}
(<COMMA>
- id=<ID>
+ id=id()
{
- option.addNoCacheGroup(validateMetadataID(id.image));
+ option.addNoCacheGroup(id);
}
)*]
)*
@@ -2575,7 +2560,7 @@
(
// Reference
refToken=<QMARK>
- |
+ |
// Literal
literal=literal()
|
@@ -2594,16 +2579,9 @@
// ElementSymbol
(symbol=<ID>
{
- // Check that this isn't actually a string expression. That
- // is a possibility due to the token definitions where a
- // quoted group ("group") may look like a string constant ("xyz").
- // Due to the ordering of token definitions (which is important
- // in other places), this will be matched as an ID, not as a
- // StringVal. Anywhere that an expression can be used, the
- // only valid choice is as a string constant.
String symbolImage = symbol.image;
if(isStringLiteral(symbolImage, info)) {
- literal = new Constant(symbolImage.substring(1, symbolImage.length()-1));
+ literal = new Constant(normalizeStringLiteral(symbolImage));
symbol = null;
}
}
@@ -2629,7 +2607,7 @@
if(refToken != null) {
return new Reference(info.referenceCount++);
} else if(symbol != null) {
- return new ElementSymbol(validateMetadataID(symbol.image));
+ return new ElementSymbol(normalizeId(symbol.image));
} else if(literal != null) {
return literal; // may be null literal
} else if (subquery != null){
@@ -2837,9 +2815,9 @@
<RPAREN>
)
|
- ( funcToken = <ID>
+ ( funcName = id()
{
- funcName = validateFunctionName(funcToken.image);
+ funcName = validateFunctionName(funcName);
}
<LPAREN>
[
@@ -2944,21 +2922,12 @@
{
Token t = null;
String strVal = null;
- char tickChar = '\'';
Class escapeType = null;
Constant constant = null;
}
{
(
- t=<STRINGVAL> {
- strVal = t.image;
-
- if(strVal.charAt(0) == 'N') {
- strVal = strVal.substring(1);
- }
- tickChar = strVal.charAt(0);
- strVal = strVal.substring(1, strVal.length()-1);
- strVal = removeEscapeChars(strVal, tickChar);
+ strVal=stringVal() {
constant = new Constant(strVal, DataTypeManager.DefaultDataClasses.STRING);
} |
@@ -2999,10 +2968,9 @@
( (<BOOLEANTYPE> { escapeType=DataTypeManager.DefaultDataClasses.BOOLEAN; } |
<TIMESTAMPTYPE> { escapeType=DataTypeManager.DefaultDataClasses.TIMESTAMP; } |
<DATETYPE> { escapeType=DataTypeManager.DefaultDataClasses.DATE; } |
- <TIMETYPE> { escapeType=DataTypeManager.DefaultDataClasses.TIME; }) t=<STRINGVAL> {
- String str = t.image.substring(1, t.image.length()-1);
+ <TIMETYPE> { escapeType=DataTypeManager.DefaultDataClasses.TIME; }) strVal=stringVal() {
try {
- constant = new Constant(DataTypeManager.transformValue(str, escapeType), escapeType);
+ constant = new Constant(DataTypeManager.transformValue(strVal, escapeType), escapeType);
} catch (TransformationException e) {
throw new ParseException(e.getMessage()); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties 2009-11-20 17:27:16 UTC (rev 1578)
@@ -106,12 +106,7 @@
DQPBufferService.Error_initializing_buffer_manager__missing_required_property_7=Error initializing buffer manager: missing required property {0}
DQPBufferService.Failed_initializing_buffer_manager._8=Failed initializing buffer manager.
-DQPCore.License_allows_DQP_{0}=License allows DQP {0}
-DQPCore.License_allows_transactions__{0}=License allows transactions: {0}
-DQPCore.License_allows_materialized_views_{0}=License allows materialized views: {0}
-DQPCore.License_allows_updates__{0}=License allows updates: {0}
DQPCore.Exception_trying_to_determine_processor_timeslice_from_{0}=Exception trying to determine processor timeslice from {0}
-DQPCore.Group_names_must_be_set.=Group names must be set.
DQPCore.Unable_to_retrieve_metadata=Unable to retrieve metadata
DQPCore.Unable_to_parse_command=Unable to parse command: {0}
DQPCore.Unable_to_load_metadata_for_VDB_name__{0},_version__{1}=Unable to load metadata for VDB name= {0}, version= {1}
@@ -129,8 +124,8 @@
DQPCore.Clearing_code_table_cache=Clearing code table cache
DQPCore.Unable_to_check_license_for_update_capability._Updates_will_not_be_allowed_3=Unable to check license for update capability. Updates will not be allowed
DQPCore.The_request_has_been_closed.=The request {0} has been closed.
-DQPCore.The_atomic_request_has_been_cancelled=The atomic request {0} has been cancelled.
-DQPCore.The_atomic_request_cancelled_not_closed=The atomic request {0}.{1} has been cancelled, but closed yet.
+DQPCore.The_atomic_request_has_been_cancelled=The atomic request {0} has been canceled.
+DQPCore.The_atomic_request_cancelled_not_closed=The atomic request {0}.{1} has been canceled, but closed yet.
DQPCore.The_atomic_request_closed_queued=The atomic request {0} has queued to close, another request in progress.
DQPCore.failed_to_cancel=Failed to Cancel request, as request already finished processing
Modified: trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties 2009-11-20 17:27:16 UTC (rev 1578)
@@ -848,6 +848,8 @@
ResolverUtil.required_param=Required parameter ''{0}'' has no value was set or is an invalid parameter.
ResolverUtil.duplicateName=Cannot create group ''{0}'' with multiple columns named ''{1}''
ResolverUtil.error_converting_value_type=Exception converting value {0} of type {1} to expected type {2}
+ResolverUtil.setquery_order_expression=ORDER BY expression ''{0}'' cannot be used with a set query.
+ResolverUtil.invalid_unrelated=Unrelated order by column {0} cannot be used in a SET query, with SELECT DISTINCT, or GROUP BY
XMLQueryResolver.xml_only_valid_alone=If any symbol in SELECT clause is ''xml'' or group.''xml'' , then no other element is allowed.
EvaluateExpressionVisitor.Cant_get_iterator=Unable to retrieve ValueIterator with independent value expression: {0}
ResolveFunctionsVisitor.xpath_cant_be_null=XPath cannot be null
@@ -856,6 +858,8 @@
TempTableResolver.unqualified_name_required=Cannot create temporary table "{0}". Local temporary tables must be created with unqualified names.
TempTableResolver.table_already_exists=Cannot create temporary table "{0}". A table with the same name already exists.
ValidationVisitor.drop_of_nontemptable=Cannot drop a non temporary table "{0}".
+ValidationVisitor.unrelated_orderby_xml=XML queries cannot order by an unrelated order by item.
+ValidationVisitor.orderby_expression_xml=XML queries cannot order by an expression.
UpdateProcedureResolver.only_variables=Element symbol "{0}" cannot be assigned a value. Only declared VARIABLES can be assigned values.
wrong_result_type=No results found; or non-XML result object has been produced as a result of the execution of XQuery expression. Please note that only XML type results are supported.
MappingLoader.unknown_node_type=Unknown Node Type "{0}" being loaded by the XML mapping document.
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -89,7 +89,7 @@
}
@Test public void testNestedInlineViewOrderBy() throws Exception {
- String sql = "select * from (select intnum x from (select intnum from bqt1.smallb) b order by x) y order by x"; //$NON-NLS-1$
+ String sql = "select x from (select intnum x from (select intnum from bqt1.smallb) b order by x) y order by x"; //$NON-NLS-1$
String expected = "SELECT v_1.c_0 FROM (SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0) AS v_0) AS v_1 ORDER BY c_0"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -22,6 +22,8 @@
package com.metamatrix.query.parser;
+import static org.junit.Assert.*;
+
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.util.ArrayList;
@@ -29,7 +31,7 @@
import java.util.Collection;
import java.util.List;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.query.QueryParserException;
@@ -103,22 +105,8 @@
import com.metamatrix.query.sql.symbol.TestCaseExpression;
import com.metamatrix.query.sql.symbol.TestSearchedCaseExpression;
-public class TestParser extends TestCase {
+public class TestParser {
- private ParseInfo info = new ParseInfo();
-
- // ################################## FRAMEWORK ################################
-
- public TestParser(String name) {
- super(name);
- }
-
- public void setUp() {
- info.allowDoubleQuotedVariable = true;
- }
-
- // ################################## TEST HELPERS ################################
-
static void helpTest(String sql, String expectedString, Command expectedCommand) {
helpTest(sql, expectedString, expectedCommand, new ParseInfo());
}
@@ -150,7 +138,6 @@
}
}
}
-
private void helpBlockTest(String block, String expectedString, Block expectedBlock) {
Block actualBlock = null;
@@ -221,7 +208,7 @@
// ======================== Joins ===============================================
/** SELECT * FROM g1 inner join g2 on g1.a1=g2.a2 */
- public void testInnerJoin() {
+ @Test public void testInnerJoin() {
UnaryFromClause g1 = new UnaryFromClause(new GroupSymbol("g1")); //$NON-NLS-1$
UnaryFromClause g2 = new UnaryFromClause(new GroupSymbol("g2")); //$NON-NLS-1$
CompareCriteria jcrit = new CompareCriteria(
@@ -247,7 +234,7 @@
}
/** SELECT * FROM g1 cross join g2 */
- public void testCrossJoin() {
+ @Test public void testCrossJoin() {
UnaryFromClause g1 = new UnaryFromClause(new GroupSymbol("g1")); //$NON-NLS-1$
UnaryFromClause g2 = new UnaryFromClause(new GroupSymbol("g2")); //$NON-NLS-1$
JoinPredicate jp = new JoinPredicate(g1, g2, JoinType.JOIN_CROSS);
@@ -268,7 +255,7 @@
}
/** SELECT * FROM (g1 cross join g2), g3 */
- public void testFromClauses() {
+ @Test public void testFromClauses() {
UnaryFromClause g1 = new UnaryFromClause(new GroupSymbol("g1")); //$NON-NLS-1$
UnaryFromClause g2 = new UnaryFromClause(new GroupSymbol("g2")); //$NON-NLS-1$
JoinPredicate jp = new JoinPredicate(g1, g2, JoinType.JOIN_CROSS);
@@ -290,12 +277,12 @@
}
/** SELECT * FROM g1 inner join g2 */
- public void testInvalidInnerJoin() {
+ @Test public void testInvalidInnerJoin() {
helpException("SELECT * FROM g1 inner join g2"); //$NON-NLS-1$
}
/** SELECT * FROM (g1 cross join g2) cross join g3 */
- public void testMultiCrossJoin() {
+ @Test public void testMultiCrossJoin() {
UnaryFromClause g1 = new UnaryFromClause(new GroupSymbol("g1")); //$NON-NLS-1$
UnaryFromClause g2 = new UnaryFromClause(new GroupSymbol("g2")); //$NON-NLS-1$
JoinPredicate jp = new JoinPredicate(g1, g2, JoinType.JOIN_CROSS);
@@ -317,7 +304,7 @@
}
/** SELECT * FROM (g1 cross join g2) cross join (g3 cross join g4) */
- public void testMultiCrossJoin2() {
+ @Test public void testMultiCrossJoin2() {
UnaryFromClause g1 = new UnaryFromClause(new GroupSymbol("g1")); //$NON-NLS-1$
UnaryFromClause g2 = new UnaryFromClause(new GroupSymbol("g2")); //$NON-NLS-1$
JoinPredicate jp = new JoinPredicate(g1, g2, JoinType.JOIN_CROSS);
@@ -342,7 +329,7 @@
}
/** SELECT * FROM g1 cross join (g2 cross join g3) */
- public void testMultiCrossJoin3() {
+ @Test public void testMultiCrossJoin3() {
UnaryFromClause g1 = new UnaryFromClause(new GroupSymbol("g1")); //$NON-NLS-1$
UnaryFromClause g2 = new UnaryFromClause(new GroupSymbol("g2")); //$NON-NLS-1$
UnaryFromClause g3 = new UnaryFromClause(new GroupSymbol("g3")); //$NON-NLS-1$
@@ -365,7 +352,7 @@
}
/** SELECT * FROM g1 cross join (g2 cross join g3), g4 */
- public void testMixedJoin() {
+ @Test public void testMixedJoin() {
UnaryFromClause g1 = new UnaryFromClause(new GroupSymbol("g1")); //$NON-NLS-1$
UnaryFromClause g2 = new UnaryFromClause(new GroupSymbol("g2")); //$NON-NLS-1$
UnaryFromClause g3 = new UnaryFromClause(new GroupSymbol("g3")); //$NON-NLS-1$
@@ -389,7 +376,7 @@
}
/** SELECT * FROM g1 cross join (g2 cross join g3), g4, g5 cross join g6 */
- public void testMixedJoin2() {
+ @Test public void testMixedJoin2() {
UnaryFromClause g1 = new UnaryFromClause(new GroupSymbol("g1")); //$NON-NLS-1$
UnaryFromClause g2 = new UnaryFromClause(new GroupSymbol("g2")); //$NON-NLS-1$
UnaryFromClause g3 = new UnaryFromClause(new GroupSymbol("g3")); //$NON-NLS-1$
@@ -418,7 +405,7 @@
}
/** SELECT * FROM g1, g2 inner join g3 on g2.a=g3.a */
- public void testMixedJoin3() {
+ @Test public void testMixedJoin3() {
UnaryFromClause g1 = new UnaryFromClause(new GroupSymbol("g1")); //$NON-NLS-1$
UnaryFromClause g2 = new UnaryFromClause(new GroupSymbol("g2")); //$NON-NLS-1$
UnaryFromClause g3 = new UnaryFromClause(new GroupSymbol("g3")); //$NON-NLS-1$
@@ -446,7 +433,7 @@
}
/** Select myG.a myA, myH.b from g myG right outer join h myH on myG.x=myH.x */
- public void testRightOuterJoinWithAliases() {
+ @Test public void testRightOuterJoinWithAliases() {
UnaryFromClause g = new UnaryFromClause(new GroupSymbol("myG", "g")); //$NON-NLS-1$ //$NON-NLS-2$
UnaryFromClause h = new UnaryFromClause(new GroupSymbol("myH", "h")); //$NON-NLS-1$ //$NON-NLS-2$
CompareCriteria jcrit = new CompareCriteria(
@@ -473,7 +460,7 @@
}
/** Select myG.x myX, myH.y from g myG right join h myH on myG.x=myH.x */
- public void testRightJoinWithAliases() {
+ @Test public void testRightJoinWithAliases() {
UnaryFromClause g = new UnaryFromClause(new GroupSymbol("myG", "g")); //$NON-NLS-1$ //$NON-NLS-2$
UnaryFromClause h = new UnaryFromClause(new GroupSymbol("myH", "h")); //$NON-NLS-1$ //$NON-NLS-2$
CompareCriteria jcrit = new CompareCriteria(
@@ -500,7 +487,7 @@
}
/** Select myG.a myA, myH.b from g myG left outer join h myH on myG.x=myH.x */
- public void testLeftOuterJoinWithAliases() {
+ @Test public void testLeftOuterJoinWithAliases() {
UnaryFromClause g = new UnaryFromClause(new GroupSymbol("myG", "g")); //$NON-NLS-1$ //$NON-NLS-2$
UnaryFromClause h = new UnaryFromClause(new GroupSymbol("myH", "h")); //$NON-NLS-1$ //$NON-NLS-2$
CompareCriteria jcrit = new CompareCriteria(
@@ -527,7 +514,7 @@
}
/** Select myG.a myA, myH.b from g myG left join h myH on myG.x=myH.x */
- public void testLeftJoinWithAliases() {
+ @Test public void testLeftJoinWithAliases() {
UnaryFromClause g = new UnaryFromClause(new GroupSymbol("myG", "g")); //$NON-NLS-1$ //$NON-NLS-2$
UnaryFromClause h = new UnaryFromClause(new GroupSymbol("myH", "h")); //$NON-NLS-1$ //$NON-NLS-2$
CompareCriteria jcrit = new CompareCriteria(
@@ -554,7 +541,7 @@
}
/** Select myG.a myA, myH.b from g myG full outer join h myH on myG.x=myH.x */
- public void testFullOuterJoinWithAliases() {
+ @Test public void testFullOuterJoinWithAliases() {
UnaryFromClause g = new UnaryFromClause(new GroupSymbol("myG", "g")); //$NON-NLS-1$ //$NON-NLS-2$
UnaryFromClause h = new UnaryFromClause(new GroupSymbol("myH", "h")); //$NON-NLS-1$ //$NON-NLS-2$
CompareCriteria jcrit = new CompareCriteria(
@@ -581,7 +568,7 @@
}
/** Select g.a, h.b from g full join h on g.x=h.x */
- public void testFullJoin() {
+ @Test public void testFullJoin() {
UnaryFromClause g = new UnaryFromClause(new GroupSymbol("g")); //$NON-NLS-1$
UnaryFromClause h = new UnaryFromClause(new GroupSymbol("h")); //$NON-NLS-1$
CompareCriteria jcrit = new CompareCriteria(
@@ -609,7 +596,7 @@
// ======================= Convert ==============================================
/** SELECT CONVERT(a, string) FROM g */
- public void testConversionFunction() {
+ @Test public void testConversionFunction() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -628,7 +615,7 @@
}
/** SELECT CONVERT(CONVERT(a, timestamp), string) FROM g */
- public void testConversionFunction2() {
+ @Test public void testConversionFunction2() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -650,7 +637,7 @@
// ======================= Functions ==============================================
/** SELECT 5 + length(concat(a, 'x')) FROM g */
- public void testMultiFunction() {
+ @Test public void testMultiFunction() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -671,7 +658,7 @@
}
/** SELECT REPLACE(a, 'x', 'y') AS y FROM g */
- public void testAliasedFunction() {
+ @Test public void testAliasedFunction() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -691,7 +678,7 @@
}
/** SELECT cast(a as string) FROM g */
- public void testCastFunction() {
+ @Test public void testCastFunction() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -710,7 +697,7 @@
}
/** SELECT cast(cast(a as timestamp) as string) FROM g */
- public void testMultiCastFunction() {
+ @Test public void testMultiCastFunction() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -730,7 +717,7 @@
}
/** SELECT left(fullname, 3) as x FROM system.groups */
- public void testLeftFunction() {
+ @Test public void testLeftFunction() {
GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -750,7 +737,7 @@
}
/** SELECT right(fullname, 3) as x FROM system.groups */
- public void testRightFunction() {
+ @Test public void testRightFunction() {
GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -770,7 +757,7 @@
}
/** SELECT char('x') AS x FROM system.groups */
- public void testCharFunction() {
+ @Test public void testCharFunction() {
GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -790,7 +777,7 @@
}
/** SELECT insert('x', 1, 'a') as x FROM system.groups */
- public void testInsertFunction() {
+ @Test public void testInsertFunction() {
GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -811,7 +798,7 @@
- public void testInsertIntoSelect() {
+ @Test public void testInsertIntoSelect() {
GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -835,7 +822,7 @@
}
/** SELECT translate('x', 'x', 'y') FROM system.groups */
- public void testTranslateFunction() {
+ @Test public void testTranslateFunction() {
GroupSymbol g = new GroupSymbol("system.groups"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -854,7 +841,7 @@
}
/** SELECT timestampadd(SQL_TSI_FRAC_SECOND, 10, '2003-05-01 10:20:30') as x FROM my.group1 */
- public void testTimestampaddFunctionFracSecond() {
+ @Test public void testTimestampaddFunctionFracSecond() {
GroupSymbol g = new GroupSymbol("my.group1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -875,7 +862,7 @@
}
/** SELECT timestampadd(SQL_TSI_SECOND, 10, '2003-05-01 10:20:30') as x FROM my.group1 */
- public void testTimestampaddFunctionSecond() {
+ @Test public void testTimestampaddFunctionSecond() {
GroupSymbol g = new GroupSymbol("my.group1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -896,7 +883,7 @@
}
/** SELECT timestampadd(SQL_TSI_MINUTE, 10, '2003-05-01 10:20:30') as x FROM my.group1 */
- public void testTimestampaddFunctionMinute() {
+ @Test public void testTimestampaddFunctionMinute() {
GroupSymbol g = new GroupSymbol("my.group1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -917,7 +904,7 @@
}
/** SELECT timestampadd(SQL_TSI_HOUR, 10, '2003-05-01 10:20:30') as x FROM my.group1 */
- public void testTimestampaddFunctionHour() {
+ @Test public void testTimestampaddFunctionHour() {
GroupSymbol g = new GroupSymbol("my.group1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -938,7 +925,7 @@
}
/** SELECT timestampadd(SQL_TSI_DAY, 10, '2003-05-01 10:20:30') as x FROM my.group1 */
- public void testTimestampaddFunctionDay() {
+ @Test public void testTimestampaddFunctionDay() {
GroupSymbol g = new GroupSymbol("my.group1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -959,7 +946,7 @@
}
/** SELECT timestampadd(SQL_TSI_WEEK, 10, '2003-05-01 10:20:30') as x FROM my.group1 */
- public void testTimestampaddFunctionWeek() {
+ @Test public void testTimestampaddFunctionWeek() {
GroupSymbol g = new GroupSymbol("my.group1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -980,7 +967,7 @@
}
/** SELECT timestampadd(SQL_TSI_QUARTER, 10, '2003-05-01 10:20:30') as x FROM my.group1 */
- public void testTimestampaddFunctionQuarter() {
+ @Test public void testTimestampaddFunctionQuarter() {
GroupSymbol g = new GroupSymbol("my.group1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1001,7 +988,7 @@
}
/** SELECT timestampadd(SQL_TSI_YEAR, 10, '2003-05-01 10:20:30') as x FROM my.group1 */
- public void testTimestampaddFunctionYear() {
+ @Test public void testTimestampaddFunctionYear() {
GroupSymbol g = new GroupSymbol("my.group1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1022,7 +1009,7 @@
}
/** SELECT timestampdiff(SQL_TSI_FRAC_SECOND, '2003-05-01 10:20:10', '2003-05-01 10:20:30') as x FROM my.group1 */
- public void testTimestampdiffFunctionFracSecond() {
+ @Test public void testTimestampdiffFunctionFracSecond() {
GroupSymbol g = new GroupSymbol("my.group1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1043,7 +1030,7 @@
}
/** SELECT 5 + 2 + 3 FROM g */
- public void testArithmeticOperatorPrecedence1() {
+ @Test public void testArithmeticOperatorPrecedence1() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1063,7 +1050,7 @@
}
/** SELECT 5 + 2 - 3 FROM g */
- public void testArithmeticOperatorPrecedence2() {
+ @Test public void testArithmeticOperatorPrecedence2() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1083,7 +1070,7 @@
}
/** SELECT 5 + 2 * 3 FROM g */
- public void testArithmeticOperatorPrecedence3() {
+ @Test public void testArithmeticOperatorPrecedence3() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1104,7 +1091,7 @@
}
/** SELECT 5 * 2 + 3 FROM g */
- public void testArithmeticOperatorPrecedence4() {
+ @Test public void testArithmeticOperatorPrecedence4() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1124,7 +1111,7 @@
}
/** SELECT 5 * 2 * 3 FROM g */
- public void testArithmeticOperatorPrecedence5() {
+ @Test public void testArithmeticOperatorPrecedence5() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1144,7 +1131,7 @@
}
/** SELECT 1 + 2 * 3 + 4 * 5 FROM g */
- public void testArithmeticOperatorPrecedenceMixed1() {
+ @Test public void testArithmeticOperatorPrecedenceMixed1() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1166,7 +1153,7 @@
}
/** SELECT 1 * 2 + 3 * 4 + 5 FROM g */
- public void testArithmeticOperatorPrecedenceMixed2() {
+ @Test public void testArithmeticOperatorPrecedenceMixed2() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1188,7 +1175,7 @@
}
/** SELECT 5 - 4 - 3 - 2 FROM g --> SELECT ((5 - 4) - 3) - 2 FROM g */
- public void testLeftAssociativeExpressions1() {
+ @Test public void testLeftAssociativeExpressions1() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1209,7 +1196,7 @@
}
/** SELECT 5 / 4 / 3 / 2 FROM g --> SELECT ((5 / 4) / 3) / 2 FROM g */
- public void testLeftAssociativeExpressions2() {
+ @Test public void testLeftAssociativeExpressions2() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1230,7 +1217,7 @@
}
/** SELECT 'a' || 'b' || 'c' FROM g */
- public void testConcatOperator1() {
+ @Test public void testConcatOperator1() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1250,7 +1237,7 @@
}
/** SELECT 2 + 3 || 5 + 1 * 2 FROM g */
- public void testMixedOperators1() {
+ @Test public void testMixedOperators1() {
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1274,7 +1261,7 @@
// ======================= Group By ==============================================
/** SELECT a FROM m.g GROUP BY b, c */
- public void testGroupBy() {
+ @Test public void testGroupBy() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1297,7 +1284,7 @@
}
/** SELECT a FROM m.g GROUP BY b, c HAVING b=5*/
- public void testGroupByHaving() {
+ @Test public void testGroupByHaving() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1322,7 +1309,7 @@
}
/** SELECT COUNT(a) AS c FROM m.g */
- public void testAggregateFunction() {
+ @Test public void testAggregateFunction() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1341,7 +1328,7 @@
}
/** SELECT (COUNT(a)) AS c FROM m.g - this kind of query is generated by ODBC sometimes */
- public void testAggregateFunctionWithParens() {
+ @Test public void testAggregateFunctionWithParens() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1360,7 +1347,7 @@
}
/** SELECT a FROM m.g GROUP BY a HAVING COUNT(b) > 0*/
- public void testHavingFunction() {
+ @Test public void testHavingFunction() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1388,7 +1375,7 @@
}
/** SELECT a FROM m.g GROUP BY a, b HAVING COUNT(b) > 0 AND b+5 > 0 */
- public void testCompoundHaving() {
+ @Test public void testCompoundHaving() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1423,22 +1410,22 @@
}
/** SELECT a FROM m.g GROUP BY a, b HAVING COUNT(AVG(b)) */
- public void testFailNestedAggregateInHaving() {
+ @Test public void testFailNestedAggregateInHaving() {
helpException("SELECT a FROM m.g GROUP BY a, b HAVING COUNT(b) AS x = 5"); //$NON-NLS-1$
}
/** SELECT a FROM m.g GROUP BY a, b AS x */
- public void testFailAliasInHaving() {
+ @Test public void testFailAliasInHaving() {
helpException("SELECT a FROM m.g GROUP BY a, b AS x"); //$NON-NLS-1$
}
/** SELECT a FROM m.g GROUP BY count(a) */
- public void testFailAggregateInGroupBy() {
+ @Test public void testFailAggregateInGroupBy() {
helpException("SELECT a FROM m.g GROUP BY count(a)"); //$NON-NLS-1$
}
- public void testExceptionLength() {
+ @Test public void testExceptionLength() {
String sql = "SELECT * FROM Customer where Customer.Name = (select lastname from CUSTOMER where acctid = 9"; ////$NON-NLS-1$
try {
QueryParser.getQueryParser().parseCommand(sql);
@@ -1453,7 +1440,7 @@
- public void testFunctionOfAggregates() {
+ @Test public void testFunctionOfAggregates() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1476,7 +1463,7 @@
}
/** SELECT 5-null, a.g1.c1 FROM a.g1 */
- public void testArithmeticNullFunction() {
+ @Test public void testArithmeticNullFunction() {
GroupSymbol g = new GroupSymbol("a.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1497,7 +1484,7 @@
}
/** SELECT 'abc' FROM a.g1 */
- public void testStringLiteral() {
+ @Test public void testStringLiteral() {
GroupSymbol g = new GroupSymbol("a.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1516,7 +1503,7 @@
/** SELECT 'O''Leary' FROM a.g1 */
- public void testStringLiteralEscapedTick() {
+ @Test public void testStringLiteralEscapedTick() {
GroupSymbol g = new GroupSymbol("a.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1534,7 +1521,7 @@
}
/** SELECT '''abc''' FROM a.g1 */
- public void testStringLiteralEscapedTick2() {
+ @Test public void testStringLiteralEscapedTick2() {
GroupSymbol g = new GroupSymbol("a.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1552,7 +1539,7 @@
}
/** SELECT 'a''b''c' FROM a.g1 */
- public void testStringLiteralEscapedTick3() {
+ @Test public void testStringLiteralEscapedTick3() {
GroupSymbol g = new GroupSymbol("a.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1570,25 +1557,25 @@
}
/** SELECT " "" " FROM a.g1 */
- public void testStringLiteralEscapedTick4() {
+ @Test public void testStringLiteralEscapedTick4() {
GroupSymbol g = new GroupSymbol("a.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
Select select = new Select();
- select.addSymbol(new ExpressionSymbol("expr", new Constant(" \" "))); //$NON-NLS-1$ //$NON-NLS-2$
+ select.addSymbol(new ElementSymbol(" \" ")); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
helpTest("SELECT \" \"\" \" FROM a.g1", //$NON-NLS-1$
- "SELECT ' \" ' FROM a.g1", //$NON-NLS-1$
+ "SELECT \" \"\" \" FROM a.g1", //$NON-NLS-1$
query);
}
/** SELECT 123456789012 FROM a.g1 */
- public void testLongLiteral() {
+ @Test public void testLongLiteral() {
GroupSymbol g = new GroupSymbol("a.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1606,7 +1593,7 @@
}
/** SELECT 1000000000000000000000000 FROM a.g1 */
- public void testBigIntegerLiteral() {
+ @Test public void testBigIntegerLiteral() {
GroupSymbol g = new GroupSymbol("a.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1624,7 +1611,7 @@
}
/** SELECT 1.3e8 FROM a.g1 */
- public void testFloatWithE() {
+ @Test public void testFloatWithE() {
GroupSymbol g = new GroupSymbol("a.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1642,7 +1629,7 @@
}
/** SELECT -1.3e-6 FROM a.g1 */
- public void testFloatWithMinusE() {
+ @Test public void testFloatWithMinusE() {
GroupSymbol g = new GroupSymbol("a.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1660,7 +1647,7 @@
}
/** SELECT -1.3e+8 FROM a.g1 */
- public void testFloatWithPlusE() {
+ @Test public void testFloatWithPlusE() {
GroupSymbol g = new GroupSymbol("a.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1678,7 +1665,7 @@
}
/** SELECT {d'2002-10-02'} FROM m.g1 */
- public void testDateLiteral1() {
+ @Test public void testDateLiteral1() {
GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1696,7 +1683,7 @@
}
/** SELECT {d'2002-9-1'} FROM m.g1 */
- public void testDateLiteral2() {
+ @Test public void testDateLiteral2() {
GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1714,12 +1701,12 @@
}
/** SELECT {d'bad'} FROM m.g1 */
- public void testDateLiteralFail() {
+ @Test public void testDateLiteralFail() {
helpException("SELECT {d'bad'} FROM m.g1"); //$NON-NLS-1$
}
/** SELECT {t '11:10:00' } FROM m.g1 */
- public void testTimeLiteral1() {
+ @Test public void testTimeLiteral1() {
GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1737,7 +1724,7 @@
}
/** SELECT {t '5:10:00'} FROM m.g1 */
- public void testTimeLiteral2() {
+ @Test public void testTimeLiteral2() {
GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1755,12 +1742,12 @@
}
/** SELECT {t 'xyz'} FROM m.g1 */
- public void testTimeLiteralFail() {
+ @Test public void testTimeLiteralFail() {
helpException("SELECT {t 'xyz'} FROM m.g1"); //$NON-NLS-1$
}
/** SELECT {ts'2002-10-02 19:00:02.50'} FROM m.g1 */
- public void testTimestampLiteral() {
+ @Test public void testTimestampLiteral() {
GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1778,7 +1765,7 @@
}
/** SELECT {b'true'} FROM m.g1 */
- public void testBooleanLiteralTrue() {
+ @Test public void testBooleanLiteralTrue() {
Boolean expected = Boolean.TRUE;
Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
String sql = "SELECT {b'true'}"; //$NON-NLS-1$
@@ -1800,7 +1787,7 @@
query);
}
/** SELECT TRUE FROM m.g1 */
- public void testBooleanLiteralTrue2() {
+ @Test public void testBooleanLiteralTrue2() {
Boolean expected = Boolean.TRUE;
Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
String sql = "SELECT TRUE"; //$NON-NLS-1$
@@ -1810,7 +1797,7 @@
}
/** SELECT {b'false'} FROM m.g1 */
- public void testBooleanLiteralFalse() {
+ @Test public void testBooleanLiteralFalse() {
Boolean expected = Boolean.FALSE;
Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
String sql = "SELECT {b'false'}"; //$NON-NLS-1$
@@ -1820,7 +1807,7 @@
}
/** SELECT FALSE FROM m.g1 */
- public void testBooleanLiteralFalse2() {
+ @Test public void testBooleanLiteralFalse2() {
Boolean expected = Boolean.FALSE;
Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
String sql = "SELECT {b'false'}"; //$NON-NLS-1$
@@ -1829,7 +1816,7 @@
helpTestLiteral(expected, expectedType, sql, expectedSql);
}
- public void testBooleanLiteralUnknown() {
+ @Test public void testBooleanLiteralUnknown() {
Boolean expected = null;
Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
String sql = "SELECT {b'unknown'}"; //$NON-NLS-1$
@@ -1838,7 +1825,7 @@
helpTestLiteral(expected, expectedType, sql, expectedSql);
}
- public void testBooleanLiteralUnknown2() {
+ @Test public void testBooleanLiteralUnknown2() {
Boolean expected = null;
Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
String sql = "SELECT UNKNOWN"; //$NON-NLS-1$
@@ -1848,7 +1835,7 @@
}
/** SELECT DISTINCT a FROM g */
- public void testSelectDistinct(){
+ @Test public void testSelectDistinct(){
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1866,7 +1853,7 @@
}
/** SELECT ALL a FROM g */
- public void testSelectAll(){
+ @Test public void testSelectAll(){
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1886,7 +1873,7 @@
//=========================Aliasing==============================================
/** SELECT a AS myA, b FROM g */
- public void testAliasInSelect(){
+ @Test public void testAliasInSelect(){
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1905,7 +1892,7 @@
}
/** SELECT a myA, b FROM g, h */
- public void testAliasInSelect2(){
+ @Test public void testAliasInSelect2(){
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
GroupSymbol h = new GroupSymbol("h"); //$NON-NLS-1$
From from = new From();
@@ -1926,7 +1913,7 @@
}
/** SELECT myG.a FROM g AS myG */
- public void testAliasInFrom(){
+ @Test public void testAliasInFrom(){
GroupSymbol g = new GroupSymbol("myG", "g"); //$NON-NLS-1$ //$NON-NLS-2$
From from = new From();
from.addGroup(g);
@@ -1943,7 +1930,7 @@
}
/** SELECT myG.*, myH.b FROM g AS myG, h AS myH */
- public void testAliasesInFrom(){
+ @Test public void testAliasesInFrom(){
GroupSymbol g = new GroupSymbol("myG", "g"); //$NON-NLS-1$ //$NON-NLS-2$
GroupSymbol h = new GroupSymbol("myH", "h"); //$NON-NLS-1$ //$NON-NLS-2$
From from = new From();
@@ -1964,7 +1951,7 @@
}
/** SELECT myG.a, myH.b FROM g myG, h myH */
- public void testHiddenAliasesInFrom(){
+ @Test public void testHiddenAliasesInFrom(){
GroupSymbol g = new GroupSymbol("myG", "g"); //$NON-NLS-1$ //$NON-NLS-2$
GroupSymbol h = new GroupSymbol("myH", "h"); //$NON-NLS-1$ //$NON-NLS-2$
From from = new From();
@@ -1985,19 +1972,19 @@
}
/** SELECT a AS or FROM g */
- public void testAliasInSelectUsingKeywordFails(){
+ @Test public void testAliasInSelectUsingKeywordFails(){
helpException("SELECT a AS or FROM g"); //$NON-NLS-1$
}
/** SELECT or.a FROM g AS or */
- public void testAliasInFromUsingKeywordFails(){
+ @Test public void testAliasInFromUsingKeywordFails(){
helpException("SELECT or.a FROM g AS or"); //$NON-NLS-1$
}
// ======================= Misc ==============================================
/** Select a From db.g Where a IS NULL */
- public void testIsNullCriteria1(){
+ @Test public void testIsNullCriteria1(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2018,7 +2005,7 @@
}
/** Select a From db.g Where a IS NOT NULL */
- public void testIsNullCriteria2(){
+ @Test public void testIsNullCriteria2(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2040,7 +2027,7 @@
}
/** Select a From db.g Where Not a IS NULL */
- public void testNotIsNullCriteria(){
+ @Test public void testNotIsNullCriteria(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2061,7 +2048,7 @@
}
/** SELECT a from db.g where a <> "value" */
- public void testStringNotEqualDoubleTicks(){
+ @Test public void testStringNotEqualDoubleTicks(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2083,7 +2070,7 @@
}
/** SELECT a from db.g where a != "value" */
- public void testNotEquals2(){
+ @Test public void testNotEquals2(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2105,7 +2092,7 @@
}
/** SELECT a from db."g" where a = 5 */
- public void testPartlyQuotedGroup(){
+ @Test public void testPartlyQuotedGroup(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2126,7 +2113,7 @@
}
/** SELECT a from "db"."g" where a = 5 */
- public void testFullyQuotedGroup(){
+ @Test public void testFullyQuotedGroup(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2147,7 +2134,7 @@
}
/** SELECT "db".g.a from db.g */
- public void testPartlyQuotedElement1(){
+ @Test public void testPartlyQuotedElement1(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2166,7 +2153,7 @@
}
/** SELECT "db"."g".a from db.g */
- public void testPartlyQuotedElement2(){
+ @Test public void testPartlyQuotedElement2(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2185,7 +2172,7 @@
}
/** SELECT "db"."g"."a" from db.g */
- public void testPartlyQuotedElement3(){
+ @Test public void testPartlyQuotedElement3(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2204,26 +2191,44 @@
}
/** SELECT ""g"".""a" from db.g */
- public void testStringLiteralLikeQuotedElement(){
+ @Test public void testStringLiteralLikeQuotedElement(){
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
Select select = new Select();
- ExpressionSymbol a = new ExpressionSymbol("expr", new Constant("g\".\"a")); //$NON-NLS-1$ //$NON-NLS-2$
- select.addSymbol(a);
+ select.addSymbol(new ElementSymbol("g\".\"a")); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
helpTest("SELECT \"g\"\".\"\"a\" from g", //$NON-NLS-1$
- "SELECT 'g\".\"a' FROM g", //$NON-NLS-1$
+ "SELECT \"g\"\"\".\"\"\"a\" FROM g", //$NON-NLS-1$
query);
}
+
+ /** SELECT ""g"".""a" from db.g */
+ @Test public void testStringLiteralLikeQuotedElement1(){
+ GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
+ From from = new From();
+ from.addGroup(g);
+ Select select = new Select();
+ select.addSymbol(new ExpressionSymbol("expr", new Constant("g\".\"a"))); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Query query = new Query();
+ query.setSelect(select);
+ query.setFrom(from);
+ ParseInfo info = new ParseInfo();
+ info.allowDoubleQuotedVariable = false;
+ helpTest("SELECT \"g\"\".\"\"a\" from g", //$NON-NLS-1$
+ "SELECT 'g\".\"a' FROM g", //$NON-NLS-1$
+ query, info);
+ }
+
/** SELECT g.x AS "select" FROM g */
- public void testQuotedAlias(){
+ @Test public void testQuotedAlias(){
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2242,7 +2247,7 @@
}
/** SELECT g.x AS year FROM g */
- public void testQuotedAlias2(){
+ @Test public void testQuotedAlias2(){
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2259,9 +2264,28 @@
"SELECT g.x AS year FROM g", //$NON-NLS-1$
query);
}
+
+ @Test public void testQuotedAlias3(){
+ GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
+ From from = new From();
+ from.addGroup(g);
+
+ Select select = new Select();
+ AliasSymbol a = new AliasSymbol("some year", new ElementSymbol("g.x")); //$NON-NLS-1$ //$NON-NLS-2$
+ select.addSymbol(a);
+
+ Query query = new Query();
+ query.setSelect(select);
+ query.setFrom(from);
+
+ helpTest("SELECT g.x AS \"some year\" FROM g", //$NON-NLS-1$
+ "SELECT g.x AS \"some year\" FROM g", //$NON-NLS-1$
+ query);
+ }
+
/** SELECT g."select" FROM g */
- public void testReservedWordElement1(){
+ @Test public void testReservedWordElement1(){
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2280,7 +2304,7 @@
}
/** SELECT newModel5.ResultSetDocument.MappingClasses.from.from.Query1InputSet.x FROM newModel5.ResultSetDocument.MappingClasses.from.from.Query1InputSet */
- public void testReservedWordElement2() {
+ @Test public void testReservedWordElement2() {
GroupSymbol g = new GroupSymbol("newModel5.ResultSetDocument.MappingClasses.from.from.Query1InputSet"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2299,7 +2323,7 @@
}
/** SELECT * FROM newModel5.ResultSetDocument.MappingClasses.from.from.Query1InputSet */
- public void testReservedWordGroup1(){
+ @Test public void testReservedWordGroup1(){
GroupSymbol g = new GroupSymbol("newModel5.ResultSetDocument.MappingClasses.from.from.Query1InputSet"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2317,7 +2341,7 @@
}
/** SELECT * FROM newModel5."ResultSetDocument.MappingClasses.from.from.Query1InputSet" */
- public void testReservedWordGroup2(){
+ @Test public void testReservedWordGroup2(){
GroupSymbol g = new GroupSymbol("newModel5.ResultSetDocument.MappingClasses.from.from.Query1InputSet"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2335,7 +2359,7 @@
}
/** SELECT * FROM model.doc WHERE ab.cd.@ef = 'abc' */
- public void testXMLCriteriaWithAttribute() {
+ @Test public void testXMLCriteriaWithAttribute() {
GroupSymbol g = new GroupSymbol("model.doc"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2355,13 +2379,8 @@
query);
}
- /** SELECT * FROM model.doc WHERE @ef = 'abc' */
- public void testXMLCriteriaWithUnqualifiedAttribute() {
- helpException("SELECT * FROM model.doc WHERE @ef = 'abc'"); //$NON-NLS-1$
- }
-
/** SELECT a from db.g where a <> 'value' */
- public void testStringNotEqual(){
+ @Test public void testStringNotEqual(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2383,7 +2402,7 @@
}
/** SELECT a from db.g where a BETWEEN 1000 AND 2000 */
- public void testBetween1(){
+ @Test public void testBetween1(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2406,7 +2425,7 @@
}
/** SELECT a from db.g where a NOT BETWEEN 1000 AND 2000 */
- public void testBetween2(){
+ @Test public void testBetween2(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2429,7 +2448,7 @@
}
/** SELECT a from db.g where a < 1000 */
- public void testCompareLT(){
+ @Test public void testCompareLT(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2451,7 +2470,7 @@
}
/** SELECT a from db.g where a > 1000 */
- public void testCompareGT(){
+ @Test public void testCompareGT(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2473,7 +2492,7 @@
}
/** SELECT a from db.g where a <= 1000 */
- public void testCompareLE(){
+ @Test public void testCompareLE(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2495,7 +2514,7 @@
}
/** SELECT a from db.g where a >= 1000 */
- public void testCompareGE(){
+ @Test public void testCompareGE(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2517,22 +2536,22 @@
}
/** SELECT a from db.g where b = x and a = 1000 */
- public void testCompoundCompare1(){
+ @Test public void testCompoundCompare1(){
helpTestCompoundCompare("SELECT a from db.g where b = x and a = 1000"); //$NON-NLS-1$
}
/** SELECT a from db.g where (b = x and a = 1000) */
- public void testCompoundCompare2(){
+ @Test public void testCompoundCompare2(){
helpTestCompoundCompare("SELECT a from db.g where (b = x and a = 1000)"); //$NON-NLS-1$
}
/** SELECT a from db.g where ((b = x) and (a = 1000)) */
- public void testCompoundCompare3(){
+ @Test public void testCompoundCompare3(){
helpTestCompoundCompare("SELECT a from db.g where ((b = x) and (a = 1000))"); //$NON-NLS-1$
}
/** SELECT a from db.g where (((b = x) and (a = 1000))) */
- public void testCompoundCompare4(){
+ @Test public void testCompoundCompare4(){
helpTestCompoundCompare("SELECT a from db.g where (((b = x) and (a = 1000)))"); //$NON-NLS-1$
}
@@ -2561,7 +2580,7 @@
}
/** SELECT a FROM db.g WHERE b IN (1000,5000)*/
- public void testSetCriteria0(){
+ @Test public void testSetCriteria0(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2586,7 +2605,7 @@
}
/** SELECT a FROM db.g WHERE b NOT IN (1000,5000)*/
- public void testSetCriteria1(){
+ @Test public void testSetCriteria1(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2613,7 +2632,7 @@
// ================================== order by ==================================
/** SELECT a FROM db.g WHERE b = aString order by c*/
- public void testOrderBy(){
+ @Test public void testOrderBy(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2635,7 +2654,7 @@
}
/** SELECT a FROM db.g WHERE b = aString order by c desc*/
- public void testOrderByDesc(){
+ @Test public void testOrderByDesc(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2659,7 +2678,7 @@
}
/** SELECT a FROM db.g WHERE b = aString order by c,d*/
- public void testOrderBys(){
+ @Test public void testOrderBys(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2682,7 +2701,7 @@
}
/** SELECT a FROM db.g WHERE b = aString order by c desc,d desc*/
- public void testOrderBysDesc(){
+ @Test public void testOrderBysDesc(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2708,7 +2727,7 @@
}
/** SELECT a FROM db.g WHERE b = aString order by c desc,d*/
- public void testMixedOrderBys(){
+ @Test public void testMixedOrderBys(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2736,7 +2755,7 @@
// ================================== match ====================================
/** SELECT a FROM db.g WHERE b LIKE 'aString'*/
- public void testLike0(){
+ @Test public void testLike0(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2758,7 +2777,7 @@
}
/** SELECT a FROM db.g WHERE b NOT LIKE 'aString'*/
- public void testLike1(){
+ @Test public void testLike1(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2780,7 +2799,7 @@
}
/** SELECT a from db.g where b like '#String' escape '#'*/
- public void testLikeWithEscape(){
+ @Test public void testLikeWithEscape(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2801,12 +2820,12 @@
query);
}
- public void testLikeWithEscapeException(){
+ @Test public void testLikeWithEscapeException(){
helpException("SELECT a from db.g where b like '#String' escape '#1'", "Parsing error: Like escape value must be a single character."); //$NON-NLS-1$ //$NON-NLS-2$
}
/** SELECT "date"."time" from db.g */
- public void testReservedWordsInElement() {
+ @Test public void testReservedWordsInElement() {
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2825,7 +2844,7 @@
}
/** SELECT a */
- public void testNoFromClause(){
+ @Test public void testNoFromClause(){
Select select = new Select();
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
ExpressionSymbol b = new ExpressionSymbol("expr", new Constant(new Integer(5), Integer.class)); //$NON-NLS-1$
@@ -2839,27 +2858,27 @@
// ==================== misc queries that should fail ===========================
/** FROM g WHERE a = 'aString' */
- public void testFailsNoSelectClause(){
+ @Test public void testFailsNoSelectClause(){
helpException("FROM g WHERE a = 'aString'"); //$NON-NLS-1$
}
/** SELECT a WHERE a = 'aString' */
- public void testFailsNoFromClause(){
+ @Test public void testFailsNoFromClause(){
helpException("SELECT a WHERE a = 'aString'"); //$NON-NLS-1$
}
/** SELECT xx.yy%.a from xx.yy */
- public void testFailsWildcardInSelect(){
+ @Test public void testFailsWildcardInSelect(){
helpException("SELECT xx.yy%.a from xx.yy"); //$NON-NLS-1$
}
/** SELECT a or b from g */
- public void testFailsOrInSelect(){
+ @Test public void testFailsOrInSelect(){
helpException("SELECT a or b from g"); //$NON-NLS-1$
}
/** SELECT a FROM g WHERE a LIKE x*/
- public void testLikeWOConstant(){
+ @Test public void testLikeWOConstant(){
GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2881,12 +2900,12 @@
}
/** SELECT a from g ORDER BY b DSC*/
- public void testFailsDSCMisspelled(){
+ @Test public void testFailsDSCMisspelled(){
helpException("SELECT a from g ORDER BY b DSC"); //$NON-NLS-1$
}
/** Test reusability of parser */
- public void testReusabilityOfParserObject() {
+ @Test public void testReusabilityOfParserObject() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2908,7 +2927,7 @@
}
/** SELECT a from db.g where b LIKE ? */
- public void testParameter1() {
+ @Test public void testParameter1() {
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2930,7 +2949,7 @@
}
/** SELECT a from db.g where b LIKE ? */
- public void testParameter2() {
+ @Test public void testParameter2() {
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -2972,7 +2991,7 @@
}
/** SELECT a, b FROM (SELECT c FROM m.g) AS y */
- public void testSubquery1() {
+ @Test public void testSubquery1() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -3004,7 +3023,7 @@
}
/** SELECT a, b FROM ((SELECT c FROM m.g)) AS y */
- public void testSubquery1a() {
+ @Test public void testSubquery1a() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -3036,7 +3055,7 @@
}
/** SELECT a, b FROM m.g1 JOIN (SELECT c FROM m.g2) AS y ON m.g1.a = y.c */
- public void testSubquery2() {
+ @Test public void testSubquery2() {
GroupSymbol g = new GroupSymbol("m.g2"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -3073,12 +3092,12 @@
}
/** SELECT a, b FROM (SELECT c FROM m.g2) */
- public void testSubqueryInvalid() {
+ @Test public void testSubqueryInvalid() {
helpException("SELECT a, b FROM (SELECT c FROM m.g2)"); //$NON-NLS-1$
}
/** INSERT INTO m.g (a) VALUES (?) */
- public void testInsertWithReference() {
+ @Test public void testInsertWithReference() {
Insert insert = new Insert();
insert.setGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
List vars = new ArrayList();
@@ -3092,14 +3111,14 @@
insert);
}
- public void testStoredQueryWithNoParameter(){
+ @Test public void testStoredQueryWithNoParameter(){
StoredProcedure storedQuery = new StoredProcedure();
storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
helpTest("exec proc1()", "EXEC proc1()", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
helpTest("execute proc1()", "EXEC proc1()", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testStoredQueryWithNoParameter2(){
+ @Test public void testStoredQueryWithNoParameter2(){
StoredProcedure storedQuery = new StoredProcedure();
storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
@@ -3116,7 +3135,7 @@
helpTest("SELECT X.A FROM (exec proc1()) AS X", "SELECT X.A FROM (EXEC proc1()) AS X", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testStoredQuery(){
+ @Test public void testStoredQuery(){
StoredProcedure storedQuery = new StoredProcedure();
storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
SPParameter parameter = new SPParameter(1, new Constant("param1")); //$NON-NLS-1$
@@ -3126,7 +3145,7 @@
helpTest("execute proc1('param1')", "EXEC proc1('param1')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testStoredQuery2(){
+ @Test public void testStoredQuery2(){
StoredProcedure storedQuery = new StoredProcedure();
storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
SPParameter parameter = new SPParameter(1, new Constant("param1")); //$NON-NLS-1$
@@ -3144,7 +3163,7 @@
helpTest("SELECT X.A FROM (exec proc1('param1')) AS X", "SELECT X.A FROM (EXEC proc1('param1')) AS X", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testStoredQuery2SanityCheck(){
+ @Test public void testStoredQuery2SanityCheck(){
StoredProcedure storedQuery = new StoredProcedure();
storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
SPParameter parameter = new SPParameter(1, new Constant("param1")); //$NON-NLS-1$
@@ -3186,14 +3205,14 @@
helpTest("SELECT X.A FROM ((exec proc1('param1'))) AS X", "SELECT X.A FROM (EXEC proc1('param1')) AS X", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testErrorStatement(){
+ @Test public void testErrorStatement(){
RaiseErrorStatement errStmt = new RaiseErrorStatement(new Constant("Test only")); //$NON-NLS-1$
helpStmtTest("ERROR 'Test only';", "ERROR 'Test only';", //$NON-NLS-1$ //$NON-NLS-2$
errStmt);
}
- public void testIfStatement(){
+ @Test public void testIfStatement(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
Statement ifStmt = new DeclareStatement(a, shortType);
@@ -3219,7 +3238,7 @@
stmt);
}
- /*public void testIfStatement1(){
+ /*@Test public void testIfStatement1(){
ElementSymbol a = new ElementSymbol("a");
String shortType = new String("short");
Statement ifStmt = new DeclareStatement(a, shortType);
@@ -3245,7 +3264,7 @@
stmt);
}*/
- public void testCriteriaSelector0(){
+ @Test public void testCriteriaSelector0(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3255,7 +3274,7 @@
helpCriteriaSelectorTest("IS NULL CRITERIA ON (a)", "IS NULL CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCriteriaSelector1(){
+ @Test public void testCriteriaSelector1(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3265,7 +3284,7 @@
helpCriteriaSelectorTest("= CRITERIA ON (a)", "= CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCriteriaSelector2(){
+ @Test public void testCriteriaSelector2(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3275,7 +3294,7 @@
helpCriteriaSelectorTest("<> CRITERIA ON (a)", "<> CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCriteriaSelector3(){
+ @Test public void testCriteriaSelector3(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3285,7 +3304,7 @@
helpCriteriaSelectorTest("< CRITERIA ON (a)", "< CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCriteriaSelector4(){
+ @Test public void testCriteriaSelector4(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3295,7 +3314,7 @@
helpCriteriaSelectorTest("> CRITERIA ON (a)", "> CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCriteriaSelector5(){
+ @Test public void testCriteriaSelector5(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3305,7 +3324,7 @@
helpCriteriaSelectorTest(">= CRITERIA ON (a)", ">= CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCriteriaSelector6(){
+ @Test public void testCriteriaSelector6(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3315,7 +3334,7 @@
helpCriteriaSelectorTest("<= CRITERIA ON (a)", "<= CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCriteriaSelector7(){
+ @Test public void testCriteriaSelector7(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3326,7 +3345,7 @@
}
- public void testCriteriaSelector8(){
+ @Test public void testCriteriaSelector8(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3336,7 +3355,7 @@
helpCriteriaSelectorTest("IN CRITERIA ON (a)", "IN CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCriteriaSelector9(){
+ @Test public void testCriteriaSelector9(){
//ElementSymbol a = new ElementSymbol("a");
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3346,7 +3365,7 @@
helpCriteriaSelectorTest("CRITERIA", "CRITERIA", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCriteriaSelector10(){
+ @Test public void testCriteriaSelector10(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3357,7 +3376,7 @@
}
/**HAS IS NULL CRITERIA ON (a)*/
- public void testHasIsNullCriteria(){
+ @Test public void testHasIsNullCriteria(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3374,7 +3393,7 @@
}
/**HAS LIKE CRITERIA ON (a)*/
- public void testHasLikeCriteria(){
+ @Test public void testHasLikeCriteria(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3390,7 +3409,7 @@
hasSelector);
}
- public void testHasEQCriteria(){
+ @Test public void testHasEQCriteria(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3406,7 +3425,7 @@
hasSelector);
}
- public void testHasNECriteria(){
+ @Test public void testHasNECriteria(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3423,7 +3442,7 @@
}
/**HAS IN CRITERIA ON (a)*/
- public void testHasInCriteria(){
+ @Test public void testHasInCriteria(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3440,7 +3459,7 @@
}
/**HAS COMPARE_LT CRITERIA ON (a)*/
- public void testHasLTCriteria(){
+ @Test public void testHasLTCriteria(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3457,7 +3476,7 @@
}
/**HAS COMPARE_LE CRITERIA ON (a)*/
- public void testHasLECriteria(){
+ @Test public void testHasLECriteria(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3474,7 +3493,7 @@
}
/**HAS COMPARE_GT CRITERIA ON (a)*/
- public void testHasGTCriteria(){
+ @Test public void testHasGTCriteria(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3491,7 +3510,7 @@
}
/**HAS COMPARE_GE CRITERIA ON (a)*/
- public void testHasGECriteria(){
+ @Test public void testHasGECriteria(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3508,7 +3527,7 @@
}
/**HAS BETWEEN CRITERIA ON (a)*/
- public void testHasBetweenCriteria(){
+ @Test public void testHasBetweenCriteria(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3524,7 +3543,7 @@
hasSelector);
}
- public void testTranslateCriteria(){
+ @Test public void testTranslateCriteria(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3550,7 +3569,7 @@
}
- public void testAssignStatement(){
+ @Test public void testAssignStatement(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List symbols = new ArrayList();
@@ -3581,7 +3600,7 @@
helpStmtTest("a = 'aString';", "a = 'aString';", exprStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testAssignStatement2(){
+ @Test public void testAssignStatement2(){
Insert insert = new Insert();
insert.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
List vars = new ArrayList();
@@ -3600,7 +3619,7 @@
}
- public void testDeclareStatement(){
+ @Test public void testDeclareStatement(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
DeclareStatement stmt = new DeclareStatement(a, type);
@@ -3608,7 +3627,7 @@
helpStmtTest("DECLARE short a;","DECLARE short a;", stmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDeclareStatementWithAssignment(){
+ @Test public void testDeclareStatementWithAssignment(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
DeclareStatement stmt = new DeclareStatement(a, type, new Constant(null));
@@ -3616,7 +3635,7 @@
helpStmtTest("DECLARE short a = null;","DECLARE short a = null;", stmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDeclareStatementWithAssignment1(){
+ @Test public void testDeclareStatementWithAssignment1(){
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("string"); //$NON-NLS-1$
DeclareStatement stmt = new DeclareStatement(a, type, sampleQuery());
@@ -3624,7 +3643,7 @@
helpStmtTest("DECLARE string a = SELECT a1 FROM g WHERE a2 = 5;","DECLARE string a = SELECT a1 FROM g WHERE a2 = 5;", stmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testStatement() {
+ @Test public void testStatement() {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
DeclareStatement declStmt = new DeclareStatement(a, type);
@@ -3634,7 +3653,7 @@
stmt);
}
- public void testBlock() {
+ @Test public void testBlock() {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
DeclareStatement declStmt = new DeclareStatement(a, type);
@@ -3645,7 +3664,7 @@
block);
}
- public void testCommandStatement(){
+ @Test public void testCommandStatement(){
Query query = sampleQuery();
Command sqlCmd = query;
@@ -3676,7 +3695,7 @@
return query;
}
- public void testDynamicCommandStatement(){
+ @Test public void testDynamicCommandStatement(){
List symbols = new ArrayList();
ElementSymbol a1 = new ElementSymbol("a1"); //$NON-NLS-1$
@@ -3699,7 +3718,7 @@
}
//sql is a variable, also uses the as, into, and update clauses
- public void testDynamicCommandStatement1(){
+ @Test public void testDynamicCommandStatement1(){
List symbols = new ArrayList();
ElementSymbol a1 = new ElementSymbol("a1"); //$NON-NLS-1$
@@ -3727,7 +3746,7 @@
cmdStmt);
}
- public void testDynamicCommandStatementWithUsing(){
+ @Test public void testDynamicCommandStatementWithUsing(){
SetClauseList using = new SetClauseList();
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
@@ -3746,22 +3765,22 @@
}
//as clause should use short names
- public void testDynamicCommandStatement2(){
+ @Test public void testDynamicCommandStatement2(){
helpException("create virtual procedure begin execute string z as variables.a1 string, a2 integer into #g; end"); //$NON-NLS-1$
}
//using clause should use short names
- public void testDynamicCommandStatement3(){
+ @Test public void testDynamicCommandStatement3(){
helpException("create virtual procedure begin execute string z as a1 string, a2 integer into #g using variables.x=variables.y; end", "Parsing error: Invalid simple identifier format: [variables.x]"); //$NON-NLS-1$ //$NON-NLS-2$
}
//into clause requires as clause
- public void testDynamicCommandStatement4(){
+ @Test public void testDynamicCommandStatement4(){
helpException("create virtual procedure begin execute string z into #g using x=variables.y; end"); //$NON-NLS-1$
}
/** original test */
- public void testCreateUpdateProcedureCommand(){
+ @Test public void testCreateUpdateProcedureCommand(){
helpTestCreateUpdateProcedureCommandCase3025("CREATE PROCEDURE\nBEGIN\nDECLARE short var1;"+ //$NON-NLS-1$
"IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = SELECT a1 FROM g WHERE a2 = 5;\nEND\n"+ //$NON-NLS-1$
"ELSE\nBEGIN\nDECLARE short var2;\nvar2 = SELECT b1 FROM g WHERE a2 = 5;\nEND\n" + //$NON-NLS-1$
@@ -3770,7 +3789,7 @@
}
/** test that a command in parens isn't parsed as a ScalarSubquery */
- public void testCreateUpdateProcedureCommandCase3025_1(){
+ @Test public void testCreateUpdateProcedureCommandCase3025_1(){
helpTestCreateUpdateProcedureCommandCase3025("CREATE PROCEDURE\nBEGIN\nDECLARE short var1;"+ //$NON-NLS-1$
"IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = (SELECT a1 FROM g WHERE a2 = 5);\nEND\n"+ //$NON-NLS-1$
@@ -3780,7 +3799,7 @@
}
/** test that a command in DOUBLE parens isn't parsed as a ScalarSubquery */
- public void testCreateUpdateProcedureCommandCase3025_2(){
+ @Test public void testCreateUpdateProcedureCommandCase3025_2(){
helpTestCreateUpdateProcedureCommandCase3025("CREATE PROCEDURE\nBEGIN\nDECLARE short var1;"+ //$NON-NLS-1$
"IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = ((SELECT a1 FROM g WHERE a2 = 5) );\nEND\n"+ //$NON-NLS-1$
"ELSE\nBEGIN\nDECLARE short var2;\nvar2 = SELECT b1 FROM g WHERE a2 = 5;\nEND\n" + //$NON-NLS-1$
@@ -3868,7 +3887,7 @@
}
/** test an expression in parentheses in an assignment statement */
- public void testCreateUpdateProcedureCommandCase3025_3(){
+ @Test public void testCreateUpdateProcedureCommandCase3025_3(){
String procedureString = "CREATE PROCEDURE\nBEGIN\nDECLARE short var1;"+ //$NON-NLS-1$
"IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = (concat('x', 'y') );\nEND\n"+ //$NON-NLS-1$
@@ -3879,7 +3898,7 @@
}
/** test an expression in parentheses in an assignment statement */
- public void testCreateUpdateProcedureCommandCase3025_4(){
+ @Test public void testCreateUpdateProcedureCommandCase3025_4(){
String procedureString = "CREATE PROCEDURE\nBEGIN\nDECLARE short var1;"+ //$NON-NLS-1$
"IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = ((concat('x', 'y') ));\nEND\n"+ //$NON-NLS-1$
@@ -3890,7 +3909,7 @@
}
/** test an expression without parentheses in an assignment statement */
- public void testCreateUpdateProcedureCommandCase3025_5(){
+ @Test public void testCreateUpdateProcedureCommandCase3025_5(){
String procedureString = "CREATE PROCEDURE\nBEGIN\nDECLARE short var1;"+ //$NON-NLS-1$
"IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = concat('x', 'y') ;\nEND\n"+ //$NON-NLS-1$
@@ -3976,7 +3995,7 @@
}
/**IF statement with has criteria */
- public void testCreateUpdateProcedureCommand1(){
+ @Test public void testCreateUpdateProcedureCommand1(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -4056,7 +4075,7 @@
"var2 = SELECT b1 FROM g WHERE a2 = 5;"+"\n"+"END"+"\n"+"END", cmd); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
- public void testCreateUpdateProcedureCommand0(){
+ @Test public void testCreateUpdateProcedureCommand0(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -4137,7 +4156,7 @@
}
/**IF statement with has LIKE criteria */
- public void testCreateUpdateProcedureCommand2(){
+ @Test public void testCreateUpdateProcedureCommand2(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -4219,7 +4238,7 @@
}
/**IF statement with has IN criteria */
- public void testCreateUpdateProcedureCommand3(){
+ @Test public void testCreateUpdateProcedureCommand3(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -4301,7 +4320,7 @@
}
/**IF statement with has <> criteria */
- public void testCreateUpdateProcedureCommand4(){
+ @Test public void testCreateUpdateProcedureCommand4(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -4383,7 +4402,7 @@
}
/**Has criteria in WHERE clause*/
- public void testCreateUpdateProcedureCommand5(){
+ @Test public void testCreateUpdateProcedureCommand5(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -4473,7 +4492,7 @@
}
/** Translate criteria (empty criteriaSelector in WHERE clause*/
- public void testCreateUpdateProcedureCommand7(){
+ @Test public void testCreateUpdateProcedureCommand7(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -4566,7 +4585,7 @@
}
/** Translate criteria (is null criteriaSelector in WHERE clause*/
- public void testCreateUpdateProcedureCommand9(){
+ @Test public void testCreateUpdateProcedureCommand9(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -4659,7 +4678,7 @@
}
/** Translate criteria ( only with WHERE clause) */
- public void testCreateUpdateProcedureCommand10(){
+ @Test public void testCreateUpdateProcedureCommand10(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -4752,7 +4771,7 @@
}
/** Translate criteria ( only with WHERE clause) */
- public void testCreateUpdateProcedureCommand12(){
+ @Test public void testCreateUpdateProcedureCommand12(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -4851,7 +4870,7 @@
}
/** Translate criteria (with only Criteria in WHERE clause) */
- public void testCreateUpdateProcedureCommand11(){
+ @Test public void testCreateUpdateProcedureCommand11(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -4943,7 +4962,7 @@
}
/**IF statement with has criteria no on */
- public void testCreateUpdateProcedureCommand8(){
+ @Test public void testCreateUpdateProcedureCommand8(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -5017,7 +5036,7 @@
"var2 = SELECT b1 FROM g WHERE a2 = 5;"+"\n"+"END"+"\n"+"END", cmd); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
- public void testSubquerySetCriteria0() {
+ @Test public void testSubquerySetCriteria0() {
//test wrap up command with subquerySetCriteria
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
@@ -5047,7 +5066,7 @@
outer);
}
- public void testSubquerySetCriteria1() {
+ @Test public void testSubquerySetCriteria1() {
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
@@ -5077,7 +5096,7 @@
outer);
}
- public void testSubquerySetCriteriaWithExec() {
+ @Test public void testSubquerySetCriteriaWithExec() {
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -5101,7 +5120,7 @@
outer);
}
- public void testSubquerySetCriteriaWithUnion() {
+ @Test public void testSubquerySetCriteriaWithUnion() {
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -5143,7 +5162,7 @@
outer);
}
- public void testVariablesInExec(){
+ @Test public void testVariablesInExec(){
StoredProcedure storedQuery = new StoredProcedure();
storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
SPParameter parameter = new SPParameter(1, new ElementSymbol("param1")); //$NON-NLS-1$
@@ -5153,7 +5172,7 @@
helpTest("execute proc1(param1)", "EXEC proc1(param1)", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testExecSubquery(){
+ @Test public void testExecSubquery(){
Query query = new Query();
Select select = new Select();
select.addSymbol(new AllSymbol());
@@ -5170,7 +5189,7 @@
query);
}
- public void testUnicode1() {
+ @Test public void testUnicode1() {
try {
byte[] data = { (byte)0xd0, (byte)0x9c, (byte)0xd0, (byte)0xbe, (byte)0xd1, (byte)0x81, (byte)0xd0, (byte)0xba, (byte)0xd0, (byte)0xb2, (byte)0xd0, (byte)0xb0};
@@ -5194,7 +5213,7 @@
}
}
- public void testUnicode2() {
+ @Test public void testUnicode2() {
String sql = "SELECT * FROM TestDocument.TestDocument WHERE Subject='\u0041\u005a'"; //$NON-NLS-1$
Query query = new Query();
@@ -5210,7 +5229,7 @@
helpTest(sql, query.toString(), query);
}
- public void testUnicode3() {
+ @Test public void testUnicode3() {
String sql = "SELECT '\u05e0'"; //$NON-NLS-1$
Query query = new Query();
@@ -5222,7 +5241,7 @@
helpTest(sql, query.toString(), query);
}
- public void testUnicode4() {
+ @Test public void testUnicode4() {
String sql = "SELECT \u05e0 FROM g"; //$NON-NLS-1$
Query query = new Query();
@@ -5237,7 +5256,7 @@
helpTest(sql, query.toString(), query);
}
- public void testEscapedFunction1() {
+ @Test public void testEscapedFunction1() {
String sql = "SELECT * FROM a.thing WHERE e1 = {fn concat('a', 'b')}"; //$NON-NLS-1$
Query query = new Query();
@@ -5256,7 +5275,7 @@
query);
}
- public void testEscapedFunction2() {
+ @Test public void testEscapedFunction2() {
String sql = "SELECT * FROM a.thing WHERE e1 = {fn convert(5, string)}"; //$NON-NLS-1$
Query query = new Query();
@@ -5275,7 +5294,7 @@
query);
}
- public void testEscapedFunction3() {
+ @Test public void testEscapedFunction3() {
String sql = "SELECT * FROM a.thing WHERE e1 = {fn cast(5 as string)}"; //$NON-NLS-1$
Query query = new Query();
@@ -5292,7 +5311,7 @@
helpTest(sql, "SELECT * FROM a.thing WHERE e1 = cast(5 AS string)", query); //$NON-NLS-1$
}
- public void testEscapedFunction4() {
+ @Test public void testEscapedFunction4() {
String sql = "SELECT * FROM a.thing WHERE e1 = {fn concat({fn concat('a', 'b')}, 'c')}"; //$NON-NLS-1$
Query query = new Query();
@@ -5310,7 +5329,7 @@
helpTest(sql, "SELECT * FROM a.thing WHERE e1 = concat(concat('a', 'b'), 'c')", query); //$NON-NLS-1$
}
- public void testFunctionWithUnderscore() {
+ @Test public void testFunctionWithUnderscore() {
String sql = "SELECT yowza_yowza() FROM a.thing"; //$NON-NLS-1$
Query query = new Query();
@@ -5327,7 +5346,7 @@
helpTest(sql, "SELECT yowza_yowza() FROM a.thing", query); //$NON-NLS-1$
}
- public void testManyInnerJoins1() {
+ @Test public void testManyInnerJoins1() {
String sql = "SELECT * " + //$NON-NLS-1$
"FROM SQL1.dbo.Customers INNER JOIN SQL1.dbo.Orders " + //$NON-NLS-1$
"ON SQL1.dbo.Customers.CustomerID = SQL1.dbo.Orders.CustomerID " + //$NON-NLS-1$
@@ -5369,7 +5388,7 @@
helpTest(sql, sqlExpected, query);
}
- public void testManyInnerJoins2() {
+ @Test public void testManyInnerJoins2() {
String sql = "SELECT * " + //$NON-NLS-1$
"FROM A INNER JOIN (B RIGHT OUTER JOIN C ON b1 = c1) " + //$NON-NLS-1$
"ON a1 = b1 " + //$NON-NLS-1$
@@ -5415,7 +5434,7 @@
helpTest(sql, sqlExpected, query);
}
- public void testManyInnerJoins3() {
+ @Test public void testManyInnerJoins3() {
String sql = "SELECT * " + //$NON-NLS-1$
"FROM A INNER JOIN " + //$NON-NLS-1$
"(B RIGHT OUTER JOIN C ON b1 = c1 " + //$NON-NLS-1$
@@ -5459,7 +5478,7 @@
helpTest(sql, sqlExpected, query);
}
- public void testLoopStatement(){
+ @Test public void testLoopStatement(){
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -5491,7 +5510,7 @@
+"\n"+"END", loopStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLoopStatementWithOrderBy(){
+ @Test public void testLoopStatementWithOrderBy(){
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -5527,7 +5546,7 @@
+"\n"+"END", loopStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testWhileStatement(){
+ @Test public void testWhileStatement(){
ElementSymbol x = new ElementSymbol("x", false); //$NON-NLS-1$
Function f = new Function("+", new Expression[] { x, new Constant(new Integer(1)) }); //$NON-NLS-1$
Statement assignmentStmt = new AssignmentStatement(x, f);
@@ -5541,17 +5560,17 @@
+"\n"+"END", whileStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testBreakStatement(){
+ @Test public void testBreakStatement(){
Statement breakStmt = new BreakStatement();
helpStmtTest("break;", "BREAK;", breakStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testContinueStatement(){
+ @Test public void testContinueStatement(){
Statement contStmt = new ContinueStatement();
helpStmtTest("continue;", "CONTINUE;", contStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testVirtualProcedure(){
+ @Test public void testVirtualProcedure(){
ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$
String intType = new String("integer"); //$NON-NLS-1$
Statement dStmt = new DeclareStatement(x, intType);
@@ -5604,7 +5623,7 @@
}
- public void testScalarSubqueryExpressionInSelect(){
+ @Test public void testScalarSubqueryExpressionInSelect(){
Select s1 = new Select();
s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5628,7 +5647,7 @@
q2);
}
- public void testScalarSubqueryExpressionInSelect2(){
+ @Test public void testScalarSubqueryExpressionInSelect2(){
Select s1 = new Select();
s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5651,7 +5670,7 @@
q2);
}
- public void testScalarSubqueryExpressionInSelect3(){
+ @Test public void testScalarSubqueryExpressionInSelect3(){
Select s1 = new Select();
s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5675,7 +5694,7 @@
q2);
}
- public void testScalarSubqueryExpressionWithAlias(){
+ @Test public void testScalarSubqueryExpressionWithAlias(){
Select s1 = new Select();
s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5699,7 +5718,7 @@
q2);
}
- public void testScalarSubqueryExpressionInComplexExpression() throws QueryParserException {
+ @Test public void testScalarSubqueryExpressionInComplexExpression() throws QueryParserException {
Select s2 = new Select();
s2.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5716,7 +5735,7 @@
q2);
}
- public void testScalarSubqueryExpressionInComplexExpression2() throws QueryParserException{
+ @Test public void testScalarSubqueryExpressionInComplexExpression2() throws QueryParserException{
Select s2 = new Select();
s2.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5733,7 +5752,7 @@
q2);
}
- public void testScalarSubqueryExpressionInComplexExpression3() throws QueryParserException{
+ @Test public void testScalarSubqueryExpressionInComplexExpression3() throws QueryParserException{
Select s2 = new Select();
s2.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5750,7 +5769,7 @@
q2);
}
- public void testScalarSubqueryExpressionInFunction() throws QueryParserException{
+ @Test public void testScalarSubqueryExpressionInFunction() throws QueryParserException{
Select s2 = new Select();
s2.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5767,11 +5786,11 @@
q2);
}
- public void testBadScalarSubqueryExpression() {
+ @Test public void testBadScalarSubqueryExpression() {
helpException("SELECT e1, length(SELECT e1 FROM m.g1) as X FROM m.g2"); //$NON-NLS-1$
}
- public void testExistsPredicateCriteria(){
+ @Test public void testExistsPredicateCriteria(){
Select s1 = new Select();
s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5796,7 +5815,7 @@
q2);
}
- public void testAnyQuantifierSubqueryComparePredicate(){
+ @Test public void testAnyQuantifierSubqueryComparePredicate(){
Select s1 = new Select();
s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5822,7 +5841,7 @@
}
- public void testSomeQuantifierSubqueryComparePredicate(){
+ @Test public void testSomeQuantifierSubqueryComparePredicate(){
Select s1 = new Select();
s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5848,7 +5867,7 @@
}
- public void testAllQuantifierSubqueryComparePredicate(){
+ @Test public void testAllQuantifierSubqueryComparePredicate(){
Select s1 = new Select();
s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5874,7 +5893,7 @@
}
- public void testScalarSubqueryComparePredicate(){
+ @Test public void testScalarSubqueryComparePredicate(){
Select s1 = new Select();
s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
@@ -5900,7 +5919,7 @@
}
- public void testSelectInto(){
+ @Test public void testSelectInto(){
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -5920,7 +5939,7 @@
q);
}
- public void testCaseExpression1() {
+ @Test public void testCaseExpression1() {
CaseExpression expr = TestCaseExpression.example(4);
Select select = new Select();
select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$
@@ -5946,7 +5965,7 @@
helpTest(query, query, q);
}
- public void testCaseExpression2() {
+ @Test public void testCaseExpression2() {
CaseExpression expr = TestCaseExpression.example(4);
expr.setElseExpression(null);
Select select = new Select();
@@ -5972,7 +5991,7 @@
helpTest(query, query, q);
}
- public void testCaseExpression3() {
+ @Test public void testCaseExpression3() {
SearchedCaseExpression expr = TestSearchedCaseExpression.example2(4);
Select select = new Select();
select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$
@@ -5995,7 +6014,7 @@
helpTest(query, query, q);
}
- public void testSearchedCaseExpression1() {
+ @Test public void testSearchedCaseExpression1() {
SearchedCaseExpression expr = TestSearchedCaseExpression.example(4);
Select select = new Select();
select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$
@@ -6020,7 +6039,7 @@
helpTest(query, query, q);
}
- public void testSearchedCaseExpression2() {
+ @Test public void testSearchedCaseExpression2() {
SearchedCaseExpression expr = TestSearchedCaseExpression.example(4);
expr.setElseExpression(null);
Select select = new Select();
@@ -6045,7 +6064,7 @@
helpTest(query, query, q);
}
- public void testSearchedCaseExpression3() {
+ @Test public void testSearchedCaseExpression3() {
SearchedCaseExpression expr = TestSearchedCaseExpression.example(4);
Select select = new Select();
select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$
@@ -6068,7 +6087,7 @@
helpTest(query, query, q);
}
- public void testAndOrPrecedence_1575() {
+ @Test public void testAndOrPrecedence_1575() {
Select s = new Select();
s.addSymbol(new AllSymbol());
From f = new From();
@@ -6087,7 +6106,7 @@
"SELECT * FROM m.g1 WHERE (e1 = 0) OR ((e2 = 1) AND (e3 = 3))", q); //$NON-NLS-1$
}
- public void testAndOrPrecedence2_1575() {
+ @Test public void testAndOrPrecedence2_1575() {
Select s = new Select();
s.addSymbol(new AllSymbol());
From f = new From();
@@ -6130,16 +6149,16 @@
}
- public void testCompoundNonJoinCriteriaInFromWithComparisonCriteria() {
+ @Test public void testCompoundNonJoinCriteriaInFromWithComparisonCriteria() {
CompareCriteria c2 = new CompareCriteria(new ElementSymbol("e2"), CompareCriteria.EQ, new Constant(new Integer(1))); //$NON-NLS-1$
helpTestCompoundNonJoinCriteria("e2 = 1", c2); //$NON-NLS-1$
}
- public void testCompoundNonJoinCriteriaInFromWithIsNull() {
+ @Test public void testCompoundNonJoinCriteriaInFromWithIsNull() {
helpTestCompoundNonJoinCriteria("e2 IS NULL", new IsNullCriteria(new ElementSymbol("e2"))); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCompoundNonJoinCriteriaInFromUWithIN() {
+ @Test public void testCompoundNonJoinCriteriaInFromUWithIN() {
Collection values = new ArrayList();
values.add(new Constant(new Integer(0)));
values.add(new Constant(new Integer(1)));
@@ -6147,36 +6166,36 @@
helpTestCompoundNonJoinCriteria("e2 IN (0, 1)", crit); //$NON-NLS-1$
}
- public void testCompoundNonJoinCriteriaInFromUWithLIKE() {
+ @Test public void testCompoundNonJoinCriteriaInFromUWithLIKE() {
PredicateCriteria crit = new MatchCriteria(new ElementSymbol("e2"), new Constant("%")); //$NON-NLS-1$ //$NON-NLS-2$
helpTestCompoundNonJoinCriteria("e2 LIKE '%'", crit); //$NON-NLS-1$
}
- public void testCompoundNonJoinCriteria_defect15167_1() throws Exception {
+ @Test public void testCompoundNonJoinCriteria_defect15167_1() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT A.alert_id, A.primary_entity_name, A.primary_entity_level_code, A.alert_description, A.create_date, A.alert_risk_score, S.scenario_name, A.alert_status_code, A.process_id, A.actual_values_text, S.SCENARIO_CATEGORY_DESC, A.primary_entity_number, A.scenario_id, A.primary_entity_key FROM (FSK_ALERT AS A LEFT OUTER JOIN FSK_SCENARIO AS S ON A.scenario_id = S.scenario_id) INNER JOIN FSC_ACCOUNT_DIM AS C ON A.primary_entity_key = C.ACCOUNT_KEY AND ((S.current_ind = 'Y') OR (S.current_ind IS NULL)) WHERE (A.primary_entity_level_code = 'ACC') AND (C.ACCOUNT_KEY = 23923) AND (A.logical_delete_ind = 'N') OPTION PLANONLY"); //$NON-NLS-1$
}
- public void testCompoundNonJoinCriteria_defect15167_2() throws Exception {
+ @Test public void testCompoundNonJoinCriteria_defect15167_2() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT A.alert_id, A.primary_entity_name, A.primary_entity_level_code, A.alert_description, A.create_date, A.alert_risk_score, S.scenario_name, A.alert_status_code, A.process_id, A.actual_values_text, S.SCENARIO_CATEGORY_DESC, A.primary_entity_number, A.scenario_id, A.primary_entity_key FROM (FSK_ALERT AS A LEFT OUTER JOIN FSK_SCENARIO AS S ON A.scenario_id = S.scenario_id) INNER JOIN FSC_ACCOUNT_DIM AS C ON A.primary_entity_key = C.ACCOUNT_KEY AND (S.current_ind = 'Y' OR S.current_ind IS NULL) WHERE (A.primary_entity_level_code = 'ACC') AND (C.ACCOUNT_KEY = 23923) AND (A.logical_delete_ind = 'N') OPTION PLANONLY"); //$NON-NLS-1$
}
- public void testCompoundNonJoinCriteria_defect15167_3() throws Exception {
+ @Test public void testCompoundNonJoinCriteria_defect15167_3() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT A.alert_id, A.primary_entity_name, A.primary_entity_level_code, A.alert_description, A.create_date, A.alert_risk_score, S.scenario_name, A.alert_status_code, A.process_id, A.actual_values_text, S.SCENARIO_CATEGORY_DESC, A.primary_entity_number, A.scenario_id, A.primary_entity_key FROM (FSK_ALERT AS A LEFT OUTER JOIN FSK_SCENARIO AS S ON A.scenario_id = S.scenario_id) INNER JOIN FSC_ACCOUNT_DIM AS C ON (A.primary_entity_key = C.ACCOUNT_KEY AND (S.current_ind = 'Y' OR S.current_ind IS NULL)) WHERE (A.primary_entity_level_code = 'ACC') AND (C.ACCOUNT_KEY = 23923) AND (A.logical_delete_ind = 'N') OPTION PLANONLY"); //$NON-NLS-1$
}
- public void testCompoundNonJoinCriteria_defect15167_4() throws Exception {
+ @Test public void testCompoundNonJoinCriteria_defect15167_4() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT A.alert_id, A.primary_entity_name, A.primary_entity_level_code, A.alert_description, A.create_date, A.alert_risk_score, S.scenario_name, A.alert_status_code, A.process_id, A.actual_values_text, S.SCENARIO_CATEGORY_DESC, A.primary_entity_number, A.scenario_id, A.primary_entity_key FROM (FSK_ALERT AS A LEFT OUTER JOIN FSK_SCENARIO AS S ON A.scenario_id = S.scenario_id) INNER JOIN FSC_ACCOUNT_DIM AS C ON (A.primary_entity_key = C.ACCOUNT_KEY AND S.current_ind = 'Y' OR S.current_ind IS NULL) WHERE (A.primary_entity_level_code = 'ACC') AND (C.ACCOUNT_KEY = 23923) AND (A.logical_delete_ind = 'N') OPTION PLANONLY"); //$NON-NLS-1$
}
- public void testFunctionInGroupBy() throws Exception {
+ @Test public void testFunctionInGroupBy() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT SUM(s), elem+1 FROM m.g GROUP BY elem+1"); //$NON-NLS-1$
}
- public void testCaseInGroupBy() throws Exception {
+ @Test public void testCaseInGroupBy() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT SUM(elem+1), CASE elem WHEN 0 THEN 1 ELSE 2 END AS c FROM m.g GROUP BY CASE elem WHEN 0 THEN 1 ELSE 2 END"); //$NON-NLS-1$
}
- public void testNationCharString() throws Exception {
+ @Test public void testNationCharString() throws Exception {
Query query = (Query) QueryParser.getQueryParser().parseCommand("SELECT N'blah' FROM m.g"); //$NON-NLS-1$
Select select = query.getSelect();
ExpressionSymbol s = (ExpressionSymbol) select.getSymbol(0);
@@ -6184,18 +6203,18 @@
assertEquals(c, new Constant("blah")); //$NON-NLS-1$
}
- public void testNationCharString2() throws Exception {
+ @Test public void testNationCharString2() throws Exception {
Query query = (Query) QueryParser.getQueryParser().parseCommand("SELECT DISTINCT TABLE_QUALIFIER, NULL AS TABLE_OWNER, NULL AS TABLE_NAME, NULL AS TABLE_TYPE, NULL AS REMARKS FROM ATIODBCSystem.OA_TABLES WHERE TABLE_QUALIFIER LIKE N'%' ESCAPE '\\' ORDER BY TABLE_QUALIFIER "); //$NON-NLS-1$
MatchCriteria matchCrit = (MatchCriteria) query.getCriteria();
Constant c = (Constant) matchCrit.getRightExpression();
assertEquals(c, new Constant("%")); //$NON-NLS-1$
}
- public void testScalarSubquery() throws Exception {
+ @Test public void testScalarSubquery() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT (SELECT 1) FROM x"); //$NON-NLS-1$
}
- public void testElementInDoubleQuotes() throws Exception {
+ @Test public void testElementInDoubleQuotes() throws Exception {
GroupSymbol g = new GroupSymbol("x"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -6210,10 +6229,10 @@
helpTest("SELECT \"foo\" FROM x", //$NON-NLS-1$
"SELECT foo FROM x", //$NON-NLS-1$
- query, info);
+ query);
}
- public void testElementInDoubleQuotes_Insert() throws Exception {
+ @Test public void testElementInDoubleQuotes_Insert() throws Exception {
GroupSymbol g = new GroupSymbol("x"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -6226,10 +6245,10 @@
helpTest("insert into x (\"foo\") values ('bar')", //$NON-NLS-1$
"INSERT INTO x (foo) VALUES ('bar')", //$NON-NLS-1$
- query, info);
+ query);
}
- public void testElementInDoubleQuotes_Update() throws Exception {
+ @Test public void testElementInDoubleQuotes_Update() throws Exception {
GroupSymbol g = new GroupSymbol("x"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -6241,10 +6260,10 @@
helpTest("update x set \"foo\"='bar'", //$NON-NLS-1$
"UPDATE x SET foo = 'bar'", //$NON-NLS-1$
- query, info);
+ query);
}
- public void testElementInDoubleQuotes_delete() throws Exception {
+ @Test public void testElementInDoubleQuotes_delete() throws Exception {
GroupSymbol g = new GroupSymbol("x"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -6255,10 +6274,10 @@
helpTest("delete from x where \"foo\"='bar'", //$NON-NLS-1$
"DELETE FROM x WHERE foo = 'bar'", //$NON-NLS-1$
- query, info);
+ query);
}
- public void testAliasInDoubleQuotes() throws Exception {
+ @Test public void testAliasInDoubleQuotes() throws Exception {
GroupSymbol g = new GroupSymbol("x"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -6273,10 +6292,10 @@
helpTest("SELECT fooKey AS \"fooAlias\" FROM x", //$NON-NLS-1$
"SELECT fooKey AS fooAlias FROM x", //$NON-NLS-1$
- query, info);
+ query);
}
- public void testAliasInDoubleQuotesWithQuotedGroup() throws Exception {
+ @Test public void testAliasInDoubleQuotesWithQuotedGroup() throws Exception {
GroupSymbol g = new GroupSymbol("x.y.z"); //$NON-NLS-1$
From from = new From();
@@ -6297,10 +6316,10 @@
helpTest("SELECT fooKey AS \"fooAlias\" FROM \"x.y\".z where x.\"y.z\".id = 10", //$NON-NLS-1$
"SELECT fooKey AS fooAlias FROM x.y.z WHERE x.y.z.id = 10", //$NON-NLS-1$
- query, info);
+ query);
}
- public void testSingleQuotedConstant() throws Exception {
+ @Test public void testSingleQuotedConstant() throws Exception {
GroupSymbol g = new GroupSymbol("x.y.z"); //$NON-NLS-1$
From from = new From();
@@ -6316,10 +6335,10 @@
helpTest("SELECT 'fooString' FROM \"x.y.z\"", //$NON-NLS-1$
"SELECT 'fooString' FROM x.y.z", //$NON-NLS-1$
- query, info);
+ query);
}
- public void testAliasInSingleQuotes() throws Exception {
+ @Test public void testAliasInSingleQuotes() throws Exception {
GroupSymbol g = new GroupSymbol("x.y.z"); //$NON-NLS-1$
From from = new From();
@@ -6333,56 +6352,30 @@
query.setSelect(select);
query.setFrom(from);
- helpTest("SELECT fooKey 'fooAlias' FROM x.\"y\".z", //$NON-NLS-1$
- "SELECT fooKey AS fooAlias FROM x.y.z", //$NON-NLS-1$
- query, info);
+ helpException("SELECT fooKey 'fooAlias' FROM x.\"y\".z"); //$NON-NLS-1$
}
- public void testAliasInSingleQuotes2() throws Exception {
-
- GroupSymbol g = new GroupSymbol("x.y.z"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- AliasSymbol as = new AliasSymbol("fooAlias", new ElementSymbol("fooKey")); //$NON-NLS-1$ //$NON-NLS-2$
- Select select = new Select();
- select.addSymbol(as);
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- helpTest("SELECT \"fooKey\" AS 'fooAlias' FROM x.y.z", //$NON-NLS-1$
- "SELECT fooKey AS fooAlias FROM x.y.z", //$NON-NLS-1$
- query, info);
- }
-
/** QUERY Tool Format*/
- public void testQueryWithQuotes_MSQuery() throws Exception {
+ @Test public void testQueryWithQuotes_MSQuery() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT \"PART_COLOR\", \"PART_ID\", \"PART_NAME\", \"PART_WEIGHT\" FROM \"VirtualParts.base\".\"Parts\""); //$NON-NLS-1$
}
- /** MS Query Format **/
- public void testQueryWithQuotes_MSQuery2() throws Exception {
- QueryParser.getQueryParser().parseCommand("SELECT Core.ModelType.Value AS 'ModelType', DtcBase.Metamodels.DisplayName AS 'MetaModel', DtcBase.Models.Name AS 'ModelName', DtcBase.Models.Version, Core.ModelAnnotation.PrimaryMetamodelUri, DtcBase.Models.TransactionId AS 'ModelID'"); //$NON-NLS-1$
- }
-
/** MS Access Format**/
- public void testQueryWithQuotes_MSAccess() throws Exception {
+ @Test public void testQueryWithQuotes_MSAccess() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT \"PART_COLOR\" ,\"PART_ID\" ,\"PART_NAME\" ,\"PART_WEIGHT\" FROM \"parts_oracle.DEV_RRAMESH\".\"PARTS\""); //$NON-NLS-1$
}
/** BO Business View Manager**/
- public void testQueryWithQuotes_BODesigner() throws Exception {
+ @Test public void testQueryWithQuotes_BODesigner() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT DISTINCT \"PARTS\".\"PART_NAME\" FROM \"parts_oracle.DEV_RRAMESH\".\"PARTS\" \"PARTS\""); //$NON-NLS-1$
}
/** Crystal Reports **/
- public void testQueryWithQuotes_CrystalReports() throws Exception {
+ @Test public void testQueryWithQuotes_CrystalReports() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT \"Oracle_PARTS\".\"PART_COLOR\", \"Oracle_PARTS\".\"PART_ID\", \"Oracle_PARTS\".\"PART_NAME\", \"Oracle_PARTS\".\"PART_WEIGHT\", \"SQL_PARTS\".\"PART_COLOR\", \"SQL_PARTS\".\"PART_ID\", \"SQL_PARTS\".\"PART_NAME\", \"SQL_PARTS\".\"PART_WEIGHT\" FROM \"parts_oracle.DEV_RRAMESH\".\"PARTS\" \"Oracle_PARTS\", \"parts_sqlserver.dv_rreddy.dv_rreddy\".\"PARTS\" \"SQL_PARTS\" WHERE (\"Oracle_PARTS\".\"PART_ID\"=\"SQL_PARTS\".\"PART_ID\")"); //$NON-NLS-1$
}
- public void testOrderByWithNumbers_InQuotes() throws Exception {
+ @Test public void testOrderByWithNumbers_InQuotes() throws Exception {
GroupSymbol g = new GroupSymbol("z"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -6399,10 +6392,10 @@
query.setFrom(from);
query.setOrderBy(orderby);
- helpTest("SELECT x, y from z order by \"1\"", "SELECT x, y FROM z ORDER BY 1", query); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("SELECT x, y from z order by \"1\"", "SELECT x, y FROM z ORDER BY \"1\"", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testOrderByWithNumbers_AsInt() throws Exception {
+ @Test public void testOrderByWithNumbers_AsInt() throws Exception {
GroupSymbol g = new GroupSymbol("z"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -6412,7 +6405,7 @@
select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$
OrderBy orderby = new OrderBy();
- orderby.addVariable(new ElementSymbol("1"), true); //$NON-NLS-1$
+ orderby.addVariable(new ExpressionSymbol("expr", new Constant(1)), true); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
@@ -6422,58 +6415,11 @@
helpTest("SELECT x, y FROM z order by 1", "SELECT x, y FROM z ORDER BY 1", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testOrderByWithNumbers_AsNegitiveInt() throws Exception {
- try {
+ @Test(expected=QueryParserException.class) public void testOrderByWithNumbers_AsNegitiveInt() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT x, y FROM z order by -1"); //$NON-NLS-1$
- fail("order by should not have negitive values"); //$NON-NLS-1$
- }catch(Exception e) {
- // this is expected.
- }
}
- public void testOrderByWithNumbers_Expression() throws Exception {
- GroupSymbol g = new GroupSymbol("z"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Function f = new Function("+", new Expression[] {new ElementSymbol("x"), new ElementSymbol("y")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ExpressionSymbol es = new ExpressionSymbol("expr", f); //$NON-NLS-1$
- Select select = new Select();
- select.addSymbol(es);
-
- OrderBy orderby = new OrderBy();
- orderby.addVariable(new ElementSymbol("1"), true); //$NON-NLS-1$
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
- query.setOrderBy(orderby);
-
- helpTest("SELECT x+y FROM z order by 1", "SELECT (x + y) FROM z ORDER BY 1", query); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testOrderByWithNumbers_ScalarFunction() throws Exception {
- GroupSymbol g = new GroupSymbol("z"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Function f = new Function("concat", new Expression[] {new ElementSymbol("x", false), new Constant("5")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ExpressionSymbol es = new ExpressionSymbol("expr", f); //$NON-NLS-1$
- Select select = new Select();
- select.addSymbol(es);
-
- OrderBy orderby = new OrderBy();
- orderby.addVariable(new ElementSymbol("1"), true); //$NON-NLS-1$
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
- query.setOrderBy(orderby);
-
- helpTest("SELECT concat(x, \"5\") FROM z order by 1", "SELECT concat(x, '5') FROM z ORDER BY 1", query); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testEmptyAndNullInputsGiveSameErrorMessage() throws Exception {
+ @Test public void testEmptyAndNullInputsGiveSameErrorMessage() throws Exception {
String emptyMessage = null;
try {
QueryParser.getQueryParser().parseCommand(""); //$NON-NLS-1$
@@ -6493,7 +6439,7 @@
assertTrue("Expected same message for empty and null cases", emptyMessage.equals(nullMessage)); //$NON-NLS-1$
}
- public void testCase3281NamedVariable() {
+ @Test public void testCase3281NamedVariable() {
StoredProcedure storedQuery = new StoredProcedure();
storedQuery.setDisplayNamedParameters(true);
storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
@@ -6505,7 +6451,7 @@
helpTest("execute proc1(param1 = 'paramValue1')", "EXEC proc1(param1 = 'paramValue1')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCase3281NamedVariables() {
+ @Test public void testCase3281NamedVariables() {
StoredProcedure storedQuery = new StoredProcedure();
storedQuery.setDisplayNamedParameters(true);
storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
@@ -6521,7 +6467,7 @@
helpTest("execute proc1(param1 = 'paramValue1', param2 = 'paramValue2')", "EXEC proc1(param1 = 'paramValue1', param2 = 'paramValue2')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCase3281QuotedNamedVariableFails2() {
+ @Test public void testCase3281QuotedNamedVariableFails2() {
try {
QueryParser.getQueryParser().parseCommand("Exec proc1('param1' = 'paramValue1')"); //$NON-NLS-1$
fail("Named parameter name cannot be quoted"); //$NON-NLS-1$
@@ -6533,7 +6479,7 @@
}
/** Test what happens if the name of a parameter is a reserved word. It must be quoted (double-ticks). */
- public void testCase3281NamedVariablesReservedWords() {
+ @Test public void testCase3281NamedVariablesReservedWords() {
StoredProcedure storedQuery = new StoredProcedure();
storedQuery.setDisplayNamedParameters(true);
storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
@@ -6549,7 +6495,7 @@
helpTest("execute proc1(\"in\" = 'paramValue1', in2 = 'paramValue2')", "EXEC proc1(\"in\" = 'paramValue1', in2 = 'paramValue2')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testExceptionMessageWithLocation() {
+ @Test public void testExceptionMessageWithLocation() {
try {
QueryParser.getQueryParser().parseCommand("SELECT FROM"); //$NON-NLS-1$
} catch(QueryParserException e) {
@@ -6557,7 +6503,7 @@
}
}
- public void testExceptionMessageWithoutLocation() {
+ @Test public void testExceptionMessageWithoutLocation() {
try {
QueryParser.getQueryParser().parseCommand("SELECT COUNT(*) FROM a WHERE COUNT(*) > 1"); //$NON-NLS-1$
} catch(QueryParserException e) {
@@ -6565,7 +6511,7 @@
}
}
- public void testLimit() {
+ @Test public void testLimit() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(new GroupSymbol("a"))})); //$NON-NLS-1$
@@ -6576,7 +6522,7 @@
helpTest("Select * from a limit 0, 100", "SELECT * FROM a LIMIT 0, 100", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLimitWithOffset() {
+ @Test public void testLimitWithOffset() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(new GroupSymbol("a"))})); //$NON-NLS-1$
@@ -6586,7 +6532,7 @@
helpTest("Select * from a limit 50,100", "SELECT * FROM a LIMIT 50, 100", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLimitWithReferences1() {
+ @Test public void testLimitWithReferences1() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(new GroupSymbol("a"))})); //$NON-NLS-1$
@@ -6596,7 +6542,7 @@
helpTest("Select * from a limit ?,100", "SELECT * FROM a LIMIT ?, 100", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLimitWithReferences2() {
+ @Test public void testLimitWithReferences2() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(new GroupSymbol("a"))})); //$NON-NLS-1$
@@ -6606,7 +6552,7 @@
helpTest("Select * from a limit 50,?", "SELECT * FROM a LIMIT 50, ?", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLimitWithReferences3() {
+ @Test public void testLimitWithReferences3() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
From from = new From(Arrays.asList(new Object[] {new UnaryFromClause(new GroupSymbol("a"))})); //$NON-NLS-1$
@@ -6616,11 +6562,11 @@
helpTest("Select * from a limit ?,?", "SELECT * FROM a LIMIT ?, ?", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testEmptyOuterJoinCriteria() {
+ @Test public void testEmptyOuterJoinCriteria() {
helpException("select a from b left outer join c on ()"); //$NON-NLS-1$
}
- public void testCreateTempTable1() {
+ @Test public void testCreateTempTable1() {
Create create = new Create();
create.setTable(new GroupSymbol("tempTable")); //$NON-NLS-1$
List columns = new ArrayList();
@@ -6634,7 +6580,7 @@
helpTest("Create local TEMPORARY table tempTable (c1 boolean, c2 byte)", "CREATE LOCAL TEMPORARY TABLE tempTable (c1 boolean, c2 byte)", create); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCreateTempTable2() {
+ @Test public void testCreateTempTable2() {
Create create = new Create();
create.setTable(new GroupSymbol("tempTable")); //$NON-NLS-1$
List columns = new ArrayList();
@@ -6648,33 +6594,33 @@
helpTest("Create local TEMPORARY table tempTable(c1 boolean, c2 byte)", "CREATE LOCAL TEMPORARY TABLE tempTable (c1 boolean, c2 byte)", create); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testCreateTempTable3() {
+ @Test public void testCreateTempTable3() {
helpException("Create TEMPORARY table tempTable (c1 boolean, c2 byte)"); //$NON-NLS-1$
}
- public void testCreateTempTable4() {
+ @Test public void testCreateTempTable4() {
helpException("Create table tempTable (c1 boolean, c2 byte)"); //$NON-NLS-1$
}
- public void testCreateTempTable5() {
+ @Test public void testCreateTempTable5() {
helpException("Create local TEMPORARY table tempTable (c1 boolean primary, c2 byte)"); //$NON-NLS-1$
}
- public void testCreateTempTable6() {
+ @Test public void testCreateTempTable6() {
helpException("Create local TEMPORARY table tempTable (c1 varchar, c2 byte)"); //$NON-NLS-1$
}
- public void testCreateTempTable7() {
+ @Test public void testCreateTempTable7() {
helpException("Create local TEMPORARY table tempTable (c1.x boolean, c2 byte)" ,"Parsing error: Invalid simple identifier format: [c1.x]"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDropTable() {
+ @Test public void testDropTable() {
Drop drop = new Drop();
drop.setTable(new GroupSymbol("tempTable")); //$NON-NLS-1$
helpTest("DROP table tempTable", "DROP TABLE tempTable", drop); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testEscapedOuterJoin() {
+ @Test public void testEscapedOuterJoin() {
String sql = "SELECT * FROM {oj A LEFT OUTER JOIN B ON (A.x=B.x)}"; //$NON-NLS-1$
String expected = "SELECT * FROM A LEFT OUTER JOIN B ON A.x = B.x"; //$NON-NLS-1$
@@ -6693,19 +6639,19 @@
helpTest(sql, expected, query);
}
- public void testBadAlias() {
+ @Test public void testBadAlias() {
String sql = "select a as a.x from foo"; //$NON-NLS-1$
helpException(sql, "Parsing error: Invalid alias format: [a.x]"); //$NON-NLS-1$
}
- public void testBadFunctionName() {
+ @Test public void testBadFunctionName() {
String sql = "select a.x()"; //$NON-NLS-1$
helpException(sql, "Parsing error: Invalid function name: [a.x]"); //$NON-NLS-1$
}
- public void testUnionJoin() {
+ @Test public void testUnionJoin() {
String sql = "select * from pm1.g1 union join pm1.g2 where g1.e1 = 1"; //$NON-NLS-1$
String expected = "SELECT * FROM pm1.g1 UNION JOIN pm1.g2 WHERE g1.e1 = 1"; //$NON-NLS-1$
@@ -6721,13 +6667,13 @@
helpTest(sql, expected, command);
}
- public void testUnionJoin1() {
+ @Test public void testUnionJoin1() {
String sql = "select * from pm1.g1 union all join pm1.g2 where g1.e1 = 1"; //$NON-NLS-1$
helpException(sql);
}
- public void testIfElseWithoutBeginEnd() {
+ @Test public void testIfElseWithoutBeginEnd() {
String sql = "CREATE PROCEDURE BEGIN IF (x > 1) select 1; IF (x > 1) select 1; ELSE select 1; END"; //$NON-NLS-1$
String expected = "CREATE PROCEDURE\nBEGIN\nIF(x > 1)\nBEGIN\nSELECT 1;\nEND\nIF(x > 1)\nBEGIN\nSELECT 1;\nEND\nELSE\nBEGIN\nSELECT 1;\nEND\nEND"; //$NON-NLS-1$
@@ -6750,15 +6696,15 @@
helpTest(sql, expected, command);
}
- public void testBadCreate() {
+ @Test public void testBadCreate() {
helpException("create insert"); //$NON-NLS-1$
}
- public void testCommandWithSemicolon() throws Exception {
+ @Test public void testCommandWithSemicolon() throws Exception {
helpTest("select * from pm1.g1;", "SELECT * FROM pm1.g1", QueryParser.getQueryParser().parseCommand("select * from pm1.g1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testLOBTypes() throws Exception {
+ @Test public void testLOBTypes() throws Exception {
Function convert = new Function("convert", new Expression[] {new Constant(null), new Constant("blob")}); //$NON-NLS-1$ //$NON-NLS-2$
Function convert1 = new Function("convert", new Expression[] {new Constant(null), new Constant("clob")}); //$NON-NLS-1$ //$NON-NLS-2$
Function convert2 = new Function("convert", new Expression[] {new Constant(null), new Constant("xml")}); //$NON-NLS-1$ //$NON-NLS-2$
@@ -6769,7 +6715,7 @@
helpTest("select convert(null, blob), convert(null, clob), convert(null, xml)", "SELECT convert(null, blob), convert(null, clob), convert(null, xml)", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testInsertWithoutColumns() {
+ @Test public void testInsertWithoutColumns() {
Insert insert = new Insert();
insert.setGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
insert.addValue(new Constant("a")); //$NON-NLS-1$
@@ -6778,4 +6724,5 @@
"INSERT INTO m.g VALUES ('a', 'b')", //$NON-NLS-1$
insert);
}
+
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -22,6 +22,8 @@
package com.metamatrix.query.processor;
+import static org.junit.Assert.*;
+
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -31,7 +33,7 @@
import java.util.List;
import java.util.Properties;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
@@ -55,8 +57,7 @@
import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.validator.TestValidator;
-
-public class TestVirtualDepJoin extends TestCase {
+public class TestVirtualDepJoin {
/**
* @param usAcctsElem
@@ -189,7 +190,7 @@
return new FakeMetadataFacade(store);
}
- public void testVirtualDepJoinNoValues() throws Exception {
+ @Test public void testVirtualDepJoinNoValues() throws Exception {
// Create query
String sql = "select first, last, sum(amount) from Europe.CustAccts e join CustomerMaster.Customers c on c.id=e.id where c.first=-9999 group by c.id, first, last"; //$NON-NLS-1$
@@ -280,15 +281,15 @@
TestProcessor.helpProcess(plan, context, dataManager, expected);
}
- public void testVirtualDepJoinSourceSelectionPushdown() throws Exception {
+ @Test public void testVirtualDepJoinSourceSelectionPushdown() throws Exception {
helpTestVirtualDepJoinSourceSelection(true);
}
- public void testVirtualDepJoinSourceSelectionNoPushdown() throws Exception {
+ @Test public void testVirtualDepJoinSourceSelectionNoPushdown() throws Exception {
helpTestVirtualDepJoinSourceSelection(false);
}
- public void testVirtualDepJoinPartialPushdown() throws Exception {
+ @Test public void testVirtualDepJoinPartialPushdown() throws Exception {
// Create query
String sql = "SELECT * from Master.Transactions where last = 'Davis'"; //$NON-NLS-1$
@@ -343,7 +344,7 @@
TestProcessor.helpProcess(plan, context, dataManager, expected);
}
- public void testVirtualDepJoinOverAggregates() throws Exception {
+ @Test public void testVirtualDepJoinOverAggregates() throws Exception {
// Create query
String sql = "select first, last, sum(amount) from Europe.CustAccts e join CustomerMaster.Customers c on c.id=e.id where c.first='Miles' group by c.id, first, last"; //$NON-NLS-1$
@@ -398,19 +399,19 @@
assertEquals(expectedQueries, dataManager.getQueries());
}
- public void testVirtualDepJoinSelects() throws Exception {
+ @Test public void testVirtualDepJoinSelects() throws Exception {
helpTestVirtualDepJoin(false);
}
- public void testVirtualDepJoinPushdown() throws Exception {
+ @Test public void testVirtualDepJoinPushdown() throws Exception {
helpTestVirtualDepJoin(true);
}
- public void testVirtualDepMultipleDependentBatches() throws Exception {
+ @Test public void testVirtualDepMultipleDependentBatches() throws Exception {
helpTestMultipleBatches(true);
}
- public void testVirtualDepMultipleDependentBatchesNonUnique() throws Exception {
+ @Test public void testVirtualDepMultipleDependentBatchesNonUnique() throws Exception {
helpTestMultipleBatches(false);
}
@@ -632,7 +633,7 @@
elementSymbols, (List[])data.toArray(new List[data.size()]));
}
- public void testVirtualAccessVirtualDep() throws Exception {
+ @Test public void testVirtualAccessVirtualDep() throws Exception {
String sql = "SELECT a.e0, b.e2 FROM vTest.vGroup a inner join vTest.vGroup b on (a.e0 = b.e2 and a.e1 = b.e2) where b.e0=1 and b.e1='2'"; //$NON-NLS-1$
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
@@ -666,7 +667,7 @@
* Here the virtual makenotdep hint causes us to throw an exception
*
*/
- public void testVirtualAccessVirtualDep2() {
+ @Test public void testVirtualAccessVirtualDep2() {
String sql = "SELECT a.e0, b.e2 FROM vTest.vGroup a makenotdep inner join vTest.vGroup b on (a.e0 = b.e2 and a.e1 = b.e2) where b.e0=1 and b.e1='2'"; //$NON-NLS-1$
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
@@ -683,7 +684,7 @@
* same as testVirtualDepJoinOverAggregate, but the makenotdep hint prevents the
* dependent join from happening
*/
- public void testVirtualDepJoinOverAggregates2() throws Exception {
+ @Test public void testVirtualDepJoinOverAggregates2() throws Exception {
// Create query
String sql = "select first, last, sum(amount) from Europe.CustAccts e makenotdep join CustomerMaster.Customers c on c.id=e.id where c.first='Miles' group by c.id, first, last"; //$NON-NLS-1$
@@ -731,7 +732,7 @@
}
- public void testVirtualMakeDepHint() throws Exception {
+ @Test public void testVirtualMakeDepHint() throws Exception {
// Create query
String sql = "select distinct pm1.g1.e1 from (pm1.g1 inner join pm1.g2 on g1.e1 = g2.e1) makedep inner join pm2.g1 on pm2.g1.e1 = pm1.g1.e1 where pm2.g1.e3 = 1"; //$NON-NLS-1$
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -525,7 +525,7 @@
// error statement
@Test public void testProcedureProcessor7() throws Exception {
- String errorValue = "\"MY ERROR\""; //$NON-NLS-1$
+ String errorValue = "'MY ERROR'"; //$NON-NLS-1$
helpTestErrorStatment(errorValue, "MY ERROR"); //$NON-NLS-1$
}
@@ -535,7 +535,7 @@
}
@Test public void testProcedureProcessor9() throws Exception {
- String errorValue = "var1||\"MY ERROR\""; //$NON-NLS-1$
+ String errorValue = "var1||'MY ERROR'"; //$NON-NLS-1$
helpTestErrorStatment(errorValue, "5MY ERROR"); //$NON-NLS-1$
}
@@ -544,7 +544,7 @@
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "loop on (Select pm1.g1.e2 from pm1.g1 where e2 = 5) as mycursor\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "ERROR (mycursor.e2||\"MY ERROR\");\n"; //$NON-NLS-1$
+ procedure = procedure + "ERROR (mycursor.e2||'MY ERROR');\n"; //$NON-NLS-1$
procedure = procedure + "ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -35,9 +35,11 @@
import java.util.List;
import java.util.Map;
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.query.QueryMetadataException;
@@ -101,17 +103,11 @@
import com.metamatrix.query.unittest.FakeMetadataStore;
import com.metamatrix.query.unittest.TimestampUtil;
-public class TestResolver extends TestCase {
+public class TestResolver {
private FakeMetadataFacade metadata;
- // ################################## FRAMEWORK ################################
-
- public TestResolver(String name) {
- super(name);
- }
-
- public void setUp() {
+ @Before public void setUp() {
metadata = FakeMetadataFactory.example1Cached();
}
@@ -456,7 +452,7 @@
// ################################## ACTUAL TESTS ################################
- public void testElementSymbolForms() {
+ @Test public void testElementSymbolForms() {
String sql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 AS a, e4 AS b FROM pm1.g1"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
@@ -467,7 +463,7 @@
assertEquals("Resolved string form was incorrect ", sql, resolvedQuery.toString()); //$NON-NLS-1$
}
- public void testElementSymbolFormsWithAliasedGroup() {
+ @Test public void testElementSymbolFormsWithAliasedGroup() {
String sql = "SELECT x.e1, e2, x.e3 AS a, e4 AS b FROM pm1.g1 AS x"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
@@ -478,84 +474,84 @@
assertEquals("Resolved string form was incorrect ", sql, resolvedQuery.toString()); //$NON-NLS-1$
}
- public void testGroupWithVDB() {
+ @Test public void testGroupWithVDB() {
String sql = "SELECT e1 FROM myvdb.pm1.g1"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
assertEquals("Resolved string form was incorrect ", sql, resolvedQuery.toString()); //$NON-NLS-1$
}
- public void testAliasedGroupWithVDB() {
+ @Test public void testAliasedGroupWithVDB() {
String sql = "SELECT e1 FROM myvdb.pm1.g1 AS x"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
assertEquals("Resolved string form was incorrect ", sql, resolvedQuery.toString()); //$NON-NLS-1$
}
- public void testPartiallyQualifiedGroup1() {
+ @Test public void testPartiallyQualifiedGroup1() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT e1 FROM cat2.cat3.g1"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm1.cat1.cat2.cat3.g1" }); //$NON-NLS-1$
}
- public void testPartiallyQualifiedGroup2() {
+ @Test public void testPartiallyQualifiedGroup2() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT e1 FROM cat1.g2"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm1.cat1.g2" }); //$NON-NLS-1$
}
- public void testPartiallyQualifiedGroup3() {
+ @Test public void testPartiallyQualifiedGroup3() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT e1 FROM cat1.cat2.cat3.g1"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm1.cat1.cat2.cat3.g1" }); //$NON-NLS-1$
}
- public void testPartiallyQualifiedGroup4() {
+ @Test public void testPartiallyQualifiedGroup4() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT e1 FROM cat2.g2"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm2.cat2.g2" }); //$NON-NLS-1$
}
- public void testPartiallyQualifiedGroup5() {
+ @Test public void testPartiallyQualifiedGroup5() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT e1 FROM cat2.g3"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm1.cat2.g3" }); //$NON-NLS-1$
}
- public void testPartiallyQualifiedGroup6() {
+ @Test public void testPartiallyQualifiedGroup6() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT e1 FROM cat1.g1"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm2.cat1.g1" }); //$NON-NLS-1$
}
- public void testPartiallyQualifiedGroup7() {
+ @Test public void testPartiallyQualifiedGroup7() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT e1 FROM g4"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm2.g4" }); //$NON-NLS-1$
}
- public void testPartiallyQualifiedGroup8() {
+ @Test public void testPartiallyQualifiedGroup8() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT e1 FROM pm2.g3"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm2.g3" }); //$NON-NLS-1$
}
- public void testPartiallyQualifiedGroupWithAlias() {
+ @Test public void testPartiallyQualifiedGroupWithAlias() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT X.e1 FROM cat2.cat3.g1 as X"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm1.cat1.cat2.cat3.g1" }); //$NON-NLS-1$
}
- public void testPartiallyQualifiedElement1() {
+ @Test public void testPartiallyQualifiedElement1() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT cat2.cat3.g1.e1 FROM cat2.cat3.g1"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
@@ -563,7 +559,7 @@
}
/** defect 12536 */
- public void testPartiallyQualifiedElement2() {
+ @Test public void testPartiallyQualifiedElement2() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT cat3.g1.e1 FROM cat2.cat3.g1"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
@@ -571,7 +567,7 @@
}
/** defect 12536 */
- public void testPartiallyQualifiedElement3() {
+ @Test public void testPartiallyQualifiedElement3() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT cat3.g1.e1 FROM cat2.cat3.g1, cat1.g2"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
@@ -579,14 +575,14 @@
}
/** defect 12536 */
- public void testPartiallyQualifiedElement4() {
+ @Test public void testPartiallyQualifiedElement4() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT cat3.g1.e1, cat1.g2.e1 FROM cat2.cat3.g1, cat1.g2"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckSelect(resolvedQuery, new String[] { "pm1.cat1.cat2.cat3.g1.e1", "pm1.cat1.g2.e1" }); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testPartiallyQualifiedElement5() {
+ @Test public void testPartiallyQualifiedElement5() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT cat3.g1.e1, cat1.g2.e1 FROM myvdb.pm1.cat1.cat2.cat3.g1, pm1.cat1.g2"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
@@ -594,71 +590,71 @@
}
/** defect 12536 */
- public void testPartiallyQualifiedElement6() {
+ @Test public void testPartiallyQualifiedElement6() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT cat3.g1.e1, e2 FROM cat2.cat3.g1"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckSelect(resolvedQuery, new String[] { "pm1.cat1.cat2.cat3.g1.e1", "pm1.cat1.cat2.cat3.g1.e2" }); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testPartiallyQualifiedElement7() {
+ @Test public void testPartiallyQualifiedElement7() {
metadata = FakeMetadataFactory.example3();
String sql = "SELECT cat3.g1.e1, cat2.cat3.g1.e2, g1.e3 FROM pm1.cat1.cat2.cat3.g1"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckSelect(resolvedQuery, new String[] { "pm1.cat1.cat2.cat3.g1.e1", "pm1.cat1.cat2.cat3.g1.e2", "pm1.cat1.cat2.cat3.g1.e3" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testFailPartiallyQualifiedGroup1() {
+ @Test public void testFailPartiallyQualifiedGroup1() {
metadata = FakeMetadataFactory.example3();
helpResolveException("SELECT e1 FROM cat3.g1"); //$NON-NLS-1$
}
- public void testFailPartiallyQualifiedGroup2() {
+ @Test public void testFailPartiallyQualifiedGroup2() {
metadata = FakeMetadataFactory.example3();
helpResolveException("SELECT e1 FROM g1"); //$NON-NLS-1$
}
- public void testFailPartiallyQualifiedGroup3() {
+ @Test public void testFailPartiallyQualifiedGroup3() {
metadata = FakeMetadataFactory.example3();
helpResolveException("SELECT e1 FROM g2"); //$NON-NLS-1$
}
- public void testFailPartiallyQualifiedGroup4() {
+ @Test public void testFailPartiallyQualifiedGroup4() {
metadata = FakeMetadataFactory.example3();
helpResolveException("SELECT e1 FROM g3"); //$NON-NLS-1$
}
- public void testFailPartiallyQualifiedGroup5() {
+ @Test public void testFailPartiallyQualifiedGroup5() {
metadata = FakeMetadataFactory.example3();
helpResolveException("SELECT e1 FROM g5"); //$NON-NLS-1$
}
- public void testFailPartiallyQualifiedElement1() {
+ @Test public void testFailPartiallyQualifiedElement1() {
metadata = FakeMetadataFactory.example3();
helpResolveException("SELECT cat3.g1.e1 FROM pm1.cat1.cat2.cat3.g1, pm2.cat3.g1"); //$NON-NLS-1$
}
- public void testFailPartiallyQualifiedElement2() {
+ @Test public void testFailPartiallyQualifiedElement2() {
metadata = FakeMetadataFactory.example3();
helpResolveException("SELECT g1.e1 FROM pm1.cat1.cat2.cat3.g1, pm2.cat3.g1"); //$NON-NLS-1$
}
- public void testFailPartiallyQualifiedElement3() {
+ @Test public void testFailPartiallyQualifiedElement3() {
metadata = FakeMetadataFactory.example3();
helpResolveException("SELECT cat3.g1.e1 FROM pm2.cat2.g2, pm1.cat2.g3"); //$NON-NLS-1$
}
- public void testFailPartiallyQualifiedElement4() {
+ @Test public void testFailPartiallyQualifiedElement4() {
metadata = FakeMetadataFactory.example3();
helpResolveException("SELECT cat3.g1.e1 FROM pm2.cat2.g2"); //$NON-NLS-1$
}
- public void testFailPartiallyQualifiedElement5() {
+ @Test public void testFailPartiallyQualifiedElement5() {
metadata = FakeMetadataFactory.example3();
helpResolveException("SELECT cat3.g1.e1 FROM g1"); //$NON-NLS-1$
}
- public void testElementWithVDB() {
+ @Test public void testElementWithVDB() {
String sql = "SELECT myvdb.pm1.g1.e1 FROM pm1.g1"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckSelect(resolvedQuery, new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
@@ -668,7 +664,7 @@
assertEquals("Resolved string form was incorrect ", sql, resolvedQuery.toString()); //$NON-NLS-1$
}
- public void testAliasedElementWithVDB() {
+ @Test public void testAliasedElementWithVDB() {
Query resolvedQuery = (Query) helpResolve("SELECT myvdb.pm1.g1.e1 AS x FROM pm1.g1"); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "x" }); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getSelect(),
@@ -676,7 +672,7 @@
new String[] { "pm1.g1.e1" } ); //$NON-NLS-1$
}
- public void testSelectStar() {
+ @Test public void testSelectStar() {
Query resolvedQuery = (Query) helpResolve("SELECT * FROM pm1.g1"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "*" }); //$NON-NLS-1$
@@ -685,7 +681,7 @@
new String[] { "pm1.g1.e1", "pm1.g1.e2", "pm1.g1.e3", "pm1.g1.e4" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testSelectStarFromAliasedGroup() {
+ @Test public void testSelectStarFromAliasedGroup() {
Query resolvedQuery = (Query) helpResolve("SELECT * FROM pm1.g1 as x"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "*" }); //$NON-NLS-1$
@@ -694,7 +690,7 @@
new String[] { "pm1.g1.e1", "pm1.g1.e2", "pm1.g1.e3", "pm1.g1.e4" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testSelectStarFromMultipleAliasedGroups() {
+ @Test public void testSelectStarFromMultipleAliasedGroups() {
Query resolvedQuery = (Query) helpResolve("SELECT * FROM pm1.g1 as x, pm1.g1 as y"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1", "pm1.g1" }); //$NON-NLS-1$ //$NON-NLS-2$
helpCheckSelect(resolvedQuery, new String[] { "*" }); //$NON-NLS-1$
@@ -703,7 +699,7 @@
new String[] { "pm1.g1.e1", "pm1.g1.e2", "pm1.g1.e3", "pm1.g1.e4", "pm1.g1.e1", "pm1.g1.e2", "pm1.g1.e3", "pm1.g1.e4" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
}
- public void testSelectStarWhereSomeElementsAreNotSelectable() {
+ @Test public void testSelectStarWhereSomeElementsAreNotSelectable() {
Query resolvedQuery = (Query) helpResolve("SELECT * FROM pm1.g4"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g4" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "*" }); //$NON-NLS-1$
@@ -712,7 +708,7 @@
new String[] { "pm1.g4.e1", "pm1.g4.e3" } ); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testSelectGroupStarWhereSomeElementsAreNotSelectable() {
+ @Test public void testSelectGroupStarWhereSomeElementsAreNotSelectable() {
Query resolvedQuery = (Query) helpResolve("SELECT pm1.g4.* FROM pm1.g4"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g4" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "pm1.g4.*" }); //$NON-NLS-1$
@@ -721,7 +717,7 @@
new String[] { "pm1.g4.e1", "pm1.g4.e3" } ); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testFullyQualifiedSelectStar() {
+ @Test public void testFullyQualifiedSelectStar() {
Query resolvedQuery = (Query) helpResolve("SELECT pm1.g1.* FROM pm1.g1"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "pm1.g1.*" }); //$NON-NLS-1$
@@ -730,7 +726,7 @@
new String[] { "pm1.g1.e1", "pm1.g1.e2", "pm1.g1.e3", "pm1.g1.e4" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testSelectAllInAliasedGroup() {
+ @Test public void testSelectAllInAliasedGroup() {
Query resolvedQuery = (Query) helpResolve("SELECT x.* FROM pm1.g1 as x"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "x.*" }); //$NON-NLS-1$
@@ -739,7 +735,7 @@
new String[] { "pm1.g1.e1", "pm1.g1.e2", "pm1.g1.e3", "pm1.g1.e4" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testSelectExpressions() {
+ @Test public void testSelectExpressions() {
Query resolvedQuery = (Query) helpResolve("SELECT e1, concat(e1, 's'), concat(e1, 's') as c FROM pm1.g1"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "pm1.g1.e1", "expr", "c" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -748,14 +744,14 @@
new String[] { "pm1.g1.e1", "pm1.g1.e1", "pm1.g1.e1" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testSelectCountStar() {
+ @Test public void testSelectCountStar() {
Query resolvedQuery = (Query) helpResolve("SELECT count(*) FROM pm1.g1"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "count" }); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getSelect(), new String[] { }, new String[] { } );
}
- public void testMultipleIdenticalElements() {
+ @Test public void testMultipleIdenticalElements() {
Query resolvedQuery = (Query) helpResolve("SELECT e1, e1 FROM pm1.g1"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "pm1.g1.e1", "pm1.g1.e1" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -764,7 +760,7 @@
new String[] { "pm1.g1.e1", "pm1.g1.e1" }); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testMultipleIdenticalElements2() {
+ @Test public void testMultipleIdenticalElements2() {
Query resolvedQuery = (Query) helpResolve("SELECT e1, pm1.g1.e1 FROM pm1.g1"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "pm1.g1.e1", "pm1.g1.e1" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -773,7 +769,7 @@
new String[] { "pm1.g1.e1", "pm1.g1.e1" }); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testMultipleIdenticalElements3() {
+ @Test public void testMultipleIdenticalElements3() {
Query resolvedQuery = (Query) helpResolve("SELECT e1, e1 as x FROM pm1.g1"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "pm1.g1.e1", "x" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -782,7 +778,7 @@
new String[] { "pm1.g1.e1", "pm1.g1.e1" }); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDifferentElementsSameName() {
+ @Test public void testDifferentElementsSameName() {
Query resolvedQuery = (Query) helpResolve("SELECT e1 as x, e2 as x FROM pm1.g2"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g2" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "x", "x" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -791,7 +787,7 @@
new String[] { "pm1.g2.e1", "pm1.g2.e2" }); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDifferentConstantsSameName() {
+ @Test public void testDifferentConstantsSameName() {
Query resolvedQuery = (Query) helpResolve("SELECT 1 as x, 2 as x FROM pm1.g2"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g2" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "x", "x" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -800,42 +796,42 @@
new String[] { });
}
- public void testFailSameGroupsWithSameNames() {
+ @Test public void testFailSameGroupsWithSameNames() {
helpResolveException("SELECT * FROM pm1.g1 as x, pm1.g1 as x"); //$NON-NLS-1$
}
- public void testFailDifferentGroupsWithSameNames() {
+ @Test public void testFailDifferentGroupsWithSameNames() {
helpResolveException("SELECT * FROM pm1.g1 as x, pm1.g2 as x"); //$NON-NLS-1$
}
- public void testFailAmbiguousElement() {
+ @Test public void testFailAmbiguousElement() {
helpResolveException("SELECT e1 FROM pm1.g1, pm1.g2"); //$NON-NLS-1$
}
- public void testFailAmbiguousElementAliasedGroup() {
+ @Test public void testFailAmbiguousElementAliasedGroup() {
helpResolveException("SELECT e1 FROM pm1.g1 as x, pm1.g1"); //$NON-NLS-1$
}
- public void testFailFullyQualifiedElementUnknownGroup() {
+ @Test public void testFailFullyQualifiedElementUnknownGroup() {
helpResolveException("SELECT pm1.g1.e1 FROM pm1.g2"); //$NON-NLS-1$
}
- public void testFailUnknownGroup() {
+ @Test public void testFailUnknownGroup() {
helpResolveException("SELECT x.e1 FROM x"); //$NON-NLS-1$
}
- public void testFailUnknownElement() {
+ @Test public void testFailUnknownElement() {
helpResolveException("SELECT x FROM pm1.g1"); //$NON-NLS-1$
}
- public void testFailFunctionOfAggregatesInSelect() {
+ @Test public void testFailFunctionOfAggregatesInSelect() {
helpResolveException("SELECT (SUM(e0) * COUNT(e0)) FROM test.group GROUP BY e0"); //$NON-NLS-1$
}
/*
* per defect 4404
*/
- public void testFailGroupNotReferencedByAlias() {
+ @Test public void testFailGroupNotReferencedByAlias() {
helpResolveException("SELECT pm1.g1.x FROM pm1.g1 as H"); //$NON-NLS-1$
}
@@ -843,11 +839,11 @@
* per defect 4404 - this one reproduced the defect,
* then succeeded after the fix
*/
- public void testFailGroupNotReferencedByAliasSelectAll() {
+ @Test public void testFailGroupNotReferencedByAliasSelectAll() {
helpResolveException("SELECT pm1.g1.* FROM pm1.g1 as H"); //$NON-NLS-1$
}
- public void testComplicatedQuery() {
+ @Test public void testComplicatedQuery() {
Query resolvedQuery = (Query) helpResolve("SELECT pm1.g1.e2 as y, pm1.g1.E3 as z, CONVERT(pm1.g1.e1, integer) * 1000 as w FROM pm1.g1 WHERE e1 <> 'x'"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "y", "z", "w" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -856,7 +852,7 @@
new String[] { "pm1.g1.e2", "pm1.g1.e3", "pm1.g1.e1", "pm1.g1.e1" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testJoinQuery() {
+ @Test public void testJoinQuery() {
Query resolvedQuery = (Query) helpResolve("SELECT pm3.g1.e2, pm3.g2.e2 FROM pm3.g1, pm3.g2 WHERE pm3.g1.e2=pm3.g2.e2"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm3.g1", "pm3.g2" }); //$NON-NLS-1$ //$NON-NLS-2$
helpCheckSelect(resolvedQuery, new String[] { "pm3.g1.e2", "pm3.g2.e2" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -865,27 +861,27 @@
new String[] { "pm3.g1.e2", "pm3.g2.e2", "pm3.g1.e2", "pm3.g2.e2" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testHavingRequiringConvertOnAggregate1() {
+ @Test public void testHavingRequiringConvertOnAggregate1() {
helpResolve("SELECT * FROM pm1.g1 GROUP BY e4 HAVING MAX(e2) > 1.2"); //$NON-NLS-1$
}
- public void testHavingRequiringConvertOnAggregate2() {
+ @Test public void testHavingRequiringConvertOnAggregate2() {
helpResolve("SELECT * FROM pm1.g1 GROUP BY e4 HAVING MIN(e2) > 1.2"); //$NON-NLS-1$
}
- public void testHavingRequiringConvertOnAggregate3() {
+ @Test public void testHavingRequiringConvertOnAggregate3() {
helpResolve("SELECT * FROM pm1.g1 GROUP BY e4 HAVING 1.2 > MAX(e2)"); //$NON-NLS-1$
}
- public void testHavingRequiringConvertOnAggregate4() {
+ @Test public void testHavingRequiringConvertOnAggregate4() {
helpResolve("SELECT * FROM pm1.g1 GROUP BY e4 HAVING 1.2 > MIN(e2)"); //$NON-NLS-1$
}
- public void testHavingWithAggsOfDifferentTypes() {
+ @Test public void testHavingWithAggsOfDifferentTypes() {
helpResolve("SELECT * FROM pm1.g1 GROUP BY e4 HAVING MIN(e1) = MIN(e2)"); //$NON-NLS-1$
}
- public void testCaseInGroupBy() {
+ @Test public void testCaseInGroupBy() {
String sql = "SELECT SUM(e2) FROM pm1.g1 GROUP BY CASE WHEN e2 = 0 THEN 1 ELSE 2 END"; //$NON-NLS-1$
Command command = helpResolve(sql);
assertEquals(sql, command.toString());
@@ -893,7 +889,7 @@
helpCheckElements(command, new String[] {"pm1.g1.e2", "pm1.g1.e2"}, new String[] {"pm1.g1.e2", "pm1.g1.e2"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
}
- public void testFunctionInGroupBy() {
+ @Test public void testFunctionInGroupBy() {
String sql = "SELECT SUM(e2) FROM pm1.g1 GROUP BY (e2 + 1)"; //$NON-NLS-1$
Command command = helpResolve(sql);
assertEquals(sql, command.toString());
@@ -901,15 +897,15 @@
helpCheckElements(command, new String[] {"pm1.g1.e2", "pm1.g1.e2"}, new String[] {"pm1.g1.e2", "pm1.g1.e2"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
}
- public void testUnknownFunction() {
+ @Test public void testUnknownFunction() {
helpResolveException("SELECT abc(e1) FROM pm1.g1", "Error Code:ERR.015.008.0039 Message:The function 'abc(e1)' is an unknown form. Check that the function name and number of arguments is correct."); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testConversionNotPossible() {
+ @Test public void testConversionNotPossible() {
helpResolveException("SELECT dayofmonth('2002-01-01') FROM pm1.g1", "Error Code:ERR.015.008.0040 Message:The function 'dayofmonth('2002-01-01')' is a valid function form, but the arguments do not match a known type signature and cannot be converted using implicit type conversions."); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testResolveParameters() {
+ @Test public void testResolveParameters() {
List bindings = new ArrayList();
bindings.add("pm1.g2.e1"); //$NON-NLS-1$
bindings.add("pm1.g2.e2"); //$NON-NLS-1$
@@ -924,14 +920,14 @@
}
- public void testResolveParametersInsert() {
+ @Test public void testResolveParametersInsert() {
List bindings = new ArrayList();
bindings.add("pm1.g2.e1"); //$NON-NLS-1$
helpResolve("INSERT INTO pm1.g1 (e1) VALUES (?)", bindings); //$NON-NLS-1$
}
- public void testResolveParametersExec() {
+ @Test public void testResolveParametersExec() {
List bindings = new ArrayList();
bindings.add("pm1.g2.e1"); //$NON-NLS-1$
@@ -942,11 +938,11 @@
assertNotNull(ref.getType());
}
- public void testUseNonExistentAlias() {
+ @Test public void testUseNonExistentAlias() {
helpResolveException("SELECT portfoliob.e1 FROM ((pm1.g1 AS portfoliob JOIN pm1.g2 AS portidentb ON portfoliob.e1 = portidentb.e1) RIGHT OUTER JOIN pm1.g3 AS identifiersb ON portidentb.e1 = 'ISIN' and portidentb.e2 = identifiersb.e2) RIGHT OUTER JOIN pm1.g1 AS issuesb ON a.identifiersb.e1 = issuesb.e1"); //$NON-NLS-1$
}
- public void testCriteria1() {
+ @Test public void testCriteria1() {
CompareCriteria expected = new CompareCriteria();
ElementSymbol es = new ElementSymbol("pm1.g1.e1"); //$NON-NLS-1$
GroupSymbol gs = new GroupSymbol("pm1.g1"); //$NON-NLS-1$
@@ -960,7 +956,7 @@
assertEquals("Did not match expected criteria", expected, actual); //$NON-NLS-1$
}
- public void testSubquery1() {
+ @Test public void testSubquery1() {
Query resolvedQuery = (Query) helpResolve("SELECT e1 FROM pm1.g1, (SELECT pm1.g2.e1 AS x FROM pm1.g2) AS y WHERE e1 = x"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1", "y" }); //$NON-NLS-1$ //$NON-NLS-2$
helpCheckSelect(resolvedQuery, new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
@@ -970,7 +966,7 @@
}
- public void testStoredQuery1() {
+ @Test public void testStoredQuery1() {
StoredProcedure proc = (StoredProcedure) helpResolve("EXEC pm1.sq2('abc')"); //$NON-NLS-1$
// Check number of resolved parameters
@@ -994,7 +990,7 @@
* input params are numbered #1 and #2. This test tests that this disparity in ordering should not
* be a problem as long as RELATIVE ordering is in synch.
*/
- public void testStoredQueryParamOrdering_8211() {
+ @Test public void testStoredQueryParamOrdering_8211() {
StoredProcedure proc = (StoredProcedure) helpResolve("EXEC pm1.sq3a('abc', 123)"); //$NON-NLS-1$
// Check number of resolved parameters
@@ -1017,19 +1013,19 @@
assertEquals("Did not get expected type for param", expr, param.getExpression()); //$NON-NLS-1$
}
- public void testStoredSubQuery1() {
+ @Test public void testStoredSubQuery1() {
Query resolvedQuery = (Query) helpResolve("select x.e1 from (EXEC pm1.sq1()) as x"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "x" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "x.e1" }); //$NON-NLS-1$
}
- public void testStoredSubQuery2() {
+ @Test public void testStoredSubQuery2() {
Query resolvedQuery = (Query) helpResolve("select x.e1 from (EXEC pm1.sq3('abc', 5)) as x"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "x" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "x.e1" }); //$NON-NLS-1$
}
- public void testStoredSubQuery3() {
+ @Test public void testStoredSubQuery3() {
Query resolvedQuery = (Query) helpResolve("select * from (EXEC pm1.sq2('abc')) as x"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "x" }); //$NON-NLS-1$
@@ -1044,7 +1040,7 @@
assertEquals("Did not get expected type", DataTypeManager.DefaultDataClasses.INTEGER, elem2.getType()); //$NON-NLS-1$
}
- public void testStoredQueryTransformationWithVariable() throws Exception {
+ @Test public void testStoredQueryTransformationWithVariable() throws Exception {
Command command = QueryParser.getQueryParser().parseCommand("SELECT * FROM pm1.g1 WHERE pm1.sq5.in1 = 5"); //$NON-NLS-1$
// Construct command metadata
@@ -1064,7 +1060,7 @@
assertEquals("Did not find variable in resolved query", 1, vars.size()); //$NON-NLS-1$
}
- public void testStoredQueryTransformationWithVariable2() throws Exception {
+ @Test public void testStoredQueryTransformationWithVariable2() throws Exception {
Command command = QueryParser.getQueryParser().parseCommand("SELECT * FROM pm1.g1 WHERE in1 = 5"); //$NON-NLS-1$
// Construct command metadata
@@ -1084,7 +1080,7 @@
assertEquals("Did not find variable in resolved query", 1, vars.size()); //$NON-NLS-1$
}
- public void testStoredQueryTransformationWithVariable3() throws Exception {
+ @Test public void testStoredQueryTransformationWithVariable3() throws Exception {
Command command = QueryParser.getQueryParser().parseCommand("SELECT * FROM pm1.g1 WHERE in1 = 5 UNION SELECT * FROM pm1.g1"); //$NON-NLS-1$
// Construct command metadata
@@ -1103,7 +1099,7 @@
assertEquals("Did not find variable in resolved query", 1, vars.size()); //$NON-NLS-1$
}
- public void testStoredQueryTransformationWithVariable4() throws Exception {
+ @Test public void testStoredQueryTransformationWithVariable4() throws Exception {
Command command = QueryParser.getQueryParser().parseCommand("EXEC pm1.sq2(pm1.sq2.in)"); //$NON-NLS-1$
// resolve
@@ -1125,56 +1121,56 @@
}
}
- public void testExec1() {
+ @Test public void testExec1() {
helpResolve("EXEC pm1.sq2('xyz')"); //$NON-NLS-1$
}
- public void testExec2() {
+ @Test public void testExec2() {
// implicity convert 5 to proper type
helpResolve("EXEC pm1.sq2(5)"); //$NON-NLS-1$
}
- public void testExecNamedParam() {
+ @Test public void testExecNamedParam() {
Object[] expectedParameterExpressions = new Object[] {new Constant("xyz")};//$NON-NLS-1$
helpResolveExec("EXEC pm1.sq2(\"in\" = 'xyz')", expectedParameterExpressions);//$NON-NLS-1$
}
/** Should get exception because param name is wrong. */
- public void testExecWrongParamName() {
+ @Test public void testExecWrongParamName() {
helpResolveException("EXEC pm1.sq2(in1 = 'xyz')");//$NON-NLS-1$
}
- public void testExecNamedParams() {
+ @Test public void testExecNamedParams() {
Object[] expectedParameterExpressions = new Object[] {new Constant("xyz"), new Constant(new Integer(5))};//$NON-NLS-1$
helpResolveExec("EXEC pm1.sq3(\"in\" = 'xyz', in2 = 5)", expectedParameterExpressions);//$NON-NLS-1$
}
/** try entering params out of order */
- public void testExecNamedParamsReversed() {
+ @Test public void testExecNamedParamsReversed() {
Object[] expectedParameterExpressions = new Object[] {new Constant("xyz"), new Constant(new Integer(5))};//$NON-NLS-1$
helpResolveExec("EXEC pm1.sq3(in2 = 5, \"in\" = 'xyz')", expectedParameterExpressions);//$NON-NLS-1$
}
/** test omitting an optional parameter */
- public void testExecNamedParamsOptionalParam() {
+ @Test public void testExecNamedParamsOptionalParam() {
Object[] expectedParameterExpressions = new Object[] {new Constant("xyz"), new Constant(null), new Constant("something")};//$NON-NLS-1$ //$NON-NLS-2$
helpResolveExec("EXEC pm1.sq3b(\"in\" = 'xyz', in3 = 'something')", expectedParameterExpressions);//$NON-NLS-1$
}
/** test omitting a required parameter that has a default value */
- public void testExecNamedParamsOmitRequiredParamWithDefaultValue() {
+ @Test public void testExecNamedParamsOmitRequiredParamWithDefaultValue() {
Object[] expectedParameterExpressions = new Object[] {new Constant("xyz"), new Constant(new Integer(666)), new Constant("YYZ")};//$NON-NLS-1$ //$NON-NLS-2$
helpResolveExec("EXEC pm1.sq3b(\"in\" = 'xyz', in2 = 666)", expectedParameterExpressions);//$NON-NLS-1$
}
- public void testExecNamedParamsOptionalParamWithDefaults() {
+ @Test public void testExecNamedParamsOptionalParamWithDefaults() {
Object[] expectedParameterExpressions = helpGetStoredProcDefaultValues();
//override the default value for the first parameter
expectedParameterExpressions[0] = new Constant("xyz"); //$NON-NLS-1$
helpResolveExec("EXEC pm1.sqDefaults(inString = 'xyz')", expectedParameterExpressions);//$NON-NLS-1$
}
- public void testExecNamedParamsOptionalParamWithDefaultsCaseInsensitive() {
+ @Test public void testExecNamedParamsOptionalParamWithDefaultsCaseInsensitive() {
Object[] expectedParameterExpressions = helpGetStoredProcDefaultValues();
//override the default value for the first parameter
expectedParameterExpressions[0] = new Constant("xyz"); //$NON-NLS-1$
@@ -1182,7 +1178,7 @@
}
/** try just a few named parameters, in no particular order */
- public void testExecNamedParamsOptionalParamWithDefaults2() {
+ @Test public void testExecNamedParamsOptionalParamWithDefaults2() {
Object[] expectedParameterExpressions = helpGetStoredProcDefaultValues();
//override the proper default values in expected results
expectedParameterExpressions[3] = new Constant(Boolean.FALSE);
@@ -1194,7 +1190,7 @@
* Try entering in no actual parameters, rely entirely on defaults.
* This also tests the default value transformation code in ExecResolver.
*/
- public void testExecNamedParamsOptionalParamWithAllDefaults() {
+ @Test public void testExecNamedParamsOptionalParamWithAllDefaults() {
Object[] expectedParameterExpressions = helpGetStoredProcDefaultValues();
helpResolveExec("EXEC pm1.sqDefaults()", expectedParameterExpressions);//$NON-NLS-1$
}
@@ -1227,16 +1223,16 @@
}
/** Should get exception because there are two required params */
- public void testExceptionNotSupplyingRequiredParam() {
+ @Test public void testExceptionNotSupplyingRequiredParam() {
helpResolveException("EXEC pm1.sq3(in2 = 5)");//$NON-NLS-1$
}
/** Should get exception because the default value in metadata is bad for input param */
- public void testExceptionBadDefaultValue() {
+ @Test public void testExceptionBadDefaultValue() {
helpResolveException("EXEC pm1.sqBadDefault()");//$NON-NLS-1$
}
- public void testExecWithForcedConvertOfStringToCorrectType() {
+ @Test public void testExecWithForcedConvertOfStringToCorrectType() {
// force conversion of '5' to proper type (integer)
helpResolve("EXEC pm1.sq3('x', '5')"); //$NON-NLS-1$
}
@@ -1244,11 +1240,11 @@
/**
* True/false are consistently representable by integers
*/
- public void testExecBadType() {
+ @Test public void testExecBadType() {
helpResolve("EXEC pm1.sq3('xyz', {b'true'})"); //$NON-NLS-1$
}
- public void testSubqueryInUnion() {
+ @Test public void testSubqueryInUnion() {
String sql = "SELECT IntKey, FloatNum FROM BQT1.MediumA WHERE (IntKey >= 0) AND (IntKey < 15) " + //$NON-NLS-1$
"UNION ALL " + //$NON-NLS-1$
"SELECT BQT2.SmallB.IntKey, y.FloatNum " + //$NON-NLS-1$
@@ -1260,7 +1256,7 @@
helpResolve(sql, FakeMetadataFactory.exampleBQTCached(), null);
}
- public void testSubQueryINClause1(){
+ @Test public void testSubQueryINClause1(){
//select e1 from pm1.g1 where e2 in (select e2 from pm4.g1)
//sub command
@@ -1311,7 +1307,7 @@
* project symbol of the subquery is not the same type as the expression in
* the SubquerySetCriteria object
*/
- public void testSubQueryINClauseImplicitConversion(){
+ @Test public void testSubQueryINClauseImplicitConversion(){
//select e1 from pm1.g1 where e2 in (select e1 from pm4.g1)
//sub command
@@ -1371,7 +1367,7 @@
* type of the expression of the SubquerySetCriteria and the type of the
* projected symbol of the subquery.
*/
- public void testSubQueryINClauseNoConversionFails(){
+ @Test public void testSubQueryINClauseNoConversionFails(){
//select e1 from pm1.g1 where e1 in (select e2 from pm4.g1)
//sub command
@@ -1402,27 +1398,27 @@
this.helpResolveFails(outerQuery);
}
- public void testSubQueryINClauseTooManyColumns(){
+ @Test public void testSubQueryINClauseTooManyColumns(){
String sql = "select e1 from pm1.g1 where e1 in (select e1, e2 from pm4.g1)"; //$NON-NLS-1$
//test
this.helpResolveException(sql);
}
- public void testStoredQueryInFROMSubquery() {
+ @Test public void testStoredQueryInFROMSubquery() {
String sql = "select X.e1 from (EXEC pm1.sq3('abc', 123)) as X"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testStoredQueryInINSubquery() throws Exception {
+ @Test public void testStoredQueryInINSubquery() throws Exception {
String sql = "select * from pm1.g1 where e1 in (EXEC pm1.sqsp1())"; //$NON-NLS-1$
helpResolve(sql);
}
// variable resolution
- public void testCreateUpdateProcedure1() {
+ @Test public void testCreateUpdateProcedure1() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1437,7 +1433,7 @@
}
// variable resolution, variable used in if statement
- public void testCreateUpdateProcedure3() {
+ @Test public void testCreateUpdateProcedure3() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1454,7 +1450,7 @@
// variable resolution, variable used in if statement, variable comapred against
// differrent datatype element
- public void testCreateUpdateProcedure4() {
+ @Test public void testCreateUpdateProcedure4() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
@@ -1469,7 +1465,7 @@
}
// variable resolution, variable used in if statement, invalid operation on variable
- public void testCreateUpdateProcedure5() {
+ @Test public void testCreateUpdateProcedure5() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
@@ -1485,7 +1481,7 @@
// variable resolution, variables declared in different blocks local variables
// should not override
- public void testCreateUpdateProcedure6() {
+ @Test public void testCreateUpdateProcedure6() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1504,7 +1500,7 @@
// variable resolution, variables declared in different blocks local variables
// inner block using outer block variables
- public void testCreateUpdateProcedure7() {
+ @Test public void testCreateUpdateProcedure7() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1523,7 +1519,7 @@
// variable resolution, variables declared in differrent blocks local variables
// outer block cannot use inner block variables
- public void testCreateUpdateProcedure8() {
+ @Test public void testCreateUpdateProcedure8() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1543,7 +1539,7 @@
// variable resolution, variables declared in differrent blocks local variables
// should override, outer block variables still valid afetr inner block is declared
- public void testCreateUpdateProcedure9() {
+ @Test public void testCreateUpdateProcedure9() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1562,7 +1558,7 @@
}
// special variable ROWS_UPDATED resolution
- public void testCreateUpdateProcedure10() {
+ @Test public void testCreateUpdateProcedure10() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1578,7 +1574,7 @@
}
// special variable ROWS_UPDATED used with declared variable
- public void testCreateUpdateProcedure11() {
+ @Test public void testCreateUpdateProcedure11() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1593,7 +1589,7 @@
}
// special variable INPUT used with declared variable
- public void testCreateUpdateProcedure12() {
+ @Test public void testCreateUpdateProcedure12() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1608,7 +1604,7 @@
}
// special variable CHANGING used with declared variable
- public void testCreateUpdateProcedure14() {
+ @Test public void testCreateUpdateProcedure14() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1626,7 +1622,7 @@
}
// special variable CHANGING and INPUT used in conpound criteria
- public void testCreateUpdateProcedure15() {
+ @Test public void testCreateUpdateProcedure15() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1644,7 +1640,7 @@
}
// special variable CHANGING and INPUT used in conpound criteria, with declared variables
- public void testCreateUpdateProcedure16() {
+ @Test public void testCreateUpdateProcedure16() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1662,7 +1658,7 @@
}
// special variable CHANGING compared against integer no implicit conversion available
- public void testCreateUpdateProcedure17() {
+ @Test public void testCreateUpdateProcedure17() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "if(CHANGING.e4 = {d'2000-01-01'})\n"; //$NON-NLS-1$
@@ -1678,7 +1674,7 @@
}
// virtual group elements used in procedure(HAS CRITERIA)
- public void testCreateUpdateProcedure18() {
+ @Test public void testCreateUpdateProcedure18() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1693,7 +1689,7 @@
}
// virtual group elements used in procedure in if statement(HAS CRITERIA)
- public void testCreateUpdateProcedure19() {
+ @Test public void testCreateUpdateProcedure19() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1711,7 +1707,7 @@
}
// virtual group elements used in procedure(TRANSLATE CRITERIA)
- public void testCreateUpdateProcedure20() {
+ @Test public void testCreateUpdateProcedure20() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1726,7 +1722,7 @@
}
// virtual group elements used in procedure(TRANSLATE CRITERIA)
- public void testCreateUpdateProcedure21() {
+ @Test public void testCreateUpdateProcedure21() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1741,7 +1737,7 @@
}
// using undefined variable should fail
- public void testCreateUpdateProcedure22() {
+ @Test public void testCreateUpdateProcedure22() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
// procedure = procedure + "DECLARE integer var1;\n";
@@ -1757,7 +1753,7 @@
}
// using undefined variable declared is of invalid datatype
- public void testCreateUpdateProcedure23() {
+ @Test public void testCreateUpdateProcedure23() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE struct var1;\n"; //$NON-NLS-1$
@@ -1772,7 +1768,7 @@
}
// using declare variable that has parts
- public void testCreateUpdateProcedure24() {
+ @Test public void testCreateUpdateProcedure24() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var2.var1;\n"; //$NON-NLS-1$
@@ -1785,7 +1781,7 @@
}
// using declare variable is qualified
- public void testCreateUpdateProcedure26() {
+ @Test public void testCreateUpdateProcedure26() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer VARIABLES.var1;\n"; //$NON-NLS-1$
@@ -1798,7 +1794,7 @@
}
// using declare variable is qualified but has more parts
- public void testCreateUpdateProcedure27() {
+ @Test public void testCreateUpdateProcedure27() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer VARIABLES.var1.var2;\n"; //$NON-NLS-1$
@@ -1811,7 +1807,7 @@
}
// using a variable that has not been declared in an assignment stmt
- public void testCreateUpdateProcedure28() {
+ @Test public void testCreateUpdateProcedure28() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
@@ -1824,7 +1820,7 @@
}
// using a variable that has not been declared in an assignment stmt
- public void testCreateUpdateProcedure29() {
+ @Test public void testCreateUpdateProcedure29() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "var1 = 1;\n"; //$NON-NLS-1$
@@ -1837,7 +1833,7 @@
}
// using invalid function in assignment expr
- public void testCreateUpdateProcedure30() {
+ @Test public void testCreateUpdateProcedure30() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
@@ -1851,7 +1847,7 @@
}
// using invalid function in assignment expr
- public void testCreateUpdateProcedure31() {
+ @Test public void testCreateUpdateProcedure31() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
@@ -1865,7 +1861,7 @@
}
// using a variable being used inside a subcomand
- public void testCreateUpdateProcedure32() {
+ @Test public void testCreateUpdateProcedure32() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
@@ -1881,7 +1877,7 @@
// variable resolution, variables declared in differrent blocks local variables
// should override, outer block variables still valid afetr inner block is declared
// fails as variable being compared against incorrect type
- public void testCreateUpdateProcedure33() {
+ @Test public void testCreateUpdateProcedure33() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1900,7 +1896,7 @@
}
// physical elements used on criteria of the if statement
- public void testCreateUpdateProcedure34() {
+ @Test public void testCreateUpdateProcedure34() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1917,7 +1913,7 @@
}
// virtual elements used on criteria of the if statement
- public void testCreateUpdateProcedure35() {
+ @Test public void testCreateUpdateProcedure35() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1934,7 +1930,7 @@
}
// physical elements used on criteria of the if statement
- public void testCreateUpdateProcedure36() {
+ @Test public void testCreateUpdateProcedure36() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1951,7 +1947,7 @@
}
// TranslateCriteria on criteria of the if statement
- public void testCreateUpdateProcedure37() {
+ @Test public void testCreateUpdateProcedure37() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1969,7 +1965,7 @@
// validating Translate CRITERIA, elements on it should be virtual group elements
// but can use variables
- public void testCreateUpdateProcedure38() {
+ @Test public void testCreateUpdateProcedure38() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1983,7 +1979,7 @@
}
// physical elements used on criteria of the if statement
- public void testCreateUpdateProcedure39() {
+ @Test public void testCreateUpdateProcedure39() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -2000,7 +1996,7 @@
}
// TranslateCriteria on criteria of the if statement
- public void testCreateUpdateProcedure40() {
+ @Test public void testCreateUpdateProcedure40() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -2017,7 +2013,7 @@
}
// TranslateCriteria on criteria of the if statement
- public void testCreateUpdateProcedure41() {
+ @Test public void testCreateUpdateProcedure41() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -2034,7 +2030,7 @@
}
// TranslateCriteria on criteria of the if statement
- public void testCreateUpdateProcedure42() {
+ @Test public void testCreateUpdateProcedure42() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -2051,7 +2047,7 @@
}
// TranslateCriteria on criteria of the if statement
- public void testCreateUpdateProcedure43() throws Exception {
+ @Test public void testCreateUpdateProcedure43() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -2071,7 +2067,7 @@
}
// special variable CHANGING compared against integer no implicit conversion available
- public void testCreateUpdateProcedure44() {
+ @Test public void testCreateUpdateProcedure44() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "if(INPUT.e1 = 10)\n"; //$NON-NLS-1$
@@ -2087,7 +2083,7 @@
}
// special variable CHANGING compared against integer no implicit conversion available
- public void testCreateUpdateProcedure45() throws Exception {
+ @Test public void testCreateUpdateProcedure45() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "if(INPUT.e1 = 10)\n"; //$NON-NLS-1$
@@ -2108,7 +2104,7 @@
}
// special variable CHANGING compared against integer no implicit conversion available
- public void testCreateUpdateProcedure46() throws Exception {
+ @Test public void testCreateUpdateProcedure46() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1;\n"; //$NON-NLS-1$
@@ -2126,7 +2122,7 @@
}
// TranslateCriteria on criteria of the if statement
- public void testCreateUpdateProcedure47() {
+ @Test public void testCreateUpdateProcedure47() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -2143,7 +2139,7 @@
}
// validating Translate CRITERIA, elements(left elements on on it should be virtual group elements
- public void testCreateUpdateProcedure48() {
+ @Test public void testCreateUpdateProcedure48() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -2157,7 +2153,7 @@
}
// resolving Translate CRITERIA, right element should be present on the command
- public void testCreateUpdateProcedure49() {
+ @Test public void testCreateUpdateProcedure49() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = pm1.g2.e1);\n"; //$NON-NLS-1$
@@ -2170,7 +2166,7 @@
}
// resolving criteria selector(on HAS CRITERIA), elements on it should be virtual group elements
- public void testCreateUpdateProcedure50() {
+ @Test public void testCreateUpdateProcedure50() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -2187,7 +2183,7 @@
}
// resolving Translate CRITERIA, right side expression in the translate criteria should be elements on the command
- public void testCreateUpdateProcedure51() {
+ @Test public void testCreateUpdateProcedure51() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -2204,7 +2200,7 @@
// validating Translate CRITERIA, elements on it should be virtual group elements
// but can use variables, gut left exprs should always be virtual elements
- public void testCreateUpdateProcedure52() {
+ @Test public void testCreateUpdateProcedure52() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -2220,7 +2216,7 @@
// resolving AssignmentStatement, variable type and assigned type
// do not match and no implicit conversion available
- public void testCreateUpdateProcedure53() {
+ @Test public void testCreateUpdateProcedure53() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -2236,7 +2232,7 @@
// resolving AssignmentStatement, variable type and assigned type
// do not match, but implicit conversion available
- public void testCreateUpdateProcedure54() {
+ @Test public void testCreateUpdateProcedure54() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
@@ -2252,7 +2248,7 @@
// resolving AssignmentStatement, variable type and assigned type
// do not match, but implicit conversion available
- public void testCreateUpdateProcedure55() {
+ @Test public void testCreateUpdateProcedure55() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
@@ -2267,7 +2263,7 @@
}
// no user command provided - should throw resolver exception
- public void testCreateUpdateProcedure56() {
+ @Test public void testCreateUpdateProcedure56() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
@@ -2278,7 +2274,7 @@
helpResolveException(procedure, FakeMetadataFactory.example1Cached(), "Error Code:ERR.015.008.0012 Message:Unable to resolve update procedure as the virtual group context is ambiguous."); //$NON-NLS-1$
}
- public void testDefect14912_CreateUpdateProcedure57_FunctionWithElementParamInAssignmentStatement() {
+ @Test public void testDefect14912_CreateUpdateProcedure57_FunctionWithElementParamInAssignmentStatement() {
// Tests that the function params are resolved before the function for assignment statements
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -2294,7 +2290,7 @@
// addresses Cases 4624. Before change to UpdateProcedureResolver,
// this case failed with assertion exception.
- public void testCase4624() {
+ @Test public void testCase4624() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "VARIABLES.ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
@@ -2312,7 +2308,7 @@
}
// addresses Cases 5474.
- public void testCase5474() {
+ @Test public void testCase5474() {
String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer VARIABLES.NLEVELS;\n"; //$NON-NLS-1$
@@ -2322,7 +2318,7 @@
helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
}
- public void testIssue174102() throws Exception {
+ @Test public void testIssue174102() throws Exception {
String procedure = "CREATE VIRTUAL PROCEDURE \n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE string crit = 'WHERE pm1.sq2.in = \"test\"';\n"; //$NON-NLS-1$
@@ -2335,7 +2331,7 @@
// Address Issue 174519.
// Expected result is resolver failure, but with different error.
- public void testIssue174519() {
+ @Test public void testIssue174519() {
String procedure = "CREATE VIRTUAL PROCEDURE \n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE string VARIABLES.l_in = pm1.sq1.in;\n"; //$NON-NLS-1$
@@ -2363,11 +2359,11 @@
return metadata;
}
- public void testIsXMLQuery1() throws Exception {
+ @Test public void testIsXMLQuery1() throws Exception {
helpTestIsXMLQuery("SELECT * FROM pm1.g1", false); //$NON-NLS-1$
}
- public void testIsXMLQuery2() throws Exception {
+ @Test public void testIsXMLQuery2() throws Exception {
helpTestIsXMLQuery("SELECT * FROM xmltest.doc1", true); //$NON-NLS-1$
}
@@ -2376,19 +2372,19 @@
* is used (assuming short doc name isn't ambiguous in a
* VDB). Defect 11479.
*/
- public void testIsXMLQuery3() throws Exception {
+ @Test public void testIsXMLQuery3() throws Exception {
helpTestIsXMLQuery("SELECT * FROM doc1", true); //$NON-NLS-1$
}
- public void testIsXMLQueryFail1() throws Exception {
+ @Test public void testIsXMLQueryFail1() throws Exception {
helpTestIsXMLQuery("SELECT * FROM xmltest.doc1, xmltest.doc2", false); //$NON-NLS-1$
}
- public void testIsXMLQueryFail2() throws Exception {
+ @Test public void testIsXMLQueryFail2() throws Exception {
helpTestIsXMLQuery("SELECT * FROM xmltest.doc1, pm1.g1", false); //$NON-NLS-1$
}
- public void testIsXMLQueryFail3() throws Exception {
+ @Test public void testIsXMLQueryFail3() throws Exception {
helpTestIsXMLQuery("SELECT * FROM pm1.g1, xmltest.doc1", false); //$NON-NLS-1$
}
@@ -2396,7 +2392,7 @@
* "docA" is ambiguous as there exist two documents called
* xmlTest2.docA and xmlTest3.docA. Defect 11479.
*/
- public void testIsXMLQueryFail4() throws Exception {
+ @Test public void testIsXMLQueryFail4() throws Exception {
Query query = (Query) helpParse("SELECT * FROM docA"); //$NON-NLS-1$
try {
@@ -2407,7 +2403,7 @@
}
}
- public void testStringConversion1() {
+ @Test public void testStringConversion1() {
// Expected left expression
ElementSymbol e1 = new ElementSymbol("pm3.g1.e2"); //$NON-NLS-1$
e1.setType(DataTypeManager.DefaultDataClasses.DATE);
@@ -2443,7 +2439,7 @@
assertEquals("Did not match expected criteria", expected, actual); //$NON-NLS-1$
}
- public void testStringConversion2() {
+ @Test public void testStringConversion2() {
// Expected left expression
ElementSymbol e1 = new ElementSymbol("pm3.g1.e2"); //$NON-NLS-1$
e1.setType(DataTypeManager.DefaultDataClasses.DATE);
@@ -2480,7 +2476,7 @@
}
// special test for both sides are String
- public void testStringConversion3() {
+ @Test public void testStringConversion3() {
// Expected left expression
ElementSymbol e1 = new ElementSymbol("pm3.g1.e1"); //$NON-NLS-1$
e1.setType(DataTypeManager.DefaultDataClasses.STRING);
@@ -2506,7 +2502,7 @@
assertEquals("Did not match expected criteria", expected, actual); //$NON-NLS-1$
}
- public void testDateToTimestampConversion_defect9747() {
+ @Test public void testDateToTimestampConversion_defect9747() {
// Expected left expression
ElementSymbol e1 = new ElementSymbol("pm3.g1.e4"); //$NON-NLS-1$
e1.setType(DataTypeManager.DefaultDataClasses.TIMESTAMP);
@@ -2528,14 +2524,14 @@
assertEquals("Did not match expected criteria", expected, actual); //$NON-NLS-1$
}
- public void testFailedConversion_defect9725() throws Exception{
+ @Test public void testFailedConversion_defect9725() throws Exception{
helpResolveException("select * from pm3.g1 where pm3.g1.e4 > {b 'true'}", "Error Code:ERR.015.008.0027 Message:The expressions in this criteria are being compared but are of differing types (timestamp and boolean) and no implicit conversion is available: pm3.g1.e4 > TRUE"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Constants will now auto resolve if they are consistently representable in the target type
*/
- public void testDefect23257() throws Exception{
+ @Test public void testDefect23257() throws Exception{
StoredProcedure command = (StoredProcedure)helpResolve("EXEC pm5.vsp59()"); //$NON-NLS-1$
CommandStatement cs = (CommandStatement)((CreateUpdateProcedureCommand)command.getSubCommand()).getBlock().getStatements().get(1);
@@ -2545,7 +2541,7 @@
assertEquals(DataTypeManager.DefaultDataClasses.SHORT, ((Expression)insert.getValues().get(1)).getType());
}
- public void testLookupFunction() {
+ @Test public void testLookupFunction() {
String sql = "SELECT lookup('pm1.g1', 'e1', 'e2', e2) AS x, lookup('pm1.g1', 'e4', 'e3', e3) AS y FROM pm1.g1"; //$NON-NLS-1$
Query resolvedQuery = (Query) helpResolve(sql);
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
@@ -2561,39 +2557,39 @@
assertEquals("Wrong type for second symbol", Double.class, ((SingleElementSymbol)projSymbols.get(1)).getType()); //$NON-NLS-1$
}
- public void testLookupFunctionFailBadElement() {
+ @Test public void testLookupFunctionFailBadElement() {
String sql = "SELECT lookup('nosuch', 'elementhere', 'e2', e2) AS x FROM pm1.g1"; //$NON-NLS-1$
helpResolveException(sql);
}
- public void testLookupFunctionFailNotConstantArg1() {
+ @Test public void testLookupFunctionFailNotConstantArg1() {
String sql = "SELECT lookup(e1, 'e1', 'e2', e2) AS x FROM pm1.g1"; //$NON-NLS-1$
helpResolveException(sql);
}
- public void testLookupFunctionFailNotConstantArg2() {
+ @Test public void testLookupFunctionFailNotConstantArg2() {
String sql = "SELECT lookup('pm1.g1', e1, 'e2', e2) AS x FROM pm1.g1"; //$NON-NLS-1$
helpResolveException(sql);
}
- public void testLookupFunctionFailNotConstantArg3() {
+ @Test public void testLookupFunctionFailNotConstantArg3() {
String sql = "SELECT lookup('pm1.g1', 'e1', e1, e2) AS x FROM pm1.g1"; //$NON-NLS-1$
helpResolveException(sql);
}
- public void testLookupFunctionVirtualGroup() throws Exception {
+ @Test public void testLookupFunctionVirtualGroup() throws Exception {
String sql = "SELECT lookup('vm1.g1', 'e1', 'e2', e2) FROM vm1.g1 "; //$NON-NLS-1$
Query command = (Query) helpParse(sql);
QueryResolver.resolveCommand(command, FakeMetadataFactory.example1Cached());
}
- public void testLookupFunctionPhysicalGroup() throws Exception {
+ @Test public void testLookupFunctionPhysicalGroup() throws Exception {
String sql = "SELECT lookup('pm1.g1', 'e1', 'e2', e2) FROM pm1.g1 "; //$NON-NLS-1$
Query command = (Query) helpParse(sql);
QueryResolver.resolveCommand(command, FakeMetadataFactory.example1Cached());
}
- public void testLookupFunctionFailBadKeyElement() throws Exception {
+ @Test public void testLookupFunctionFailBadKeyElement() throws Exception {
String sql = "SELECT lookup('pm1.g1', 'e1', 'x', e2) AS x, lookup('pm1.g1', 'e4', 'e3', e3) AS y FROM pm1.g1"; //$NON-NLS-1$
Command command = QueryParser.getQueryParser().parseCommand(sql);
try {
@@ -2605,7 +2601,7 @@
}
// special test for both sides are String
- public void testSetCriteriaCastFromExpression_9657() {
+ @Test public void testSetCriteriaCastFromExpression_9657() {
// parse
Criteria expected = null;
Criteria actual = null;
@@ -2631,89 +2627,89 @@
assertEquals("Did not match expected criteria", expected, actual); //$NON-NLS-1$
}
- public void testVirtualProcedure(){
+ @Test public void testVirtualProcedure(){
helpResolve("EXEC pm1.vsp1()"); //$NON-NLS-1$
}
- public void testVirtualProcedure2(){
+ @Test public void testVirtualProcedure2(){
helpResolve("EXEC pm1.vsp14()"); //$NON-NLS-1$
}
- public void testVirtualProcedurePartialParameterReference() {
+ @Test public void testVirtualProcedurePartialParameterReference() {
helpResolve("EXEC pm1.vsp58(5)"); //$NON-NLS-1$
}
//cursor starts with "#" Defect14924
- public void testVirtualProcedureInvalid1(){
+ @Test public void testVirtualProcedureInvalid1(){
helpResolveException("EXEC pm1.vsp32()","Cursor names cannot begin with \"#\" as that indicates the name of a temporary table: #mycursor."); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testVirtualProcedureWithOrderBy() {
+ @Test public void testVirtualProcedureWithOrderBy() {
helpResolve("EXEC pm1.vsp29()"); //$NON-NLS-1$
}
- public void testVirtualProcedureWithTempTableAndOrderBy() {
+ @Test public void testVirtualProcedureWithTempTableAndOrderBy() {
helpResolve("EXEC pm1.vsp33()"); //$NON-NLS-1$
}
- public void testVirtualProcedureWithConstAndOrderBy() {
+ @Test public void testVirtualProcedureWithConstAndOrderBy() {
helpResolve("EXEC pm1.vsp34()"); //$NON-NLS-1$
}
- public void testVirtualProcedureWithNoFromAndOrderBy() {
+ @Test public void testVirtualProcedureWithNoFromAndOrderBy() {
helpResolve("EXEC pm1.vsp28()"); //$NON-NLS-1$
}
/** select e1 from pm1.g1 where e2 BETWEEN 1000 AND 2000 */
- public void testBetween1(){
+ @Test public void testBetween1(){
String sql = "select e1 from pm1.g1 where e2 BETWEEN 1000 AND 2000"; //$NON-NLS-1$
helpResolve(sql);
}
/** select e1 from pm1.g1 where e2 NOT BETWEEN 1000 AND 2000 */
- public void testBetween2(){
+ @Test public void testBetween2(){
String sql = "select e1 from pm1.g1 where e2 NOT BETWEEN 1000 AND 2000"; //$NON-NLS-1$
helpResolve(sql);
}
/** select e2 from pm1.g1 where e4 BETWEEN 1000 AND e2 */
- public void testBetween3(){
+ @Test public void testBetween3(){
String sql = "select e2 from pm1.g1 where e4 BETWEEN 1000 AND e2"; //$NON-NLS-1$
helpResolve(sql);
}
/** select e2 from pm1.g1 where e2 BETWEEN 1000 AND e4 */
- public void testBetween4(){
+ @Test public void testBetween4(){
String sql = "select e2 from pm1.g1 where e2 BETWEEN 1000 AND e4"; //$NON-NLS-1$
helpResolve(sql);
}
/** select e1 from pm1.g1 where 1000 BETWEEN e1 AND e2 */
- public void testBetween5(){
+ @Test public void testBetween5(){
String sql = "select e1 from pm1.g1 where 1000 BETWEEN e1 AND e2"; //$NON-NLS-1$
helpResolve(sql);
}
/** select e1 from pm1.g1 where 1000 BETWEEN e2 AND e1 */
- public void testBetween6(){
+ @Test public void testBetween6(){
String sql = "select e1 from pm1.g1 where 1000 BETWEEN e2 AND e1"; //$NON-NLS-1$
helpResolve(sql);
}
/** select e1 from pm3.g1 where e2 BETWEEN e3 AND e4 */
- public void testBetween7(){
+ @Test public void testBetween7(){
String sql = "select e1 from pm3.g1 where e2 BETWEEN e3 AND e4"; //$NON-NLS-1$
helpResolve(sql);
}
/** select pm3.g1.e1 from pm3.g1, pm3.g2 where pm3.g1.e4 BETWEEN pm3.g1.e2 AND pm3.g2.e2 */
- public void testBetween8(){
+ @Test public void testBetween8(){
String sql = "select pm3.g1.e1 from pm3.g1, pm3.g2 where pm3.g1.e4 BETWEEN pm3.g1.e2 AND pm3.g2.e2"; //$NON-NLS-1$
helpResolve(sql);
}
/** select e1 from pm1.g1 where e2 = any (select e2 from pm4.g1) */
- public void testCompareSubQuery1(){
+ @Test public void testCompareSubQuery1(){
String sql = "select e1 from pm1.g1 where e2 = any (select e2 from pm4.g1)"; //$NON-NLS-1$
Query outerQuery = (Query) this.helpResolveSubquery(sql, new String[0]);
@@ -2734,128 +2730,128 @@
}
/** select e1 from pm1.g1 where e2 = all (select e2 from pm4.g1) */
- public void testCompareSubQuery2(){
+ @Test public void testCompareSubQuery2(){
String sql = "select e1 from pm1.g1 where e2 = all (select e2 from pm4.g1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
/** select e1 from pm1.g1 where e2 < (select e2 from pm4.g1 where e1 = '3') */
- public void testCompareSubQuery3(){
+ @Test public void testCompareSubQuery3(){
String sql = "select e1 from pm1.g1 where e2 < (select e2 from pm4.g1 where e1 = '3')"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
/** select e1 from pm1.g1 where e2 < (select e2 from pm4.g1 where e1 = '3') */
- public void testCompareSubQueryImplicitConversion(){
+ @Test public void testCompareSubQueryImplicitConversion(){
String sql = "select e1 from pm1.g1 where e1 < (select e2 from pm4.g1 where e1 = '3')"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
- public void testExistsSubQuery(){
+ @Test public void testExistsSubQuery(){
String sql = "select e1 from pm1.g1 where exists (select e2 from pm4.g1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
- public void testExistsSubQuery2(){
+ @Test public void testExistsSubQuery2(){
String sql = "select e1 from pm1.g1 where exists (select e1, e2 from pm4.g1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
- public void testScalarSubQueryInSelect(){
+ @Test public void testScalarSubQueryInSelect(){
String sql = "select e1, (select e2 from pm4.g1 where e1 = '3') from pm1.g1"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
- public void testScalarSubQueryInSelect2(){
+ @Test public void testScalarSubQueryInSelect2(){
String sql = "select (select e2 from pm4.g1 where e1 = '3'), e1 from pm1.g1"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
- public void testScalarSubQueryInSelectWithAlias(){
+ @Test public void testScalarSubQueryInSelectWithAlias(){
String sql = "select e1, (select e2 from pm4.g1 where e1 = '3') as X from pm1.g1"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
- public void testSelectWithNoFrom() {
+ @Test public void testSelectWithNoFrom() {
String sql = "SELECT 5"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testSelectWithNoFrom_Alias() {
+ @Test public void testSelectWithNoFrom_Alias() {
String sql = "SELECT 5 AS INTKEY"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testSelectWithNoFrom_Alias_OrderBy() {
+ @Test public void testSelectWithNoFrom_Alias_OrderBy() {
String sql = "SELECT 5 AS INTKEY ORDER BY INTKEY"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testSubqueryCorrelatedInCriteria(){
+ @Test public void testSubqueryCorrelatedInCriteria(){
String sql = "select e2 from pm1.g1 where e2 = all (select e2 from pm4.g1 where pm1.g1.e1 = pm4.g1.e1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"pm1.g1.e1"}); //$NON-NLS-1$
}
- public void testSubqueryCorrelatedInCriteria2(){
+ @Test public void testSubqueryCorrelatedInCriteria2(){
String sql = "select e1 from pm1.g1 where e2 = all (select e2 from pm4.g1 where pm1.g1.e1 = e1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"pm1.g1.e1"}); //$NON-NLS-1$
}
- public void testSubqueryCorrelatedInCriteria3(){
+ @Test public void testSubqueryCorrelatedInCriteria3(){
String sql = "select e1 from pm1.g1 X where e2 = all (select e2 from pm4.g1 where X.e1 = pm4.g1.e1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"X.e1"}); //$NON-NLS-1$
}
- public void testSubqueryCorrelatedInCriteria4(){
+ @Test public void testSubqueryCorrelatedInCriteria4(){
String sql = "select e2 from pm1.g1 X where e2 in (select e2 from pm1.g1 Y where X.e1 = Y.e1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"X.e1"}); //$NON-NLS-1$
}
- public void testSubqueryCorrelatedInCriteria5(){
+ @Test public void testSubqueryCorrelatedInCriteria5(){
String sql = "select e1 from pm1.g1 X where e2 = all (select e2 from pm1.g1 Y where X.e1 = e1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"X.e1"}); //$NON-NLS-1$
}
/* 'e5' is only in pm4.g2 */
- public void testSubqueryCorrelatedInCriteria6(){
+ @Test public void testSubqueryCorrelatedInCriteria6(){
String sql = "select e1 from pm4.g2 where e2 = some (select e2 from pm4.g1 where e5 = e1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"pm4.g2.e5"}); //$NON-NLS-1$
}
/* 'e5' is only in pm4.g2 */
- public void testSubqueryCorrelatedInCriteria7(){
+ @Test public void testSubqueryCorrelatedInCriteria7(){
String sql = "select e1 from pm4.g2 where exists (select e2 from pm4.g1 where e5 = e1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"pm4.g2.e5"}); //$NON-NLS-1$
}
- public void testSubqueryCorrelatedInHaving(){
+ @Test public void testSubqueryCorrelatedInHaving(){
String sql = "select e1, e2 from pm4.g2 group by e2 having e2 in (select e2 from pm4.g1 where e5 = e1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"pm4.g2.e5"}); //$NON-NLS-1$
}
- public void testSubqueryCorrelatedInHaving2(){
+ @Test public void testSubqueryCorrelatedInHaving2(){
String sql = "select e1, e2 from pm4.g2 group by e2 having e2 <= all (select e2 from pm4.g1 where e5 = e1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"pm4.g2.e5"}); //$NON-NLS-1$
}
/* 'e5' is only in pm4.g2 */
- public void testSubqueryCorrelatedInSelect(){
+ @Test public void testSubqueryCorrelatedInSelect(){
String sql = "select e1, (select e2 from pm4.g1 where e5 = e1) from pm4.g2"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"pm4.g2.e5"}); //$NON-NLS-1$
}
- public void testSubqueryCorrelatedInSelect2(){
+ @Test public void testSubqueryCorrelatedInSelect2(){
String sql = "select e1, (select e2 from pm4.g1 where pm4.g2.e5 = e1) from pm4.g2"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"pm4.g2.e5"}); //$NON-NLS-1$
}
- public void testSubqueryCorrelatedInSelect3(){
+ @Test public void testSubqueryCorrelatedInSelect3(){
String sql = "select e1, (select e2 from pm4.g1 Y where X.e5 = Y.e1) from pm4.g2 X"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"X.e5"}); //$NON-NLS-1$
}
/* 'e5' is only in pm4.g2 */
- public void testNestedCorrelatedSubqueries(){
+ @Test public void testNestedCorrelatedSubqueries(){
String sql = "select e1, (select e2 from pm1.g1 where e2 = all (select e2 from pm4.g1 where e5 = e1)) from pm4.g2"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"pm4.g2.e5"}); //$NON-NLS-1$
}
@@ -2863,7 +2859,7 @@
/**
* 'e5' is in pm4.g2, so it will be resolved to the group aliased as 'Y'
*/
- public void testNestedCorrelatedSubqueries2(){
+ @Test public void testNestedCorrelatedSubqueries2(){
String sql = "select e1, (select e2 from pm4.g2 Y where e2 = all (select e2 from pm4.g1 where e5 = e1)) from pm4.g2 X"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"Y.e5"}); //$NON-NLS-1$
}
@@ -2871,7 +2867,7 @@
/**
* 'e5' is in pm4.g2; it will be resolved to the group aliased as 'X'
*/
- public void testNestedCorrelatedSubqueries3(){
+ @Test public void testNestedCorrelatedSubqueries3(){
String sql = "select e1, (select e2 from pm4.g2 Y where e2 = all (select e2 from pm4.g1 where X.e5 = e1)) from pm4.g2 X"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"X.e5"}); //$NON-NLS-1$
}
@@ -2879,17 +2875,17 @@
/**
* 'e5' is in X and Y
*/
- public void testNestedCorrelatedSubqueries4(){
+ @Test public void testNestedCorrelatedSubqueries4(){
String sql = "select X.e2 from pm4.g2 Y, pm4.g2 X where X.e2 = all (select e2 from pm4.g1 where e5 = e1)"; //$NON-NLS-1$
helpResolveException(sql, metadata, "Element \"e5\" is ambiguous, it exists in two or more groups."); //$NON-NLS-1$
}
- public void testSubqueryCorrelatedInCriteriaVirtualLayer(){
+ @Test public void testSubqueryCorrelatedInCriteriaVirtualLayer(){
String sql = "select e2 from vm1.g1 where e2 = all (select e2 from vm1.g2 where vm1.g1.e1 = vm1.g2.e1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"vm1.g1.e1"}); //$NON-NLS-1$
}
- public void testSubqueryCorrelatedInCriteriaVirtualLayer2(){
+ @Test public void testSubqueryCorrelatedInCriteriaVirtualLayer2(){
String sql = "select e2 from vm1.g1 X where e2 = all (select e2 from vm1.g2 where X.e1 = vm1.g2.e1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[]{"X.e1"}); //$NON-NLS-1$
}
@@ -2898,7 +2894,7 @@
* Although this query makes no sense, the "e1" in the nested criteria is
* NOT a correlated reference
*/
- public void testSubqueryNonCorrelatedInCriteria(){
+ @Test public void testSubqueryNonCorrelatedInCriteria(){
String sql = "select e2 from pm1.g1 where e2 = all (select e2 from pm4.g1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
@@ -2907,7 +2903,7 @@
* Although this query makes no sense, the "e1" in the nested criteria is
* NOT a correlated reference
*/
- public void testSubqueryNonCorrelatedInCriteria2(){
+ @Test public void testSubqueryNonCorrelatedInCriteria2(){
String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1 WHERE e1 IN (SELECT e1 FROM pm1.g1))"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
@@ -2916,7 +2912,7 @@
* Although this query makes no sense, the "e1" in the nested criteria is
* NOT a correlated reference
*/
- public void testSubqueryNonCorrelatedInCriteria3(){
+ @Test public void testSubqueryNonCorrelatedInCriteria3(){
String sql = "SELECT e2 FROM pm2.g1 WHERE e1 IN (SELECT e1 FROM pm1.g1)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
@@ -2926,7 +2922,7 @@
* group in metadata, not the temporary child metadata group defined by the
* outer query.
*/
- public void testSubquery_defect10090(){
+ @Test public void testSubquery_defect10090(){
String sql = "select pm1.g1.e1 from pm1.g1 where pm1.g1.e2 in (select pm1.g1.e2 from pm1.g1 where pm1.g1.e4 = 2.0)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
@@ -2934,18 +2930,18 @@
/**
* Workaround is to alias group in FROM of outer query (aliasing subquery group doesn't work)
*/
- public void testSubquery_defect10090Workaround(){
+ @Test public void testSubquery_defect10090Workaround(){
String sql = "select X.e1 from pm1.g1 X where X.e2 in (select pm1.g1.e2 from pm1.g1 where pm1.g1.e4 = 2.0)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
- public void testSubquery2_defect10090(){
+ @Test public void testSubquery2_defect10090(){
String sql = "select pm1.g1.e1 from pm1.g1 where pm1.g1.e2 in (select X.e2 from pm1.g1 X where X.e4 = 2.0)"; //$NON-NLS-1$
this.helpResolveSubquery(sql, new String[0]);
}
/** test jdbc USER method */
- public void testUser() {
+ @Test public void testUser() {
//String sql = "select intkey from SmallA where user() = 'bqt2'";
// Expected left expression
@@ -2968,14 +2964,14 @@
assertEquals("Did not match expected criteria", expected, actual); //$NON-NLS-1$
}
- public void testCaseExpression1() {
+ @Test public void testCaseExpression1() {
String sql = "SELECT e1, CASE e2 WHEN 0 THEN 20 WHEN 1 THEN 21 WHEN 2 THEN 500 END AS testElement FROM pm1.g1" //$NON-NLS-1$
+" WHERE e1 = CASE WHEN e2 = 0 THEN 'a' WHEN e2 = 1 THEN 'b' ELSE 'c' END"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testCaseExpression2() {
+ @Test public void testCaseExpression2() {
// nested case expressions
String sql = "SELECT CASE e2" + //$NON-NLS-1$
" WHEN 0 THEN CASE e1 " + //$NON-NLS-1$
@@ -2989,13 +2985,13 @@
helpResolve(sql);
}
- public void testCaseExpressionWithNestedFunction() {
+ @Test public void testCaseExpressionWithNestedFunction() {
String sql = "SELECT CASE WHEN e2 < 0 THEN abs(CASE WHEN e2 < 0 THEN -1 ELSE e2 END)" + //$NON-NLS-1$
" ELSE e2 END FROM pm1.g1"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testFunctionWithNestedCaseExpression() {
+ @Test public void testFunctionWithNestedCaseExpression() {
String sql = "SELECT abs(CASE e1 WHEN 'testString1' THEN -13" + //$NON-NLS-1$
" WHEN 'testString2' THEN -5" + //$NON-NLS-1$
" ELSE abs(e2)" + //$NON-NLS-1$
@@ -3003,12 +2999,12 @@
helpResolve(sql);
}
- public void testDefect10809(){
+ @Test public void testDefect10809(){
String sql = "select * from LOB_TESTING_ONE where CLOB_COLUMN LIKE '%fff%'"; //$NON-NLS-1$
helpResolve(helpParse(sql), FakeMetadataFactory.exampleLOB(), AnalysisRecord.createNonRecordingRecord());
}
- public void testNonAutoConversionOfLiteralIntegerToShort() throws Exception {
+ @Test public void testNonAutoConversionOfLiteralIntegerToShort() throws Exception {
// parse
Query command = (Query) QueryParser.getQueryParser().parseCommand("SELECT intkey FROM bqt1.smalla WHERE shortvalue = 5"); //$NON-NLS-1$
@@ -3022,7 +3018,7 @@
assertEquals("Sql is incorrect after resolving", "SELECT intkey FROM bqt1.smalla WHERE shortvalue = 5", command.toString()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testNonAutoConversionOfLiteralIntegerToShort2() throws Exception {
+ @Test public void testNonAutoConversionOfLiteralIntegerToShort2() throws Exception {
// parse
Query command = (Query) QueryParser.getQueryParser().parseCommand("SELECT intkey FROM bqt1.smalla WHERE 5 = shortvalue"); //$NON-NLS-1$
@@ -3036,42 +3032,42 @@
assertEquals("Sql is incorrect after resolving", "SELECT intkey FROM bqt1.smalla WHERE 5 = shortvalue", command.toString()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testAliasedOrderBy() {
+ @Test public void testAliasedOrderBy() {
Query resolvedQuery = (Query) helpResolve("SELECT pm1.g1.e1 as y FROM pm1.g1 ORDER BY y"); //$NON-NLS-1$
helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
helpCheckSelect(resolvedQuery, new String[] { "y" }); //$NON-NLS-1$
}
- public void testUnaliasedOrderBySucceeds() {
+ @Test public void testUnaliasedOrderBySucceeds() {
helpResolve("SELECT pm1.g1.e1 a, pm1.g1.e1 b FROM pm1.g1 ORDER BY pm1.g1.e1"); //$NON-NLS-1$
}
/**
* the group g1 is not known to the order by clause of a union
*/
- public void testUnionOrderByFail() {
+ @Test public void testUnionOrderByFail() {
helpResolveException("SELECT pm1.g1.e1 FROM pm1.g1 UNION SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY g1.e1", "Error Code:ERR.015.008.0043 Message:Element 'g1.e1' in ORDER BY was not found in SELECT clause."); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testUnionOrderByFail1() {
+ @Test public void testUnionOrderByFail1() {
helpResolveException("SELECT pm1.g1.e1 FROM pm1.g1 UNION SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY pm1.g1.e1", "Error Code:ERR.015.008.0043 Message:Element 'pm1.g1.e1' in ORDER BY was not found in SELECT clause."); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testOrderByPartiallyQualified() {
+ @Test public void testOrderByPartiallyQualified() {
helpResolve("SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY g1.e1"); //$NON-NLS-1$
}
/**
* the group g1 is not known to the order by clause of a union
*/
- public void testUnionOrderBy() {
+ @Test public void testUnionOrderBy() {
helpResolve("SELECT pm1.g1.e1 FROM pm1.g1 UNION SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY e1"); //$NON-NLS-1$
}
/**
* Test for defect 12087 - Insert with implicit conversion from integer to short
*/
- public void testImplConversionBetweenIntAndShort() throws Exception {
+ @Test public void testImplConversionBetweenIntAndShort() throws Exception {
Command command = QueryParser.getQueryParser().parseCommand("Insert into pm1.g1(e1) Values(convert(100, short))"); //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example6();
@@ -3104,14 +3100,14 @@
return new FakeMetadataFacade(store);
}
- public void testDefect12968_union() {
+ @Test public void testDefect12968_union() {
helpResolve(
helpParse("SELECT myModel.myTable.myColumn AS myColumn from myModel.myTable UNION " + //$NON-NLS-1$
"SELECT convert(null, string) AS myColumn From myModel2.mySchema.myTable2"), //$NON-NLS-1$
example_12968(), AnalysisRecord.createNonRecordingRecord());
}
- public void testDefect13029_CorrectlySetUpdateProcedureTempGroupIDs() {
+ @Test public void testDefect13029_CorrectlySetUpdateProcedureTempGroupIDs() {
StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\nDECLARE string var1;") //$NON-NLS-1$
@@ -3158,7 +3154,7 @@
}
- public void testUnionQueryWithNull() throws Exception{
+ @Test public void testUnionQueryWithNull() throws Exception{
helpResolve("SELECT NULL, e2 FROM pm1.g2 UNION ALL SELECT e1, e2 FROM pm1.g3"); //$NON-NLS-1$
helpResolve("SELECT e1, e2 FROM pm1.g1 UNION ALL SELECT NULL, e2 FROM pm1.g2 UNION ALL SELECT e1, e2 FROM pm1.g3"); //$NON-NLS-1$
helpResolve("SELECT e1, NULL FROM pm1.g2 UNION ALL SELECT e1, e2 FROM pm1.g3"); //$NON-NLS-1$
@@ -3167,7 +3163,7 @@
helpResolve("SELECT e1, NULL as e2 FROM pm1.g1 UNION ALL SELECT e1, e3 FROM pm1.g2"); //$NON-NLS-1$
}
- public void testUnionQueryWithDiffTypes() throws Exception{
+ @Test public void testUnionQueryWithDiffTypes() throws Exception{
helpResolve("SELECT e1, e3 FROM pm1.g1 UNION ALL SELECT e2, e3 FROM pm1.g2"); //$NON-NLS-1$
helpResolve("SELECT e1, e3 FROM pm1.g1 UNION ALL SELECT e2, e3 FROM pm1.g2 UNION ALL SELECT NULL, e3 FROM pm1.g2"); //$NON-NLS-1$
helpResolve("SELECT e1, e3 FROM pm1.g1 UNION ALL SELECT e3, e3 FROM pm1.g2 UNION ALL SELECT NULL, e3 FROM pm1.g2"); //$NON-NLS-1$
@@ -3182,30 +3178,30 @@
helpResolve("select e2 from pm3.g1 union select e3 from pm3.g1 union select e4 from pm3.g1"); //$NON-NLS-1$
}
- public void testUnionQueryWithDiffTypesFails() throws Exception{
+ @Test public void testUnionQueryWithDiffTypesFails() throws Exception{
helpResolveException("SELECT e1 FROM pm1.g1 UNION (SELECT e2 FROM pm1.g2 UNION SELECT e2 from pm1.g1 order by e2)", "The Expression e2 used in a nested UNION ORDER BY clause cannot be implicitly converted from type integer to type string."); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testNestedUnionQueryWithNull() throws Exception{
+ @Test public void testNestedUnionQueryWithNull() throws Exception{
SetQuery command = (SetQuery)helpResolve("SELECT e2, e3 FROM pm1.g1 UNION (SELECT null, e3 FROM pm1.g2 UNION SELECT null, e3 from pm1.g1)"); //$NON-NLS-1$
assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, ((SingleElementSymbol)command.getProjectedSymbols().get(0)).getType());
}
- public void testSelectIntoNoFrom() {
+ @Test public void testSelectIntoNoFrom() {
helpResolve("SELECT 'a', 19, {b'true'}, 13.999 INTO pm1.g1"); //$NON-NLS-1$
}
- public void testSelectInto() {
+ @Test public void testSelectInto() {
helpResolve("SELECT e1, e2, e3, e4 INTO pm1.g1 FROM pm1.g2"); //$NON-NLS-1$
}
- public void testSelectIntoTempGroup() {
+ @Test public void testSelectIntoTempGroup() {
helpResolve("SELECT 'a', 19, {b'true'}, 13.999 INTO #myTempTable"); //$NON-NLS-1$
helpResolve("SELECT e1, e2, e3, e4 INTO #myTempTable FROM pm1.g1"); //$NON-NLS-1$
}
- public void testSelectIntoInProcNoFrom() {
+ @Test public void testSelectIntoInProcNoFrom() {
StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
.append("BEGIN\n") //$NON-NLS-1$
.append("SELECT 'a', 19, {b'true'}, 13.999 INTO pm1.g1;\n") //$NON-NLS-1$
@@ -3226,7 +3222,7 @@
FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
- public void testSelectIntoInProc() {
+ @Test public void testSelectIntoInProc() {
StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
.append("BEGIN\n") //$NON-NLS-1$
.append("SELECT e1, e2, e3, e4 INTO pm1.g1 FROM pm1.g2;\n") //$NON-NLS-1$
@@ -3248,7 +3244,7 @@
}
//baseline test to ensure that a declare assignment cannot contain the declared variable
- public void testDeclareStatement() {
+ @Test public void testDeclareStatement() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer VARIABLES.var1 = VARIABLES.var1;\n"; //$NON-NLS-1$
@@ -3260,7 +3256,7 @@
helpFailUpdateProcedure(procedure, userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
- public void testDynamicIntoInProc() {
+ @Test public void testDynamicIntoInProc() {
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
@@ -3273,7 +3269,7 @@
FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
- public void testDynamicStatement() {
+ @Test public void testDynamicStatement() {
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
@@ -3285,7 +3281,7 @@
FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
- public void testDynamicStatementType() {
+ @Test public void testDynamicStatementType() {
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
@@ -3298,47 +3294,47 @@
}
//procedural relational mapping
- public void testProcInVirtualGroup1(){
+ @Test public void testProcInVirtualGroup1(){
String sql = "select e1 from pm1.vsp26 where param1=1 and param2='a'"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testProcInVirtualGroup2(){
+ @Test public void testProcInVirtualGroup2(){
String sql = "select * from pm1.vsp26 as p where param1=1 and param2='a'"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testProcInVirtualGroup3(){
+ @Test public void testProcInVirtualGroup3(){
String sql = "SELECT P.e1 as ve3 FROM pm1.vsp26 as P, pm1.g2 where P.e1=g2.e1 and param1=1 and param2='a'"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testProcInVirtualGroup4(){
+ @Test public void testProcInVirtualGroup4(){
String sql = "SELECT P.e1 as ve3 FROM pm1.vsp26 as P, vm1.g1 where P.e1=g1.e1 and param1=1 and param2='a'"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testProcInVirtualGroup5(){
+ @Test public void testProcInVirtualGroup5(){
String sql = "SELECT * FROM (SELECT p.* FROM pm1.vsp26 as P, vm1.g1 where P.e1=g1.e1) x where param1=1 and param2='a'"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testProcInVirtualGroup6(){
+ @Test public void testProcInVirtualGroup6(){
String sql = "SELECT P.e1 as ve3, P.e2 as ve4 FROM pm1.vsp26 as P where param1=1 and param2='a'"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testProcInVirtualGroup7(){
+ @Test public void testProcInVirtualGroup7(){
String sql = "SELECT P.e2 as ve3, P.e1 as ve4 FROM pm1.vsp47 as P where param1=1 and param2='a'"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testProcInVirtualGroup7a(){
+ @Test public void testProcInVirtualGroup7a(){
String sql = "SELECT P.e2 as ve3, P.e1 as ve4 FROM pm1.vsp47 as P where param1=1"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testMaterializedTransformation() {
+ @Test public void testMaterializedTransformation() {
String userSql = "SELECT MATVIEW.E1 FROM MATVIEW"; //$NON-NLS-1$
QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
@@ -3366,7 +3362,7 @@
}
- public void testMaterializedTransformationLoading() {
+ @Test public void testMaterializedTransformationLoading() {
String userSql = "SELECT MATVIEW.E1 INTO MatTable.MatStage FROM MATVIEW"; //$NON-NLS-1$
QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
@@ -3392,7 +3388,7 @@
}
- public void testMaterializedTransformationNoCache() {
+ @Test public void testMaterializedTransformationNoCache() {
String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE MatView.MatView"; //$NON-NLS-1$
QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
@@ -3416,7 +3412,7 @@
}
//related to defect 14423
- public void testMaterializedTransformationNoCache2() {
+ @Test public void testMaterializedTransformationNoCache2() {
String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE"; //$NON-NLS-1$
QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
@@ -3439,7 +3435,7 @@
assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
}
- public void testNoCacheInTransformation(){
+ @Test public void testNoCacheInTransformation(){
String userSql = "SELECT VGROUP.E1 FROM VGROUP"; //$NON-NLS-1$
QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
@@ -3454,7 +3450,7 @@
assertEquals("Commands don't match", expectedTransformationSql, transCommand.toString()); //$NON-NLS-1$
}
- public void testProcParamComparison_defect13653() {
+ @Test public void testProcParamComparison_defect13653() {
String userSql = "SELECT * FROM (EXEC mmspTest1.MMSP5('a')) AS a, (EXEC mmsptest1.mmsp6('b')) AS b"; //$NON-NLS-1$
QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
@@ -3484,12 +3480,12 @@
assertTrue("Params should be not equal", ! params[0].equals(params[1])); //$NON-NLS-1$
}
- public void testXpathValueValid_defect15088() {
+ @Test public void testXpathValueValid_defect15088() {
String userSql = "SELECT xpathValue('<?xml version=\"1.0\" encoding=\"utf-8\" ?><a><b><c>test</c></b></a>', 'a/b/c')"; //$NON-NLS-1$
helpResolve(userSql, FakeMetadataFactory.exampleBQTCached(), AnalysisRecord.createNonRecordingRecord());
}
- public void testXpathValueInvalid_defect15088() throws Exception {
+ @Test public void testXpathValueInvalid_defect15088() throws Exception {
String userSql = "SELECT xpathValue('<?xml version=\"1.0\" encoding=\"utf-8\" ?><a><b><c>test</c></b></a>', '//*[local-name()=''bookName\"]')"; //$NON-NLS-1$
Command command = helpParse(userSql);
@@ -3501,7 +3497,7 @@
}
}
- public void testNullConstantInSelect() throws Exception {
+ @Test public void testNullConstantInSelect() throws Exception {
String userSql = "SELECT null as x"; //$NON-NLS-1$
Query query = (Query)helpParse(userSql);
@@ -3513,7 +3509,7 @@
assertEquals(DataTypeManager.DefaultDataClasses.STRING, symbol.getType());
}
- public void test11716() throws Exception {
+ @Test public void test11716() throws Exception {
String sql = "SELECT e1 FROM pm1.g1 where e1='1'"; //$NON-NLS-1$
Map externalMetadata = new HashMap();
GroupSymbol inputSet = new GroupSymbol("INPUT"); //$NON-NLS-1$
@@ -3527,7 +3523,7 @@
assertFalse(groups.contains(inputSet));
}
- public void testDefect15872() throws Exception {
+ @Test public void testDefect15872() throws Exception {
String sql = "CREATE VIRTUAL PROCEDURE " //$NON-NLS-1$
+ "BEGIN " //$NON-NLS-1$
+"SELECT * FROM pm1.g1 where model.table.param=e1; " //$NON-NLS-1$
@@ -3547,21 +3543,21 @@
assertNotNull("Input parameter does not have group", inElement.getGroupSymbol()); //$NON-NLS-1$
}
- public void testDefect16894_resolverException_1() {
+ @Test public void testDefect16894_resolverException_1() {
helpResolve("SELECT * FROM (SELECT * FROM Pm1.g1 AS Y) AS X"); //$NON-NLS-1$
}
- public void testDefect16894_resolverException_2() {
+ @Test public void testDefect16894_resolverException_2() {
helpResolve("SELECT * FROM (SELECT * FROM Pm1.g1) AS X"); //$NON-NLS-1$
}
- public void testDefect17385() throws Exception{
+ @Test public void testDefect17385() throws Exception{
String sql = "select e1 as x ORDER BY x"; //$NON-NLS-1$
helpResolveException(sql);
}
// Not support XML query as subquery
-// public void testDefect17743() {
+// @Test public void testDefect17743() {
// CompareCriteria expected = new CompareCriteria();
// ElementSymbol es = new ElementSymbol("node1"); //$NON-NLS-1$
// GroupSymbol gs = new GroupSymbol("doc1"); //$NON-NLS-1$
@@ -3576,12 +3572,12 @@
// }
- public void testValidFullElementNotInQueryGroups() {
+ @Test public void testValidFullElementNotInQueryGroups() {
helpResolveException("select pm1.g1.e1 FROM pm1.g1 g"); //$NON-NLS-1$
}
- public void testUnionInSubquery() {
+ @Test public void testUnionInSubquery() {
String sql = "SELECT StringKey FROM (SELECT BQT2.SmallB.StringKey FROM BQT2.SmallB union SELECT convert(BQT2.SmallB.FloatNum, string) FROM BQT2.SmallB) x"; //$NON-NLS-1$
// parse
@@ -3600,17 +3596,17 @@
}
}
- public void testCommandUpdatingCount1() throws Exception{
+ @Test public void testCommandUpdatingCount1() throws Exception{
Command command = helpResolve("SELECT * FROM pm1.g1 as x, pm1.g1 as y"); //$NON-NLS-1$
assertEquals(0, command.updatingModelCount(metadata));
}
- public void testCommandUpdatingCount2() throws Exception{
+ @Test public void testCommandUpdatingCount2() throws Exception{
Command command = helpResolve("SELECT * FROM doc1"); //$NON-NLS-1$
assertEquals(0, command.updatingModelCount(metadata));
}
- public void testCommandUpdating3() throws Exception{
+ @Test public void testCommandUpdating3() throws Exception{
StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
.append("BEGIN\n") //$NON-NLS-1$
.append("INSERT INTO pm1.g1 (e1) VALUES (input.e1);\n") //$NON-NLS-1$
@@ -3624,12 +3620,12 @@
assertEquals(2, command.updatingModelCount(metadata));
}
- public void testCommandUpdatingCount5() throws Exception{
+ @Test public void testCommandUpdatingCount5() throws Exception{
Command command = helpResolve("SELECT pm1.g1.e1 FROM pm1.g1 UNION SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY e1"); //$NON-NLS-1$
assertEquals(0, command.updatingModelCount(metadata));
}
- public void testCommandUpdatingCount6() throws Exception{
+ @Test public void testCommandUpdatingCount6() throws Exception{
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "if(INPUT.e1 = 10)\n"; //$NON-NLS-1$
@@ -3646,54 +3642,54 @@
}
/** case 3955 */
- public void testCommandUpdatingCountPhysicalInsert() throws Exception{
+ @Test public void testCommandUpdatingCountPhysicalInsert() throws Exception{
Command command = helpResolve("INSERT INTO pm1.g1 (e2) VALUES (666) "); //$NON-NLS-1$
assertEquals(1, command.updatingModelCount(metadata));
}
/** case 3955 */
- public void testCommandUpdatingCountVirtualInsert() throws Exception{
+ @Test public void testCommandUpdatingCountVirtualInsert() throws Exception{
Command command = helpResolve("INSERT INTO vm1.g1 (e2) VALUES (666) "); //$NON-NLS-1$
assertEquals(2, command.updatingModelCount(metadata));
}
/** case 3955 */
- public void testCommandUpdatingCountPhysicalUpdate() throws Exception{
+ @Test public void testCommandUpdatingCountPhysicalUpdate() throws Exception{
Command command = helpResolve("UPDATE pm1.g1 SET e2=667 WHERE e2=666"); //$NON-NLS-1$
assertEquals(1, command.updatingModelCount(metadata));
}
/** case 3955 */
- public void testCommandUpdatingCountVirtualUpdate() throws Exception{
+ @Test public void testCommandUpdatingCountVirtualUpdate() throws Exception{
Command command = helpResolve("UPDATE vm1.g1 SET e2=667 WHERE e2=666"); //$NON-NLS-1$
assertEquals(2, command.updatingModelCount(metadata));
}
/** case 3955 */
- public void testCommandUpdatingCountPhysicalDelete() throws Exception{
+ @Test public void testCommandUpdatingCountPhysicalDelete() throws Exception{
Command command = helpResolve("DELETE FROM pm1.g1 WHERE e2 = 666 "); //$NON-NLS-1$
assertEquals(1, command.updatingModelCount(metadata));
}
/** case 3955 */
- public void testCommandUpdatingCountVirtualDelete() throws Exception{
+ @Test public void testCommandUpdatingCountVirtualDelete() throws Exception{
Command command = helpResolve("DELETE FROM vm1.g37 WHERE e2 = 666 "); //$NON-NLS-1$
assertEquals(2, command.updatingModelCount(metadata));
}
- public void testCommandUpdatingCountEmbeddedExecs() throws Exception {
+ @Test public void testCommandUpdatingCountEmbeddedExecs() throws Exception {
Command command = helpResolve("SELECT * FROM pm1.g1 WHERE e1 IN ((select e1 from (EXEC pm1.sp1()) x), (select e1 from (EXEC pm1.sp2(1)) x))"); //$NON-NLS-1$
assertEquals(2, command.updatingModelCount(new TempMetadataAdapter(metadata, new TempMetadataStore())));
}
- public void testCommandUpdatingCountEmbeddedExec() throws Exception {
+ @Test public void testCommandUpdatingCountEmbeddedExec() throws Exception {
Command command = helpResolve("SELECT * FROM pm1.g1 WHERE e1 IN (select e1 from (EXEC pm1.sp1()) x)"); //$NON-NLS-1$
assertEquals(2, command.updatingModelCount(new TempMetadataAdapter(metadata, new TempMetadataStore())));
}
- public void testCommandUpdatingCountFromLastStatement() throws Exception {
+ @Test public void testCommandUpdatingCountFromLastStatement() throws Exception {
String procedure = "CREATE VIRTUAL PROCEDURE \n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "declare integer x = convert(pm1.sq1.in, integer) + 5;\n"; //$NON-NLS-1$
@@ -3706,7 +3702,7 @@
assertEquals(1, command.updatingModelCount(new TempMetadataAdapter(metadata, new TempMetadataStore())));
}
- public void testCommandUpdatingCountFromMetadata() throws Exception {
+ @Test public void testCommandUpdatingCountFromMetadata() throws Exception {
FakeMetadataFacade metadata = FakeMetadataFactory.example1();
FakeMetadataObject proc = metadata.getStore().findObject("pm1.sp1", FakeMetadataObject.PROCEDURE); //$NON-NLS-1$
proc.putProperty(FakeMetadataObject.Props.UPDATE_COUNT, new Integer(0));
@@ -3724,23 +3720,23 @@
assertEquals(0, command.updatingModelCount(metadata));
}
- public void testParameterError() throws Exception {
+ @Test public void testParameterError() throws Exception {
helpResolveException("EXEC pm1.sp2(1, 2)", metadata, "Error Code:ERR.015.008.0007 Message:Incorrect number of parameters specified on the stored procedure pm1.sp2 - expected 1 but got 2"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testUnionOfAliasedLiteralsGetsModified() {
+ @Test public void testUnionOfAliasedLiteralsGetsModified() {
String sql = "SELECT 5 AS x UNION ALL SELECT 10 AS x"; //$NON-NLS-1$
Command c = helpResolve(sql);
assertEquals(sql, c.toString());
}
- public void testXMLWithProcSubquery() {
+ @Test public void testXMLWithProcSubquery() {
String sql = "SELECT * FROM xmltest.doc4 WHERE node2 IN (SELECT e1 FROM (EXEC pm1.vsp1()) AS x)"; //$NON-NLS-1$
Command c = helpResolve(sql);
assertEquals(sql, c.toString());
}
- public void testDefect18832() {
+ @Test public void testDefect18832() {
String sql = "SELECT * from (SELECT null as a, e1 FROM pm1.g1) b"; //$NON-NLS-1$
Command c = helpResolve(sql);
List projectedSymbols = c.getProjectedSymbols();
@@ -3750,7 +3746,7 @@
}
}
- public void testDefect18832_2() {
+ @Test public void testDefect18832_2() {
String sql = "SELECT a.*, b.* from (SELECT null as a, e1 FROM pm1.g1) a, (SELECT e1 FROM pm1.g1) b"; //$NON-NLS-1$
Command c = helpResolve(sql);
List projectedSymbols = c.getProjectedSymbols();
@@ -3760,12 +3756,12 @@
}
}
- public void testDefect20113() {
+ @Test public void testDefect20113() {
String sql = "SELECT g1.* from pm1.g1"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testDefect20113_2() {
+ @Test public void testDefect20113_2() {
String sql = "SELECT g7.* from g7"; //$NON-NLS-1$
helpResolve(sql);
}
@@ -3777,7 +3773,7 @@
}
}
- public void testNestedInlineViews() throws Exception {
+ @Test public void testNestedInlineViews() throws Exception {
String sql = "SELECT * FROM (SELECT * FROM (SELECT * FROM pm1.g1) AS Y) AS X"; //$NON-NLS-1$
Command c = helpResolve(sql);
assertEquals(sql, c.toString());
@@ -3785,7 +3781,7 @@
verifyProjectedTypes(c, new Class[] { String.class, Integer.class, Boolean.class, Double.class });
}
- public void testNestedInlineViewsNoStar() throws Exception {
+ @Test public void testNestedInlineViewsNoStar() throws Exception {
String sql = "SELECT e1 FROM (SELECT e1 FROM (SELECT e1 FROM pm1.g1) AS Y) AS X"; //$NON-NLS-1$
Command c = helpResolve(sql);
assertEquals(sql, c.toString());
@@ -3793,14 +3789,14 @@
verifyProjectedTypes(c, new Class[] { String.class });
}
- public void testNestedInlineViewsCount() throws Exception {
+ @Test public void testNestedInlineViewsCount() throws Exception {
String sql = "SELECT COUNT(*) FROM (SELECT * FROM (SELECT * FROM pm1.g1) AS Y) AS X"; //$NON-NLS-1$
Command c = helpResolve(sql);
assertEquals(sql, c.toString());
verifyProjectedTypes(c, new Class[] { Integer.class });
}
- public void testAggOverInlineView() throws Exception {
+ @Test public void testAggOverInlineView() throws Exception {
String sql = "SELECT SUM(x) FROM (SELECT (e2 + 1) AS x FROM pm1.g1) AS g"; //$NON-NLS-1$
Command c = helpResolve(sql);
assertEquals(sql, c.toString());
@@ -3808,7 +3804,7 @@
}
- public void testCaseOverInlineView() throws Exception {
+ @Test public void testCaseOverInlineView() throws Exception {
String sql = "SELECT CASE WHEN x > 0 THEN 1.0 ELSE 2.0 END FROM (SELECT e2 AS x FROM pm1.g1) AS g"; //$NON-NLS-1$
Command c = helpResolve(sql);
assertEquals(sql, c.toString());
@@ -3817,21 +3813,21 @@
}
//procedure - select * from temp table
- public void testDefect20083_1 (){
+ @Test public void testDefect20083_1 (){
helpResolve("EXEC pm1.vsp56()"); //$NON-NLS-1$
}
//procedure - select * from temp table order by
- public void testDefect20083_2 (){
+ @Test public void testDefect20083_2 (){
helpResolve("EXEC pm1.vsp57()"); //$NON-NLS-1$
}
- public void testTypeConversionOverUnion() throws Exception {
+ @Test public void testTypeConversionOverUnion() throws Exception {
String sql = "SELECT * FROM (SELECT e2, e1 FROM pm1.g1 UNION SELECT convert(e2, string), e1 FROM pm1.g1) FOO where e2/2 = 1"; //$NON-NLS-1$
helpResolveException(sql);
}
- public void testVariableDeclarationAfterStatement() throws Exception{
+ @Test public void testVariableDeclarationAfterStatement() throws Exception{
String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "select * from pm1.g1 where pm1.g1.e1 = VARIABLES.X;\n"; //$NON-NLS-1$
@@ -3845,7 +3841,7 @@
* same as above, but with an xml query
* @throws Exception
*/
- public void testVariableDeclarationAfterStatement1() throws Exception{
+ @Test public void testVariableDeclarationAfterStatement1() throws Exception{
String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "select * from xmltest.doc1 where node1 = VARIABLES.X;\n"; //$NON-NLS-1$
@@ -3855,35 +3851,35 @@
helpResolveException(procedure, "Error Code:ERR.015.008.0019 Message:Unable to resolve element: VARIABLES.X"); //$NON-NLS-1$
}
- public void testCreate() {
+ @Test public void testCreate() {
String sql = "CREATE LOCAL TEMPORARY TABLE temp_table (column1 string)"; //$NON-NLS-1$
Command c = helpResolve(sql);
assertEquals(sql, c.toString());
}
- public void testCreateQualifiedName() {
+ @Test public void testCreateQualifiedName() {
String sql = "CREATE LOCAL TEMPORARY TABLE pm1.g1 (column1 string)"; //$NON-NLS-1$
helpResolveException(sql, "Cannot create temporary table \"pm1.g1\". Local temporary tables must be created with unqualified names."); //$NON-NLS-1$
}
- public void testCreateAlreadyExists() {
+ @Test public void testCreateAlreadyExists() {
String sql = "CREATE LOCAL TEMPORARY TABLE g1 (column1 string)"; //$NON-NLS-1$
helpResolveException(sql, "Cannot create temporary table \"g1\". A table with the same name already exists."); //$NON-NLS-1$
}
- public void testCreateImplicitName() {
+ @Test public void testCreateImplicitName() {
String sql = "CREATE LOCAL TEMPORARY TABLE #g1 (column1 string)"; //$NON-NLS-1$
Command c = helpResolve(sql);
assertEquals(sql, c.toString());
}
- public void testCreateInProc() throws Exception{
+ @Test public void testCreateInProc() throws Exception{
helpResolveException("CREATE VIRTUAL PROCEDURE BEGIN create local temporary table g1(c1 string); end", "Cannot create temporary table \"g1\". A table with the same name already exists.");//$NON-NLS-1$ //$NON-NLS-2$
}
//this was the old virt.agg procedure. It was defined in such a way that relied on the scope leak of #temp
//the exception here is a little weak since there are multiple uses of #temp in the block
- public void testTempTableScope() {
+ @Test public void testTempTableScope() {
String proc = "CREATE VIRTUAL PROCEDURE " //$NON-NLS-1$
+ "BEGIN " //$NON-NLS-1$
+ " DECLARE integer VARIABLES.BITS;" //$NON-NLS-1$
@@ -3902,17 +3898,17 @@
helpResolveException(proc, FakeMetadataFactory.exampleBitwise(), "Group does not exist: #temp"); //$NON-NLS-1$
}
- public void testDrop() {
+ @Test public void testDrop() {
String sql = "DROP TABLE temp_table"; //$NON-NLS-1$
helpResolveException(sql, "Group does not exist: temp_table"); //$NON-NLS-1$
}
- public void testInvalidVirtualProcedure2(){
+ @Test public void testInvalidVirtualProcedure2(){
helpResolveException("EXEC pm1.vsp12()", FakeMetadataFactory.example1Cached(), "Symbol mycursor.e2 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
}
// variable declared is of special type ROWS_RETURNED
- public void testDeclareRowsUpdated() {
+ @Test public void testDeclareRowsUpdated() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer rows_updated;\n"; //$NON-NLS-1$
@@ -3926,7 +3922,7 @@
}
// validating INPUT element assigned
- public void testAssignInput() {
+ @Test public void testAssignInput() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -3941,7 +3937,7 @@
}
// validating CHANGING element assigned
- public void testAssignChanging() {
+ @Test public void testAssignChanging() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -3956,7 +3952,7 @@
}
// variables cannot be used among insert elements
- public void testVariableInInsert() {
+ @Test public void testVariableInInsert() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -3971,7 +3967,7 @@
}
// variables cannot be used among insert elements
- public void testVariableInInsert2() {
+ @Test public void testVariableInInsert2() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -3986,7 +3982,7 @@
}
//should resolve first to the table's column
- public void testVariableInInsert3() {
+ @Test public void testVariableInInsert3() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer e2;\n"; //$NON-NLS-1$
@@ -4000,7 +3996,7 @@
FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
- public void testAmbigousInput() {
+ @Test public void testAmbigousInput() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "select e1;\n"; //$NON-NLS-1$
@@ -4012,7 +4008,7 @@
FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"e1\" is ambiguous, it exists in two or more groups."); //$NON-NLS-1$
}
- public void testLoopRedefinition() {
+ @Test public void testLoopRedefinition() {
StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n declare string var1;") //$NON-NLS-1$
@@ -4031,11 +4027,11 @@
FakeMetadataObject.Props.UPDATE_PROCEDURE, "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$
}
- public void testLoopRedefinition2(){
+ @Test public void testLoopRedefinition2(){
helpResolveException("EXEC pm1.vsp11()", FakeMetadataFactory.example1Cached(), "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testTempGroupElementShouldNotBeResolable() {
+ @Test public void testTempGroupElementShouldNotBeResolable() {
StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n select 1 as a into #temp;") //$NON-NLS-1$
@@ -4048,7 +4044,7 @@
FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
}
- public void testTempGroupElementShouldNotBeResolable1() {
+ @Test public void testTempGroupElementShouldNotBeResolable1() {
StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n select 1 as a into #temp;") //$NON-NLS-1$
@@ -4061,7 +4057,7 @@
FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
}
- public void testVariableResolutionWithIntervening() {
+ @Test public void testVariableResolutionWithIntervening() {
StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n declare string x;") //$NON-NLS-1$
@@ -4073,7 +4069,7 @@
helpResolve(proc.toString());
}
- public void testProcedureScoping() {
+ @Test public void testProcedureScoping() {
StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
//note that this declare takes presedense over the proc INPUT.e1 and CHANGING.e1 variables
@@ -4106,7 +4102,7 @@
assertEquals("LOOPCURSOR", value.getGroupSymbol().getCanonicalName()); //$NON-NLS-1$
}
- public void testResolveUnqualifiedCriteria() throws Exception{
+ @Test public void testResolveUnqualifiedCriteria() throws Exception{
Criteria criteria = QueryParser.getQueryParser().parseCriteria("e1 = 1"); //$NON-NLS-1$
// resolve
@@ -4118,13 +4114,13 @@
}
}
- public void testSameNameRoot() {
+ @Test public void testSameNameRoot() {
String sql = "select p.e1 from pm1.g1 as pp, pm1.g1 as p"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testDefect23342() throws Exception {
+ @Test public void testDefect23342() throws Exception {
String sql = "CREATE VIRTUAL PROCEDURE " //$NON-NLS-1$
+ "BEGIN " //$NON-NLS-1$
+ "IF (param = '1')" //$NON-NLS-1$
@@ -4143,7 +4139,7 @@
QueryResolver.resolveCommand(command, externalMetadata, false, metadata, AnalysisRecord.createNonRecordingRecord());
}
- public void testProcedureCreate() {
+ @Test public void testProcedureCreate() {
StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n create local temporary table t1 (e1 string);") //$NON-NLS-1$
@@ -4160,7 +4156,7 @@
/**
* it is not ok to redefine the loopCursor
*/
- public void testProcedureCreate1() {
+ @Test public void testProcedureCreate1() {
StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
@@ -4174,7 +4170,7 @@
helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Cannot create temporary table \"loopCursor\". A table with the same name already exists."); //$NON-NLS-1$
}
- public void testProcedureCreateDrop() {
+ @Test public void testProcedureCreateDrop() {
StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n drop table t1;") //$NON-NLS-1$
@@ -4186,7 +4182,7 @@
helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: t1"); //$NON-NLS-1$
}
- public void testProcedureCreateDrop1() {
+ @Test public void testProcedureCreateDrop1() {
StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n create local temporary table t1 (e1 string);") //$NON-NLS-1$
@@ -4198,7 +4194,7 @@
helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
- public void testBatchedUpdateResolver() throws Exception {
+ @Test public void testBatchedUpdateResolver() throws Exception {
String update1 = "update pm1.g1 set e1 =1"; //$NON-NLS-1$
String update2 = "update pm2.g1 set e1 =1"; //$NON-NLS-1$
@@ -4210,12 +4206,12 @@
helpResolve(command);
}
- public void testAmbiguousAllInGroup() {
+ @Test public void testAmbiguousAllInGroup() {
String sql = "SELECT g1.* from pm1.g1, pm2.g1"; //$NON-NLS-1$
helpResolveException(sql, metadata, "The symbol g1.* refers to more than one group defined in the FROM clause."); //$NON-NLS-1$
}
- public void testRowsUpdatedInProcedure(){
+ @Test public void testRowsUpdatedInProcedure(){
String sql = "CREATE VIRTUAL PROCEDURE " //$NON-NLS-1$
+ "BEGIN " //$NON-NLS-1$
+"SELECT ROWS_UPDATED; " //$NON-NLS-1$
@@ -4224,7 +4220,7 @@
helpResolveException(sql, metadata, "Element \"ROWS_UPDATED\" is not defined by any relevant group."); //$NON-NLS-1$
}
- public void testXMLQueryWithVariable() {
+ @Test public void testXMLQueryWithVariable() {
String sql = "CREATE VIRTUAL PROCEDURE " //$NON-NLS-1$
+ "BEGIN " //$NON-NLS-1$
+ "declare string x = '1'; " //$NON-NLS-1$
@@ -4243,7 +4239,7 @@
/**
* We could check to see if the expressions are evaluatable to a constant, but that seems unnecessary
*/
- public void testLookupWithoutConstant() throws Exception{
+ @Test public void testLookupWithoutConstant() throws Exception{
String sql = "SELECT lookup('pm1.g1', convert('e3', float), 'e2', e2) FROM pm1.g1"; //$NON-NLS-1$
helpResolveException(sql, metadata, "Error Code:ERR.015.008.0063 Message:The first three arguments for the LOOKUP function must be specified as constants."); //$NON-NLS-1$
@@ -4252,19 +4248,19 @@
/**
* We cannot implicitly convert the argument to double due to lack of precision
*/
- public void testPowerWithBigInteger_Fails() throws Exception {
+ @Test public void testPowerWithBigInteger_Fails() throws Exception {
String sql = "SELECT power(10, 999999999999999999999999999999999999999999999)"; //$NON-NLS-1$
helpResolveException(sql);
}
- public void testPowerWithLong_Fails() throws Exception {
+ @Test public void testPowerWithLong_Fails() throws Exception {
String sql = "SELECT power(10, 999999999999)"; //$NON-NLS-1$
helpResolveException(sql);
}
- public void testCreateAfterImplicitTempTable() {
+ @Test public void testCreateAfterImplicitTempTable() {
StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n select e1 into #temp from pm1.g1;") //$NON-NLS-1$
@@ -4276,7 +4272,7 @@
helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
- public void testInsertAfterCreate() {
+ @Test public void testInsertAfterCreate() {
StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n create local temporary table #temp (e1 string, e2 string);") //$NON-NLS-1$
@@ -4288,25 +4284,25 @@
helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
- public void testUpdateError() {
+ @Test public void testUpdateError() {
String userUpdateStr = "UPDATE vm1.g2 SET e1='x'"; //$NON-NLS-1$
helpResolveException(userUpdateStr, metadata, "Error Code:ERR.015.008.0009 Message:Update is not allowed on the virtual group vm1.g2: no Update procedure was defined."); //$NON-NLS-1$
}
- public void testInsertError() {
+ @Test public void testInsertError() {
String userUpdateStr = "INSERT into vm1.g2 (e1) values ('x')"; //$NON-NLS-1$
helpResolveException(userUpdateStr, metadata, "Error Code:ERR.015.008.0009 Message:Insert is not allowed on the virtual group vm1.g2: no Insert procedure was defined."); //$NON-NLS-1$
}
- public void testDeleteError() {
+ @Test public void testDeleteError() {
String userUpdateStr = "DELETE from vm1.g2 where e1='x'"; //$NON-NLS-1$
helpResolveException(userUpdateStr, metadata, "Error Code:ERR.015.008.0009 Message:Delete is not allowed on the virtual group vm1.g2: no Delete procedure was defined."); //$NON-NLS-1$
}
- public void testResolveXMLSelect() {
+ @Test public void testResolveXMLSelect() {
String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE string VARIABLES.X = 1;\n"; //$NON-NLS-1$
@@ -4316,13 +4312,13 @@
helpResolveException(procedure, "Error Code:ERR.015.008.0019 Message:Unable to resolve element: VARIABLES.X"); //$NON-NLS-1$
}
- public void testXMLJoinFail() {
+ @Test public void testXMLJoinFail() {
String query = "select * from xmltest.doc1, xmltest.doc1"; //$NON-NLS-1$
helpResolveException(query, "Error Code:ERR.015.008.0003 Message:Only one XML document may be specified in the FROM clause of a query."); //$NON-NLS-1$
}
- public void testExecProjectedSymbols() {
+ @Test public void testExecProjectedSymbols() {
String query = "exec pm1.sq1()"; //$NON-NLS-1$
StoredProcedure proc = (StoredProcedure)helpResolve(query);
@@ -4337,7 +4333,7 @@
}
}
- public void testExecWithDuplicateNames() {
+ @Test public void testExecWithDuplicateNames() {
FakeMetadataFacade metadata = FakeMetadataFactory.example1();
FakeMetadataStore store = metadata.getStore();
@@ -4356,48 +4352,48 @@
helpResolveException("select * from pm1.sq2", metadata, "Cannot access procedure pm1.sq2 using table semantics since the parameter and result set column names are not all unique."); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testInlineViewNullLiteralInUnion() {
+ @Test public void testInlineViewNullLiteralInUnion() {
String sql = "select e2 from pm1.g1 union all (select x from (select null as x) y)"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testSelectIntoWithDuplicateNames() {
+ @Test public void testSelectIntoWithDuplicateNames() {
String sql = "select 1 as x, 2 as x into #temp"; //$NON-NLS-1$
helpResolveException(sql, "Cannot create group '#temp' with multiple columns named 'x'"); //$NON-NLS-1$
}
- public void testCreateWithDuplicateNames() {
+ @Test public void testCreateWithDuplicateNames() {
String sql = "CREATE LOCAL TEMPORARY TABLE temp_table (column1 string, column1 string)"; //$NON-NLS-1$
helpResolveException(sql, "Cannot create group \'temp_table\' with multiple columns named \'column1\'"); //$NON-NLS-1$
}
- public void testValidateScalarSubqueryTooManyColumns() {
+ @Test public void testValidateScalarSubqueryTooManyColumns() {
helpResolveException("SELECT e2, (SELECT e1, e2 FROM pm1.g1 WHERE e2 = '3') FROM pm1.g2", "There must be exactly one projected symbol of the subquery: (SELECT e1, e2 FROM pm1.g1 WHERE e2 = '3')"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testXMLQuery4() {
+ @Test public void testXMLQuery4() {
helpResolveException("SELECT * FROM xmltest.doc1 group by a2", "Queries against XML documents can not have a GROUP By clause"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testXMLQuery5() {
+ @Test public void testXMLQuery5() {
helpResolveException("SELECT * FROM xmltest.doc1 having a2='x'", "Queries against XML documents can not have a HAVING clause"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testSelectIntoWithOrderBy() {
+ @Test public void testSelectIntoWithOrderBy() {
String sql = "select e1, e2 into #temp from pm1.g1 order by e1 limit 10"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testUnionBranchesWithDifferentElementCounts() {
+ @Test public void testUnionBranchesWithDifferentElementCounts() {
helpResolveException("SELECT e2, e3 FROM pm1.g1 UNION SELECT e2 FROM pm1.g2","Queries combined with the set operator UNION must have the same number of output elements."); //$NON-NLS-1$ //$NON-NLS-2$
helpResolveException("SELECT e2 FROM pm1.g1 UNION SELECT e2, e3 FROM pm1.g2","Queries combined with the set operator UNION must have the same number of output elements."); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testSelectIntoWithNullLiteral() {
+ @Test public void testSelectIntoWithNullLiteral() {
String sql = "select null as x into #temp from pm1.g1"; //$NON-NLS-1$
Query query = (Query)helpResolve(sql);
@@ -4409,7 +4405,7 @@
assertEquals(DataTypeManager.DefaultDataClasses.STRING, id.getType());
}
- public void testInsertWithNullLiteral() {
+ @Test public void testInsertWithNullLiteral() {
String sql = "insert into #temp (x) values (null)"; //$NON-NLS-1$
Insert insert = (Insert)helpResolve(sql);
@@ -4421,25 +4417,25 @@
assertEquals(DataTypeManager.DefaultDataClasses.STRING, id.getType());
}
- public void testInsertWithoutColumnsFails() {
+ @Test public void testInsertWithoutColumnsFails() {
String sql = "Insert into pm1.g1 values (1, 2)"; //$NON-NLS-1$
helpResolveException(sql, "Error Code:ERR.015.008.0010 Message:INSERT statement must have the same number of elements and values specified. This statement has 4 elements and 2 values."); //$NON-NLS-1$
}
- public void testInsertWithoutColumnsFails1() {
+ @Test public void testInsertWithoutColumnsFails1() {
String sql = "Insert into pm1.g1 values (1, 2, 3, 4)"; //$NON-NLS-1$
helpResolveException(sql, "Error Code:ERR.015.008.0041 Message:Expected value of type 'boolean' but '3' is of type 'integer' and no implicit conversion is available."); //$NON-NLS-1$
}
- public void testInsertWithQueryFails() {
+ @Test public void testInsertWithQueryFails() {
String sql = "Insert into pm1.g1 select 1, 2, 3, 4"; //$NON-NLS-1$
helpResolveException(sql, "Cannot convert insert query expression projected symbol '3' of type java.lang.Integer to insert column 'pm1.g1.e3' of type java.lang.Boolean"); //$NON-NLS-1$
}
- public void testInsertWithoutColumnsPasses() {
+ @Test public void testInsertWithoutColumnsPasses() {
String sql = "Insert into pm1.g1 values (1, 2, true, 4)"; //$NON-NLS-1$
helpResolve(sql);
@@ -4447,14 +4443,14 @@
assertEquals(4, command.getVariables().size());
}
- public void testInsertWithoutColumnsUndefinedTemp() {
+ @Test public void testInsertWithoutColumnsUndefinedTemp() {
String sql = "Insert into #temp values (1, 2)"; //$NON-NLS-1$
Insert command = (Insert)helpResolve(sql);
assertEquals(2, command.getVariables().size());
}
- public void testImplicitTempInsertWithNoColumns() {
+ @Test public void testImplicitTempInsertWithNoColumns() {
StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n create local temporary table #matt (x integer);") //$NON-NLS-1$
@@ -4465,46 +4461,38 @@
String sExpected = "CREATE VIRTUAL PROCEDURE\nBEGIN\nCREATE LOCAL TEMPORARY TABLE #matt (x integer);\nINSERT INTO #matt (#MATT.X) VALUES (1);\nEND\n\tCREATE LOCAL TEMPORARY TABLE #matt (x integer)\n\tINSERT INTO #matt (#MATT.X) VALUES (1)\n"; //$NON-NLS-1$
String sActual = cmd.printCommandTree();
- Assert.assertEquals( sExpected, sActual );
+ assertEquals( sExpected, sActual );
}
- public void testCase6319() throws QueryResolverException, MetaMatrixComponentException {
+ @Test public void testCase6319() throws QueryResolverException, MetaMatrixComponentException {
String sql = "select floatnum from bqt1.smalla group by floatnum having sum(floatnum) between 51.0 and 100.0 "; //$NON-NLS-1$
Query query = (Query)helpParse(sql);
QueryResolver.resolveCommand(query, FakeMetadataFactory.exampleBQTCached());
}
- public void testUniqeNamesWithInlineView() {
+ @Test public void testUniqeNamesWithInlineView() {
helpResolveException("select * from (select count(intNum) a, count(stringKey) b, bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intkey) q1 order by q1.a", FakeMetadataFactory.exampleBQTCached(), "Cannot create group 'q1' with multiple columns named 'b'"); //$NON-NLS-1$ //$NON-NLS-2$
}
-
- public void testNumberedOrderBy1_4_fails() throws Exception {
- helpResolveException("SELECT pm1.g1.e1 as a, avg(e2) as a FROM pm1.g1 ORDER BY 1", "Error Code:ERR.015.008.0042 Message:Element 'a' in ORDER BY is ambiguous and may refer to more than one element of SELECT clause."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testNumberedOrderBy6_fails() throws Exception {
- helpResolveException("SELECT a.e1, b.e1 FROM pm1.g1 AS a, pm1.g1 AS b ORDER BY 2", "Error Code:ERR.015.008.0042 Message:Element 'e1' in ORDER BY is ambiguous and may refer to more than one element of SELECT clause."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testResolveOldProcRelational() {
+
+ @Test public void testResolveOldProcRelational() {
helpResolveException("SELECT * FROM pm1.g1, (exec pm1.sq2(pm1.g1.e1)) as a", "Symbol pm1.g1.e1 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testResolverOrderOfPrecedence() {
+ @Test public void testResolverOrderOfPrecedence() {
helpResolveException("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 CROSS JOIN (pm1.g2 LEFT OUTER JOIN pm2.g1 on pm1.g1.e1 = pm2.g1.e1)", "Symbol pm1.g1.e1 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* The cross join should parse/resolve with higher precedence
*/
- public void testResolverOrderOfPrecedence_1() {
+ @Test public void testResolverOrderOfPrecedence_1() {
helpResolve("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 CROSS JOIN pm1.g2 LEFT OUTER JOIN pm2.g1 on pm1.g1.e1 = pm2.g1.e1"); //$NON-NLS-1$
}
/**
* should be the same as exec with too many params
*/
- public void testCallableStatementTooManyParameters() throws Exception {
+ @Test public void testCallableStatementTooManyParameters() throws Exception {
String sql = "{call pm4.spTest9(?, ?)}"; //$NON-NLS-1$
TestResolver.helpResolveException(sql, FakeMetadataFactory.exampleBQTCached(), "Error Code:ERR.015.008.0007 Message:Incorrect number of parameters specified on the stored procedure pm4.spTest9 - expected 1 but got 2"); //$NON-NLS-1$
@@ -4513,7 +4501,7 @@
/**
* delete procedures should not reference input or changing vars.
*/
- public void testDefect16451() {
+ @Test public void testDefect16451() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure += "BEGIN\n"; //$NON-NLS-1$
procedure += "Select pm1.g1.e2 from pm1.g1 where e1 = input.e1;\n"; //$NON-NLS-1$
@@ -4526,13 +4514,13 @@
FakeMetadataObject.Props.DELETE_PROCEDURE, "Symbol input.e1 is specified with an unknown group context"); //$NON-NLS-1$
}
- public void testInvalidVirtualProcedure3() throws Exception {
+ @Test public void testInvalidVirtualProcedure3() throws Exception {
helpResolveException("EXEC pm1.vsp18()", "Group does not exist: temptable"); //$NON-NLS-1$ //$NON-NLS-2$
}
// variable resolution, variable comapred against
// differrent datatype element for which there is no implicit transformation)
- public void testCreateUpdateProcedure2() {
+ @Test public void testCreateUpdateProcedure2() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure += "BEGIN\n"; //$NON-NLS-1$
procedure += "DECLARE boolean var1;\n"; //$NON-NLS-1$
@@ -4546,7 +4534,7 @@
}
// special variable INPUT compared against invalid type
- public void testInvalidInputInUpdate() {
+ @Test public void testInvalidInputInUpdate() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure += "BEGIN\n"; //$NON-NLS-1$
procedure += "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -4560,7 +4548,7 @@
FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e2' with expected type integer to expression 'INPUT.e1'"); //$NON-NLS-1$
}
- public void testUpdateSetClauseReferenceType() {
+ @Test public void testUpdateSetClauseReferenceType() {
String sql = "UPDATE pm1.g1 SET pm1.g1.e1 = 1, pm1.g1.e2 = ?;"; //$NON-NLS-1$
Update update = (Update)helpResolve(sql, FakeMetadataFactory.example1Cached(), null);
@@ -4570,40 +4558,40 @@
assertNotNull(ref.getType());
}
- public void testNoTypeCriteria() {
+ @Test public void testNoTypeCriteria() {
String sql = "select * from pm1.g1 where ? = ?"; //$NON-NLS-1$
helpResolveException(sql, FakeMetadataFactory.example1Cached(), "Error Code:ERR.015.008.0026 Message:Expression '? = ?' has a parameter with non-determinable type information. The use of an explicit convert may be necessary."); //$NON-NLS-1$
}
- public void testReferenceInSelect() {
+ @Test public void testReferenceInSelect() {
String sql = "select ?, e1 from pm1.g1"; //$NON-NLS-1$
Query command = (Query)helpResolve(sql, FakeMetadataFactory.example1Cached(), null);
assertEquals(DataTypeManager.DefaultDataClasses.STRING, ((SingleElementSymbol)command.getProjectedSymbols().get(0)).getType());
}
- public void testReferenceInSelect1() {
+ @Test public void testReferenceInSelect1() {
String sql = "select convert(?, integer), e1 from pm1.g1"; //$NON-NLS-1$
Query command = (Query)helpResolve(sql, FakeMetadataFactory.example1Cached(), null);
assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, ((SingleElementSymbol)command.getProjectedSymbols().get(0)).getType());
}
- public void testUnionWithObjectTypeConversion() {
+ @Test public void testUnionWithObjectTypeConversion() {
String sql = "select convert(null, xml) from pm1.g1 union all select 1"; //$NON-NLS-1$
SetQuery query = (SetQuery)helpResolve(sql, FakeMetadataFactory.example1Cached(), null);
assertEquals(DataTypeManager.DefaultDataClasses.OBJECT, ((SingleElementSymbol)query.getProjectedSymbols().get(0)).getType());
}
- public void testUnionWithSubQuery() {
+ @Test public void testUnionWithSubQuery() {
String sql = "select 1 from pm1.g1 where exists (select 1) union select 2"; //$NON-NLS-1$
SetQuery command = (SetQuery)helpResolve(sql);
assertEquals(1, command.getSubCommands().size());
}
- public void testOrderBy_J658a() {
+ @Test public void testOrderBy_J658a() {
Query resolvedQuery = (Query) helpResolve("SELECT pm1.g1.e1, e2, e3 as x, (5+2) as y FROM pm1.g1 ORDER BY e3"); //$NON-NLS-1$
OrderBy orderBy = resolvedQuery.getOrderBy();
int[] expectedPositions = new int[] {2};
@@ -4613,30 +4601,28 @@
private void helpTestOrderBy(OrderBy orderBy, int[] expectedPositions) {
assertEquals(expectedPositions.length, orderBy.getVariableCount());
for (int i = 0; i < expectedPositions.length; i++) {
- ElementSymbol symbol = (ElementSymbol)orderBy.getVariable(i);
- TempMetadataID tid = (TempMetadataID)symbol.getMetadataID();
- assertEquals(expectedPositions[i], tid.getPosition());
+ assertEquals(expectedPositions[i], orderBy.getExpressionPosition(i));
}
}
- public void testOrderBy_J658b() {
+ @Test public void testOrderBy_J658b() {
Query resolvedQuery = (Query) helpResolve("SELECT pm1.g1.e1, e2, e3 as x, (5+2) as y FROM pm1.g1 ORDER BY e2, e3 "); //$NON-NLS-1$
helpTestOrderBy(resolvedQuery.getOrderBy(), new int[] {1, 2});
}
- public void testOrderBy_J658c() {
+ @Test public void testOrderBy_J658c() {
Query resolvedQuery = (Query) helpResolve("SELECT pm1.g1.e1, e2 as x, e3 as y FROM pm1.g1 ORDER BY x, e3 "); //$NON-NLS-1$
helpTestOrderBy(resolvedQuery.getOrderBy(), new int[] {1, 2});
}
// ambiguous, should fail
- public void testOrderBy_J658d() {
+ @Test public void testOrderBy_J658d() {
helpResolveException("SELECT pm1.g1.e1, e2 as x, e3 as x FROM pm1.g1 ORDER BY x, e1 ", "Error Code:ERR.015.008.0042 Message:Element 'x' in ORDER BY is ambiguous and may refer to more than one element of SELECT clause."); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testOrderBy_J658e() {
+ @Test public void testOrderBy_J658e() {
Query resolvedQuery = (Query) helpResolve("SELECT pm1.g1.e1, e2 as x, e3 as e2 FROM pm1.g1 ORDER BY x, e2 "); //$NON-NLS-1$
helpTestOrderBy(resolvedQuery.getOrderBy(), new int[] {1, 2});
}
- public void testSPOutParamWithExec() {
+ @Test public void testSPOutParamWithExec() {
StoredProcedure proc = (StoredProcedure)helpResolve("exec pm2.spTest8(1)", FakeMetadataFactory.exampleBQTCached(), null);
assertEquals(2, proc.getProjectedSymbols().size());
}
@@ -4645,22 +4631,22 @@
* Note that the call syntax is not quite correct, the output parameter is not in the arg list.
* That hack is handled by the PreparedStatementRequest
*/
- public void testSPOutParamWithCallableStatement() {
+ @Test public void testSPOutParamWithCallableStatement() {
StoredProcedure proc = (StoredProcedure)helpResolve("{call pm2.spTest8(1)}", FakeMetadataFactory.exampleBQTCached(), null);
assertEquals(3, proc.getProjectedSymbols().size());
}
- public void testProcRelationalWithOutParam() {
+ @Test public void testProcRelationalWithOutParam() {
Query proc = (Query)helpResolve("select * from pm2.spTest8 where inkey = 1", FakeMetadataFactory.exampleBQTCached(), null);
assertEquals(3, proc.getProjectedSymbols().size());
}
- public void testSPReturnParamWithNoResultSet() {
+ @Test public void testSPReturnParamWithNoResultSet() {
StoredProcedure proc = (StoredProcedure)helpResolve("exec pm4.spTest9(1)", FakeMetadataFactory.exampleBQTCached(), null);
assertEquals(1, proc.getProjectedSymbols().size());
}
- public void testSecondPassFunctionResolving() {
+ @Test public void testSecondPassFunctionResolving() {
helpResolve("SELECT pm1.g1.e1 FROM pm1.g1 where lower(?) = e1 "); //$NON-NLS-1$
}
@@ -4673,7 +4659,7 @@
* <p>
* SELECT SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END) FROM pm1.g1
*/
- public void testAggregateWithBetweenInCaseInSelect() {
+ @Test public void testAggregateWithBetweenInCaseInSelect() {
String sql = "SELECT SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END) FROM pm1.g1"; //$NON-NLS-1$
helpResolve(sql);
}
@@ -4687,7 +4673,7 @@
* <p>
* SELECT CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END FROM pm1.g1
*/
- public void testBetweenInCaseInSelect() {
+ @Test public void testBetweenInCaseInSelect() {
String sql = "SELECT CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END FROM pm1.g1"; //$NON-NLS-1$
helpResolve(sql);
}
@@ -4701,21 +4687,39 @@
* <p>
* SELECT * FROM pm1.g1 WHERE e3 = CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END
*/
- public void testBetweenInCase() {
+ @Test public void testBetweenInCase() {
String sql = "SELECT * FROM pm1.g1 WHERE e3 = CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END"; //$NON-NLS-1$
helpResolve(sql);
}
- public void testOrderByUnrelated() {
+ @Test public void testOrderByUnrelated() {
helpResolve("SELECT pm1.g1.e1, e2 as x, e3 as y FROM pm1.g1 ORDER BY e4"); //$NON-NLS-1$
}
- public void testOrderByUnrelated1() {
+ @Test public void testOrderByUnrelated1() {
helpResolveException("SELECT distinct pm1.g1.e1, e2 as x, e3 as y FROM pm1.g1 ORDER BY e4"); //$NON-NLS-1$
}
- public void testOrderByUnrelated2() {
+ @Test public void testOrderByUnrelated2() {
helpResolveException("SELECT max(e2) FROM pm1.g1 group by e1 ORDER BY e4"); //$NON-NLS-1$
}
+
+ @Test public void testOrderByExpression() {
+ Query query = (Query)helpResolve("select pm1.g1.e1 from pm1.g1 order by e2 || e3 "); //$NON-NLS-1$
+ assertEquals(-1, query.getOrderBy().getExpressionPosition(0));
+ }
+
+ @Test public void testOrderByExpression1() {
+ Query query = (Query)helpResolve("select pm1.g1.e1 || e2 from pm1.g1 order by pm1.g1.e1 || e2 "); //$NON-NLS-1$
+ assertEquals(0, query.getOrderBy().getExpressionPosition(0));
+ }
+
+ @Test public void testOrderByExpression2() {
+ helpResolveException("select pm1.g1.e1 from pm1.g1 union select pm1.g2.e1 from pm1.g2 order by pm1.g1.e1 || 2", "ORDER BY expression '(pm1.g1.e1 || 2)' cannot be used with a set query."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ @Test public void testOrderByConstantFails() {
+ helpResolveException("select pm1.g1.e1 from pm1.g1 order by 2"); //$NON-NLS-1$
+ }
+
}
\ No newline at end of file
Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -22,11 +22,14 @@
package com.metamatrix.query.rewriter;
+import static com.metamatrix.query.rewriter.TestQueryRewriter.*;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryParserException;
@@ -38,7 +41,6 @@
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.ExpressionSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
@@ -49,7 +51,7 @@
/**
* Converted from older resolver tests
*/
-public class TestOrderByRewrite extends TestCase {
+public class TestOrderByRewrite {
private static Command getCommand(String sql) throws QueryParserException, QueryResolverException, MetaMatrixComponentException, QueryValidatorException {
Command command = QueryParser.getQueryParser().parseCommand(sql);
@@ -84,17 +86,14 @@
int expCount = 0;
for (Iterator i = langObj.getVariables().iterator(); i.hasNext();) {
SingleElementSymbol ses = (SingleElementSymbol)i.next();
- if (ses instanceof AliasSymbol) {
- AliasSymbol aSymbol = (AliasSymbol)ses;
- if (aSymbol.getSymbol() instanceof ExpressionSymbol) {
- assertEquals("Expression Symbols does not match: ", functionsNames[expCount++], aSymbol.getSymbol().toString()); //$NON-NLS-1$
- }
+ if (ses instanceof ExpressionSymbol) {
+ assertEquals("Expression Symbols does not match: ", functionsNames[expCount++], ses.toString()); //$NON-NLS-1$
}
}
assertEquals("Wrong number of Symbols: ", functionsNames.length, expCount); //$NON-NLS-1$
}
- public void testNumberedOrderBy1() throws Exception {
+ @Test public void testNumberedOrderBy1() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT pm1.g1.e1, e2, e3 as x, (5+2) as y FROM pm1.g1 ORDER BY 3, 4, 1, 2"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e3", "pm1.g1.e1", "pm1.g1.e2" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -104,7 +103,7 @@
new String[] {});
}
- public void testNumberedOrderBy1_1() throws Exception {
+ @Test public void testNumberedOrderBy1_1() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT pm1.g1.e1, e2, e3 as x, (5 + e4) FROM pm1.g1 ORDER BY 3, 4, 1, 2"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e3", "pm1.g1.e4", "pm1.g1.e1", "pm1.g1.e2" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -114,7 +113,7 @@
new String[] {"(5.0 + e4)"}); //$NON-NLS-1$
}
- public void testNumberedOrderBy1_2() throws Exception {
+ @Test public void testNumberedOrderBy1_2() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT pm1.g1.e1, e2, concat(e3,'x'), concat(e2, 5) FROM pm1.g1 ORDER BY 3, 4, 1, 2"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e3", "pm1.g1.e2", "pm1.g1.e1", "pm1.g1.e2" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -124,7 +123,7 @@
new String[] {"concat(e3, 'x')", "concat(e2, '5')"}); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testNumberedOrderBy1_3() throws Exception {
+ @Test public void testNumberedOrderBy1_3() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT pm1.g1.e1, avg(e2), e3, concat(e2, 5) FROM pm1.g1 ORDER BY 3, 4, 1, 2"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e3", "pm1.g1.e2", "pm1.g1.e1", "pm1.g1.e2" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -134,7 +133,7 @@
new String[] {"concat(e2, '5')", "AVG(e2)"}); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testNumberedOrderBy1_4() throws Exception {
+ @Test public void testNumberedOrderBy1_4() throws Exception {
String sql = "select e1, (select e2 from pm4.g1) from pm4.g2 X order by 2"; //$NON-NLS-1$
Query resolvedQuery = (Query) getCommand(sql);
@@ -142,140 +141,140 @@
new String[] {"(SELECT e2 FROM pm4.g1)"}); //$NON-NLS-1$
}
- public void testOrderBy1() throws Exception {
+ @Test public void testOrderBy1() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT pm1.g1.e1, e2, e3 as x, (5+2) as y FROM pm1.g1 ORDER BY x, y, pm1.g1.e1, e2"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e3", "pm1.g1.e1", "pm1.g1.e2" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new String[] { "pm1.g1.e3", "pm1.g1.e1", "pm1.g1.e2" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testOrderBy2() throws Exception {
+ @Test public void testOrderBy2() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT * FROM pm1.g1 ORDER BY e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy3() throws Exception {
+ @Test public void testOrderBy3() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT * FROM pm1.g1 ORDER BY pm1.g1.e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy4() throws Exception {
+ @Test public void testOrderBy4() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT e1 FROM pm1.g1 ORDER BY pm1.g1.e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy5() throws Exception {
+ @Test public void testOrderBy5() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT e1 FROM pm1.g1 ORDER BY e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy6() throws Exception {
+ @Test public void testOrderBy6() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT e1 FROM pm1.g1 AS x ORDER BY e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "x.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy7() throws Exception {
+ @Test public void testOrderBy7() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT e1 FROM pm1.g1 AS x ORDER BY x.e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "x.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy8() throws Exception {
+ @Test public void testOrderBy8() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT x.e1 FROM pm1.g1 AS x ORDER BY e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "x.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy9() throws Exception {
+ @Test public void testOrderBy9() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT x.e1 FROM pm1.g1 AS x ORDER BY x.e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "x.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy10() throws Exception {
+ @Test public void testOrderBy10() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT a.e1, b.e1 FROM pm1.g1 AS a, pm1.g1 AS b ORDER BY a.e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "a.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy11() throws Exception {
+ @Test public void testOrderBy11() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT a.e1, b.e1 FROM pm1.g1 AS a, pm1.g1 AS b ORDER BY b.e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "b.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy12() throws Exception {
+ @Test public void testOrderBy12() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT a.e1, pm1.g1.e1 FROM pm1.g1 AS a, pm1.g1 ORDER BY a.e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "a.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy13() throws Exception {
+ @Test public void testOrderBy13() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT a.e1, pm1.g1.e1 FROM pm1.g1 AS a, pm1.g1 ORDER BY pm1.g1.e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy14() throws Exception {
+ @Test public void testOrderBy14() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT a.e1 as x, pm1.g1.e1 as y FROM pm1.g1 AS a, pm1.g1 ORDER BY x"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "a.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testOrderBy15() throws Exception {
+ @Test public void testOrderBy15() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT a.e1 as x, pm1.g1.e1 as y FROM pm1.g1 AS a, pm1.g1 ORDER BY y"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testNumberedOrderBy2() throws Exception {
+ @Test public void testNumberedOrderBy2() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT * FROM pm1.g1 ORDER BY 1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testNumberedOrderBy3() throws Exception {
+ @Test public void testNumberedOrderBy3() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT * FROM pm1.g1 ORDER BY 1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testNumberedOrderBy4() throws Exception {
+ @Test public void testNumberedOrderBy4() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT e1 FROM pm1.g1 ORDER BY 1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testNumberedOrderBy5() throws Exception {
+ @Test public void testNumberedOrderBy5() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT x.e1 FROM pm1.g1 AS x ORDER BY 1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "x.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
}
- public void testNumberedOrderBy8() throws Exception {
+ @Test public void testNumberedOrderBy8() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT a.e1 as x, pm1.g1.e1 as y FROM pm1.g1 AS a, pm1.g1 ORDER BY 1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "a.e1" }, //$NON-NLS-1$
@@ -285,7 +284,7 @@
/**
* partially-qualified ORDER BY's with ambiguous short group names
*/
- public void testDefect10729() throws Exception {
+ @Test public void testDefect10729() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY g1.e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
@@ -295,18 +294,36 @@
/**
* partially-qualified ORDER BY's with ambiguous short group names
*/
- public void testDefect10729a() throws Exception {
+ @Test public void testDefect10729a() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY e1"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" } ); //$NON-NLS-1$
}
- public void testAliasedOrderBy_ConstantElement() throws Exception {
+ @Test public void testAliasedOrderBy_ConstantElement() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT 0 AS SOMEINT, pm1.g1.e1 as y FROM pm1.g1 ORDER BY y, SOMEINT"); //$NON-NLS-1$
helpCheckElements(resolvedQuery.getOrderBy(),
new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
new String[] { "pm1.g1.e1" } ); //$NON-NLS-1$
}
+
+ @Test public void testOrderByExpression() throws Exception {
+ Query resolvedQuery = (Query) getCommand("SELECT 0 AS SOMEINT, pm1.g1.e2 as y FROM pm1.g1 ORDER BY y + SOMEINT, e3"); //$NON-NLS-1$
+ assertEquals("SELECT Y_1.SOMEINT, Y_1.Y FROM (SELECT X_1.SOMEINT, X_1.Y, X_1.E3, (X_1.Y + X_1.SOMEINT) AS EXPR1 FROM (SELECT 0 AS SOMEINT, pm1.g1.e2 AS y, e3 FROM pm1.g1) AS X_1) AS Y_1 ORDER BY Y_1.EXPR1, Y_1.E3", resolvedQuery.toString()); //$NON-NLS-1$
+ }
+
+ @Test public void testRewiteOrderBy() {
+ helpTestRewriteCommand("SELECT 1+1 as a FROM pm1.g1 order by a", "SELECT 2 AS a FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRewiteOrderBy1() {
+ helpTestRewriteCommand("SELECT 1+1 as a FROM pm1.g1 union select pm1.g2.e1 from pm1.g2 order by a", "SELECT '2' AS a FROM pm1.g1 UNION SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY a"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testOrderByDuplicateRemoval() {
+ String sql = "SELECT pm1.g1.e1, pm1.g1.e1 as c1234567890123456789012345678901234567890, pm1.g1.e2 FROM pm1.g1 ORDER BY c1234567890123456789012345678901234567890, e2, e1 "; //$NON-NLS-1$
+ helpTestRewriteCommand(sql, "SELECT pm1.g1.e1, pm1.g1.e1 AS c1234567890123456789012345678901234567890, pm1.g1.e2 FROM pm1.g1 ORDER BY c1234567890123456789012345678901234567890, pm1.g1.e2"); //$NON-NLS-1$
+ }
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -161,7 +161,7 @@
assertNotNull("Expected a QueryValidatorException but got none.", exception); //$NON-NLS-1$
}
- private Command helpTestRewriteCommand(String original, String expected) {
+ static Command helpTestRewriteCommand(String original, String expected) {
try {
return helpTestRewriteCommand(original, expected, FakeMetadataFactory.example1Cached());
} catch(MetaMatrixException e) {
@@ -169,7 +169,7 @@
}
}
- private Command helpTestRewriteCommand(String original, String expected, QueryMetadataInterface metadata) throws MetaMatrixException {
+ static Command helpTestRewriteCommand(String original, String expected, QueryMetadataInterface metadata) throws MetaMatrixException {
Command command = QueryParser.getQueryParser().parseCommand(original);
QueryResolver.resolveCommand(command, metadata);
Command rewriteCommand = QueryRewriter.rewrite(command, null, metadata, null);
@@ -1035,7 +1035,7 @@
rewritProc = rewritProc + "DECLARE String var1;\n"; //$NON-NLS-1$
rewritProc = rewritProc + "IF((var1 = 'x') OR (var1 = 'y'))\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
- rewritProc = rewritProc + "SELECT pm1.g1.e2, null AS E2_0, FALSE AS E2_1, TRUE AS E1 FROM pm1.g1;\n"; //$NON-NLS-1$
+ rewritProc = rewritProc + "SELECT pm1.g1.e2, null, FALSE, TRUE FROM pm1.g1;\n"; //$NON-NLS-1$
rewritProc = rewritProc + "END\n"; //$NON-NLS-1$
rewritProc = rewritProc + "END"; //$NON-NLS-1$
@@ -1365,7 +1365,7 @@
@Test public void testRewriteProcedure24() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "UPDATE pm1.g1 SET e2=Input.e2 WHERE TRANSLATE LIKE CRITERIA ON (e1) WITH (e1=concat(pm1.g1.e1, \"%\"));\n"; //$NON-NLS-1$
+ procedure = procedure + "UPDATE pm1.g1 SET e2=Input.e2 WHERE TRANSLATE LIKE CRITERIA ON (e1) WITH (e1=concat(pm1.g1.e1, '%'));\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g1 set E2=1 where e2 = 1 and e1 LIKE 'mnopxyz_'"; //$NON-NLS-1$
@@ -1998,15 +1998,7 @@
}
}
}
-
- @Test public void testRewiteOrderBy() {
- helpTestRewriteCommand("SELECT 1+1 as a FROM pm1.g1 order by a", "SELECT 2 AS a FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRewiteOrderBy1() {
- helpTestRewriteCommand("SELECT 1+1 as a FROM pm1.g1 union select pm1.g2.e1 from pm1.g2 order by a", "SELECT '2' AS a FROM pm1.g1 UNION SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY a"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
+
/**
* The rewrite creates inline view to do the type conversion.
*
@@ -2032,12 +2024,7 @@
helpTestRewriteCommand(sql, "SELECT 1 AS a"); //$NON-NLS-1$
}
-
- @Test public void testOrderByDuplicateRemoval() {
- String sql = "SELECT pm1.g1.e1, pm1.g1.e1 as c1234567890123456789012345678901234567890 FROM pm1.g1 ORDER BY c1234567890123456789012345678901234567890, e1 "; //$NON-NLS-1$
- helpTestRewriteCommand(sql, "SELECT pm1.g1.e1, pm1.g1.e1 AS c1234567890123456789012345678901234567890 FROM pm1.g1 ORDER BY c1234567890123456789012345678901234567890"); //$NON-NLS-1$
- }
-
+
/**
* Case 4814
*/
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java 2009-11-20 16:46:40 UTC (rev 1577)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java 2009-11-20 17:27:16 UTC (rev 1578)
@@ -512,7 +512,7 @@
public void testOption1() {
Option option = new Option();
- helpTest(option, ""); //$NON-NLS-1$
+ helpTest(option, "OPTION"); //$NON-NLS-1$
}
public void testOption2() {
15 years, 1 month
teiid SVN: r1577 - trunk/test-integration/db/src/test/java/org/teiid/test/testcases.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-20 11:46:40 -0500 (Fri, 20 Nov 2009)
New Revision: 1577
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
Log:
Teiid 773 - removed unneeded method
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java 2009-11-20 16:46:03 UTC (rev 1576)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java 2009-11-20 16:46:40 UTC (rev 1577)
@@ -4,7 +4,6 @@
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.datasource.DataSourceFactory;
import org.teiid.test.framework.exception.TransactionRuntimeException;
public abstract class BaseAbstractTransactionTestCase extends TestCase {
@@ -38,21 +37,6 @@
config.setProperty(key, value);
}
- /**
- * Call to assign a specific database type to the model. When a datasource
- * is requested for this model, a datasource of the specific dbtype will be
- * returned. See {@link DataSourceFactory} for the logic that controls this
- * behavior.
- *
- * @param modelName
- * @param dbtype
- *
- * @since
- */
- protected void setAssignModelToDatabaseType(String modelName, String dbtype) {
- config.setModelAssignedToDatabaseType(modelName, dbtype);
- }
-
}
15 years, 1 month
teiid SVN: r1576 - trunk/test-integration/db/src/main/resources.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-20 11:46:03 -0500 (Fri, 20 Nov 2009)
New Revision: 1576
Modified:
trunk/test-integration/db/src/main/resources/default-config.properties
Log:
Teiid 773 - changed to use the EmbeddedDataSource
Modified: trunk/test-integration/db/src/main/resources/default-config.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/default-config.properties 2009-11-19 22:35:07 UTC (rev 1575)
+++ trunk/test-integration/db/src/main/resources/default-config.properties 2009-11-20 16:46:03 UTC (rev 1576)
@@ -2,6 +2,8 @@
# Common Properties for everybody
##########################################
+connection-type=datasource
+
process-batch = 20
connector-batch = 20
@@ -13,14 +15,16 @@
# properties for Teiid connection
##########################################
#driver=org.teiid.jdbc.TeiidDriver
-driver=org.teiid.jdbc.TeiidDataSource
+driver=com.metamatrix.jdbc.EmbeddedDataSource
+#URL=jdbc:teiid:Transaction@mm://localhost:31000
URL=jdbc:metamatrix:Transaction@target/classes/transactions/transaction.properties;user=admin;password=teiid
User=admin
Password=teiid
DatabaseName=Transaction
+#ServerName=localhost
ServerName=target/classes/transactions/transaction.properties
-PortNumber=0
+PortNumber=31000
application-name=txn-test
# jboss
15 years, 1 month
teiid SVN: r1575 - trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-19 17:35:07 -0500 (Thu, 19 Nov 2009)
New Revision: 1575
Removed:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
Log:
Teiid 773 - refactored don't need the class
Deleted: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java 2009-11-19 18:58:25 UTC (rev 1574)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java 2009-11-19 22:35:07 UTC (rev 1575)
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.framework.transaction;
-
-import org.teiid.test.framework.ConfigPropertyLoader;
-import org.teiid.test.framework.ConfigPropertyNames;
-import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.exception.QueryTestFailedException;
-import org.teiid.test.framework.exception.TransactionRuntimeException;
-
-
-
-public class TransactionFactory {
-
-
-
- private TransactionFactory(){}
-
-
- public static TransactionContainer create(ConfigPropertyLoader config) throws QueryTestFailedException {
- TransactionContainer transacton = null;
-
-// String type = config.getProperty(ConfigPropertyNames.TRANSACTION_TYPE);
-// if (type == null) {
-// type = ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION;
-// }
-//
-// System.out.println("Create TransactionContainer: " + type);
-//
-// if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION)) {
-// transacton = new LocalTransaction(config);
-// }
-// else if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.XATRANSACTION)) {
-// transacton = new XATransaction(config);
-// }
-// else if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.JNDI_TRANSACTION)) {
-// transacton = new JNDITransaction(config);
-//
-// } else {
-// throw new TransactionRuntimeException("Invalid property value of " + type + " for " + ConfigPropertyNames.TRANSACTION_TYPE );
-// }
-
- return transacton;
- }
-
-}
15 years, 1 month