teiid SVN: r1282 - in trunk: runtime/src/main/java/com/metamatrix/dqp/embedded/services and 4 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-08-26 12:31:05 -0400 (Wed, 26 Aug 2009)
New Revision: 1282
Modified:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
trunk/runtime/src/test/resources/dqp/dqp.properties
trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java
Log:
TEIID-697: Fixing the "exportConfiguration" call to return the configuration properties from the "deploy.properties" instead of "configuration.xml"
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-08-26 16:23:28 UTC (rev 1281)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-08-26 16:31:05 UTC (rev 1282)
@@ -104,7 +104,7 @@
Cache.QUERY_SERVICE_RESULT_SET_CACHE
};
- EmbeddedConnectionFactoryImpl manager = null;
+ private EmbeddedConnectionFactoryImpl manager = null;
BaseAdmin(EmbeddedConnectionFactoryImpl manager){
this.manager = manager;
@@ -546,7 +546,7 @@
MMSystem system = new MMSystem();
system.setStartTime(new Date(manager.getStartTime()));
system.setStarted(manager.isAlive());
- system.setProperties(manager.getProperties());
+ system.setProperties(getConfigurationService().getSystemProperties());
return system;
}
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java 2009-08-26 16:23:28 UTC (rev 1281)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java 2009-08-26 16:31:05 UTC (rev 1282)
@@ -22,6 +22,8 @@
package com.metamatrix.dqp.embedded.admin;
+import java.io.IOException;
+import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -47,7 +49,6 @@
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.config.api.ComponentTypeDefn;
import com.metamatrix.common.config.api.ComponentTypeID;
-import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.common.config.api.ConnectorArchive;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.config.api.ConnectorBindingType;
@@ -64,7 +65,6 @@
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.dqp.embedded.configuration.ConnectorConfigurationReader;
import com.metamatrix.dqp.embedded.configuration.ConnectorConfigurationWriter;
-import com.metamatrix.dqp.embedded.configuration.ServerConfigFileWriter;
import com.metamatrix.dqp.embedded.configuration.VDBConfigurationReader;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
@@ -761,9 +761,11 @@
*/
public char[] exportConfiguration() throws AdminException {
try {
- ConfigurationModelContainer model = getConfigurationService().getSystemConfiguration();
- return ServerConfigFileWriter.writeToCharArray(model);
- } catch (MetaMatrixComponentException e) {
+ StringWriter sw = new StringWriter();
+ Properties props = getConfigurationService().getSystemProperties();
+ props.store(sw, "Export of Teiid Configuration Properties"); //$NON-NLS-1$
+ return sw.toString().toCharArray();
+ } catch (IOException e) {
throw new AdminComponentException(e);
}
}
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-08-26 16:23:28 UTC (rev 1281)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-08-26 16:31:05 UTC (rev 1282)
@@ -188,7 +188,7 @@
List results = new ArrayList();
if (matches(identifier, "dqp")) { //$NON-NLS-1$
// First get the queue statistics for the DQP
- Collection c = manager.getDQP().getQueueStatistics();;
+ Collection c = getManager().getDQP().getQueueStatistics();;
if (c != null && !c.isEmpty()) {
results.addAll(c);
}
@@ -260,7 +260,7 @@
ArrayList requestList = new ArrayList();
// List contains both top and atomic requests, only add the top requests
- List<RequestInfo> requests = manager.getDQP().getRequests();
+ List<RequestInfo> requests = getManager().getDQP().getRequests();
for(RequestInfo request:requests) {
if (request.getConnectorBindingUUID() == null) {
requestList.add(request);
@@ -281,7 +281,7 @@
}
ArrayList atomicRequestList = new ArrayList();
- List<RequestInfo> requests = manager.getDQP().getRequests();
+ List<RequestInfo> requests = getManager().getDQP().getRequests();
for (RequestInfo request:requests) {
if (request.getConnectorBindingUUID() != null) {
atomicRequestList.add(request);
@@ -322,7 +322,7 @@
switch(type) {
case MMAdminObject.OBJECT_TYPE_SYSTEM_OBJECT:
- Properties properties = manager.getProperties();
+ Properties properties = getConfigurationService().getSystemProperties();
return convertPropertyDefinitions(properties);
case MMAdminObject.OBJECT_TYPE_CONNECTOR_BINDING:
@@ -374,7 +374,7 @@
@Override
public Collection<ProcessObject> getProcesses(String processIdentifier) throws AdminException {
ArrayList<ProcessObject> list = new ArrayList<ProcessObject>();
- list.add(this.manager.getProcess());
+ list.add(getManager().getProcess());
return list;
}
}
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-08-26 16:23:28 UTC (rev 1281)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-08-26 16:31:05 UTC (rev 1282)
@@ -173,13 +173,13 @@
if (matches(identifier, cacheTypes[i])) {
if(cacheTypes[i].equals(Cache.CODE_TABLE_CACHE)) {
processed = true;
- manager.getDQP().clearCodeTableCache();
+ getManager().getDQP().clearCodeTableCache();
} else if(cacheTypes[i].equals(Cache.PREPARED_PLAN_CACHE)) {
processed = true;
- manager.getDQP().clearPlanCache();
+ getManager().getDQP().clearPlanCache();
} else if(cacheTypes[i].equals( Cache.QUERY_SERVICE_RESULT_SET_CACHE)) {
processed = true;
- manager.getDQP().clearResultSetCache();
+ getManager().getDQP().clearResultSetCache();
} else if (cacheTypes[i].equals(Cache.CONNECTOR_RESULT_SET_CACHE)) {
processed = true;
try {
@@ -243,7 +243,7 @@
RequestID id = new RequestID(connId, requestId);
try {
- this.manager.getDQP().cancelRequest(id);
+ getManager().getDQP().cancelRequest(id);
} catch (MetaMatrixComponentException e) {
throw new AdminComponentException(e);
}
@@ -269,7 +269,7 @@
AtomicRequestID id = new AtomicRequestID(new RequestID(connId, requestId), nodeId, executionId);
try {
- this.manager.getDQP().cancelAtomicRequest(id);
+ getManager().getDQP().cancelAtomicRequest(id);
} catch (MetaMatrixComponentException e) {
throw new AdminComponentException(e);
}
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-08-26 16:23:28 UTC (rev 1281)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-08-26 16:31:05 UTC (rev 1282)
@@ -224,7 +224,7 @@
if (valid(configFile)) {
return getFullyQualifiedPath(configFile);
}
- return null;
+ return Thread.currentThread().getContextClassLoader().getResource("configuration.xml"); //$NON-NLS-1$
}
/**
@@ -978,9 +978,6 @@
this.configurationModel = getSystemConfiguration();
ServerConfigFileReader configReader = loadServerConfigFile();
- // Add properties to all the user preferences.
- getUserPreferences().putAll(configReader.getSystemProperties());
-
// Get the alternate connector bindings from the server configuration
Map connectorBindings = configReader.getConnectorBindings();
@@ -1337,7 +1334,7 @@
* @return true if yes to use buffering; false otherwise
*/
public boolean useDiskBuffering() {
- return Boolean.valueOf(getUserPreferences().getProperty(DQPEmbeddedProperties.BufferService.DQP_BUFFER_USEDISK, "true")).booleanValue(); //$NON-NLS-1$
+ return Boolean.valueOf(getUserPreferences().getProperty(DQPEmbeddedProperties.DQP_BUFFER_USEDISK, "true")).booleanValue(); //$NON-NLS-1$
}
private File getWorkDir() {
@@ -1366,7 +1363,7 @@
* @return must a return a location
*/
public String getBufferMemorySize() {
- return getUserPreferences().getProperty(DQPEmbeddedProperties.BufferService.DQP_BUFFER_MEMORY, "64"); //$NON-NLS-1$
+ return getUserPreferences().getProperty(DQPEmbeddedProperties.DQP_BUFFER_MEMORY, "64"); //$NON-NLS-1$
}
/**
@@ -1378,10 +1375,10 @@
public String getProcessorBatchSize() {
- return getUserPreferences().getProperty(DQPEmbeddedProperties.BufferService.DQP_PROCESSOR_BATCH_SIZE, "2000"); //$NON-NLS-1$
+ return getUserPreferences().getProperty(DQPEmbeddedProperties.DQP_PROCESSOR_BATCH_SIZE, "2000"); //$NON-NLS-1$
}
public String getConnectorBatchSize() {
- return getUserPreferences().getProperty(DQPEmbeddedProperties.BufferService.DQP_CONNECTOR_BATCH_SIZE, "2000"); //$NON-NLS-1$
+ return getUserPreferences().getProperty(DQPEmbeddedProperties.DQP_CONNECTOR_BATCH_SIZE, "2000"); //$NON-NLS-1$
}
@Override
Modified: trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-08-26 16:23:28 UTC (rev 1281)
+++ trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-08-26 16:31:05 UTC (rev 1282)
@@ -134,13 +134,6 @@
if (vdbDefinitions == null) {
props.setProperty(DQPEmbeddedProperties.VDB_DEFINITION, deployDirectory.getCanonicalPath());
}
-
- // create log directory
- File logDirectory = new File(teiidHome, props.getProperty(DQPEmbeddedProperties.DQP_LOGDIR, "log")); //$NON-NLS-1$
- props.setProperty(DQPEmbeddedProperties.DQP_LOGDIR, logDirectory.getCanonicalPath());
- if (!logDirectory.exists()) {
- logDirectory.mkdirs();
- }
} catch (IOException e) {
throw new ApplicationInitializationException(e);
}
@@ -278,7 +271,7 @@
return this.starttime;
}
- public Properties getProperties() {
+ private Properties getProperties() {
if (isAlive()) {
return ((ConfigurationService)findService(DQPServiceNames.CONFIGURATION_SERVICE)).getSystemProperties();
}
Modified: trunk/runtime/src/test/resources/dqp/dqp.properties
===================================================================
--- trunk/runtime/src/test/resources/dqp/dqp.properties 2009-08-26 16:23:28 UTC (rev 1281)
+++ trunk/runtime/src/test/resources/dqp/dqp.properties 2009-08-26 16:31:05 UTC (rev 1282)
@@ -33,5 +33,8 @@
#only for testing, as this takes more time to start and shutdown
xa.enable_recovery=false
+MaxCodeTables=50
+MaxPlanCacheSize=100
+MaxFetchSize=20000
teiid.home=target/scratch
Modified: trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java 2009-08-26 16:23:28 UTC (rev 1281)
+++ trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java 2009-08-26 16:31:05 UTC (rev 1282)
@@ -36,7 +36,6 @@
import org.junit.Before;
import org.junit.Test;
-import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminObject;
import org.teiid.adminapi.AdminOptions;
@@ -375,9 +374,6 @@
addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
Collection<ConnectorType> types = getAdmin().getConnectorTypes(STAR);
- for (ConnectorType type:types) {
- // System.out.println(type.getName());
- }
assertEquals("31 types expected", 31, types.size()); //$NON-NLS-1$
@@ -664,10 +660,10 @@
getConnection(ADMIN, PROPS_FILE);
cleanDeploy();
- Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/serverconfigexport.xml", getAdmin().exportConfiguration()); //$NON-NLS-1$
- File f = new File(UnitTestUtil.getTestScratchPath()+"/serverconfigexport.xml"); //$NON-NLS-1$
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/serverconfigexport.properties", getAdmin().exportConfiguration()); //$NON-NLS-1$
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/serverconfigexport.properties"); //$NON-NLS-1$
assertTrue("Exported configuration must exist", f.exists()); //$NON-NLS-1$
- f.delete();
+ //f.delete();
closeConnection();
}
@@ -1018,60 +1014,7 @@
closeConnection();
}
-// /**
-// * SIP51, SIP52
-// * @throws Exception
-// */
-// @Test public void testDeleteInvalidVdb() throws Exception {
-// getConnection(ADMIN, PROPS_FILE);
-// cleanDeploy();
-//
-// String VDB_NAME = "DeleteInvalid"; //$NON-NLS-1$
-// try {
-// // Try clean deployment twice
-// try {
-// addVDB(VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORSInvalid.vdb"); //$NON-NLS-1$
-// fail("Failed with exception "); //$NON-NLS-1$
-// } catch (Exception e) {
-// //pass
-// }
-// } catch (Exception x) {
-// fail("Failed with exception " + Util.getStackTraceAsString(x)); //$NON-NLS-1$
-// } finally {
-// closeConnection();
-// }
-// }
-//
-// /**
-// * Opens connection to the VDB and tries to deploy when conn is open.
-// * The redeployment should not affect the current connection.
-// * @throws Exception
-// */
-// @Test public void testKeepConnectionReplaceVdb () throws Exception {
-// getConnection(ADMIN, PROPS_FILE);
-// cleanDeploy();
-//
-// String VDB_NAME = "ReplaceActive"; //$NON-NLS-1$
-// try {
-// VDB vdb = addVDB(VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORS.vdb"); //$NON-NLS-1$
-// String currentVersion = vdb.getVDBVersion();
-// assertEquals("1", currentVersion); //$NON-NLS-1$
-//
-// // Connect and run test query
-// pushConnection();
-// Connection c1 = getConnection( VDB_NAME, PROPS_FILE);
-// execute("SELECT * FROM C_REPOS_DB_RELEASE"); //$NON-NLS-1$
-//
-// // Redeploy the VDB while the connection is open. New VDB has A_CCOUNT table
-// vdb = deployVdbClean(admin, VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORS1.vdb"); //$NON-NLS-1$
-//
-// testConnection(testConn, "select * from C_ACCOUNT", false, "Redeploy V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
-// } catch (Exception x) {
-// fail("Failed with exception " + Util.getStackTraceAsString(x)); //$NON-NLS-1$
-// } finally {
-// Util.closeQuietly(conn);
-// }
-// }
+
VDB addVDB(String name, String vdbFile) {
try {
Modified: trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java
===================================================================
--- trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java 2009-08-26 16:23:28 UTC (rev 1281)
+++ trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java 2009-08-26 16:31:05 UTC (rev 1282)
@@ -15,7 +15,6 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
14 years, 8 months
teiid SVN: r1281 - in trunk: client/src/main/java/com/metamatrix/dqp/embedded and 2 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-08-26 12:23:28 -0400 (Wed, 26 Aug 2009)
New Revision: 1281
Modified:
trunk/build/kit-runtime/deploy.properties
trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
Log:
TEIID-802: consolidated all the proeprties to DQPEmbeddedProperties and renames some of the process based properties
Modified: trunk/build/kit-runtime/deploy.properties
===================================================================
--- trunk/build/kit-runtime/deploy.properties 2009-08-25 23:03:38 UTC (rev 1280)
+++ trunk/build/kit-runtime/deploy.properties 2009-08-26 16:23:28 UTC (rev 1281)
@@ -5,15 +5,9 @@
# name of the process that uniquely identifies this process( if ignored one will be assigned)
processName=localhost
-#Path to the Teiid Configuration file
-dqp.configFile=./deploy/configuration.xml
-
-# Path to the directory where the VDBs are located, or list of VDBS separated by ";"
+# Path to the directory where the VDBs are located
dqp.deploydir=./deploy/
-#Log file (optional) - will be modified to include the instance name, i.e. teiid_1.log
-dqp.logFile=./log/teiid.log
-
#Extensions directory - where the Connector Binding's classpath jar files are loaded.
#Use of this property is an implicit declaration that each Connector Binding has its own Class Loader.
dqp.extensions=./extensions/
@@ -32,16 +26,19 @@
#
#Process pool maximum thread count. (default 64)
-ProcessPoolMaxThreads=64
+process.maxThreads=64
#Query processor time slice, in milliseconds. (default 2000)
-ProcessorTimeslice=2000
+process.timeSliceInMilli=2000
+#Plan debug messages allowed. see option debug.
+process.optionDebugAllowed=true
+
#Maximum allowed fetch size, set via JDBC. User requested value ignored above this value. (default 20000)
-MaxFetchSize=20000
+process.maxRowsFetchSize=20000
-#The maximum number of query plans that are cached. Note: this is a memory based cache. (default 250)
-MaxPlanCacheSize=250
+# The max lob chunk size transferred each time when processing blobs, clobs(10KB default)
+process.lobChunkSizeInKB=10
#
# BufferManager Settings
@@ -63,23 +60,26 @@
# Cache Settings
#
+#The maximum number of query plans that are cached. Note: this is a memory based cache. (default 250)
+PreparedPlanCache.maxCount=250
+
#Maximum number of cached lookup tables. Note: this is a memory based cache. (default 20)
-MaxCodeTables=20
+CodeTables.maxCount=20
#Maximum number of records in a single lookup table (default 10000)
-MaxCodeTableRecords=10000
+CodeTables.maxRows=10000
#Denotes whether or not result set caching is enabled. (default false)
-ResultSetCacheEnabled=false
+ResultSetCache.enabled=false
#The maximum size in MB the result set cache will be allowed to grow to before objects are removed. 0 indicates no limit. (default 50)
-#ResultSetCacheSize=50
+#ResultSetCache.maxSizeInMB=50
#The maximum time a result set will be kept in cache before being automatically cleared. 0 indicates no limit. (default 3600000)
-#ResultSetCacheMaxAge=3600000
+#ResultSetCache.maxAgeInSeconds=3600000
#Defines whether caching is restricted to a specific session ('session') or a specific VDB version ('vdb'). (default vdb)
-#ResultSetCacheScope=vdb
+#ResultSetCache.scope=vdb
#
# Session Service Settings
Modified: trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java 2009-08-25 23:03:38 UTC (rev 1280)
+++ trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java 2009-08-26 16:23:28 UTC (rev 1281)
@@ -25,11 +25,7 @@
/**
*/
public interface DQPEmbeddedProperties {
- public static final String DQP_LOGDIR = "dqp.logdir"; //$NON-NLS-1$
public static final String DQP_EXTENSIONS = "dqp.extensions"; //$NON-NLS-1$
- public static final String DQP_CONFIGFILE = "dqp.configFile"; //$NON-NLS-1$
- public static final String DQP_METADATA_SYSTEMURL = "dqp.metadata.systemURL"; //$NON-NLS-1$
- public static final String VDB_DEFINITION = "vdb.definition"; //$NON-NLS-1$
public static final String USER_DEFINED_FUNCTIONS = "dqp.userDefinedFunctionsFile"; //$NON-NLS-1$
public static final String COMMON_EXTENSION_CLASPATH = "dqp.extension.CommonClasspath"; //$NON-NLS-1$
public static final String DQP_WORKDIR = "dqp.workdir"; //$NON-NLS-1$
@@ -37,7 +33,28 @@
public static final String DQP_LIBDIR = "dqp.lib"; //$NON-NLS-1$
public static final String PROCESSNAME = "processName"; //$NON-NLS-1$
public static final String CLUSTERNAME = "clusterName"; //$NON-NLS-1$
+
+ //legacy
+ public static final String VDB_DEFINITION = "vdb.definition"; //$NON-NLS-1$
+ public static final String DQP_CONFIGFILE = "dqp.configFile"; //$NON-NLS-1$
+ public static final String DQP_METADATA_SYSTEMURL = "dqp.metadata.systemURL"; //$NON-NLS-1$
+ // cache properties
+ public static final String USE_RESULTSET_CACHE = "ResultSetCache.enabled"; //$NON-NLS-1$
+ public static final String MAX_RESULTSET_CACHE_SIZE = "ResultSetCache.maxSizeInMB"; //$NON-NLS-1$
+ public static final String MAX_RESULTSET_CACHE_AGE = "ResultSetCache.maxAgeInSeconds"; //$NON-NLS-1$
+ public static final String RESULTSET_CACHE_SCOPE = "ResultSetCache.scope"; //$NON-NLS-1$
+ public static final String MAX_CODE_TABLE_RECORDS = "CodeTables.maxRows"; //$NON-NLS-1$
+ public static final String MAX_CODE_TABLES = "CodeTables.maxCount"; //$NON-NLS-1$
+ public static final String MAX_PLAN_CACHE_SIZE = "PreparedPlanCache.maxCount"; //$NON-NLS-1$
+
+ // engine properties
+ public static final String STREAMING_BATCH_SIZE = "process.lobChunkSizeInKB"; //$NON-NLS-1$
+ public static final String PROCESS_POOL_MAX_THREADS = "process.maxThreads"; //$NON-NLS-1$
+ public static final String PROCESS_TIMESLICE = "process.timeSliceInMilli"; //$NON-NLS-1$
+ public static final String PROCESSOR_DEBUG_ALLOWED = "process.optionDebugAllowed"; //$NON-NLS-1$
+ public static final String MAX_FETCH_SIZE = "process.maxRowsFetchSize"; //$NON-NLS-1$
+
// socket specific
public static final String BIND_ADDRESS = "server.bindAddress"; //$NON-NLS-1$
public static final String SERVER_PORT = "server.portNumber"; //$NON-NLS-1$
@@ -45,55 +62,36 @@
public static final String INPUT_BUFFER_SIZE = "server.inputBufferSize"; //$NON-NLS-1$
public static final String OUTPUT_BUFFER_SIZE = "server.outputBufferSize"; //$NON-NLS-1$
- //derived properties
+ //derived properties (should make user avoid updating these)
public static final String DQP_TMPDIR = "mm.io.tmpdir"; //$NON-NLS-1$
public static final String BOOTURL = "bootURL"; //$NON-NLS-1$
public static final String ENABLE_SOCKETS = "sockets.enabled"; //$NON-NLS-1$
public static final String HOST_ADDRESS = "hostAddress"; //$NON-NLS-1$
public static final String DQP_BOOTSTRAP_FILE = "bootstrapFile"; //$NON-NLS-1$
public static final String TEIID_HOME = "teiid.home"; //$NON-NLS-1$
+
- public interface BufferService {
- /**
- * Property prefix for DQP Buffer Service properties.
- */
- public static final String BUFFER_PREFIX = "dqp.buffer"; //$NON-NLS-1$
-
- /**
- * Determines whether buffer management should be all-memory (if false)
- * or mixed memory and disk access (if true). Default value is false.
- */
- public static final String DQP_BUFFER_USEDISK = BUFFER_PREFIX + ".usedisk"; //$NON-NLS-1$
-
- /**
- * Determines amount of memory to use in-memory before buffering to
- * disk. This property is not used if DQP_BUFFER_USEDISK = true. The
- * value is in megabytes. Default value is 64.
- */
- public static final String DQP_BUFFER_MEMORY = BUFFER_PREFIX + ".memory"; //$NON-NLS-1$
+ /**
+ * Determines whether buffer management should be all-memory (if false)
+ * or mixed memory and disk access (if true). Default value is false.
+ */
+ public static final String DQP_BUFFER_USEDISK = "dqp.buffer.usedisk"; //$NON-NLS-1$
- /**
- * The maximum number of rows a processor batch should contain. Default is 2000.
- */
- public static final String DQP_PROCESSOR_BATCH_SIZE = BUFFER_PREFIX + ".processorBatchSize"; //$NON-NLS-1$
-
- /**
- * The maximum number of rows a connector batch should contain. Default is 2000.
- */
- public static final String DQP_CONNECTOR_BATCH_SIZE = BUFFER_PREFIX + ".connectorBatchSize"; //$NON-NLS-1$
- }
+ /**
+ * Determines amount of memory to use in-memory before buffering to
+ * disk. This property is not used if DQP_BUFFER_USEDISK = true. The
+ * value is in megabytes. Default value is 64.
+ */
+ public static final String DQP_BUFFER_MEMORY = "dqp.buffer.memory"; //$NON-NLS-1$
+
+ /**
+ * The maximum number of rows a processor batch should contain. Default is 2000.
+ */
+ public static final String DQP_PROCESSOR_BATCH_SIZE = "dqp.buffer.processorBatchSize"; //$NON-NLS-1$
+
+ /**
+ * The maximum number of rows a connector batch should contain. Default is 2000.
+ */
+ public static final String DQP_CONNECTOR_BATCH_SIZE = "dqp.buffer.connectorBatchSize"; //$NON-NLS-1$
- public interface DataService {
- /**
- * Property prefix for DQP Data Service properties.
- */
- public static final String DATA_PREFIX = "dqp.data"; //$NON-NLS-1$
- }
-
- public interface MetadataService {
- /**
- * Property prefix for DQP Metadata Service properties.
- */
- public static final String METADATA_PREFIX = "dqp.metadata"; //$NON-NLS-1$
- }
}
Modified: trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java 2009-08-25 23:03:38 UTC (rev 1280)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/DQPConfigSource.java 2009-08-26 16:23:28 UTC (rev 1281)
@@ -29,24 +29,6 @@
*/
public interface DQPConfigSource {
- public static final String MAX_FETCH_SIZE = "MaxFetchSize"; //$NON-NLS-1$
- public static final String MAX_CODE_TABLE_RECORDS = "MaxCodeTableRecords"; //$NON-NLS-1$
- public static final String MAX_CODE_TABLES = "MaxCodeTables"; //$NON-NLS-1$
- public static final String MAX_RESULTSET_CACHE_SIZE = "ResultSetCacheMaxSize"; //$NON-NLS-1$
- public static final String MAX_RESULTSET_CACHE_AGE = "ResultSetCacheMaxAge"; //$NON-NLS-1$
- public static final String MAX_PLAN_CACHE_SIZE = "MaxPlanCacheSize"; //$NON-NLS-1$
- public static final String PROCESSOR_TIMESLICE = "ProcessorTimeslice"; //$NON-NLS-1$
- public static final String USE_RESULTSET_CACHE = "ResultSetCacheEnabled"; //$NON-NLS-1$
- public static final String RESULTSET_CACHE_SCOPE = "ResultSetCacheScope"; //$NON-NLS-1$
- public static final String STREAMING_BATCH_SIZE = "metamatrix.server.streamingBatchSize"; //$NON-NLS-1$
-
- public static final String PROCESS_POOL_MAX_THREADS = "ProcessPoolMaxThreads"; //$NON-NLS-1$
- public static final String PROCESSOR_DEBUG_ALLOWED = "ProcessorDebugAllowed"; //$NON-NLS-1$
-
- /**
- * Get the DQP properties, as described in {@link DQPProperties}.
- * @return Set of properties to configure DQP
- */
public Properties getProperties();
public ApplicationService getServiceInstance(Class<? extends ApplicationService> type);
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-08-25 23:03:38 UTC (rev 1280)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-08-26 16:23:28 UTC (rev 1281)
@@ -71,6 +71,7 @@
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.client.MetadataResult;
import com.metamatrix.dqp.client.ResultsFuture;
+import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
@@ -121,6 +122,7 @@
//Constants
private static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
private static final int DEFAULT_MAX_CODE_TABLES = 20;
+ private static final int DEFAULT_FETCH_SIZE = 2000;
private static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
private static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
private static final int DEFAULT_MAX_PROCESS_WORKERS = 15;
@@ -131,7 +133,7 @@
private int maxCodeTableRecords = DEFAULT_MAX_CODE_TABLE_RECORDS;
private int maxCodeTables = DEFAULT_MAX_CODE_TABLES;
- private int maxFetchSize = 20000;
+ private int maxFetchSize = DEFAULT_FETCH_SIZE;
// Resources
private ConnectorCapabilitiesCache connectorCapabilitiesCache = new ConnectorCapabilitiesCache();
@@ -626,20 +628,26 @@
ApplicationEnvironment env = this.getEnvironment();
PropertiesUtils.setBeanProperties(this, props, null);
+
+ this.processorTimeslice = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.PROCESS_TIMESLICE, DEFAULT_PROCESSOR_TIMESLICE);
+ this.maxFetchSize = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_FETCH_SIZE, DEFAULT_FETCH_SIZE);
+ this.processorDebugAllowed = PropertiesUtils.getBooleanProperty(props, DQPEmbeddedProperties.PROCESSOR_DEBUG_ALLOWED, true);
+ this.maxCodeTableRecords = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_CODE_TABLE_RECORDS, DEFAULT_MAX_CODE_TABLE_RECORDS);
+ this.maxCodeTables = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_CODE_TABLES, DEFAULT_MAX_CODE_TABLES);
- this.chunkSize = PropertiesUtils.getIntProperty(props, DQPConfigSource.STREAMING_BATCH_SIZE, 10) * 1024;
+ this.chunkSize = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.STREAMING_BATCH_SIZE, 10) * 1024;
//result set cache
- if(PropertiesUtils.getBooleanProperty(props, DQPConfigSource.USE_RESULTSET_CACHE, false)){
+ if(PropertiesUtils.getBooleanProperty(props, DQPEmbeddedProperties.USE_RESULTSET_CACHE, false)){
Properties rsCacheProps = new Properties();
- rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, props.getProperty(DQPConfigSource.MAX_RESULTSET_CACHE_SIZE, DEFAULT_MAX_RESULTSET_CACHE_SIZE));
- rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, props.getProperty(DQPConfigSource.MAX_RESULTSET_CACHE_AGE, DEFAULT_MAX_RESULTSET_CACHE_AGE));
- rsCacheProps.setProperty(ResultSetCache.RS_CACHE_SCOPE, props.getProperty(DQPConfigSource.RESULTSET_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_VDB));
+ rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, props.getProperty(DQPEmbeddedProperties.MAX_RESULTSET_CACHE_SIZE, DEFAULT_MAX_RESULTSET_CACHE_SIZE));
+ rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, props.getProperty(DQPEmbeddedProperties.MAX_RESULTSET_CACHE_AGE, DEFAULT_MAX_RESULTSET_CACHE_AGE));
+ rsCacheProps.setProperty(ResultSetCache.RS_CACHE_SCOPE, props.getProperty(DQPEmbeddedProperties.RESULTSET_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_VDB));
this.rsCache = new ResultSetCache(rsCacheProps, ResourceFinder.getCacheFactory());
}
//prepared plan cache
- int maxSizeTotal = PropertiesUtils.getIntProperty(props, DQPConfigSource.MAX_PLAN_CACHE_SIZE, PreparedPlanCache.DEFAULT_MAX_SIZE_TOTAL);
+ int maxSizeTotal = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_PLAN_CACHE_SIZE, PreparedPlanCache.DEFAULT_MAX_SIZE_TOTAL);
prepPlanCache = new PreparedPlanCache(maxSizeTotal);
// Processor debug flag
@@ -654,7 +662,7 @@
metadataService = (MetadataService) env.findService(DQPServiceNames.METADATA_SERVICE);
// Create the worker pools to tie the queues together
- processWorkerPool = WorkerPoolFactory.newWorkerPool(PROCESS_PLAN_QUEUE_NAME, PropertiesUtils.getIntProperty(props, DQPConfigSource.PROCESS_POOL_MAX_THREADS, DEFAULT_MAX_PROCESS_WORKERS));
+ processWorkerPool = WorkerPoolFactory.newWorkerPool(PROCESS_PLAN_QUEUE_NAME, PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.PROCESS_POOL_MAX_THREADS, DEFAULT_MAX_PROCESS_WORKERS));
tempTableStoresHolder = new TempTableStoresHolder(bufferManager);
@@ -663,7 +671,7 @@
(VDBService) env.findService(DQPServiceNames.VDB_SERVICE),
(BufferService) env.findService(DQPServiceNames.BUFFER_SERVICE),
this.maxCodeTables,
- this.maxCodeTableRecords);
+ this.maxCodeTableRecords);
}
public List getXmlSchemas(String docName) throws MetaMatrixComponentException,
@@ -760,25 +768,4 @@
MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment(), this.tempTableStoresHolder);
return processor.processMessage(workContext.getRequestID(requestID), workContext, preparedSql, allowDoubleQuotedVariable);
}
-
- public void setMaxFetchSize(int maxFetchSize) {
- this.maxFetchSize = maxFetchSize;
- }
-
- public void setProcessorDebugAllowed(boolean processorDebugAllowed) {
- this.processorDebugAllowed = processorDebugAllowed;
- }
-
- public void setMaxCodeTableRecords(int maxCodeTableRecords) {
- this.maxCodeTableRecords = maxCodeTableRecords;
- }
-
- public void setMaxCodeTables(int maxCodeTables) {
- this.maxCodeTables = maxCodeTables;
- }
-
- public void setProcessorTimeslice(int processorTimeslice) {
- this.processorTimeslice = processorTimeslice;
- }
-
}
\ No newline at end of file
14 years, 8 months
teiid SVN: r1280 - trunk/common-core/src/main/java/com/metamatrix/common/util.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-08-25 19:03:38 -0400 (Tue, 25 Aug 2009)
New Revision: 1280
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
Log:
TEIID-801
Modified: trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2009-08-25 20:26:27 UTC (rev 1279)
+++ trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2009-08-25 23:03:38 UTC (rev 1280)
@@ -129,7 +129,10 @@
while ( propNameEnum.hasMoreElements() ) {
String name = (String) propNameEnum.nextElement();
if ( name.startsWith(searchStr)) {
- results.put(name.substring(searchStr.length()), props.get(name));
+ Object value = props.get(name);
+ if (value != null) {
+ results.put(name.substring(searchStr.length()), value);
+ }
}
else if (addAll) {
results.put(name, props.get(name));
14 years, 8 months
teiid SVN: r1279 - in trunk/common-core/src: test/java/com/metamatrix/common/util and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-08-25 16:26:27 -0400 (Tue, 25 Aug 2009)
New Revision: 1279
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java
Log:
TEIID-801
Modified: trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2009-08-25 19:40:43 UTC (rev 1278)
+++ trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2009-08-25 20:26:27 UTC (rev 1279)
@@ -803,6 +803,7 @@
}
boolean matched = true;
+ boolean modified = false;
while(matched) {
// now match the pattern, then extract and find the value
@@ -821,9 +822,12 @@
throw new MetaMatrixRuntimeException(CorePlugin.Util.getString("PropertiesUtils.failed_to_resolve_property", nestedkey)); //$NON-NLS-1$
}
value = value.substring(0,start)+nestedvalue+value.substring(end+1);
+ modified = true;
}
}
- original.setProperty(key, value);
+ if(modified) {
+ original.setProperty(key, value);
+ }
}
return original;
}
Modified: trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java 2009-08-25 19:40:43 UTC (rev 1278)
+++ trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java 2009-08-25 20:26:27 UTC (rev 1279)
@@ -632,6 +632,7 @@
p.setProperty("key4", "${key2}/value4"); //$NON-NLS-1$ //$NON-NLS-2$
p.setProperty("key5", "${testdirectory}/testdata"); //$NON-NLS-1$ //$NON-NLS-2$
p.setProperty("key7", "anotherdir/${testdirectory}/${key1}"); //$NON-NLS-1$ //$NON-NLS-2$
+ int currentSize = p.size();
Properties m = PropertiesUtils.resolveNestedProperties(p);
assertEquals("value1/value2", m.getProperty("key2")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -640,7 +641,7 @@
assertEquals("c:/metamatrix/testdirectory/testdata", m.getProperty("key5")); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("anotherdir/c:/metamatrix/testdirectory/value1", m.getProperty("key7")); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue(p == m); // no cloning.
-
+ assertTrue(currentSize == m.size());
p.setProperty("key6", "${foo}"); //$NON-NLS-1$ //$NON-NLS-2$
14 years, 8 months
teiid SVN: r1278 - in trunk: common-core/src/main/java/com/metamatrix/common/types/basic and 9 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-08-25 15:40:43 -0400 (Tue, 25 Aug 2009)
New Revision: 1278
Added:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigIntegerTransform.java
Removed:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigDecimalToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigIntegerToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BooleanToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/CharacterToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DateToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimeToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimestampToStringTransform.java
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/AnyToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ClobToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/SQLXMLToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java
trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties
trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java
trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java
trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
Log:
TEIID-800 TEIID-799 TEIID-798 TEIID-797 updating the parser and conversion to support unknown keyword for booleans, adding better handling of char/boolean types, and changing the parser to use use common conversion logic for escaped literals.
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -42,7 +42,12 @@
import javax.xml.transform.stream.StreamSource;
import com.metamatrix.common.types.basic.AnyToObjectTransform;
+import com.metamatrix.common.types.basic.AnyToStringTransform;
import com.metamatrix.common.types.basic.BooleanToNumberTransform;
+import com.metamatrix.common.types.basic.FloatingNumberToBigDecimalTransform;
+import com.metamatrix.common.types.basic.FloatingNumberToBigIntegerTransform;
+import com.metamatrix.common.types.basic.FixedNumberToBigDecimalTransform;
+import com.metamatrix.common.types.basic.FixedNumberToBigIntegerTransform;
import com.metamatrix.common.types.basic.NullToAnyTransform;
import com.metamatrix.common.types.basic.NumberToBooleanTransform;
import com.metamatrix.common.types.basic.NumberToByteTransform;
@@ -587,8 +592,7 @@
DefaultDataClasses.BIG_DECIMAL, true));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.BIG_DECIMAL, true));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.BigDecimalToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.BIG_DECIMAL));
DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.BigIntegerToBigDecimalTransform());
@@ -605,8 +609,7 @@
DefaultDataClasses.BIG_INTEGER, true));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.BIG_INTEGER, true));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.BigIntegerToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.BIG_INTEGER));
DataTypeManager
.addTransform(new BooleanToNumberTransform(BigDecimal.valueOf(1), BigDecimal.valueOf(0)));
@@ -624,13 +627,10 @@
.addTransform(new BooleanToNumberTransform(Short.valueOf((short)1), Short.valueOf((short)0)));
DataTypeManager
.addTransform(new BooleanToNumberTransform(Byte.valueOf((byte)1), Byte.valueOf((byte)0)));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.BooleanToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.BOOLEAN));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.ByteToBigDecimalTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.ByteToBigIntegerTransform());
+ DataTypeManager.addTransform(new FixedNumberToBigDecimalTransform(DefaultDataClasses.BYTE));
+ DataTypeManager.addTransform(new FixedNumberToBigIntegerTransform(DefaultDataClasses.BYTE));
DataTypeManager.addTransform(new NumberToBooleanTransform(Byte.valueOf((byte)1), Byte.valueOf((byte)0)));
DataTypeManager.addTransform(new NumberToDoubleTransform(
DefaultDataClasses.BYTE, false));
@@ -642,24 +642,19 @@
DefaultDataClasses.BYTE, false));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.BYTE, false));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.ByteToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.BYTE));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.CharacterToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.CHAR));
DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.ClobToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.DATE));
DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.DateToStringTransform());
- DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.DateToTimestampTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.DoubleToBigDecimalTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.DoubleToBigIntegerTransform());
+ DataTypeManager.addTransform(new FloatingNumberToBigDecimalTransform(DefaultDataClasses.DOUBLE));
+ DataTypeManager.addTransform(new FloatingNumberToBigIntegerTransform(DefaultDataClasses.DOUBLE));
DataTypeManager.addTransform(new NumberToBooleanTransform(Double.valueOf(1), Double.valueOf(0)));
DataTypeManager.addTransform(new NumberToByteTransform(
DefaultDataClasses.DOUBLE));
@@ -671,13 +666,10 @@
DefaultDataClasses.DOUBLE, true));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.DOUBLE, true));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.DoubleToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.DOUBLE));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.FloatToBigDecimalTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.FloatToBigIntegerTransform());
+ DataTypeManager.addTransform(new FloatingNumberToBigDecimalTransform(DefaultDataClasses.FLOAT));
+ DataTypeManager.addTransform(new FloatingNumberToBigIntegerTransform(DefaultDataClasses.FLOAT));
DataTypeManager.addTransform(new NumberToBooleanTransform(Float.valueOf(1), Float.valueOf(0)));
DataTypeManager.addTransform(new NumberToByteTransform(
DefaultDataClasses.FLOAT));
@@ -689,13 +681,10 @@
DefaultDataClasses.FLOAT, true));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.FLOAT, true));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.FloatToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.FLOAT));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.IntegerToBigDecimalTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.IntegerToBigIntegerTransform());
+ DataTypeManager.addTransform(new FixedNumberToBigDecimalTransform(DefaultDataClasses.INTEGER));
+ DataTypeManager.addTransform(new FixedNumberToBigIntegerTransform(DefaultDataClasses.INTEGER));
DataTypeManager.addTransform(new NumberToBooleanTransform(Integer.valueOf(1), Integer.valueOf(0)));
DataTypeManager.addTransform(new NumberToByteTransform(
DefaultDataClasses.INTEGER));
@@ -707,13 +696,10 @@
DefaultDataClasses.INTEGER, false));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.INTEGER, true));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.IntegerToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.INTEGER));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.LongToBigDecimalTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.LongToBigIntegerTransform());
+ DataTypeManager.addTransform(new FixedNumberToBigDecimalTransform(DefaultDataClasses.LONG));
+ DataTypeManager.addTransform(new FixedNumberToBigIntegerTransform(DefaultDataClasses.LONG));
DataTypeManager.addTransform(new NumberToBooleanTransform(Long.valueOf(1), Long.valueOf(0)));
DataTypeManager.addTransform(new NumberToByteTransform(
DefaultDataClasses.LONG));
@@ -725,13 +711,10 @@
DefaultDataClasses.LONG, true));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.LONG, true));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.LongToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.LONG));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.ShortToBigDecimalTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.ShortToBigIntegerTransform());
+ DataTypeManager.addTransform(new FixedNumberToBigDecimalTransform(DefaultDataClasses.SHORT));
+ DataTypeManager.addTransform(new FixedNumberToBigIntegerTransform(DefaultDataClasses.SHORT));
DataTypeManager.addTransform(new NumberToBooleanTransform(Short.valueOf((short)1), Short.valueOf((short)0)));
DataTypeManager.addTransform(new NumberToByteTransform(
DefaultDataClasses.SHORT));
@@ -743,8 +726,7 @@
DefaultDataClasses.SHORT, false));
DataTypeManager.addTransform(new NumberToLongTransform(
DefaultDataClasses.SHORT, false));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.ShortToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.SHORT));
DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.StringToBigDecimalTransform());
@@ -782,15 +764,13 @@
DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.TimestampToDateTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.TIMESTAMP));
DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.TimestampToStringTransform());
- DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.TimestampToTimeTransform());
DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.TimeToTimestampTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.TimeToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.TIME));
for (Class<?> type : getAllDataTypeClasses()) {
if (type != DefaultDataClasses.OBJECT) {
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/AnyToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/AnyToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/AnyToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -28,19 +28,27 @@
* This class can be subclassed to do a simple anything-->String by
* just calling toString(). Just extend and implement getSouceType().
*/
-public abstract class AnyToStringTransform extends AbstractTransform {
+public class AnyToStringTransform extends AbstractTransform {
+ private Class<?> sourceType;
+
+ public AnyToStringTransform(Class<?> sourceType) {
+ this.sourceType = sourceType;
+ }
+
/**
* Type of the incoming value.
* @return Source type
*/
- public abstract Class getSourceType();
+ public Class<?> getSourceType() {
+ return sourceType;
+ }
/**
* Type of the outgoing value.
* @return Target type
*/
- public Class getTargetType() {
+ public Class<?> getTargetType() {
return String.class;
}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigDecimalToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigDecimalToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigDecimalToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-public class BigDecimalToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return BigDecimal.class;
- }
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigIntegerToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigIntegerToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigIntegerToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-public class BigIntegerToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return BigInteger.class;
- }
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BooleanToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BooleanToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BooleanToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class BooleanToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Boolean.class;
- }
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigDecimalTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigDecimalTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigDecimalTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class ByteToBigDecimalTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return BigDecimal.valueOf((Byte) value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Byte.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigDecimal.class;
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigIntegerTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigIntegerTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigIntegerTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class ByteToBigIntegerTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return BigInteger.valueOf((Byte)value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Byte.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigInteger.class;
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class ByteToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Byte.class;
- }
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/CharacterToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/CharacterToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/CharacterToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class CharacterToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Character.class;
- }
-}
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ClobToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ClobToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ClobToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -29,10 +29,15 @@
import com.metamatrix.common.types.ClobType;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.TransformationException;
+import com.metamatrix.common.types.DataTypeManager.DefaultDataClasses;
import com.metamatrix.core.CorePlugin;
public class ClobToStringTransform extends AnyToStringTransform {
+ public ClobToStringTransform() {
+ super(DefaultDataClasses.CLOB);
+ }
+
/**
* This method transforms a value of the source type into a value
* of the target type.
@@ -67,14 +72,6 @@
}
}
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return ClobType.class;
- }
-
/**
* @see com.metamatrix.common.types.AbstractTransform#isNarrowing()
*/
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DateToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DateToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DateToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.sql.Date;
-
-public class DateToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Date.class;
- }
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigDecimalTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigDecimalTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigDecimalTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class DoubleToBigDecimalTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return BigDecimal.valueOf((Double)value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Double.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigDecimal.class;
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigIntegerTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigIntegerTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigIntegerTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class DoubleToBigIntegerTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- String doubleString = value.toString();
- int index = doubleString.lastIndexOf("."); //$NON-NLS-1$
- if(index >= 0) {
- return new BigInteger(doubleString.substring(0, index));
- }
- return new BigInteger(doubleString);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Double.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigInteger.class;
- }
-
- /**
- * Flag if the transformation from source to target is
- * a narrowing transformation that may lose information.
- * @return True - this transformation is narrowing
- */
- public boolean isNarrowing() {
- return true;
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class DoubleToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Double.class;
- }
-}
Copied: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigDecimalTransform.java (from rev 1276, trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigDecimalTransform.java)
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigDecimalTransform.java (rev 0)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigDecimalTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.types.basic;
+
+import java.math.BigDecimal;
+
+import com.metamatrix.common.types.AbstractTransform;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.TransformationException;
+
+public class FixedNumberToBigDecimalTransform extends AbstractTransform {
+
+ private Class<?> sourceType;
+
+ public FixedNumberToBigDecimalTransform(Class<?> sourceType) {
+ this.sourceType = sourceType;
+ }
+
+ /**
+ * This method transforms a value of the source type into a value
+ * of the target type.
+ * @param value Incoming value of source type
+ * @return Outgoing value of target type
+ * @throws TransformationException if value is an incorrect input type or
+ * the transformation fails
+ */
+ public Object transform(Object value) throws TransformationException {
+ if(value == null) {
+ return value;
+ }
+
+ return BigDecimal.valueOf(((Number)value).longValue());
+ }
+
+ /**
+ * Type of the incoming value.
+ * @return Source type
+ */
+ public Class<?> getSourceType() {
+ return sourceType;
+ }
+
+ /**
+ * Type of the outgoing value.
+ * @return Target type
+ */
+ public Class<?> getTargetType() {
+ return DataTypeManager.DefaultDataClasses.BIG_DECIMAL;
+ }
+
+}
Copied: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigIntegerTransform.java (from rev 1276, trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigIntegerTransform.java)
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigIntegerTransform.java (rev 0)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigIntegerTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.types.basic;
+
+import java.math.BigInteger;
+
+import com.metamatrix.common.types.AbstractTransform;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.TransformationException;
+
+public class FixedNumberToBigIntegerTransform extends AbstractTransform {
+
+ private Class<?> sourceType;
+
+ public FixedNumberToBigIntegerTransform(Class<?> sourceType) {
+ this.sourceType = sourceType;
+ }
+
+ /**
+ * This method transforms a value of the source type into a value
+ * of the target type.
+ * @param value Incoming value of source type
+ * @return Outgoing value of target type
+ * @throws TransformationException if value is an incorrect input type or
+ * the transformation fails
+ */
+ public Object transform(Object value) throws TransformationException {
+ if(value == null) {
+ return value;
+ }
+
+ return BigInteger.valueOf(((Number)value).longValue());
+ }
+
+ /**
+ * Type of the incoming value.
+ * @return Source type
+ */
+ public Class<?> getSourceType() {
+ return sourceType;
+ }
+
+ /**
+ * Type of the outgoing value.
+ * @return Target type
+ */
+ public Class<?> getTargetType() {
+ return DataTypeManager.DefaultDataClasses.BIG_INTEGER;
+ }
+
+}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigDecimalTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigDecimalTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigDecimalTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class FloatToBigDecimalTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return BigDecimal.valueOf((Float)value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Float.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigDecimal.class;
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigIntegerTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigIntegerTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigIntegerTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class FloatToBigIntegerTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- String floatString = value.toString();
- int index = floatString.lastIndexOf("."); //$NON-NLS-1$
- if(index >= 0) {
- return new BigInteger(floatString.substring(0, index));
- }
- return new BigInteger(floatString);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Float.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigInteger.class;
- }
-
- /**
- * Flag if the transformation from source to target is
- * a narrowing transformation that may lose information.
- * @return True - this transformation is narrowing
- */
- public boolean isNarrowing() {
- return true;
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class FloatToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Float.class;
- }
-}
Copied: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigDecimalTransform.java (from rev 1276, trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigDecimalTransform.java)
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigDecimalTransform.java (rev 0)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigDecimalTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.types.basic;
+
+import java.math.BigDecimal;
+
+import com.metamatrix.common.types.AbstractTransform;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.TransformationException;
+
+public class FloatingNumberToBigDecimalTransform extends AbstractTransform {
+
+ private Class<?> sourceType;
+
+ public FloatingNumberToBigDecimalTransform(Class<?> sourceType) {
+ this.sourceType = sourceType;
+ }
+
+ /**
+ * This method transforms a value of the source type into a value
+ * of the target type.
+ * @param value Incoming value of source type
+ * @return Outgoing value of target type
+ * @throws TransformationException if value is an incorrect input type or
+ * the transformation fails
+ */
+ public Object transform(Object value) throws TransformationException {
+ if(value == null) {
+ return value;
+ }
+
+ return BigDecimal.valueOf(((Number)value).doubleValue());
+ }
+
+ /**
+ * Type of the incoming value.
+ * @return Source type
+ */
+ public Class<?> getSourceType() {
+ return sourceType;
+ }
+
+ /**
+ * Type of the outgoing value.
+ * @return Target type
+ */
+ public Class<?> getTargetType() {
+ return DataTypeManager.DefaultDataClasses.BIG_DECIMAL;
+ }
+
+}
Copied: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigIntegerTransform.java (from rev 1276, trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigIntegerTransform.java)
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigIntegerTransform.java (rev 0)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigIntegerTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.types.basic;
+
+import java.math.BigInteger;
+
+import com.metamatrix.common.types.AbstractTransform;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.TransformationException;
+
+public class FloatingNumberToBigIntegerTransform extends AbstractTransform {
+
+ private Class<?> sourceType;
+
+ public FloatingNumberToBigIntegerTransform(Class<?> sourceType) {
+ this.sourceType = sourceType;
+ }
+
+ /**
+ * This method transforms a value of the source type into a value
+ * of the target type.
+ * @param value Incoming value of source type
+ * @return Outgoing value of target type
+ * @throws TransformationException if value is an incorrect input type or
+ * the transformation fails
+ */
+ public Object transform(Object value) throws TransformationException {
+ if(value == null) {
+ return value;
+ }
+
+ String doubleString = String.valueOf(value);
+ int index = doubleString.lastIndexOf("."); //$NON-NLS-1$
+ if(index >= 0) {
+ return new BigInteger(doubleString.substring(0, index));
+ }
+ return new BigInteger(doubleString);
+ }
+
+ /**
+ * Type of the incoming value.
+ * @return Source type
+ */
+ public Class getSourceType() {
+ return sourceType;
+ }
+
+ /**
+ * Type of the outgoing value.
+ * @return Target type
+ */
+ public Class getTargetType() {
+ return DataTypeManager.DefaultDataClasses.BIG_INTEGER;
+ }
+
+ /**
+ * Flag if the transformation from source to target is
+ * a narrowing transformation that may lose information.
+ * @return True - this transformation is narrowing
+ */
+ public boolean isNarrowing() {
+ return true;
+ }
+
+}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigDecimalTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigDecimalTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigDecimalTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class IntegerToBigDecimalTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return BigDecimal.valueOf((Integer)value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Integer.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigDecimal.class;
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigIntegerTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigIntegerTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigIntegerTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class IntegerToBigIntegerTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return new BigInteger(String.valueOf(value));
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Integer.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigInteger.class;
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class IntegerToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Integer.class;
- }
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigDecimalTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigDecimalTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigDecimalTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class LongToBigDecimalTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return new BigDecimal((Long)value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Long.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigDecimal.class;
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigIntegerTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigIntegerTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigIntegerTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class LongToBigIntegerTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return new BigInteger(String.valueOf(value));
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Long.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigInteger.class;
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class LongToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Long.class;
- }
-}
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/SQLXMLToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/SQLXMLToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/SQLXMLToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -28,10 +28,15 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.TransformationException;
import com.metamatrix.common.types.XMLType;
+import com.metamatrix.common.types.DataTypeManager.DefaultDataClasses;
import com.metamatrix.core.CorePlugin;
public class SQLXMLToStringTransform extends AnyToStringTransform {
+ public SQLXMLToStringTransform() {
+ super(DefaultDataClasses.XML);
+ }
+
/**
* This method transforms a value of the source type into a value
* of the target type.
@@ -58,14 +63,6 @@
}
}
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return XMLType.class;
- }
-
/**
* @see com.metamatrix.common.types.AbstractTransform#isNarrowing()
*/
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigDecimalTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigDecimalTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigDecimalTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class ShortToBigDecimalTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return new BigDecimal((Short)value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Short.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigDecimal.class;
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigIntegerTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigIntegerTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigIntegerTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class ShortToBigIntegerTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return new BigInteger(String.valueOf(value));
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Short.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigInteger.class;
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class ShortToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Short.class;
- }
-}
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -22,14 +22,21 @@
package com.metamatrix.common.types.basic;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
import com.metamatrix.common.types.AbstractTransform;
import com.metamatrix.common.types.TransformationException;
+import com.metamatrix.common.types.DataTypeManager.DefaultDataClasses;
+import com.metamatrix.core.CorePlugin;
+import com.metamatrix.core.ErrorMessageKeys;
public class StringToBooleanTransform extends AbstractTransform {
- private static final String TRUE = "1"; //$NON-NLS-1$
- private static final String FALSE = "0"; //$NON-NLS-1$
-
+ private static final Set<String> TRUE = new HashSet<String>(Arrays.asList("1", "TRUE")); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final Set<String> FALSE = new HashSet<String>(Arrays.asList("0", "FALSE")); //$NON-NLS-1$ //$NON-NLS-2$
+
/**
* This method transforms a value of the source type into a value
* of the target type.
@@ -42,30 +49,33 @@
if(value == null) {
return value;
}
- String str = ((String)value).trim();
- if (TRUE.equals(str)) {
+ String str = ((String)value).trim().toUpperCase();
+ if (TRUE.contains(str)) {
return Boolean.TRUE;
}
- else if (FALSE.equals(str)) {
+ if (FALSE.contains(str)) {
return Boolean.FALSE;
}
- return Boolean.valueOf((String)value);
+ if ("UNKNOWN".equals(str)) { //$NON-NLS-1$
+ return null;
+ }
+ throw new TransformationException(ErrorMessageKeys.TYPES_ERR_0013, CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0013, getSourceType().getSimpleName(), value));
}
/**
* Type of the incoming value.
* @return Source type
*/
- public Class getSourceType() {
- return String.class;
+ public Class<?> getSourceType() {
+ return DefaultDataClasses.STRING;
}
/**
* Type of the outgoing value.
* @return Target type
*/
- public Class getTargetType() {
- return Boolean.class;
+ public Class<?> getTargetType() {
+ return DefaultDataClasses.BOOLEAN;
}
-
+
}
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -24,8 +24,6 @@
import com.metamatrix.common.types.AbstractTransform;
import com.metamatrix.common.types.TransformationException;
-import com.metamatrix.core.CorePlugin;
-import com.metamatrix.core.ErrorMessageKeys;
public class StringToCharacterTransform extends AbstractTransform {
@@ -41,21 +39,21 @@
if(value == null) {
return value;
}
-
+
String s = (String) value;
- switch(s.length()) {
- case 0: return null;
- case 1: return new Character( s.charAt(0) );
- default:
- throw new TransformationException(ErrorMessageKeys.TYPES_ERR_0017, CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0017, value));
+
+ if (s.length() == 0) {
+ return new Character(' ');
}
+
+ return new Character( s.charAt(0) );
}
/**
* Type of the incoming value.
* @return Source type
*/
- public Class getSourceType() {
+ public Class<?> getSourceType() {
return String.class;
}
@@ -63,8 +61,13 @@
* Type of the outgoing value.
* @return Target type
*/
- public Class getTargetType() {
+ public Class<?> getTargetType() {
return Character.class;
}
+
+ @Override
+ public boolean isNarrowing() {
+ return true;
+ }
}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimeToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimeToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimeToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.sql.Time;
-
-public class TimeToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Time.class;
- }
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimestampToStringTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimestampToStringTransform.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimestampToStringTransform.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.sql.Timestamp;
-
-public class TimestampToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Timestamp.class;
- }
-}
Modified: trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties
===================================================================
--- trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties 2009-08-25 19:40:43 UTC (rev 1278)
@@ -344,7 +344,7 @@
ERR.003.029.0004=Transform cannot be null.
ERR.003.029.0005=Transform source name cannot be null: {0}
ERR.003.029.0006=Transform target name cannot be null: {0}
-ERR.003.029.0013=Failed to transform {0} to Boolean. Expected 0 or 1 for {1}
+ERR.003.029.0013=Failed to transform {0} to Boolean. Expected 0, 1, ''TRUE'', ''FALSE'', or ''UNKNOWN'' for ''{1}''
ERR.003.029.0014=Invalid BigDecimal format in String: {0}
ERR.003.029.0015=Invalid BigInteger format in String: {0}
ERR.003.029.0016=Invalid Byte format in String: {0}
@@ -400,4 +400,4 @@
ExceptionHolder.converted_exception=Remote exception: {0} ... Original type hierarchy {1}.
PropertiesUtils.failed_to_resolve_property=failed to completely resolve the property value for key {0}
-transform.invalid_string_for_date=The string representation ''{0}'' of a {1} value is out of range.
\ No newline at end of file
+transform.invalid_string_for_date=The string representation ''{0}'' of a {1} value is not valid.
\ No newline at end of file
Modified: trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -92,7 +92,7 @@
helpTestTransform(new String("0"), Boolean.FALSE); //$NON-NLS-1$
helpTestTransform(new String("true"), Boolean.TRUE); //$NON-NLS-1$
helpTestTransform(new String("false"), Boolean.FALSE); //$NON-NLS-1$
- helpTestTransform(new String("foo"), Boolean.FALSE); //$NON-NLS-1$
+ helpTransformException(new String("foo"), DataTypeManager.DefaultDataClasses.BOOLEAN); //$NON-NLS-1$
}
@Test public void testByte2Boolean() throws TransformationException {
@@ -149,7 +149,8 @@
private String[] dataTypes = TestDataTypeManager.dataTypes;
private char[][] conversions = TestDataTypeManager.conversions;
private static boolean isException(String src, String tgt, Object source) {
- return (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.XML))
+ return (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.BOOLEAN) && source == testData[0][2])
+ || (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.XML))
|| (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.CHAR))
|| (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.TIME))
|| (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.TIMESTAMP))
@@ -228,7 +229,7 @@
}
@Test public void testStringToTimestampOutOfRange() throws Exception {
- helpTransformException("2005-13-01 11:13:01", DefaultDataClasses.TIMESTAMP, "The string representation '2005-13-01 11:13:01' of a Timestamp value is out of range."); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTransformException("2005-13-01 11:13:01", DefaultDataClasses.TIMESTAMP, "The string representation '2005-13-01 11:13:01' of a Timestamp value is not valid."); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testStringToTimeTimestampWithWS() throws Exception {
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2009-08-25 19:40:43 UTC (rev 1278)
@@ -381,8 +381,14 @@
<entry>false</entry>
</row>
<row>
+ <entry>'unknown'</entry>
+ <entry>unknown</entry>
+ </row>
+ <row>
<entry>other</entry>
- <entry>false</entry>
+ <entry>
+ <emphasis>error</emphasis>
+ </entry>
</row>
<row>
<entry morerows="2">Numeric</entry>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml 2009-08-25 19:40:43 UTC (rev 1278)
@@ -413,7 +413,7 @@
</row>
<row>
<entry valign="top"><anchor id="prod82"/>literal ::= </entry>
-<entry valign="top">( <STRINGVAL> | <INTEGERVAL> | <FLOATVAL> | <FALSE> | <TRUE> | <NULL> | ( <BOOLEANTYPE> <STRINGVAL> <RBRACE> ) | ( <TIMESTAMPTYPE> <STRINGVAL> <RBRACE> ) | ( <DATETYPE> <STRINGVAL> <RBRACE> ) | ( <TIMETYPE> <STRINGVAL> <RBRACE> ) )</entry>
+<entry valign="top">( <STRINGVAL> | <INTEGERVAL> | <FLOATVAL> | <FALSE> | <TRUE> | <UNKNOWN> | <NULL> | ( <BOOLEANTYPE> <STRINGVAL> <RBRACE> ) | ( <TIMESTAMPTYPE> <STRINGVAL> <RBRACE> ) | ( <DATETYPE> <STRINGVAL> <RBRACE> ) | ( <TIMETYPE> <STRINGVAL> <RBRACE> ) )</entry>
</row>
</tbody>
</tgroup>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2009-08-25 19:40:43 UTC (rev 1278)
@@ -756,7 +756,7 @@
<para>ASCII(x)</para>
</entry>
<entry>
- <para>Provide ASCII value of character x</para>
+ <para>Provide ASCII value of the left most character in x. The empty string will as input will return null.</para>
</entry>
<entry>
<para>return type is integer</para>
@@ -782,7 +782,7 @@
x and/or y is null, returns null.</para>
</entry>
<entry>
- <para>x, y, is string</para>
+ <para>x, y in {string}</para>
</entry>
</row>
<row>
@@ -795,7 +795,7 @@
is null, returns the other value.</para>
</entry>
<entry>
- <para>x, y, is string</para>
+ <para>x, y in {string}</para>
</entry>
</row>
<row>
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -50,131 +50,107 @@
// ================== Function = plus =====================
- public static Object plus(Object x, Object y) throws FunctionExecutionException {
- if(x instanceof Integer) {
- if(y instanceof Integer) {
- return new Integer(((Integer)x).intValue() + ((Integer)y).intValue());
- }
- } else if(x instanceof Long) {
- if(y instanceof Long) {
- return new Long(((Long)x).longValue() + ((Long)y).longValue());
- }
- } else if(x instanceof Float) {
- if(y instanceof Float) {
- return new Float(((Float)x).floatValue() + ((Float)y).floatValue());
- }
- } else if(x instanceof Double) {
- if(y instanceof Double) {
- return new Double(((Double)x).doubleValue() + ((Double)y).doubleValue());
- }
- } else if(x instanceof BigInteger) {
- if(y instanceof BigInteger) {
- return ((BigInteger)x).add((BigInteger) y);
- }
- } else if(x instanceof BigDecimal) {
- if(y instanceof BigDecimal) {
- return ((BigDecimal)x).add((BigDecimal) y);
- }
- }
-
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new Object[]{"plus", x.getClass().getName(), y.getClass().getName()})); //$NON-NLS-1$
+ public static int plus(int x, int y) {
+ return x + y;
}
+
+ public static long plus(long x, long y) {
+ return x + y;
+ }
+
+ public static float plus(float x, float y) {
+ return x + y;
+ }
+
+ public static double plus(double x, double y) {
+ return x + y;
+ }
+
+ public static Object plus(BigInteger x, BigInteger y) {
+ return x.add(y);
+ }
+
+ public static Object plus(BigDecimal x, BigDecimal y) {
+ return x.add(y);
+ }
// ================== Function = minus =====================
- public static Object minus(Object x, Object y) throws FunctionExecutionException {
- if(x instanceof Integer) {
- if(y instanceof Integer) {
- return new Integer(((Integer)x).intValue() - ((Integer)y).intValue());
- }
- } else if(x instanceof Long) {
- if(y instanceof Long) {
- return new Long(((Long)x).longValue() - ((Long)y).longValue());
- }
- } else if(x instanceof Float) {
- if(y instanceof Float) {
- return new Float(((Float)x).floatValue() - ((Float)y).floatValue());
- }
- } else if(x instanceof Double) {
- if(y instanceof Double) {
- return new Double(((Double)x).doubleValue() - ((Double)y).doubleValue());
- }
- } else if(x instanceof BigInteger) {
- if(y instanceof BigInteger) {
- return ((BigInteger)x).subtract((BigInteger) y);
- }
- } else if(x instanceof BigDecimal) {
- if(y instanceof BigDecimal) {
- return ((BigDecimal)x).subtract((BigDecimal) y);
- }
- }
-
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new Object[]{"minus", x.getClass().getName(), y.getClass().getName()})); //$NON-NLS-1$
+ public static int minus(int x, int y) {
+ return x - y;
}
+
+ public static long minus(long x, long y) {
+ return x - y;
+ }
+
+ public static float minus(float x, float y) {
+ return x - y;
+ }
+
+ public static double minus(double x, double y) {
+ return x - y;
+ }
+
+ public static Object minus(BigInteger x, BigInteger y) {
+ return x.subtract(y);
+ }
+
+ public static Object minus(BigDecimal x, BigDecimal y) {
+ return x.subtract(y);
+ }
// ================== Function = multiply =====================
- public static Object multiply(Object x, Object y) throws FunctionExecutionException {
- if(x instanceof Integer) {
- if(y instanceof Integer) {
- return new Integer(((Integer)x).intValue() * ((Integer)y).intValue());
- }
- } else if(x instanceof Long) {
- if(y instanceof Long) {
- return new Long(((Long)x).longValue() * ((Long)y).longValue());
- }
- } else if(x instanceof Float) {
- if(y instanceof Float) {
- return new Float(((Float)x).floatValue() * ((Float)y).floatValue());
- }
- } else if(x instanceof Double) {
- if(y instanceof Double) {
- return new Double(((Double)x).doubleValue() * ((Double)y).doubleValue());
- }
- } else if(x instanceof BigInteger) {
- if(y instanceof BigInteger) {
- return ((BigInteger)x).multiply((BigInteger) y);
- }
- } else if(x instanceof BigDecimal) {
- if(y instanceof BigDecimal) {
- return ((BigDecimal)x).multiply((BigDecimal) y);
- }
- }
-
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new Object[]{"multiply", x.getClass().getName(), y.getClass().getName()})); //$NON-NLS-1$
+ public static int multiply(int x, int y) {
+ return x * y;
}
+
+ public static long multiply(long x, long y) {
+ return x * y;
+ }
+
+ public static float multiply(float x, float y) {
+ return x * y;
+ }
+
+ public static double multiply(double x, double y) {
+ return x * y;
+ }
+
+ public static Object multiply(BigInteger x, BigInteger y) {
+ return x.multiply(y);
+ }
+
+ public static Object multiply(BigDecimal x, BigDecimal y) {
+ return x.multiply(y);
+ }
// ================== Function = divide =====================
- public static Object divide(Object x, Object y) throws FunctionExecutionException {
- if(x instanceof Integer) {
- if(y instanceof Integer) {
- return new Integer(((Integer)x).intValue() / ((Integer)y).intValue());
- }
- } else if(x instanceof Long) {
- if(y instanceof Long) {
- return new Long(((Long)x).longValue() / ((Long)y).longValue());
- }
- } else if(x instanceof Float) {
- if(y instanceof Float) {
- return new Float(((Float)x).floatValue() / ((Float)y).floatValue());
- }
- } else if(x instanceof Double) {
- if(y instanceof Double) {
- return new Double(((Double)x).doubleValue() / ((Double)y).doubleValue());
- }
- } else if(x instanceof BigInteger) {
- if(y instanceof BigInteger) {
- return ((BigInteger)x).divide((BigInteger) y);
- }
- } else if(x instanceof BigDecimal) {
- if(y instanceof BigDecimal) {
- return ((BigDecimal)x).divide((BigDecimal) y, BigDecimal.ROUND_HALF_UP);
- }
- }
-
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new Object[]{"divide", x.getClass().getName(), y.getClass().getName()})); //$NON-NLS-1$
+ public static int divide(int x, int y) {
+ return x / y;
}
+
+ public static long divide(long x, long y) {
+ return x / y;
+ }
+
+ public static float divide(float x, float y) {
+ return x / y;
+ }
+
+ public static double divide(double x, double y) {
+ return x / y;
+ }
+
+ public static Object divide(BigInteger x, BigInteger y) {
+ return x.divide(y);
+ }
+
+ public static Object divide(BigDecimal x, BigDecimal y) {
+ return x.divide(y, BigDecimal.ROUND_HALF_UP);
+ }
// ================== Function = abs =====================
@@ -322,49 +298,29 @@
// ================== Function = sign =====================
- public static Object sign(Object x) throws FunctionExecutionException {
- if(x == null) {
- return null;
- } else if(x instanceof Integer) {
- int xVal = ((Integer)x).intValue();
- if(xVal > 0) {
- return new Integer(1);
- } else if(xVal == 0) {
- return new Integer(0);
- }
- return new Integer(-1);
- } else if(x instanceof Long) {
- long xVal = ((Long)x).longValue();
- if(xVal > 0) {
- return new Integer(1);
- } else if(xVal == 0) {
- return new Integer(0);
- }
- return new Integer(-1);
- } else if(x instanceof Float) {
- float xVal = ((Float)x).floatValue();
- if(xVal > 0) {
- return new Integer(1);
- } else if(xVal == 0) {
- return new Integer(0);
- }
- return new Integer(-1);
- } else if(x instanceof Double) {
- double xVal = ((Double)x).doubleValue();
- if(xVal > 0) {
- return new Integer(1);
- } else if(xVal == 0) {
- return new Integer(0);
- }
- return new Integer(-1);
- } else if(x instanceof BigInteger) {
- return new Integer(((BigInteger)x).signum());
- } else if(x instanceof BigDecimal) {
- return new Integer(((BigDecimal)x).signum());
- }
+ public static Object sign(int x) {
+ return Integer.signum(x);
+ }
+
+ public static Object sign(long x) {
+ return Long.signum(x);
+ }
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "sign", x.getClass().getName())); //$NON-NLS-1$
+ public static Object sign(float x) {
+ return Math.signum(x);
}
+
+ public static Object sign(double x) {
+ return Math.signum(x);
+ }
+
+ public static Object sign(BigInteger x) {
+ return new Integer(x.signum());
+ }
+
+ public static Object sign(BigDecimal x) {
+ return new Integer(x.signum());
+ }
// ================== Function = sqrt =====================
@@ -853,25 +809,16 @@
// ================== Function = ascii =====================
- public static Object ascii(Object ch)
- throws FunctionExecutionException {
-
- char c = 0;
- if(ch instanceof Character) {
- c = ((Character) ch).charValue();
- } else if(ch instanceof String) {
- String s = (String) ch;
- if(s.length() >= 1) {
- c = s.charAt(0);
- } else if(s.length() == 0) {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0021, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0021));
- }
- } else {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "ascii", ch.getClass().getName())); //$NON-NLS-1$
- }
-
- return new Integer(c);
+ public static Integer ascii(String ch) {
+ if(ch.length() == 0) {
+ return null;
+ }
+ return (int)ch.charAt(0);
}
+
+ public static Integer ascii(Character ch) {
+ return (int)ch.charValue();
+ }
// ================== Function = chr =====================
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -269,11 +269,7 @@
}
private QueryParserException convertParserException(ParseException pe) {
- QueryParserException qpe = null;
-
- qpe = new QueryParserException(QueryPlugin.Util.getString("QueryParser.parsingError", pe.getMessage())); //$NON-NLS-1$
-
- return qpe;
+ return new QueryParserException(QueryPlugin.Util.getString("QueryParser.parsingError", pe.getMessage())); //$NON-NLS-1$
}
/**
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-08-25 19:38:18 UTC (rev 1277)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -30,8 +30,6 @@
import java.util.List;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.ReservedWords;
@@ -105,7 +103,6 @@
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.util.ErrorMessageKeys;
/**
* <p>The SQLStringVisitor will visit a set of language objects and return the
@@ -1131,34 +1128,32 @@
}
public void visit(Constant obj) {
+ Class<?> type = obj.getType();
Object[] constantParts = null;
if (obj.isMultiValued()) {
constantParts = new Object[] {"?"}; //$NON-NLS-1$
} else if(obj.isNull()) {
- constantParts = new Object[] {"null"}; //$NON-NLS-1$
+ if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
+ constantParts = new Object[] {ReservedWords.UNKNOWN};
+ } else {
+ constantParts = new Object[] {"null"}; //$NON-NLS-1$
+ }
} else {
- try {
- Class type = obj.getType();
- if(type.equals(DataTypeManager.DefaultDataClasses.STRING)) {
- String strValue = (String) obj.getValue();
- strValue = escapeStringValue(strValue);
- constantParts = new Object[] { getStringQuoteBegin(), strValue, getStringQuoteEnd() };
- } else if(Number.class.isAssignableFrom(type)) {
- constantParts = new Object[] { obj.getValue().toString() };
- } else if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
- constantParts = new Object[] { obj.getValue().equals(Boolean.TRUE) ? ReservedWords.TRUE : ReservedWords.FALSE};
- } else if(type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
- constantParts = new Object[] { "{ts'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
- } else if(type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
- constantParts = new Object[] { "{t'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
- } else if(type.equals(DataTypeManager.DefaultDataClasses.DATE)) {
- constantParts = new Object[] { "{d'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- constantParts = new Object[] { getStringQuoteBegin(), obj.getValue().toString(), getStringQuoteEnd() };
- }
- } catch(RuntimeException e) {
- Assertion.failed(QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0026, e.getMessage()));
- }
+ if(Number.class.isAssignableFrom(type)) {
+ constantParts = new Object[] { obj.getValue().toString() };
+ } else if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
+ constantParts = new Object[] { obj.getValue().equals(Boolean.TRUE) ? ReservedWords.TRUE : ReservedWords.FALSE};
+ } else if(type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
+ constantParts = new Object[] { "{ts'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
+ } else if(type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
+ constantParts = new Object[] { "{t'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
+ } else if(type.equals(DataTypeManager.DefaultDataClasses.DATE)) {
+ constantParts = new Object[] { "{d'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ String strValue = obj.getValue().toString();
+ strValue = escapeStringValue(strValue);
+ constantParts = new Object[] { getStringQuoteBegin(), strValue, getStringQuoteEnd() };
+ }
}
replaceStringParts(constantParts);
Modified: trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2009-08-25 19:40:43 UTC (rev 1278)
@@ -15,7 +15,7 @@
import java.math.BigInteger;
import java.util.*;
-import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.*;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageObject;
@@ -2949,7 +2949,7 @@
Token t = null;
String strVal = null;
char tickChar = '\'';
-
+ Class escapeType = null;
Constant constant = null;
}
{
@@ -2995,52 +2995,23 @@
}
} |
- t=<FALSE> { constant = new Constant(Boolean.FALSE, DataTypeManager.DefaultDataClasses.BOOLEAN); } |
- t=<TRUE> { constant = new Constant(Boolean.TRUE, DataTypeManager.DefaultDataClasses.BOOLEAN); } |
- t=<NULL> { constant = new Constant(null); } |
+ t=<FALSE> { constant = new Constant(Boolean.FALSE, DataTypeManager.DefaultDataClasses.BOOLEAN); } |
+ t=<TRUE> { constant = new Constant(Boolean.TRUE, DataTypeManager.DefaultDataClasses.BOOLEAN); } |
+ t=<UNKNOWN> { constant = new Constant(null, DataTypeManager.DefaultDataClasses.BOOLEAN); } |
+ t=<NULL> { constant = new Constant(null); } |
- ( <BOOLEANTYPE> t=<STRINGVAL> {
- String boolStr = t.image.substring(1, t.image.length()-1);
- if(boolStr.equalsIgnoreCase("true")) { //$NON-NLS-1$
- constant = new Constant(Boolean.TRUE, DataTypeManager.DefaultDataClasses.BOOLEAN);
- } else if(boolStr.equalsIgnoreCase("false")) { //$NON-NLS-1$
- constant = new Constant(Boolean.FALSE, DataTypeManager.DefaultDataClasses.BOOLEAN);
- } else {
- Object[] params = new Object[] { boolStr };
- throw new ParseException(QueryPlugin.Util.getString("SQLParser.Boolean_parse", params)); //$NON-NLS-1$
- }
- } <RBRACE> ) |
-
- ( <TIMESTAMPTYPE> t=<STRINGVAL> {
- String timestampStr = t.image.substring(1, t.image.length()-1);
+ ( (<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);
try {
- constant = new Constant(java.sql.Timestamp.valueOf(timestampStr), DataTypeManager.DefaultDataClasses.TIMESTAMP);
- } catch(IllegalArgumentException e) {
- Object[] params = new Object[] { timestampStr };
- throw new ParseException(QueryPlugin.Util.getString("SQLParser.Timestamp_parse", params)); //$NON-NLS-1$
- }
- } <RBRACE>) |
-
- ( <DATETYPE> t=<STRINGVAL> {
- String dateStr = t.image.substring(1, t.image.length()-1);
- try {
- constant = new Constant(java.sql.Date.valueOf(dateStr), DataTypeManager.DefaultDataClasses.DATE);
- } catch(IllegalArgumentException e) {
- Object[] params = new Object[] { dateStr };
- throw new ParseException(QueryPlugin.Util.getString("SQLParser.Date_parse", params)); //$NON-NLS-1$
- }
- } <RBRACE>) |
+ constant = new Constant(DataTypeManager.transformValue(str, escapeType), escapeType);
+ } catch (TransformationException e) {
+ throw new ParseException(e.getMessage()); //$NON-NLS-1$
+ }
+ } <RBRACE> )
- ( <TIMETYPE> t=<STRINGVAL> {
- String timeStr = t.image.substring(1, t.image.length()-1);
- try {
- constant = new Constant(java.sql.Time.valueOf(timeStr), DataTypeManager.DefaultDataClasses.TIME);
- } catch(IllegalArgumentException e) {
- Object[] params = new Object[] { timeStr };
- throw new ParseException(QueryPlugin.Util.getString("SQLParser.Time_parse", params)); //$NON-NLS-1$
- }
- } <RBRACE>)
-
)
{
return constant;
Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -408,7 +408,7 @@
}
@Test public void testConvertStringBoolean3() throws Exception {
- helpConvert("x", "boolean", Boolean.FALSE); //$NON-NLS-1$ //$NON-NLS-2$
+ helpConvertFail("x", "boolean"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testConvertStringBoolean4() throws Exception {
@@ -424,7 +424,7 @@
}
@Test public void testConvertStringChar2() throws Exception {
- helpConvertFail("xx", "char"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpConvert("xx", "char", new Character('x')); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testConvertStringByte1() throws Exception {
@@ -494,26 +494,17 @@
helpConvert(ts, "string", "2003-08-22 22:43:53.003333333"); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testAscii1() throws Exception {
- Integer code = (Integer) FunctionMethods.ascii(new Character(' '));
- assertEquals("Didn't get expected code", 32, code.intValue()); //$NON-NLS-1$
- }
-
@Test public void testAscii2() throws Exception {
- Integer code = (Integer) FunctionMethods.ascii(" "); //$NON-NLS-1$
+ Integer code = FunctionMethods.ascii(" "); //$NON-NLS-1$
assertEquals("Didn't get expected code", 32, code.intValue()); //$NON-NLS-1$
}
@Test public void testAscii4() throws Exception {
- try {
- FunctionMethods.ascii(""); //$NON-NLS-1$
- fail("Expected function exception"); //$NON-NLS-1$
- } catch (FunctionExecutionException e) {
- }
+ assertNull(FunctionMethods.ascii("")); //$NON-NLS-1$
}
@Test public void testAscii5() throws Exception {
- Integer code = (Integer) FunctionMethods.ascii("abc"); //$NON-NLS-1$
+ Integer code = FunctionMethods.ascii("abc"); //$NON-NLS-1$
assertEquals("Didn't get expected code", 97, code.intValue()); //$NON-NLS-1$
}
@@ -672,7 +663,7 @@
@Test public void testBitnot() throws Exception {
// Both values are integers
- Integer result = (Integer) FunctionMethods.bitnot(new Integer(0xF0F));
+ Integer result = FunctionMethods.bitnot(0xF0F);
assertNotNull("Result should not be null", result); //$NON-NLS-1$
assertEquals("result should be 0xFFFFF0F0", 0xFFFFF0F0, result.intValue()); //$NON-NLS-1$
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -53,7 +53,7 @@
// Build signature
Class[] objectSignature = new Class[numArgs];
for(int i=0; i<numArgs; i++) {
- objectSignature[i] = java.lang.Object.class;
+ objectSignature[i] = Integer.TYPE;
}
// Find Method
Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-08-25 19:38:18 UTC (rev 1277)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-08-25 19:40:43 UTC (rev 1278)
@@ -1708,7 +1708,7 @@
query.setSelect(select);
query.setFrom(from);
- helpTest("SELECT {d'2002-9-1'} FROM m.g1", //$NON-NLS-1$
+ helpTest("SELECT {d'2002-09-01'} FROM m.g1", //$NON-NLS-1$
"SELECT {d'2002-09-01'} FROM m.g1", //$NON-NLS-1$
query);
}
@@ -1749,7 +1749,7 @@
query.setSelect(select);
query.setFrom(from);
- helpTest("SELECT {t '5:10:00'} FROM m.g1", //$NON-NLS-1$
+ helpTest("SELECT {t '05:10:00'} FROM m.g1", //$NON-NLS-1$
"SELECT {t'05:10:00'} FROM m.g1", //$NON-NLS-1$
query);
}
@@ -1779,75 +1779,74 @@
/** SELECT {b'true'} FROM m.g1 */
public void testBooleanLiteralTrue() {
- GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
+ Boolean expected = Boolean.TRUE;
+ Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
+ String sql = "SELECT {b'true'}"; //$NON-NLS-1$
+ String expectedSql = "SELECT TRUE"; //$NON-NLS-1$
+
+ helpTestLiteral(expected, expectedType, sql, expectedSql);
+ }
- Select select = new Select();
- select.addSymbol(new ExpressionSymbol("expr", new Constant(Boolean.valueOf("true")))); //$NON-NLS-1$ //$NON-NLS-2$
+ private void helpTestLiteral(Boolean expected, Class<?> expectedType,
+ String sql, String expectedSql) {
+ Select select = new Select();
+ select.addSymbol(new ExpressionSymbol("expr", new Constant(expected, expectedType))); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
- query.setFrom(from);
- helpTest("SELECT {b'true'} FROM m.g1", //$NON-NLS-1$
- "SELECT TRUE FROM m.g1", //$NON-NLS-1$
- query);
- }
+ helpTest(sql,
+ expectedSql,
+ query);
+ }
/** SELECT TRUE FROM m.g1 */
public void testBooleanLiteralTrue2() {
- GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- select.addSymbol(new ExpressionSymbol("expr", new Constant(Boolean.valueOf("true")))); //$NON-NLS-1$ //$NON-NLS-2$
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- helpTest("SELECT TRUE FROM m.g1", //$NON-NLS-1$
- "SELECT TRUE FROM m.g1", //$NON-NLS-1$
- query);
+ Boolean expected = Boolean.TRUE;
+ Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
+ String sql = "SELECT TRUE"; //$NON-NLS-1$
+ String expectedSql = "SELECT TRUE"; //$NON-NLS-1$
+
+ helpTestLiteral(expected, expectedType, sql, expectedSql);
}
/** SELECT {b'false'} FROM m.g1 */
public void testBooleanLiteralFalse() {
- GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- select.addSymbol(new ExpressionSymbol("expr", new Constant(Boolean.valueOf("false")))); //$NON-NLS-1$ //$NON-NLS-2$
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- helpTest("SELECT {b'false'} FROM m.g1", //$NON-NLS-1$
- "SELECT FALSE FROM m.g1", //$NON-NLS-1$
- query);
+ Boolean expected = Boolean.FALSE;
+ Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
+ String sql = "SELECT {b'false'}"; //$NON-NLS-1$
+ String expectedSql = "SELECT FALSE"; //$NON-NLS-1$
+
+ helpTestLiteral(expected, expectedType, sql, expectedSql);
}
/** SELECT FALSE FROM m.g1 */
public void testBooleanLiteralFalse2() {
- GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- select.addSymbol(new ExpressionSymbol("expr", new Constant(Boolean.valueOf("false")))); //$NON-NLS-1$ //$NON-NLS-2$
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- helpTest("SELECT FALSE FROM m.g1", //$NON-NLS-1$
- "SELECT FALSE FROM m.g1", //$NON-NLS-1$
- query);
+ Boolean expected = Boolean.FALSE;
+ Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
+ String sql = "SELECT {b'false'}"; //$NON-NLS-1$
+ String expectedSql = "SELECT FALSE"; //$NON-NLS-1$
+
+ helpTestLiteral(expected, expectedType, sql, expectedSql);
}
+ public void testBooleanLiteralUnknown() {
+ Boolean expected = null;
+ Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
+ String sql = "SELECT {b'unknown'}"; //$NON-NLS-1$
+ String expectedSql = "SELECT UNKNOWN"; //$NON-NLS-1$
+
+ helpTestLiteral(expected, expectedType, sql, expectedSql);
+ }
+
+ public void testBooleanLiteralUnknown2() {
+ Boolean expected = null;
+ Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
+ String sql = "SELECT UNKNOWN"; //$NON-NLS-1$
+ String expectedSql = "SELECT UNKNOWN"; //$NON-NLS-1$
+
+ helpTestLiteral(expected, expectedType, sql, expectedSql);
+ }
+
/** SELECT {b 'xyz'} FROM m.g1 */
public void testBooleanLiteralFail() {
helpException("SELECT {b 'xyz'} FROM m.g1"); //$NON-NLS-1$
14 years, 8 months
teiid SVN: r1277 - in trunk: client-jdbc/src/test/java/com/metamatrix/jdbc/api and 8 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-08-25 15:38:18 -0400 (Tue, 25 Aug 2009)
New Revision: 1277
Added:
trunk/test-integration/src/test/java/org/teiid/runtime/
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/MyFunctions.java
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestDqpReDeployment.java
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java
trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/Util.java
trunk/test-integration/src/test/resources/admin/
trunk/test-integration/src/test/resources/admin/Admin.vdb
trunk/test-integration/src/test/resources/admin/BQT1Binding.cdk
trunk/test-integration/src/test/resources/admin/Empty.vdb
trunk/test-integration/src/test/resources/admin/QT_Ora9DSwDEF.vdb
trunk/test-integration/src/test/resources/admin/TestEmpty.vdb
trunk/test-integration/src/test/resources/admin/TestORS.vdb
trunk/test-integration/src/test/resources/admin/TestORS1.vdb
trunk/test-integration/src/test/resources/admin/TestORSInvalid.vdb
trunk/test-integration/src/test/resources/admin/dqp.properties
trunk/test-integration/src/test/resources/admin/extensions/
trunk/test-integration/src/test/resources/admin/extensions/FunctionDefinitions.xmi
trunk/test-integration/src/test/resources/admin/log/
trunk/test-integration/src/test/resources/admin/loopback.cdk
trunk/test-integration/src/test/resources/admin/loopback_archive.caf
trunk/test-integration/src/test/resources/admin/loopbackconn.jar
Modified:
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java
trunk/pom.xml
trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java
Log:
TEIID-779: Moved the Admin API specific tests into test integration.
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java 2009-08-24 22:41:19 UTC (rev 1276)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java 2009-08-25 19:38:18 UTC (rev 1277)
@@ -39,12 +39,12 @@
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.Stack;
import org.junit.After;
import org.teiid.adminapi.Admin;
import org.teiid.jdbc.TeiidDriver;
-import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.script.io.MetadataReader;
import com.metamatrix.script.io.ResultSetReader;
import com.metamatrix.script.io.StringArrayReader;
@@ -66,16 +66,12 @@
protected Statement internalStatement = null;
protected int updateCount = -1;
protected String DELIMITER = " "; //$NON-NLS-1$
+ private Stack<com.metamatrix.jdbc.api.Connection> contexts = new Stack<Connection>();
@After public void tearDown() throws Exception {
closeConnection();
}
- public com.metamatrix.jdbc.api.Connection getConnection(String vdb){
- String propsFile = UnitTestUtil.getTestDataPath()+"/mmquery/mm.properties"; //$NON-NLS-1$
- return getConnection(vdb, propsFile);
- }
-
public Admin getAdmin() {
try {
assertNotNull(this.internalConnection);
@@ -85,6 +81,18 @@
}
}
+ public void pushConnection() {
+ this.contexts.push(this.internalConnection);
+ this.internalConnection = null;
+ }
+
+ public void popConnection() {
+ this.internalConnection = this.contexts.pop();
+ }
+
+ public void setConnection(com.metamatrix.jdbc.api.Connection c) {
+ this.internalConnection = c;
+ }
public com.metamatrix.jdbc.api.Connection getConnection(String vdb, String propsFile){
return getConnection(vdb, propsFile, ""); //$NON-NLS-1$
}
@@ -392,20 +400,22 @@
if (this.internalStatement != null){
try {
this.internalStatement.close();
- this.internalStatement = null;
} catch(SQLException e) {
throw new RuntimeException(e);
- }
+ } finally {
+ this.internalStatement = null;
+ }
}
}
public void closeResultSet() {
if (this.internalResultSet != null) {
try {
- this.internalResultSet.close();
- this.internalResultSet = null;
+ this.internalResultSet.close();
} catch(SQLException e) {
// ignore
+ } finally {
+ this.internalResultSet = null;
}
}
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-08-24 22:41:19 UTC (rev 1276)
+++ trunk/pom.xml 2009-08-25 19:38:18 UTC (rev 1277)
@@ -149,10 +149,6 @@
<name>java.io.tmpdir</name>
<value>${basedir}/target</value>
</property>
- <property>
- <name>teiid.home</name>
- <value>${basedir}/target</value>
- </property>
</systemProperties>
</configuration>
</plugin>
Modified: trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2009-08-24 22:41:19 UTC (rev 1276)
+++ trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2009-08-25 19:38:18 UTC (rev 1277)
@@ -98,22 +98,25 @@
public Object invoke(Object arg0, Method arg1, Object[] arg2) throws Throwable {
if (!isOpen()) {
throw ExceptionUtil.convertException(arg1, new MetaMatrixComponentException(JDBCPlugin.Util.getString("LocalTransportHandler.session_inactive"))); //$NON-NLS-1$
- }
+ }
+ Throwable exception = null;
ClassLoader current = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(classLoader);
- DQPWorkContext.setWorkContext(workContext);
-
- if (!(iface.equals(ILogon.class))) {
- sessionService.validateSession(workContext.getSessionId());
- }
-
try {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ DQPWorkContext.setWorkContext(workContext);
+
+ if (!(iface.equals(ILogon.class))) {
+ sessionService.validateSession(workContext.getSessionId());
+ }
return arg1.invoke(clientServices.getClientService(iface), arg2);
} catch (InvocationTargetException e) {
- throw e.getTargetException();
+ exception = e.getTargetException();
+ } catch(Throwable t){
+ exception = t;
} finally {
Thread.currentThread().setContextClassLoader(current);
}
+ throw ExceptionUtil.convertException(arg1, exception);
}
});
}
Modified: trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java 2009-08-24 22:41:19 UTC (rev 1276)
+++ trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java 2009-08-25 19:38:18 UTC (rev 1277)
@@ -22,30 +22,1162 @@
package com.metamatrix.server.integration;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
import java.sql.Connection;
+import java.sql.SQLException;
import java.util.Collection;
+import java.util.Properties;
+import org.junit.Before;
import org.junit.Test;
import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+import org.teiid.adminapi.AdminOptions;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.ConnectorType;
+import org.teiid.adminapi.EmbeddedLogger;
+import org.teiid.adminapi.ExtensionModule;
+import org.teiid.adminapi.LogConfiguration;
import org.teiid.adminapi.ProcessObject;
+import org.teiid.adminapi.VDB;
+import org.teiid.runtime.adminapi.Util;
-import static org.junit.Assert.*;
-
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.FileUtils;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.jdbc.MMConnection;
import com.metamatrix.jdbc.api.AbstractMMQueryTestCase;
public class TestAdminApi extends AbstractMMQueryTestCase {
- private static final String DQP_PROP_FILE = UnitTestUtil.getTestDataPath() + "/authcheck/bqt.properties;"; //$NON-NLS-1$
- private static final String VDB = "bqt"; //$NON-NLS-1$
-
+ private static final String STAR = "*"; //$NON-NLS-1$
+ private static final String PROPS_FILE = UnitTestUtil.getTestDataPath()+"/admin/dqp.properties;user=admin;password=teiid"; //$NON-NLS-1$
+ private static final String BQT = "BQT"; //$NON-NLS-1$
+ private static final String ADMIN = "admin"; //$NON-NLS-1$
+ private static final String VDB_NAME = "TestEmpty"; //$NON-NLS-1$
+ private static final String VDB_FILE = UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"; //$NON-NLS-1$
+
+
+ @Before
+ public void setUp() throws Exception {
+ FileUtils.copy(UnitTestUtil.getTestDataPath()+"/admin/Admin.vdb", UnitTestUtil.getTestScratchPath()+"/Admin.vdb"); //$NON-NLS-1$ //$NON-NLS-2$
+ FileUtils.copy(UnitTestUtil.getTestDataPath()+"/ServerConfig.xml", UnitTestUtil.getTestScratchPath()+"/configuration.xml"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ private void cleanDeploy() throws Exception {
+ Collection<VDB> vdbs = getAdmin().getVDBs(STAR);
+ for(VDB vdb:vdbs) {
+ if (!vdb.getName().equalsIgnoreCase(ADMIN)) {
+ deleteVDB(vdb.getName(), vdb.getVDBVersion());
+ }
+ }
+
+ Collection<ConnectorBinding> bindings = getAdmin().getConnectorBindings(STAR);
+ for(ConnectorBinding b:bindings) {
+ getAdmin().stopConnectorBinding(b.getIdentifier(), true);
+ getAdmin().deleteConnectorBinding(b.getIdentifier());
+ }
+ }
+
@Test public void testGetProcess() throws Exception {
- Connection conn = getConnection(VDB, DQP_PROP_FILE, "user=admin;password=teiid;"); //$NON-NLS-1$
- Admin admin = ((MMConnection)conn).getAdminAPI();
- Collection<ProcessObject> processes = admin.getProcesses("*"); //$NON-NLS-1$
+ getConnection(ADMIN, PROPS_FILE);
+ Collection<ProcessObject> processes = getAdmin().getProcesses(STAR);
assertEquals(1, processes.size());
assertNotNull(processes.iterator().next().getInetAddress());
- }
+ }
+
+ // Setting AutoCommit to "false" was failing in the DQP. This was happening because
+ // when auto commit is false, it loads a user transaction and that needs a Txn
+ // manager which currently not available in the DQP. Currently this has been stubbed
+ // not to use the txn messaging in the embedded connection.
+ @Test public void testDefect19748_setAutoCommitFalse() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ getAdmin().addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+ getAdmin().changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ pushConnection();
+ Connection c = getConnection(VDB_NAME, PROPS_FILE);
+ try {
+ c.setAutoCommit(false);
+ execute("select * from smalla"); //$NON-NLS-1$
+ }catch(SQLException e) {
+ fail("Embedded driver should have let the user set the autocommit=false"); //$NON-NLS-1$
+ }
+ closeConnection();
+ popConnection();
+
+ closeConnection();
+ }
+ @Test public void testDefect19748_setAutoCommitFalse_txnoff() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ getAdmin().addVDB(BQT, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+ getAdmin().changeVDBStatus(BQT, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ pushConnection();
+ Connection c = getConnection(BQT, PROPS_FILE+";txnAutoWrap=OFF"); //$NON-NLS-1$
+ try {
+ c.setAutoCommit(false);
+ execute("select * from smalla"); //$NON-NLS-1$
+ assertRowCount(10);
+ }catch(SQLException e) {
+ fail("Embedded driver should have let the user set the autocommit=false"); //$NON-NLS-1$
+ //pass
+ }
+ closeConnection();
+ popConnection();
+ closeConnection();
+ }
+
+ @Test public void testDefect19748_commit_txnoff() throws Exception {
+ Connection c = getConnection(ADMIN, PROPS_FILE+";txnAutoWrap=OFF"); //$NON-NLS-1$
+ cleanDeploy();
+ try {
+ c.commit();
+ }catch(SQLException e) {
+ fail("Embedded driver should have have let the user commit; because of txn off"); //$NON-NLS-1$
+ }
+ closeConnection();
+ }
+
+ @Test public void testBindingNames() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ Collection bindings = getAdmin().getConnectorBindings(STAR);
+
+ int size = bindings.size();
+
+ assertFalse("VDB does not exist", hasVDB(BQT)); //$NON-NLS-1$
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+ assertTrue("VDB does not exist", hasVDB(BQT)); //$NON-NLS-1$
+
+ bindings = getAdmin().getConnectorBindings(STAR);
+ assertEquals("Two bindings should exist", 2+size, bindings.size()); //$NON-NLS-1$
+
+ bindings = getAdmin().getConnectorBindingsInVDB("BQT*"); //$NON-NLS-1$
+ assertEquals("Two bindings should exist", 2+size, bindings.size()); //$NON-NLS-1$
+
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT2 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+
+ // make sure when the VDB is gone all the enclosed bindings are gone too
+ deleteVDB(BQT, "1"); //$NON-NLS-1$
+
+ assertFalse("Binding must be available", hasBinding("BQT_1.BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("Binding must be available", hasBinding("BQT_1.BQT2 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ closeConnection();
+ }
+
+ @Test public void testDeleteBindings() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ assertFalse("VDB does not exist", hasVDB(BQT)); //$NON-NLS-1$
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ try {
+ getAdmin().deleteConnectorBinding("BQT_1.BQT2 Oracle 9i Simple Cap"); //$NON-NLS-1$
+ fail("must have failed to delete due to active assosiation to VDB"); //$NON-NLS-1$
+ } catch(Exception e) {
+ }
+
+ getAdmin().assignBindingToModel("BQT_1.BQT1 Oracle 9i Simple Cap", "BQT", "1", "BQT2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ getAdmin().assignBindingToModel("BQT_1.BQT1 Oracle 9i Simple Cap", "BQT", "1", "SP"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ assertFalse("Binding not found", hasBinding("BQT_1.BQT2 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Check that config state has changed
+ assertTrue("Binding must be found", hasBinding("BQT_1.BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // make sure when the VDB is gone all the enclosed bindings are gone too
+ deleteVDB(BQT, "1"); //$NON-NLS-1$
+
+ assertFalse("Binding must be available", hasBinding("BQT_1.BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ closeConnection();
+ }
+
+ @Test public void testBindingNames_sharedBinding() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ getAdmin().addConnectorBinding("BQT1 Oracle 9i Simple Cap", Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/BQT1Binding.cdk"), new AdminOptions(AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("Binding must be available", hasBinding("BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ assertTrue("VDB does exist", hasVDB(BQT, "1")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Collection bindings = getAdmin().getConnectorBindings(STAR);
+ int initialSize = bindings.size();
+
+ assertTrue("Binding must be available", hasBinding("BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT2 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ assertTrue("VDB does exist", hasVDB(BQT, "2")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ bindings = getAdmin().getConnectorBindings(STAR);
+
+ assertTrue("Addtion of the same VDB should", bindings.size()==initialSize); //$NON-NLS-1$
+
+ // the bindings are shared
+ assertTrue("Binding must be available", hasBinding("BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT2 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ deleteVDB(BQT, "1"); //$NON-NLS-1$
+
+ //still bindings are there
+ assertTrue("Binding must be available", hasBinding("BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT2 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ deleteVDB(BQT, "2"); //$NON-NLS-1$
+
+ // deletion of VDB should remove the bindings specific to VDB?
+ assertTrue("Binding must be available", hasBinding("BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("Binding must be available", hasBinding("BQT_1.BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("Binding must be available", hasBinding("BQT_1.BQT2 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ getAdmin().deleteConnectorBinding("BQT1 Oracle 9i Simple Cap"); //$NON-NLS-1$
+ assertFalse("Binding must not available", hasBinding("BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ closeConnection();
+ }
+
+
+
+ @Test public void testStartStopConnectorBindings() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+ assertTrue("VDB does not exist", hasVDB(BQT, "1")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT1 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("BQT_1.BQT2 Oracle 9i Simple Cap")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ execute("SELECT * FROM System.models"); //$NON-NLS-1$
+ assertRowCount(9);
+ closeConnection();
+ popConnection();
+
+ getAdmin().stopConnectorBinding("BQT_1.BQT1 Oracle 9i Simple Cap", true); //$NON-NLS-1$
+ //calling second time has no effect
+ getAdmin().stopConnectorBinding("BQT_1.BQT1 Oracle 9i Simple Cap", true); //$NON-NLS-1$
+
+ try {
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM BQT1.SmallA"); // this should fail //$NON-NLS-1$
+ fail("maust have failed, since the connector is not started."); //$NON-NLS-1$
+ }catch(Exception e) {
+ //pass
+ }finally {
+ closeConnection();
+ popConnection();
+ }
+
+ // start the binding using un-qualified, should not start
+ try {
+ getAdmin().startConnectorBinding("BQT1 Oracle 9i Simple Cap"); //$NON-NLS-1$
+ fail("must have failed to start"); //$NON-NLS-1$
+ }catch(Exception e) {
+ //pass
+ }
+
+ // start correctly
+ getAdmin().startConnectorBinding("BQT_1.BQT1 Oracle 9i Simple Cap"); //$NON-NLS-1$
+ // calling second time should have no effect
+ getAdmin().startConnectorBinding("BQT_1.BQT1 Oracle 9i Simple Cap"); //$NON-NLS-1$
+
+ // test again
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ closeConnection();
+ popConnection();
+
+ closeConnection();
+ }
+
+ @Test public void testStartStopNonExistentConnectorBindings() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ try {
+ getAdmin().startConnectorBinding("fakeConnector"); //$NON-NLS-1$
+ fail("must have failed to start");//$NON-NLS-1$
+ }catch(Exception e) {
+ }
+
+ try {
+ getAdmin().stopConnectorBinding("fakeConnector", true);//$NON-NLS-1$
+ fail("must have failed to stop");//$NON-NLS-1$
+ }catch(Exception e) {
+ }
+
+ try {
+ getAdmin().deleteConnectorBinding("fakeConnector"); //$NON-NLS-1$
+ fail("Must have failed delete a unknown connector"); //$NON-NLS-1$
+ }catch(AdminException e) {
+ //pass
+ }
+
+ try {
+ getAdmin().exportConnectorBinding("fakeConnector"); //$NON-NLS-1$
+ fail("Must have failed exporting a unknown connector"); //$NON-NLS-1$
+ }catch(AdminException e) {
+ //pass
+ }
+
+ try {
+ getAdmin().assignBindingToModel("fakeConnector", BQT, "1", "BQT1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ fail("Must have failed assigning non-existing binding to the model"); //$NON-NLS-1$
+ }catch(AdminException e) {
+ //pass
+ }
+
+ closeConnection();
+ }
+
+ @Test public void testConnectorTypes() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ Collection<ConnectorType> types = getAdmin().getConnectorTypes(STAR);
+ for (ConnectorType type:types) {
+ // System.out.println(type.getName());
+ }
+ assertEquals("31 types expected", 31, types.size()); //$NON-NLS-1$
+
+
+ assertTrue("Should be available", hasConnectorType("Loopback Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ getAdmin().deleteConnectorType("Loopback Connector"); //$NON-NLS-1$
+
+ assertFalse("must have been deleted", hasConnectorType("Loopback Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ try {
+ getAdmin().deleteConnectorType("Oracle ANSI JDBC Connector"); //$NON-NLS-1$
+ fail("must have failed as this type in use by BQT "); //$NON-NLS-1$
+ } catch(Exception e) {
+ //pass
+ }
+
+ try {
+ getAdmin().deleteConnectorType("FakeConnector"); //$NON-NLS-1$
+ fail("must have failed as this type as this is unknown"); //$NON-NLS-1$
+ } catch(Exception e) {
+ //pass
+ }
+
+ getAdmin().addConnectorType("Loopback Connector", Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Should be available", hasConnectorType("Loopback Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ try {
+ getAdmin().addConnectorType("Loopback Connector", Util.getCharacterFile(UnitTestUtil.getTestScratchPath()+"/loopback.cdk")); //$NON-NLS-1$ //$NON-NLS-2$
+ fail("must have fail to add existing type"); //$NON-NLS-1$
+ } catch(Exception e) {
+ //pass
+ }
+
+
+ // try exporting
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/textfileexport.cdk",getAdmin().exportConnectorType("Text File Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+ File cdkFile = new File(UnitTestUtil.getTestScratchPath()+"/textfileexport.cdk"); //$NON-NLS-1$
+ assertTrue("Connector type Export should exist", cdkFile.exists()); //$NON-NLS-1$
+ cdkFile.delete();
+
+ closeConnection();
+ }
+
+ @Test public void testUpdateConnectorBindingProperty() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+ assertTrue("VDB does not exist", hasVDB(BQT, "1")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("select * from BQT1.smalla"); //$NON-NLS-1$
+ assertRowCount(50);
+ closeConnection();
+ popConnection();
+
+ Collection<ConnectorBinding> bindings = getAdmin().getConnectorBindings("BQT_1.BQT1 Oracle 9i Simple Cap"); //$NON-NLS-1$
+ for (ConnectorBinding binding:bindings) {
+ getAdmin().setProperty(binding.getIdentifier(), ConnectorBinding.class.getName(), "RowCount", "10"); //$NON-NLS-1$ //$NON-NLS-2$
+ getAdmin().stopConnectorBinding(binding.getIdentifier(), true);
+ getAdmin().startConnectorBinding(binding.getIdentifier());
+ }
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("select * from BQT1.smalla"); //$NON-NLS-1$
+ assertRowCount(10);
+ closeConnection();
+ popConnection();
+
+ // changes are persistent after the restart too.
+ getAdmin().restart();
+
+ closeConnection();
+
+ getConnection(BQT, PROPS_FILE);
+ execute("select * from BQT1.smalla"); //$NON-NLS-1$
+ assertRowCount(10);
+ closeConnection();
+
+ }
+
+ @Test public void testVDBAddsConnectorTypes() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ assertFalse(hasVDB(BQT));
+
+ if (hasConnectorType("Oracle ANSI JDBC Connector")) { //$NON-NLS-1$
+ getAdmin().deleteConnectorType("Oracle ANSI JDBC Connector"); //$NON-NLS-1$
+ }
+ assertFalse("binding must exist", hasConnectorType("Oracle ANSI JDBC Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+ assertTrue("VDB does exist", hasVDB(BQT, "1")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("connector type must exist", hasConnectorType("Oracle ANSI JDBC Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+ deleteVDB(BQT, "1"); //$NON-NLS-1$
+ closeConnection();
+ }
+
+ @Test public void testAdminOptions_addvdb_conflict_ignore() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // we start out with no bindings
+ assertFalse("VDB does not exist", hasVDB("Empty")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ getAdmin().addConnectorBinding("Loopback", Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"), new AdminOptions(AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("Loopback")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // we add a vdb, loop back which returns 10 rows
+ addVDB("Empty", UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("VDB does not exist", hasVDB("Empty", "1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ pushConnection();
+ getConnection("Empty", PROPS_FILE); //$NON-NLS-1$
+ execute("SELECT * FROM Oracle.SmallA"); //$NON-NLS-1$
+ assertRowCount(1);
+ closeConnection();
+ popConnection();
+
+ getAdmin().restart();
+
+ closeConnection();
+
+ getConnection("Empty", PROPS_FILE); //$NON-NLS-1$
+ execute("SELECT * FROM Oracle.SmallA"); //$NON-NLS-1$
+ assertRowCount(1);
+ closeConnection();
+
+ }
+
+
+ @Test public void testAdminOptions_addvdb_conflict_overwrite() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // we start out with no bindings
+ assertFalse("VDB does not exist", hasVDB("Empty")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ getAdmin().addConnectorBinding("Loopback", Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"), new AdminOptions(AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("Loopback")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // we add a vdb, loop back which returns 10 rows
+ getAdmin().addVDB("Empty", Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"), new AdminOptions(AdminOptions.OnConflict.OVERWRITE)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("VDB does not exist", hasVDB("Empty", "1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ pushConnection();
+ getConnection("Empty", PROPS_FILE); //$NON-NLS-1$
+ execute("SELECT * FROM Oracle.SmallA"); //$NON-NLS-1$
+ assertRowCount(10);
+ closeConnection();
+ popConnection();
+
+ getAdmin().restart();
+
+ pushConnection();
+ getConnection("Empty", PROPS_FILE); //$NON-NLS-1$
+ execute("SELECT * FROM Oracle.SmallA"); //$NON-NLS-1$
+ assertRowCount(10);
+ closeConnection();
+ popConnection();
+ }
+
+
+ @Test public void testAdminOptions_addvdb_conflict_Exception() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // we start out with no bindings
+ assertFalse("VDB does not exist", hasVDB("Empty")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ getAdmin().addConnectorBinding("Loopback", Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"), new AdminOptions(AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Binding must be available", hasBinding("Loopback")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertFalse("VDB does not exist", hasVDB("Empty", "1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ // we add a vdb, loop back which returns 10 rows
+ try {
+ // we add a vdb, loop back which returns 10 rows
+ getAdmin().addVDB("Empty", Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"), new AdminOptions(AdminOptions.OnConflict.EXCEPTION)); //$NON-NLS-1$ //$NON-NLS-2$
+ fail("Must have failed to Add a vdb, as loopback already exists"); //$NON-NLS-1$
+ }catch(AdminException e) {
+ // pass
+ }
+
+ assertFalse("VDB does not exist", hasVDB("Empty", "1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ closeConnection();
+ }
+
+ @Test public void testGetSessions() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ assertEquals(1, getAdmin().getSessions(STAR).size());
+
+ for (int i = 0; i < 10; i++) {
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ }
+
+ assertEquals(11, getAdmin().getSessions(STAR).size());
+
+ for (int i = 0; i < 10; i++) {
+ closeConnection();
+ popConnection();
+ }
+
+ assertEquals(1, getAdmin().getSessions(STAR).size());
+
+ closeConnection();
+ }
+
+ @Test public void testSessionTermination() throws Exception {
+ com.metamatrix.jdbc.api.Connection c = getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ assertEquals(1, getAdmin().getSessions(STAR).size());
+
+ pushConnection();
+ MMConnection c2 = (MMConnection)getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+
+ // terminate the session
+ c.getAdminAPI().terminateSession(c2.getConnectionId());
+
+ // make sure it is gone
+ assertEquals(1, c.getAdminAPI().getSessions(STAR).size());
+
+ try {
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ fail("must have failed to execute"); //$NON-NLS-1$
+ }catch(Exception e) {
+ // success
+ try {
+ closeConnection();
+ } catch (Exception e1) {
+ }
+ }
+
+ popConnection();
+ closeConnection();
+ }
+
+ @Test public void testAddExtensionModules() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ assertFalse(hasExtensionModule("Loopy.jar")); //$NON-NLS-1$
+
+ getAdmin().addExtensionModule("JAR File", "Loopy.jar", Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/loopbackconn.jar"), "JAR File"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ assertTrue("Expected extension module", hasExtensionModule("Loopy.jar")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // try to add a duplicate
+ try {
+ getAdmin().addExtensionModule("JAR File", "Loopy.jar", Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/loopbackconn.jar"), "JAR File"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ fail("should have failed to add the extension module as it is duplicate"); //$NON-NLS-1$
+ } catch(Exception e) {
+ //pass
+ }
+
+ //export the extension
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/ext.jar", getAdmin().exportExtensionModule("Loopy.jar")); //$NON-NLS-1$ //$NON-NLS-2$
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/ext.jar"); //$NON-NLS-1$
+ assertTrue(f.exists());
+ f.delete();
+
+ // delete the extension
+ getAdmin().deleteExtensionModule("Loopy.jar"); //$NON-NLS-1$
+
+ // Assert that no vdb with this name exists
+ assertFalse("Expected no prior extension module", hasExtensionModule("Loopy.jar")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ closeConnection();
+ }
+
+ @Test public void testExportConfiguration() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/serverconfigexport.xml", getAdmin().exportConfiguration()); //$NON-NLS-1$
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/serverconfigexport.xml"); //$NON-NLS-1$
+ assertTrue("Exported configuration must exist", f.exists()); //$NON-NLS-1$
+ f.delete();
+ closeConnection();
+ }
+
+ // Test exporting VDB and adding the same VDB and make sure it exported correctly
+ @Test public void testExportVDB() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // Assert that no vdb with this name exists
+ assertFalse("Expected no prior VDB", hasVDB(BQT)); //$NON-NLS-1$
+
+ // Add .VDB with included .DEF
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ // Check that config state has changed
+ assertTrue("Expected new VDB", hasVDB(BQT)); //$NON-NLS-1$
+
+ // Export the VDB
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/bqtexport.vdb", getAdmin().exportVDB(BQT, "1")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ closeConnection();
+
+ // Assert bqt.vdb exists
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/bqtexport.vdb"); //$NON-NLS-1$
+ assertTrue(f.exists());
+ f.delete();
+ }
+
+ @Test public void testVDBModified() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ // make susre it exists as file
+ File vdb = new File(UnitTestUtil.getTestScratchPath()+"/BQT_1.vdb"); //$NON-NLS-1$
+ assertTrue("Persisted VDB file does not exists", vdb.exists()); //$NON-NLS-1$
+
+ // Check when it last modified
+ long modified = vdb.lastModified();
+ Thread.sleep(1000);
+ getAdmin().assignBindingToModel("BQT_1.BQT1 Oracle 9i Simple Cap", BQT, "1", "BQT2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ // the deployed VDB is modified not the original vdb
+ assertTrue(vdb.lastModified() == modified);
+
+ closeConnection();
+ }
+
+ @Test public void testIncompleteVDB() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ VDB vdb = getAdmin().addVDB(BQT, Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/Empty.vdb"), new AdminOptions (AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$
+
+ assertTrue("Status must have been INCOMPLTE", !(vdb.getState() == VDB.ACTIVE)); //$NON-NLS-1$
+
+ try {
+ getAdmin().changeVDBStatus(BQT, "1", VDB.ACTIVE); //$NON-NLS-1$
+ fail("must have failed to set status to active"); //$NON-NLS-1$
+ } catch(Exception e) {
+
+ }
+
+ pushConnection();
+ try {
+ getConnection(BQT, PROPS_FILE);
+ fail("must have failed to get connection"); //$NON-NLS-1$
+ }catch(Exception e) {
+
+ }
+ popConnection();
+
+ getAdmin().addConnectorBinding("Loopback", Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"), new AdminOptions(AdminOptions.OnConflict.OVERWRITE)); //$NON-NLS-1$ //$NON-NLS-2$
+ getAdmin().startConnectorBinding("Loopback"); //$NON-NLS-1$
+ getAdmin().assignBindingToModel("Loopback", BQT, "1", "Oracle"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ getAdmin().changeVDBStatus(BQT, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ closeConnection();
+ popConnection();
+
+ closeConnection();
+ }
+
+ @Test public void testUseLatestVersion() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // this returns 50 rows
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ // this returns 10 row
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"); //$NON-NLS-1$
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("select * from Oracle.smalla"); //$NON-NLS-1$
+ assertRowCount(10);
+ closeConnection();
+ popConnection();
+ closeConnection();
+ }
+
+ @Test public void testDeleteVDBHavingActiveConnection() throws Exception {
+ helpDeleteVDBHavingActiveConnection(false);
+ helpDeleteVDBHavingActiveConnection(true);
+ }
+
+ // Test to delete a VDB with active connection to it
+ // 1) we should be able to delete the vdb; hasVDB should return false
+ // 2) should be able to continue the old connection, as it is
+ // 3) No new connections are allowed
+ // 4) if you add another VDB with same name, it can be given different version
+ // 5) The old one can not switch over to the new connection.
+ void helpDeleteVDBHavingActiveConnection(boolean terminate) throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // this returns 50 rows
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ assertTrue("VDB does not exist", hasVDB(BQT)); //$NON-NLS-1$
+
+ // make another context and create a 2nd connection
+ pushConnection();
+ MMConnection vdbConn = (MMConnection)getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ // we have not closed the connection here, kept active connection
+ popConnection();
+
+ // testcase (1) (here the file should still exist; but report as non existent from API)
+ deleteVDB(BQT, "1"); //$NON-NLS-1$
+ assertFalse("VDB should exist because we still have an active user", hasVDB(BQT, "1")); //$NON-NLS-1$ //$NON-NLS-2$
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/BQT_1.vdb"); //$NON-NLS-1$
+ assertTrue("since the connection is still open this file should exist", f.exists()); //$NON-NLS-1$
+
+ // testcase (2)
+ // switch to 2nd connection and try to execute, since we did not close it should work fine
+ pushConnection();
+ setConnection(vdbConn);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ popConnection();
+
+ // testcase (3)
+ // try to make third connection and should fail, because we do not allow connections
+ // to non-active vdbs
+ pushConnection();
+ try {
+ getConnection(BQT, PROPS_FILE);
+ fail("Must have failed to connect to the VDB as it is deleted"); //$NON-NLS-1$
+ }catch(Exception e) {
+ // yes failed to connect
+ }
+ popConnection();
+
+ // testcase (4)
+ // Add the VDB again to the configuration it should give new version
+ getAdmin().addVDB(BQT, Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"), new AdminOptions(AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$
+ assertTrue("Empty VDB must exist", hasVDB(BQT, "2")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // testcase (5)
+ // try to execute the 2nd connection, it should still go after the deleted vdb
+ // as we keep until this connections goes dead.
+ pushConnection();
+ setConnection(vdbConn);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ popConnection();
+
+ // now make a 4th new connection this should work
+ pushConnection();
+ getConnection(BQT, PROPS_FILE+";version=2"); //$NON-NLS-1$
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ closeConnection();
+ popConnection();
+
+ if (terminate) {
+ getAdmin().terminateSession(vdbConn.getConnectionId());
+ }
+ else {
+ // clean up 2nd connection
+ pushConnection();
+ setConnection(vdbConn);
+ closeConnection();
+ assertFalse("The vdb must have deleted as the connection closed", f.exists()); //$NON-NLS-1$
+ popConnection();
+ }
+
+ // now make a 5th new connection this should work
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$
+ assertRowCount(50);
+ closeConnection();
+ popConnection();
+
+ // here it should be gone we call delete
+ deleteVDB(BQT, "2"); //$NON-NLS-1$
+ assertFalse("VDB should exist because we still have an active user", hasVDB(BQT, "2")); //$NON-NLS-1$ //$NON-NLS-2$
+ f = new File(UnitTestUtil.getTestScratchPath()+"/BQT_2.vdb"); //$NON-NLS-1$
+ assertFalse("since the connection is still open this file should exist", f.exists()); //$NON-NLS-1$
+
+ // close the 1st connection
+ closeConnection();
+ }
+
+ private void helpConnectorBindingAddTest(int option, int rows) throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // this returns 50 rows
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"); //$NON-NLS-1$
+
+ getAdmin().addConnectorBinding("Loopback", Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"), new AdminOptions(option)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM Oracle.SmallA"); //$NON-NLS-1$
+ assertRowCount(rows);
+ closeConnection();
+ popConnection();
+ }
+
+ @Test public void testConnectorBindingAdd_optionIgnore() throws Exception {
+ helpConnectorBindingAddTest(AdminOptions.OnConflict.IGNORE, 10);
+ }
+
+ @Test public void testConnectorBindingAdd_optionException() throws Exception {
+ try {
+ helpConnectorBindingAddTest(AdminOptions.OnConflict.EXCEPTION, 10);
+ fail("Must have failed to add connector"); //$NON-NLS-1$
+ } catch(Exception e) {
+
+ }
+ }
+
+ @Test public void testConnectorBindingAdd_optionOverwrite() throws Exception {
+ helpConnectorBindingAddTest(AdminOptions.OnConflict.OVERWRITE, 1);
+ }
+
+ @Test public void testAddConnectorBindingWithProeprties() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // this returns 50 rows
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"); //$NON-NLS-1$
+
+ Properties props = new Properties();
+
+ props.setProperty("MaxResultRows","10000"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.setProperty("ConnectorThreadTTL", "120000"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.setProperty("ConnectorMaxThreads","5"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.setProperty("metamatrix.service.essentialservice", "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.setProperty("ConnectorClassPath","extensionjar:loopbackconn.jar;extensionjar:jdbcconn.jar"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.setProperty("RowCount","12"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.setProperty("ServiceClassName","com.metamatrix.server.connector.service.ConnectorService"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.setProperty("ConnectorClass","com.metamatrix.connector.loopback.LoopbackConnector"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.setProperty("WaitTime", "0"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Add the connector binding
+ getAdmin().addConnectorBinding("Loopy", "Loopback Connector", props, new AdminOptions(AdminOptions.OnConflict.OVERWRITE)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("Connector binding must exist", hasBinding("Loopy")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ getAdmin().assignBindingToModel("Loopy", "BQT", "1", "Oracle"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ getAdmin().startConnectorBinding("Loopy"); //$NON-NLS-1$
+
+ pushConnection();
+ getConnection(BQT, PROPS_FILE);
+ execute("SELECT * FROM Oracle.SmallA"); //$NON-NLS-1$
+ assertRowCount(12);
+ closeConnection();
+ popConnection();
+
+ closeConnection();
+ }
+
+ @Test public void testConnectorArchive() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+ // this returns 50 rows
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ assertFalse(hasConnectorType("Loopback")); //$NON-NLS-1$
+ assertFalse(hasExtensionModule("jdbcconn.jar")); //$NON-NLS-1$
+ assertFalse(hasExtensionModule("loopbackconn.jar")); //$NON-NLS-1$
+
+ getAdmin().addConnectorArchive(Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/loopback_archive.caf"), new AdminOptions(AdminOptions.OnConflict.IGNORE)); //$NON-NLS-1$
+
+ assertTrue(hasConnectorType("Loopback")); //$NON-NLS-1$
+ assertTrue(hasExtensionModule("jdbcconn.jar")); //$NON-NLS-1$
+ assertTrue(hasExtensionModule("loopbackconn.jar")); //$NON-NLS-1$
+
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/loopback_archive.caf"); //$NON-NLS-1$
+ Util.writeToFile(f.getCanonicalPath(), getAdmin().exportConnectorArchive("Loopback")); //$NON-NLS-1$
+ assertTrue(f.exists());
+ f.delete();
+
+ getAdmin().deleteExtensionModule("jdbcconn.jar"); //$NON-NLS-1$
+ getAdmin().deleteExtensionModule("loopbackconn.jar"); //$NON-NLS-1$
+ getAdmin().deleteConnectorType("Loopback"); //$NON-NLS-1$
+
+ assertFalse(hasConnectorType("Loopback")); //$NON-NLS-1$
+ assertFalse(hasExtensionModule("jdbcconn.jar")); //$NON-NLS-1$
+ assertFalse(hasExtensionModule("loopbackconn.jar")); //$NON-NLS-1$
+
+ closeConnection();
+ }
+
+ public class MyLogger implements EmbeddedLogger{
+ StringBuffer sb = new StringBuffer();
+ public void log(int logLevel, long timestamp, String componentName, String threadName, String message, Throwable throwable) {
+ sb.append("logLevel=").append(logLevel); //$NON-NLS-1$
+ sb.append("message=").append(message); //$NON-NLS-1$
+ }
+
+ public String getLog() {
+ return sb.toString();
+ }
+ }
+
+ @Test public void testLogListener() throws Exception {
+ getConnection(ADMIN, PROPS_FILE);
+ cleanDeploy();
+
+
+ MyLogger log = new MyLogger();
+
+ getAdmin().setLogListener(log);
+ //force a critical log
+ LogConfiguration c = getAdmin().getLogConfiguration();
+ for(String context:c.getContexts()) {
+ c.setLogLevel(context, LogConfiguration.DETAIL);
+ }
+ getAdmin().setLogConfiguration(c);
+
+ // this returns 50 rows
+ addVDB(BQT, UnitTestUtil.getTestDataPath()+"/admin/QT_Ora9DSwDEF.vdb"); //$NON-NLS-1$
+
+ assertTrue("Log should not be empty", log.getLog().length() > 0); //$NON-NLS-1$
+ closeConnection();
+ }
+
+// /**
+// * SIP51, SIP52
+// * @throws Exception
+// */
+// @Test public void testDeleteInvalidVdb() throws Exception {
+// getConnection(ADMIN, PROPS_FILE);
+// cleanDeploy();
+//
+// String VDB_NAME = "DeleteInvalid"; //$NON-NLS-1$
+// try {
+// // Try clean deployment twice
+// try {
+// addVDB(VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORSInvalid.vdb"); //$NON-NLS-1$
+// fail("Failed with exception "); //$NON-NLS-1$
+// } catch (Exception e) {
+// //pass
+// }
+// } catch (Exception x) {
+// fail("Failed with exception " + Util.getStackTraceAsString(x)); //$NON-NLS-1$
+// } finally {
+// closeConnection();
+// }
+// }
+//
+// /**
+// * Opens connection to the VDB and tries to deploy when conn is open.
+// * The redeployment should not affect the current connection.
+// * @throws Exception
+// */
+// @Test public void testKeepConnectionReplaceVdb () throws Exception {
+// getConnection(ADMIN, PROPS_FILE);
+// cleanDeploy();
+//
+// String VDB_NAME = "ReplaceActive"; //$NON-NLS-1$
+// try {
+// VDB vdb = addVDB(VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORS.vdb"); //$NON-NLS-1$
+// String currentVersion = vdb.getVDBVersion();
+// assertEquals("1", currentVersion); //$NON-NLS-1$
+//
+// // Connect and run test query
+// pushConnection();
+// Connection c1 = getConnection( VDB_NAME, PROPS_FILE);
+// execute("SELECT * FROM C_REPOS_DB_RELEASE"); //$NON-NLS-1$
+//
+// // Redeploy the VDB while the connection is open. New VDB has A_CCOUNT table
+// vdb = deployVdbClean(admin, VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORS1.vdb"); //$NON-NLS-1$
+//
+// testConnection(testConn, "select * from C_ACCOUNT", false, "Redeploy V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+// } catch (Exception x) {
+// fail("Failed with exception " + Util.getStackTraceAsString(x)); //$NON-NLS-1$
+// } finally {
+// Util.closeQuietly(conn);
+// }
+// }
+
+ VDB addVDB(String name, String vdbFile) {
+ try {
+ return getAdmin().addVDB(name, Util.getBinaryFile(vdbFile), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new MetaMatrixRuntimeException();
+ }
+ }
+
+ /**
+ * Checks to make sure the given VDB exists in the system
+ * @param vdbName - name of the VDB
+ * @return boolean - true if exists; false otherwise
+ */
+ boolean hasVDB(String vdbName) {
+ try {
+ Collection<VDB> vdbs = getAdmin().getVDBs(vdbName);
+ for (VDB vdb:vdbs) {
+ if (vdb.getName().equals(vdbName)) {
+ return true;
+ }
+ }
+ } catch (AdminException e) {
+ }
+ return false;
+ }
+
+ /**
+ * Checks to make sure the given VDB with version exists in the system
+ * @param vdbName - name of the VDB
+ * @param version - version of the VDB
+ * @return boolean - true if exists; false otherwise
+ */
+ boolean hasVDB(String vdbName, String version) {
+ try {
+ Collection<VDB> vdbs = getAdmin().getVDBs(vdbName);
+ for (VDB vdb:vdbs) {
+ if (vdb.getName().equals(vdbName) && vdb.getVDBVersion().equals(version)) {
+ return true;
+ }
+ }
+ } catch (AdminException e) {
+ }
+ return false;
+ }
+
+ /**
+ * Checks to make sure the given binging exists.
+ * @param bindingName - Name of the Binding.
+ * @return boolean - true if exists; false otherwise
+ */
+ boolean hasBinding(String bindingName) {
+ try {
+ Collection<ConnectorBinding> bindings = getAdmin().getConnectorBindings(AdminObject.WILDCARD + AdminObject.DELIMITER + bindingName);
+ for (ConnectorBinding binding:bindings) {
+ if (binding.getName().equals(bindingName)) {
+ return true;
+ }
+ }
+ } catch (AdminException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ /**
+ * Checks if given Connector Type exists in system
+ * @param typeName - Binding type name
+ * @return boolean - true if exists; false otherwise
+ */
+ boolean hasConnectorType(String typeName) {
+ try {
+ Collection<ConnectorType> types = getAdmin().getConnectorTypes(typeName);
+ for (ConnectorType type:types) {
+ if (type.getName().equals(typeName)) {
+ return true;
+ }
+ }
+ } catch (AdminException e) {
+ }
+ return false;
+ }
+
+ /**
+ * Checks if given Extension Module exists in system
+ * @param name - Extension Module name
+ * @return boolean - true if exists; false otherwise
+ */
+ boolean hasExtensionModule(String name) {
+ try {
+ Collection<ExtensionModule> modules = getAdmin().getExtensionModules(name);
+ for(ExtensionModule module:modules) {
+ if (module.getName().equals(name)) {
+ return true;
+ }
+ }
+ }catch(Exception e) {}
+ return false;
+ }
+
+ void deleteVDB(String name, String version) {
+ try {
+ getAdmin().changeVDBStatus(name, version, VDB.DELETED);
+ } catch (AdminException e) {
+ throw new MetaMatrixRuntimeException();
+ }
+ }
}
Added: trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/MyFunctions.java
===================================================================
--- trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/MyFunctions.java (rev 0)
+++ trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/MyFunctions.java 2009-08-25 19:38:18 UTC (rev 1277)
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2000-2005 MetaMatrix, Inc. All rights reserved.
+ */
+package org.teiid.runtime.adminapi;
+
+/**
+ */
+public class MyFunctions {
+
+ public static Object getPropertyNoArgs() {
+ return "xyz"; //$NON-NLS-1$
+ }
+
+ public static Object getProperty(Object propertyName) {
+ return System.getProperty((String)propertyName);
+ }
+
+}
Property changes on: trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/MyFunctions.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestDqpReDeployment.java
===================================================================
--- trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestDqpReDeployment.java (rev 0)
+++ trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestDqpReDeployment.java 2009-08-25 19:38:18 UTC (rev 1277)
@@ -0,0 +1,287 @@
+package org.teiid.runtime.adminapi;
+
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.Iterator;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminOptions;
+import org.teiid.adminapi.Session;
+import org.teiid.adminapi.VDB;
+
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.core.util.UnitTestUtil;
+
+public class TestDqpReDeployment {
+
+ String DEPLOY_FILE = UnitTestUtil.getTestDataPath()+"/admin/dqp.properties;user=admin;password=teiid"; //$NON-NLS-1$
+ String ADMIN_URL_PREFIX = "jdbc:teiid:admin@"; //$NON-NLS-1$
+
+ @Before
+ public void setUp() throws Exception {
+ FileUtils.copy(UnitTestUtil.getTestDataPath()+"/admin/Admin.vdb", UnitTestUtil.getTestScratchPath()+"/Admin.vdb"); //$NON-NLS-1$ //$NON-NLS-2$
+ FileUtils.copy(UnitTestUtil.getTestDataPath()+"/ServerConfig.xml", UnitTestUtil.getTestScratchPath()+"/configuration.xml"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ Connection conn = null;
+
+ conn = Util.getConnection(ADMIN_URL_PREFIX + DEPLOY_FILE);
+ com.metamatrix.jdbc.api.Connection mmconn = (com.metamatrix.jdbc.api.Connection) conn;
+ Admin admin = mmconn.getAdminAPI();
+
+ // Remove any existing VDBs from the previous tests.
+ Iterator iter = admin.getVDBs("*").iterator(); //$NON-NLS-1$
+ while (iter.hasNext()) {
+ VDB vdb = (VDB)iter.next();
+ if (!vdb.getName().equalsIgnoreCase("admin")){ //$NON-NLS-1$
+ admin.changeVDBStatus(vdb.getName(), vdb.getVDBVersion(), VDB.DELETED);
+ }
+ }
+ }
+
+
+ /**
+ * Opens connection to the VDB and tries to deploy when conn is open.
+ * The redeployment should not affect the current connection.
+ * @throws Exception
+ */
+ @Test public void testKeepConnectionReplaceVdb () throws Exception {
+ Connection conn = null;
+ Connection testConn = null;
+ String VDB_NAME = "ReplaceActive"; //$NON-NLS-1$
+ try {
+ conn = Util.getConnection(ADMIN_URL_PREFIX + DEPLOY_FILE);
+ com.metamatrix.jdbc.api.Connection mmconn = (com.metamatrix.jdbc.api.Connection) conn;
+ Admin admin = mmconn.getAdminAPI();
+
+ VDB vdb = deployVdbClean(admin, VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORS.vdb"); //$NON-NLS-1$
+ String currentVersion = vdb.getVDBVersion();
+ assertEquals("1", currentVersion); //$NON-NLS-1$
+
+ // Connect and run test query
+ testConn = Util.getConnection("jdbc:teiid:" + VDB_NAME + "@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "SELECT * FROM C_REPOS_DB_RELEASE", true, "Initial Test"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Redeploy the VDB while the connection is open. New VDB has A_CCOUNT table
+ vdb = deployVdbClean(admin, VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORS1.vdb"); //$NON-NLS-1$
+
+ testConnection(testConn, "select * from C_ACCOUNT", false, "Redeploy V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (Exception x) {
+ fail("Failed with exception " + Util.getStackTraceAsString(x)); //$NON-NLS-1$
+ } finally {
+ Util.closeQuietly(conn);
+ }
+ }
+
+ /**
+ * Redeploy while there is an opened connection. Restart the DQP to have the changes take effect
+ * Validate that the open connection becomes invalid and a new connection gets the latest VDB
+ * @throws Exception
+ */
+ @Test public void testReplaceVdbWithDqpRestart() throws Exception {
+ Connection conn = null;
+ Connection testConn = null;
+ Connection newTestConn = null;
+
+ String VDB_NAME = "ReplaceRestart"; //$NON-NLS-1$
+ try {
+ conn = Util.getConnection(ADMIN_URL_PREFIX + DEPLOY_FILE);
+ com.metamatrix.jdbc.api.Connection mmconn = (com.metamatrix.jdbc.api.Connection) conn;
+ Admin admin = mmconn.getAdminAPI();
+ VDB vdb = deployVdbClean(admin, VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORS.vdb"); //$NON-NLS-1$
+ String currentVersion = vdb.getVDBVersion();
+ assertEquals("1", currentVersion); //$NON-NLS-1$
+
+ // Connect and run test query
+ testConn = Util.getConnection("jdbc:teiid:" + VDB_NAME + "@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "SELECT * FROM C_REPOS_DB_RELEASE", true, "Initial V1 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "select * from C_ACCOUNT", false, "Initial V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Redeploy the VDB while the connection is open. New VDB has A_CCOUNT table
+ vdb = deployVdbClean(admin, VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORS1.vdb"); //$NON-NLS-1$
+
+ admin.restart();
+ Thread.sleep(2000);
+
+ newTestConn = Util.getConnection("jdbc:teiid:" + VDB_NAME + "@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(newTestConn, "select * from C_ACCOUNT", true, "Redeploy V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "SELECT 1", false, "Stale Conn test"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ } catch (Exception x) {
+ fail("Failed with exception " + Util.getStackTraceAsString(x)); //$NON-NLS-1$
+ } finally {
+ Util.closeQuietly(conn);
+ Util.closeQuietly(testConn);
+ Util.closeQuietly(newTestConn);
+ }
+ }
+
+ /**
+ * SIP53 Scenario 1
+ * Redeployment when there are no active connections. The new connection should get the latest version
+ * @throws Exception
+ */
+ @Test public void testReplaceNonActiveVdb () throws Exception {
+ Connection conn = null;
+ Connection testConn = null;
+ String VDB_NAME = "ReplaceNonActive"; //$NON-NLS-1$
+ try {
+ conn = Util.getConnection(ADMIN_URL_PREFIX + DEPLOY_FILE);
+ com.metamatrix.jdbc.api.Connection mmconn = (com.metamatrix.jdbc.api.Connection) conn;
+ Admin admin = mmconn.getAdminAPI();
+
+ VDB vdb = deployVdbClean(admin, VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORS.vdb"); //$NON-NLS-1$
+ String currentVersion = vdb.getVDBVersion();
+ assertEquals("1", currentVersion); //$NON-NLS-1$
+
+ // Connect and run test query
+ testConn = Util.getConnection("jdbc:teiid:" + VDB_NAME + "@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "SELECT * FROM C_REPOS_DB_RELEASE", true, "Initial V1 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "select * from C_ACCOUNT", false, "Initial V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.closeQuietly(testConn);
+
+ // Verify that there are no sessions left reset all sessions to the VDB
+ Iterator sessionIter = admin.getSessions("*").iterator(); //$NON-NLS-1$
+ while(sessionIter.hasNext()) {
+ Session session = (Session)sessionIter.next();
+ if (VDB_NAME.equals(session.getVDBName()) && currentVersion.equals(session.getVDBVersion())) {
+ fail("There should not be any sessions open against the VDB"); //$NON-NLS-1$
+ }
+ }
+
+ // Redeploy the VDB while the connection is open. New VDB has A_CCOUNT table
+ vdb = deployVdbClean(admin, VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORS1.vdb"); //$NON-NLS-1$
+
+ testConn = Util.getConnection("jdbc:teiid:" + VDB_NAME + "@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "select * from C_ACCOUNT", true, "Redeploy V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (Exception x) {
+ fail("Failed with exception " + Util.getStackTraceAsString(x)); //$NON-NLS-1$
+ } finally {
+ Util.closeQuietly(conn);
+ Util.closeQuietly(testConn);
+ }
+ }
+
+ /**
+ * SIP53 Scenario 2
+ * Similar to the <code>testReplaceNonActiveVdb</code>. Uses the session shutdown instead of
+ * expecting connections to be closed
+ * @throws Exception
+ */
+ @Test public void testReplaceVdbWithSessionClose() throws Exception {
+ Connection conn = null;
+ Connection testConn = null;
+ Connection newTestConn = null;
+ String VDB_NAME = "ReplaceSessionClose"; //$NON-NLS-1$
+ try {
+ conn = Util.getConnection(ADMIN_URL_PREFIX + DEPLOY_FILE);
+ com.metamatrix.jdbc.api.Connection mmconn = (com.metamatrix.jdbc.api.Connection) conn;
+ Admin admin = mmconn.getAdminAPI();
+ VDB vdb = deployVdbClean(admin, VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORS.vdb"); //$NON-NLS-1$
+ String currentVersion = vdb.getVDBVersion();
+
+ // Connect and run test query
+ testConn = Util.getConnection("jdbc:teiid:" + VDB_NAME + "@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "SELECT * FROM C_REPOS_DB_RELEASE", true, "Initial V1 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "select * from C_ACCOUNT", false, "Initial V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // reset all sessions to the VDB
+ Iterator sessionIter = admin.getSessions("*").iterator(); //$NON-NLS-1$
+ boolean sessionFound = false;
+ while(sessionIter.hasNext()) {
+ Session session = (Session)sessionIter.next();
+ if (VDB_NAME.equals(session.getVDBName()) && currentVersion.equals(session.getVDBVersion())) {
+ admin.terminateSession(session.getSessionID());
+ sessionFound = true;
+ }
+ }
+ if ( ! sessionFound ) {
+ fail("Did not find the expected connection to terminate"); //$NON-NLS-1$
+ }
+
+ // Redeploy the VDB while the connection is open. New VDB has A_CCOUNT table
+ vdb = deployVdbClean(admin, VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORS1.vdb"); //$NON-NLS-1$
+
+ newTestConn = Util.getConnection("jdbc:teiid:" + VDB_NAME + "@" + DEPLOY_FILE); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(newTestConn, "select * from C_ACCOUNT", true, "Redeploy V2 Test"); //$NON-NLS-1$ //$NON-NLS-2$
+ testConnection(testConn, "SELECT 1", false, "Stale Conn test"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ } catch (Exception x) {
+ fail("Failed with exception " + Util.getStackTraceAsString(x)); //$NON-NLS-1$
+ } finally {
+ Util.closeQuietly(conn);
+ Util.closeQuietly(testConn);
+ Util.closeQuietly(newTestConn);
+ }
+ }
+
+ /**
+ * SIP51, SIP52
+ * @throws Exception
+ */
+ @Test public void testDeleteInvalidVdb() throws Exception {
+ Connection conn = null;
+ String VDB_NAME = "DeleteInvalid"; //$NON-NLS-1$
+ try {
+ conn = Util.getConnection(ADMIN_URL_PREFIX + DEPLOY_FILE);
+ com.metamatrix.jdbc.api.Connection mmconn = (com.metamatrix.jdbc.api.Connection) conn;
+ Admin admin = mmconn.getAdminAPI();
+ // Try clean deployment twice
+ try {
+ deployVdbClean(admin, VDB_NAME, UnitTestUtil.getTestDataPath()+"/admin/TestORSInvalid.vdb"); //$NON-NLS-1$
+ fail("Failed with exception "); //$NON-NLS-1$
+ } catch (Exception e) {
+ //pass
+ }
+ } catch (Exception x) {
+ fail("Failed with exception " + Util.getStackTraceAsString(x)); //$NON-NLS-1$
+ } finally {
+ Util.closeQuietly(conn);
+ }
+ }
+
+
+ private VDB deployVdbClean(Admin admin, String vdbName, String vdbFile) throws Exception{
+
+ VDB vdb;
+ // Remove any existing VDBs from the previous tests.
+ Iterator iter = admin.getVDBs(vdbName).iterator();
+ while (iter.hasNext()) {
+ vdb = (VDB)iter.next();
+ admin.changeVDBStatus(vdb.getName(), vdb.getVDBVersion(), VDB.DELETED);
+ }
+
+ vdb = admin.addVDB(vdbName,Util.getBinaryFile(vdbFile), new AdminOptions(AdminOptions.OnConflict.OVERWRITE));
+ return vdb;
+ }
+
+ void testConnection(Connection conn, String sql, boolean expectSuccess, String testName) {
+ Statement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery(sql);
+ if ( ! rs.next() ) {
+ fail(sql + "executed with 0 rows returned"); //$NON-NLS-1$
+ }
+ } catch (Exception e) {
+ if (expectSuccess) {
+ fail(testName + " failed for [" + sql + "] with " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } finally {
+ Util.closeQuietly(null, stmt, rs);
+ }
+ }
+
+
+
+
+}
Property changes on: trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestDqpReDeployment.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java
===================================================================
--- trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java (rev 0)
+++ trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java 2009-08-25 19:38:18 UTC (rev 1277)
@@ -0,0 +1,522 @@
+/*
+ * Copyright (c) 2000-2005 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.runtime.adminapi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminOptions;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.Session;
+import org.teiid.adminapi.VDB;
+import org.teiid.jdbc.TeiidDriver;
+
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.core.util.UnitTestUtil;
+import com.metamatrix.jdbc.MMConnection;
+import com.metamatrix.jdbc.api.Connection;
+
+/**
+ * @since 4.3
+ */
+public class TestEmbeddedAdmin {
+
+ private static final String VDB_FILE = UnitTestUtil.getTestDataPath()+"/admin/TestEmpty.vdb"; //$NON-NLS-1$
+ private static final String VDB_NAME = "TestEmpty"; //$NON-NLS-1$
+
+ String configFile = UnitTestUtil.getTestDataPath()+"/admin/dqp.properties"; //$NON-NLS-1$
+ Connection conn = null;
+ Connection adminConn = null;
+ Admin admin = null;
+ Statement stmt = null;
+ ResultSet result = null;
+
+ /* Utility methods */
+ private Connection getConnection(String vdb, String configFile) throws SQLException {
+ String url = "jdbc:teiid:"+vdb+"@"+configFile+";user=admin;password=teiid"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new TeiidDriver();
+ Connection conn = (Connection)DriverManager.getConnection(url);
+ return conn;
+ }
+
+ Admin getAdmin() throws Exception{
+ adminConn = getConnection("admin", configFile); //$NON-NLS-1$
+ return adminConn.getAdminAPI();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ FileUtils.copy(UnitTestUtil.getTestDataPath()+"/admin/Admin.vdb", UnitTestUtil.getTestScratchPath()+"/Admin.vdb"); //$NON-NLS-1$ //$NON-NLS-2$
+ FileUtils.copy(UnitTestUtil.getTestDataPath()+"/ServerConfig.xml", UnitTestUtil.getTestScratchPath()+"/configuration.xml"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ @After
+ public void tearDown() throws Exception {
+ if (result != null) {
+ result.close();
+ }
+ if (stmt != null) {
+ stmt.close();
+ }
+ if (adminConn != null) {
+ adminConn.close();
+ }
+ if (conn != null) {
+ conn.close();
+ }
+ }
+
+ void cleanupVDB(Admin admin, String name, String version) {
+ try {
+ // make sure we delete any
+ admin.changeVDBStatus(name, version, VDB.DELETED);
+ }catch(Exception e) {
+ //ignore it might say not found
+ }
+ }
+
+ /* Test methods */
+ @Test public void testGetConnectionToAdmin() throws Exception {
+ conn = getConnection("admin", configFile); //$NON-NLS-1$
+ assertFalse("Found a Closed Connection to Admin", conn.isClosed()); //$NON-NLS-1$
+ }
+
+ @Test public void testAddTwoVDBsWithSameNameandVersion() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ boolean found = false;
+ Collection vdbs = admin.getVDBs(VDB_NAME);
+ for (Iterator i = vdbs.iterator(); i.hasNext();) {
+ VDB vdb = (VDB)i.next();
+ if (vdb.getName().equals(VDB_NAME) && vdb.getVDBVersion().equals("1")) { //$NON-NLS-1$
+ found = true;
+ }
+ }
+ assertTrue("Deployed VDB not found in the configuration", found); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ found = false;
+ vdbs = admin.getVDBs(VDB_NAME);
+ for (Iterator i = vdbs.iterator(); i.hasNext();) {
+ VDB vdb = (VDB)i.next();
+ if (vdb.getName().equals(VDB_NAME) && vdb.getVDBVersion().equals("2")) { //$NON-NLS-1$
+ found = true;
+ }
+ }
+ assertTrue("Deployed VDB not found in the configuration", found); //$NON-NLS-1$
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ cleanupVDB(admin, VDB_NAME, "2"); //$NON-NLS-1$
+ }
+
+ @Test public void testDeployVdbImbeddedDef() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ boolean found = false;
+ Collection vdbs = admin.getVDBs(VDB_NAME);
+ for (Iterator i = vdbs.iterator(); i.hasNext();) {
+ VDB vdb = (VDB)i.next();
+ if (vdb.getName().equals(VDB_NAME)) {
+ found = true;
+ }
+ }
+ assertTrue("Deployed VDB not found in the configuration", found); //$NON-NLS-1$
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testUndeployVdb() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ boolean found = false;
+ Collection vdbs = admin.getVDBs(VDB_NAME);
+ for (Iterator i = vdbs.iterator(); i.hasNext();) {
+ VDB vdb = (VDB)i.next();
+ if (vdb.getName().equals(VDB_NAME)) {
+ found = true;
+ }
+ }
+ assertTrue("Deployed VDB not found in the configuration", found); //$NON-NLS-1$
+
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.DELETED); //$NON-NLS-1$
+
+ found = false;
+ vdbs = admin.getVDBs(VDB_NAME);
+ for (Iterator i = vdbs.iterator(); i.hasNext();) {
+ VDB vdb = (VDB)i.next();
+ if (vdb.getName().equals(VDB_NAME)) {
+ found = true;
+ }
+ }
+ assertFalse("Deployed VDB found in the configuration after delete", found); //$NON-NLS-1$
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testUndeployNonExistantVdb() throws Exception {
+ admin = getAdmin();
+ try {
+ admin.changeVDBStatus("DoesNotExist", "1", VDB.DELETED); //$NON-NLS-1$ //$NON-NLS-2$
+ fail("Must have failed to delete a non existing VDB"); //$NON-NLS-1$
+ } catch (AdminException err) {
+ assertEquals("VDB \"DoesNotExist\" version \"1\" does not exist or not in valid state.", err.getMessage()); //$NON-NLS-1$
+ }
+ }
+
+ @Test public void testGetConnectionToExistingVdb() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ conn = getConnection(VDB_NAME, configFile);
+ assertFalse("found a closed connection", conn.isClosed()); //$NON-NLS-1$
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testGetConnectionToNonExistingVdb() throws Exception {
+ try {
+ getConnection("DoesNotExist", configFile); //$NON-NLS-1$
+ fail("found a Connection to a non avtive VDB"); //$NON-NLS-1$
+ } catch (SQLException err) {
+ assertEquals("VDB \"DoesNotExist\" version \"latest\" does not exist or not in valid state.", err.getMessage()); //$NON-NLS-1$
+ }
+ }
+
+ @Test public void testGetConnectionToNotActiveVdb() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.INACTIVE); //$NON-NLS-1$
+
+ try {
+ conn = getConnection(VDB_NAME, configFile);
+ fail("found a Connection to a non avtive VDB"); //$NON-NLS-1$
+ } catch (SQLException err) {
+ assertEquals("Unexpected error finding latest version of Virtual Database TestEmpty", err.getMessage()); //$NON-NLS-1$
+ } finally {
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+ }
+
+
+ @Test public void testSelectNonPrepared() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ conn = getConnection(VDB_NAME, configFile);
+ Statement stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery("SELECT * FROM smalla"); //$NON-NLS-1$
+ if (!rs.next()) {
+ fail("SELECT * FROM smalla failed"); //$NON-NLS-1$
+ }
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testSelectPrepared() throws Exception {
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ conn = getConnection(VDB_NAME, configFile);
+ executePreparedStatement("SELECT * FROM smalla"); //$NON-NLS-1$
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testStopConnectorBinding() throws Exception {
+ addVDB();
+
+ admin.stopConnectorBinding("Loopback", true); //$NON-NLS-1$
+
+ try {
+ executeStatement("SELECT * FROM smalla"); //$NON-NLS-1$
+ fail("Ran statement on closed connector binding! Wrong!"); //$NON-NLS-1$
+ }catch(Exception e) {
+ // pass good
+ }
+
+ admin.startConnectorBinding("Loopback"); //$NON-NLS-1$
+ executeStatement("SELECT * FROM smalla"); //$NON-NLS-1$
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+
+ @Test public void testStopNonExistingConnectorBinding() throws Exception {
+ addVDB();
+
+ try {
+ admin.stopConnectorBinding("NO_CONNECTORS", true); //$NON-NLS-1$
+ fail("stopped a unknown connector Wow!"); //$NON-NLS-1$
+ } catch(AdminException e) {
+ assertEquals("Connector Binding with name \"NO_CONNECTORS\" does not exist in the configuration", e.getMessage()); //$NON-NLS-1$
+ }
+
+ executeStatement("SELECT * FROM smalla"); //$NON-NLS-1$
+
+ admin.startConnectorBinding("Loopback"); //$NON-NLS-1$
+ executeStatement("SELECT * FROM smalla"); //$NON-NLS-1$
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testAddConnectorBinding() throws Exception {
+ addVDB();
+ String LOOPBACK = "loopy"; //$NON-NLS-1$
+ admin.addConnectorBinding(LOOPBACK, Util.getCharacterFile(UnitTestUtil.getTestDataPath()+"/admin/loopback.cdk"), new AdminOptions(AdminOptions.OnConflict.OVERWRITE)); //$NON-NLS-1$
+ admin.startConnectorBinding(LOOPBACK);
+
+ boolean found = true;
+ Collection c = admin.getConnectorBindings(LOOPBACK);
+ for (Iterator i = c.iterator(); i.hasNext();) {
+ ConnectorBinding binding = (ConnectorBinding)i.next();
+ if (binding.getName().equals(LOOPBACK)) {
+ found = true;
+ }
+ }
+ assertTrue("Connector LOOPBACK not found after adding", found); //$NON-NLS-1$
+
+ admin.assignBindingToModel(LOOPBACK, VDB_NAME, "1", "Oracle"); //$NON-NLS-1$ //$NON-NLS-2$
+ stmt = conn.createStatement();
+ result = stmt.executeQuery("Select * from smalla"); //$NON-NLS-1$
+ int count = 0;
+ while (result.next()) {
+ count++;
+ }
+ assertEquals("Expected one row", 1, count); //$NON-NLS-1$
+
+
+ Collection cbindings = admin.getConnectorBindings("*"); //$NON-NLS-1$
+ ConnectorBinding binding = null;
+ for (Iterator i = cbindings.iterator(); i.hasNext();) {
+ ConnectorBinding current = (ConnectorBinding)i.next();
+ if (current.getName().equals(LOOPBACK)) {
+ binding = current;
+ }
+ }
+ admin.setProperty(binding.getIdentifier(), ConnectorBinding.class.getName(), "RowCount", "10"); //$NON-NLS-1$ //$NON-NLS-2$
+ admin.stopConnectorBinding(LOOPBACK, true);
+ admin.startConnectorBinding(LOOPBACK);
+
+ stmt = conn.createStatement();
+ result = stmt.executeQuery("Select * from smalla"); //$NON-NLS-1$
+
+ count = 0;
+ while (result.next()) {
+ count++;
+ }
+ assertEquals("Expected ten rows", 10, count); //$NON-NLS-1$
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testAddUnknownConnectorBinding() throws Exception {
+ addVDB();
+ try {
+ admin.startConnectorBinding("UNKNOWN"); //$NON-NLS-1$
+ fail("Started a unknown connector, BAD"); //$NON-NLS-1$
+ } catch(AdminException e) {
+ assertEquals("Connector Binding with name \"UNKNOWN\" does not exist in the configuration", e.getMessage()); //$NON-NLS-1$
+ }
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+
+ @Test public void testExtensionModules() throws Exception {
+ addVDB();
+
+ Collection c = admin.getExtensionModules("*"); //$NON-NLS-1$
+ assertEquals(0, c.size());
+
+ admin.addExtensionModule("jar", "loopbackconn.jar", Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/loopbackconn.jar"), "Loopback Jar"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ c = admin.getExtensionModules("*"); //$NON-NLS-1$
+ assertEquals(1, c.size());
+
+ admin.deleteExtensionModule("loopbackconn.jar"); //$NON-NLS-1$
+
+ c = admin.getExtensionModules("*"); //$NON-NLS-1$
+ assertEquals(0, c.size());
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testGetSessions() throws Exception {
+ adminConn = getConnection("admin", configFile); //$NON-NLS-1$
+ admin = adminConn.getAdminAPI();
+ admin.restart();
+
+ addVDB();
+ Collection<Session> c = admin.getSessions("*"); //$NON-NLS-1$
+ assertEquals(2, c.size());
+
+ MMConnection myconn = (MMConnection)this.conn;
+
+ admin.terminateSession(myconn.getConnectionId());
+ this.result = null;
+ this.stmt = null;
+ this.conn = null;
+
+ c = admin.getSessions("*"); //$NON-NLS-1$
+ assertEquals(1, c.size());
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+
+ @Test public void testExportVDB() throws Exception {
+ addVDB();
+
+ Util.writeToFile("Test.VDB", admin.exportVDB(VDB_NAME, "1")); //$NON-NLS-1$ //$NON-NLS-2$
+ File f = new File("Test.VDB"); //$NON-NLS-1$
+ assertTrue("failed to export vdb", f.exists()); //$NON-NLS-1$
+
+ f.delete();
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testExportConnectorBinging() throws Exception {
+ addVDB();
+
+ Util.writeToFile("Oracle.cdk", admin.exportConnectorBinding("Loopback")); //$NON-NLS-1$ //$NON-NLS-2$
+ File f = new File("Oracle.cdk"); //$NON-NLS-1$
+ assertTrue("failed to export connector binding", f.exists()); //$NON-NLS-1$
+
+ f.delete();
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testExportConnectorType() throws Exception {
+ addVDB();
+
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/loopy.cdk", admin.exportConnectorType("Loopback Connector")); //$NON-NLS-1$ //$NON-NLS-2$
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/loopy.cdk"); //$NON-NLS-1$
+ assertTrue("failed to export connector binding", f.exists()); //$NON-NLS-1$
+
+ f.delete();
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testExportServerConfig() throws Exception {
+ addVDB();
+
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/serverconfig.xml", admin.exportConfiguration()); //$NON-NLS-1$
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/serverconfig.xml"); //$NON-NLS-1$
+ assertTrue("failed to export connector binding", f.exists()); //$NON-NLS-1$
+
+ f.delete();
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+ @Test public void testExportExtensionModule() throws Exception {
+ addVDB();
+ admin.addExtensionModule("jar", "loopback.jar", Util.getBinaryFile(UnitTestUtil.getTestDataPath()+"/admin/loopbackconn.jar"), ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Util.writeToFile(UnitTestUtil.getTestScratchPath()+"/loop.jar", admin.exportExtensionModule("loopback.jar")); //$NON-NLS-1$ //$NON-NLS-2$
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/loop.jar"); //$NON-NLS-1$
+ assertTrue("failed to export connector binding", f.exists()); //$NON-NLS-1$
+
+ f.delete();
+
+ admin.deleteExtensionModule("loopback.jar"); //$NON-NLS-1$
+
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+ }
+
+
+ @Test public void testUDF() throws Exception {
+ addVDB();
+ stmt = conn.createStatement();
+ result = stmt.executeQuery("SELECT GetSystemProperty('path.separator')"); //$NON-NLS-1$
+
+ assertTrue(result.next());
+ assertEquals(System.getProperty("path.separator"), result.getObject(1)); //$NON-NLS-1$
+ assertTrue(!result.next());
+
+ result.close();
+ stmt.close();
+
+ stmt = conn.createStatement();
+ result = stmt.executeQuery("SELECT getxyz()"); //$NON-NLS-1$
+
+ assertTrue(result.next());
+ assertEquals("xyz", result.getObject(1)); //$NON-NLS-1$
+ assertTrue(!result.next());
+ }
+
+ /**
+ * @throws Exception
+ * @throws AdminException
+ * @since 4.3
+ */
+ private void addVDB() throws Exception{
+ admin = getAdmin();
+ cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+
+ admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+ admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE); //$NON-NLS-1$
+
+ conn = getConnection(VDB_NAME, configFile);
+ executeStatement("SELECT * FROM smalla"); //$NON-NLS-1$
+ }
+
+
+ private void executePreparedStatement(String query) throws Exception{
+ PreparedStatement pstmt = conn.prepareStatement(query);
+ pstmt.execute();
+ result = pstmt.getResultSet();
+ if (!result.next()) {
+ fail("SELECT * FROM smalla"); //$NON-NLS-1$
+ }
+ stmt = pstmt;
+ }
+
+ private void executeStatement(String query) throws Exception{
+ stmt = conn.createStatement();
+ result = stmt.executeQuery(query);
+ if (!result.next()) {
+ fail("SELECT * FROM smalla"); //$NON-NLS-1$
+ }
+ }
+}
Property changes on: trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/Util.java
===================================================================
--- trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/Util.java (rev 0)
+++ trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/Util.java 2009-08-25 19:38:18 UTC (rev 1277)
@@ -0,0 +1,128 @@
+package org.teiid.runtime.adminapi;
+
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+
+public class Util {
+
+
+ /* Utility methods */
+ public static Connection getConnection(String mmUrl) throws Exception {
+
+ final String DRIVER_NAME = "org.teiid.jdbc.TeiidDriver"; //$NON-NLS-1$
+ final String USER_NAME = "admin";//$NON-NLS-1$
+ final String PASSWORD = "teiid";//$NON-NLS-1$
+
+ Connection conn = null;
+ try {
+ // using the driver
+
+ Class driverClass = Class.forName(DRIVER_NAME);
+ if ( driverClass == null) {
+ throw new Exception("load class for Driver");//$NON-NLS-1$
+ }
+
+ Driver driver = (Driver) driverClass.newInstance();
+
+ DriverManager.registerDriver( driver );
+ conn = DriverManager.getConnection(mmUrl, USER_NAME, PASSWORD);
+ } catch (Exception e) {
+ throw e;
+ }
+
+ return conn;
+ }
+
+ public static void closeQuietly(Connection conn) {
+ try {
+ if (conn != null ) try { conn.close(); } catch (Exception e) {}
+ } catch (Exception x) {
+ // tastes good
+ }
+ }
+
+ public static void closeQuietly(Statement stmt) {
+ try {
+ if (stmt != null ) try { stmt.close(); } catch (Exception e) {}
+ } catch (Exception x) {
+ // tastes good
+ }
+ }
+
+ public static void closeQuietly(ResultSet rs) {
+ try {
+ if (rs != null ) try { rs.close(); } catch (Exception e) {}
+ } catch (Exception x) {
+ // tastes good
+ }
+ }
+
+ public static void closeQuietly(Connection conn, Statement stmt, ResultSet rs) {
+ closeQuietly(conn);
+ closeQuietly(stmt);
+ closeQuietly(rs);
+ }
+
+ public static String getStackTraceAsString(Exception e) {
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(stringWriter);
+ e.printStackTrace(printWriter);
+ StringBuffer error = stringWriter.getBuffer();
+ return error.toString();
+ }
+
+ @SuppressWarnings("deprecation")
+ public static char[] getCharacterFile(String file) throws IOException {
+
+ URL url = new File(file).toURL();
+
+ InputStream in = url.openStream();
+ CharArrayWriter out = new CharArrayWriter(10 * 1024);
+ int b = 0;
+ while ((b = in.read()) != -1) {
+ out.write(b);
+ }
+ return out.toCharArray();
+ }
+
+ @SuppressWarnings("deprecation")
+ public static byte[] getBinaryFile(String file) throws IOException {
+
+ URL url = new File(file).toURL();
+
+ InputStream in = url.openStream();
+ ByteArrayOutputStream out = new ByteArrayOutputStream(10 * 1024);
+ int b = 0;
+ while ((b = in.read()) != -1) {
+ out.write(b);
+ }
+ return out.toByteArray();
+ }
+
+ public static void writeToFile(String name, byte[] contents) throws Exception {
+ FileOutputStream f = new FileOutputStream(name);
+ f.write(contents);
+ f.close();
+ }
+
+ public static void writeToFile(String name, char[] contents) throws Exception {
+ FileWriter f = new FileWriter(name);
+ f.write(contents);
+ f.close();
+ }
+}
Property changes on: trunk/test-integration/src/test/java/org/teiid/runtime/adminapi/Util.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/resources/admin/Admin.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/Admin.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/BQT1Binding.cdk
===================================================================
--- trunk/test-integration/src/test/resources/admin/BQT1Binding.cdk (rev 0)
+++ trunk/test-integration/src/test/resources/admin/BQT1Binding.cdk 2009-08-25 19:38:18 UTC (rev 1277)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ConfigurationDocument>
+ <Header>
+ <ConfigurationVersion>4.2</ConfigurationVersion>
+ <ApplicationCreatedBy>MetaMatrix Console</ApplicationCreatedBy>
+ <ApplicationVersion>4.0:1949</ApplicationVersion>
+ <UserCreatedBy>MetaMatrixAdmin</UserCreatedBy>
+ <MetaMatrixSystemVersion>4.2</MetaMatrixSystemVersion>
+ <Time>2004-11-15T14:25:39.375-06:00</Time>
+ </Header>
+ <ComponentTypes>
+ <ComponentType Name="Loopback Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2004-11-12T03:46:02.937-06:00" CreatedBy="ConfigurationStartup" CreationDate="2004-11-12T03:46:02.937-06:00">
+ <PropertyDefinition Name="CapabilitiesClass" DisplayName="Capabilities Class" ShortDescription="" DefaultValue="" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ <PropertyDefinition Name="RowCount" DisplayName="Rows Per Query" ShortDescription="" DefaultValue="1" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="true" />
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.loopback.LoopbackConnector" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ <PropertyDefinition Name="WaitTime" DisplayName="Max Random Wait Time" ShortDescription="" DefaultValue="0" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ <PropertyDefinition Name="ConnectorClassPath" DisplayName="Class Path" ShortDescription="" DefaultValue="extensionjar:loopbackconn.jar;extensionjar:jdbcconn.jar" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="false" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ </ComponentType>
+ </ComponentTypes>
+ <ConnectorBindings>
+ <Connector Name="BQT1 Oracle 9i Simple Cap" ComponentType="Loopback Connector" LastChangedBy="metamatrixadmin" LastChangedDate="2005-07-20T12:58:35.551-06:00" CreatedBy="metamatrixadmin" CreationDate="2005-07-20T11:39:55.961-06:00" QueuedService="false" routingUUID="mmuuid:a6ea7cc0-c651-1f91-940a-b13465b430eb">
+ <Properties>
+ <Property Name="MaxResultRows">10000</Property>
+ <Property Name="ConnectorThreadTTL">120000</Property>
+ <Property Name="ConnectorMaxThreads">5</Property>
+ <Property Name="metamatrix.service.essentialservice">false</Property>
+ <Property Name="ConnectorClassPath">extensionjar:loopbackconn.jar;extensionjar:jdbcconn.jar</Property>
+ <Property Name="RowCount">100</Property>
+ <Property Name="ServiceClassName">com.metamatrix.server.connector.service.ConnectorService</Property>
+ <Property Name="ConnectorClass">com.metamatrix.connector.loopback.LoopbackConnector</Property>
+ <Property Name="WaitTime">0</Property>
+ </Properties>
+ </Connector>
+ </ConnectorBindings>
+</ConfigurationDocument>
\ No newline at end of file
Added: trunk/test-integration/src/test/resources/admin/Empty.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/Empty.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/QT_Ora9DSwDEF.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/QT_Ora9DSwDEF.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/TestEmpty.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/TestEmpty.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/TestORS.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/TestORS.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/TestORS1.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/TestORS1.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/TestORSInvalid.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/TestORSInvalid.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/dqp.properties
===================================================================
--- trunk/test-integration/src/test/resources/admin/dqp.properties (rev 0)
+++ trunk/test-integration/src/test/resources/admin/dqp.properties 2009-08-25 19:38:18 UTC (rev 1277)
@@ -0,0 +1,12 @@
+dqp.configFile=../../../../target/scratch/configuration.xml
+dqp.buffer.usedisk=false
+xa.enable_recovery=false
+dqp.deploydir=../../../../target/scratch
+dqp.workdir=../../../../target/scratch/work
+membership.enabled=true
+membership.superUser=admin
+membership.superUserPassword=teiid
+auth.check_entitlements=false
+dqp.userDefinedFunctionsFile=extensionjar:FunctionDefinitions.xmi
+processName=localhost
+dqp.extensions=../../../../target/scratch/extensions/;./extensions
\ No newline at end of file
Property changes on: trunk/test-integration/src/test/resources/admin/dqp.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/resources/admin/extensions/FunctionDefinitions.xmi
===================================================================
--- trunk/test-integration/src/test/resources/admin/extensions/FunctionDefinitions.xmi (rev 0)
+++ trunk/test-integration/src/test/resources/admin/extensions/FunctionDefinitions.xmi 2009-08-25 19:38:18 UTC (rev 1277)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!-- Copyright (c) 2000-2005 MetaMatrix, Inc. All rights reserved. -->
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:Diagram="http://www.metamatrix.com/metamodels/Diagram" xmlns:mmcore="http://www.metamatrix.com/metamodels/Core" xmlns:mmfunction="http://www.metamatrix.com/metamodels/MetaMatrixFunction">
+ <mmcore:ModelAnnotation xmi:uuid="mmuuid:476bf340-56da-1ebb-a41d-ec14fd2bd1f4" primaryMetamodelUri="http://www.metamatrix.com/metamodels/MetaMatrixFunction"/>
+ <Diagram:DiagramContainer xmi:uuid="mmuuid:0a2f9c80-0014-1f04-862e-867a59458599">
+ <diagram xmi:uuid="mmuuid:094abac0-0014-1f04-862e-867a59458599" type="packageDiagramType" target="mmuuid/476bf340-56da-1ebb-a41d-ec14fd2bd1f4">
+ <diagramEntity xmi:uuid="mmuuid:8b0e9c40-0017-1f04-862e-867a59458599" name="GetSystemProperty" modelObject="mmuuid/1007f880-0016-1f04-862e-867a59458599" xPosition="39" yPosition="5" height="86" width="150"/>
+ <diagramEntity xmi:uuid="mmuuid:2a88da80-002a-1f04-862e-867a59458599" name="GetSystemProperty" modelObject="mmuuid/a912c380-0029-1f04-862e-867a59458599" xPosition="34" yPosition="108" height="71" width="150"/>
+ </diagram>
+ </Diagram:DiagramContainer>
+ <mmfunction:ScalarFunction xmi:uuid="mmuuid:1007f880-0016-1f04-862e-867a59458599" name="GetSystemProperty" category="MyFunctions" invocationClass="org.teiid.runtime.adminapi.MyFunctions" invocationMethod="getProperty" deterministic="true">
+ <inputParameters xmi:uuid="mmuuid:e48dac00-0082-1f04-862e-867a59458599" name="prop" type="string"/>
+ <returnParameter xmi:uuid="mmuuid:98d39a00-0036-1f04-862e-867a59458599" type="string"/>
+ </mmfunction:ScalarFunction>
+ <mmfunction:ScalarFunction xmi:uuid="mmuuid:a912c380-0029-1f04-862e-867a59458599" name="getpushdown" category="MyFunctions" pushDown="REQUIRED" invocationClass="org.teiid.runtime.adminapi.MyFunctions" invocationMethod="getPropertyNoArgs" deterministic="true">
+ <returnParameter xmi:uuid="mmuuid:675e4cc1-003d-1f04-862e-867a59458599" type="string"/>
+ </mmfunction:ScalarFunction>
+ <mmfunction:ScalarFunction xmi:uuid="mmuuid:a912c380-0029-1f04-862e-867a59458599" name="getxyz" category="MyFunctions" invocationClass="org.teiid.runtime.adminapi.MyFunctions" invocationMethod="getPropertyNoArgs" deterministic="true">
+ <returnParameter xmi:uuid="mmuuid:675e4cc1-003d-1f04-862e-867a59458599" type="string"/>
+ </mmfunction:ScalarFunction>
+
+ <mmcore:AnnotationContainer xmi:uuid="mmuuid:7f2b50c0-00fe-1f04-862e-867a59458599">
+ <annotations xmi:uuid="mmuuid:7e372cc0-00fe-1f04-862e-867a59458599" description="No arg getter" annotatedObject="mmuuid/1007f880-0016-1f04-862e-867a59458599"/>
+ <annotations xmi:uuid="mmuuid:43050ec0-06d4-1f04-862e-867a59458599" description="" annotatedObject="mmuuid/a912c380-0029-1f04-862e-867a59458599"/>
+ <annotations xmi:uuid="mmuuid:892e2640-06d7-1f04-862e-867a59458599" description="Property name" annotatedObject="mmuuid/e48dac00-0082-1f04-862e-867a59458599"/>
+ <annotations xmi:uuid="mmuuid:f2af3440-06d9-1f04-862e-867a59458599" description="System property" annotatedObject="mmuuid/98d39a00-0036-1f04-862e-867a59458599"/>
+ </mmcore:AnnotationContainer>
+</xmi:XMI>
Property changes on: trunk/test-integration/src/test/resources/admin/extensions/FunctionDefinitions.xmi
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/resources/admin/loopback.cdk
===================================================================
--- trunk/test-integration/src/test/resources/admin/loopback.cdk (rev 0)
+++ trunk/test-integration/src/test/resources/admin/loopback.cdk 2009-08-25 19:38:18 UTC (rev 1277)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ConfigurationDocument>
+ <Header>
+ <ConfigurationVersion>4.2</ConfigurationVersion>
+ <ApplicationCreatedBy>MetaMatrix Console</ApplicationCreatedBy>
+ <ApplicationVersion>4.0:1949</ApplicationVersion>
+ <UserCreatedBy>MetaMatrixAdmin</UserCreatedBy>
+ <MetaMatrixSystemVersion>4.2</MetaMatrixSystemVersion>
+ <Time>2004-11-15T14:25:39.375-06:00</Time>
+ </Header>
+ <ComponentTypes>
+ <ComponentType Name="Loopback Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2004-11-12T03:46:02.937-06:00" CreatedBy="ConfigurationStartup" CreationDate="2004-11-12T03:46:02.937-06:00">
+ <ComponentTypeDefn Deprecated="false">
+ <PropertyDefinition Name="CapabilitiesClass" DisplayName="Capabilities Class" ShortDescription="" DefaultValue="" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ </ComponentTypeDefn>
+ <ComponentTypeDefn Deprecated="false">
+ <PropertyDefinition Name="RowCount" DisplayName="Rows Per Query" ShortDescription="" DefaultValue="1" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="true" />
+ </ComponentTypeDefn>
+ <ComponentTypeDefn Deprecated="false">
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.loopback.LoopbackConnector" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ </ComponentTypeDefn>
+ <ComponentTypeDefn Deprecated="false">
+ <PropertyDefinition Name="WaitTime" DisplayName="Max Random Wait Time" ShortDescription="" DefaultValue="0" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ </ComponentTypeDefn>
+ <ComponentTypeDefn Deprecated="false">
+ <PropertyDefinition Name="ConnectorClassPath" DisplayName="Class Path" ShortDescription="" DefaultValue="extensionjar:loopbackconn.jar;extensionjar:jdbcconn.jar" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="false" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ </ComponentTypeDefn>
+ </ComponentType>
+ </ComponentTypes>
+ <ConnectorBindings>
+ <Connector Name="TestCDK" ComponentType="Loopback Connector" LastChangedBy="metamatrixadmin" LastChangedDate="2004-11-15T11:46:14.500-06:00" CreatedBy="metamatrixadmin" CreationDate="2004-11-15T11:46:14.500-06:00" QueuedService="false">
+ <Properties>
+ <Property Name="MaxResultRows">10000</Property>
+ <Property Name="ConnectorThreadTTL">120000</Property>
+ <Property Name="ConnectorMaxThreads">5</Property>
+ <Property Name="metamatrix.service.essentialservice">false</Property>
+ <Property Name="ConnectorClassPath">extensionjar:loopbackconn.jar;extensionjar:jdbcconn.jar</Property>
+ <Property Name="RowCount">1</Property>
+ <Property Name="ServiceClassName">com.metamatrix.server.connector.service.ConnectorService</Property>
+ <Property Name="ConnectorClass">com.metamatrix.connector.loopback.LoopbackConnector</Property>
+ <Property Name="WaitTime">0</Property>
+ </Properties>
+ </Connector>
+ </ConnectorBindings>
+</ConfigurationDocument>
+
Added: trunk/test-integration/src/test/resources/admin/loopback_archive.caf
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/loopback_archive.caf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-integration/src/test/resources/admin/loopbackconn.jar
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/src/test/resources/admin/loopbackconn.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
14 years, 8 months
teiid SVN: r1276 - trunk/common-internal/src/main/java/com/metamatrix/common/log.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-08-24 18:41:19 -0400 (Mon, 24 Aug 2009)
New Revision: 1276
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/log/LogConfigurationImpl.java
Log:
TEIID-672, TEIID-697: There were conflicting ways to define the Logging Levels in the Admin API, one defined by EmbeddedLogger and second by the LogConfiguration. Log4J can return a logging level as NULL, in that case take the parent logger's log level.
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/log/LogConfigurationImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/log/LogConfigurationImpl.java 2009-08-24 21:11:47 UTC (rev 1275)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/log/LogConfigurationImpl.java 2009-08-24 22:41:19 UTC (rev 1276)
@@ -49,9 +49,12 @@
}
@Override
- public int getLogLevel(String context) {
- context = fixContext(context);
+ public int getLogLevel(String context) {
Integer level = this.contextMap.get(context);
+ if (level == null) {
+ context = fixContext(context);
+ }
+ level = this.contextMap.get(context);
if (level != null) {
return level;
}
14 years, 8 months