Skip to content

Commit

Permalink
Fixes issues with the comparison of parameters and properties. Due to…
Browse files Browse the repository at this point in the history
… the case of the parameters, sometimes a comparison would fail. They are now all compared as upper case values across the board.

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@431 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
lucboudreau committed Mar 24, 2011
1 parent 9bb70cd commit a640c01
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 58 deletions.
17 changes: 8 additions & 9 deletions src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,21 @@ abstract class XmlaOlap4jConnection implements OlapConnection {
final Map<String, String> map = parseConnectString(url, info);

this.databaseName =
map.get(XmlaOlap4jDriver.Property.Database.name());
map.get(XmlaOlap4jDriver.Property.DATABASE.name());

this.catalogName =
map.get(XmlaOlap4jDriver.Property.Catalog.name());
map.get(XmlaOlap4jDriver.Property.CATALOG.name());

this.schemaName =
map.get(XmlaOlap4jDriver.Property.Schema.name());
map.get(XmlaOlap4jDriver.Property.SCHEMA.name());

// Set URL of HTTP server.
final String serverUrl =
map.get(XmlaOlap4jDriver.Property.Server.name());
map.get(XmlaOlap4jDriver.Property.SERVER.name());
if (serverUrl == null) {
throw getHelper().createException(
"Connection property '"
+ XmlaOlap4jDriver.Property.Server.name()
+ XmlaOlap4jDriver.Property.SERVER.name()
+ "' must be specified");
}
try {
Expand Down Expand Up @@ -245,7 +245,7 @@ private XmlaHelper getHelper() {
*/
private void initSoapCache(Map<String, String> map) throws OlapException {
// Test if a SOAP cache class was defined
if (map.containsKey(XmlaOlap4jDriver.Property.Cache.name()
if (map.containsKey(XmlaOlap4jDriver.Property.CACHE.name()
.toUpperCase()))
{
// Create a properties object to pass to the proxy
Expand All @@ -256,11 +256,10 @@ private void initSoapCache(Map<String, String> map) throws OlapException {
for (Entry<String, String> entry : map.entrySet()) {
// Check if the current entry relates to cache config.
if (entry.getKey().startsWith(
XmlaOlap4jDriver.Property.Cache.name().toUpperCase()
+ "."))
XmlaOlap4jDriver.Property.CACHE.name() + "."))
{
props.put(entry.getKey().substring(
XmlaOlap4jDriver.Property.Cache.name()
XmlaOlap4jDriver.Property.CACHE.name()
.length() + 1), entry.getValue());
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/org/olap4j/driver/xmla/XmlaOlap4jDriver.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
// $Id:$
// $Id$
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
Expand Down Expand Up @@ -62,7 +62,7 @@
* <tr><td>Schema</td> <td>Schema name to use.
* By default, the first one returned by the
* XMLA server will be used.</td></tr>
**
*
* <tr><td>Database</td> <td>Name of the XMLA database.
* By default, the first one returned by the
* XMLA server will be used.</td></tr>
Expand Down Expand Up @@ -240,7 +240,7 @@ public boolean jdbcCompliant() {
* @return A Proxy with which to submit XML requests
*/
protected XmlaOlap4jProxy createProxy(Map<String, String> map) {
String cookie = map.get(Property.TestProxyCookie.name());
String cookie = map.get(Property.TESTPROXYCOOKIE.name());
if (cookie != null) {
XmlaOlap4jProxy proxy = PROXY_MAP.get(cookie);
if (proxy != null) {
Expand Down Expand Up @@ -296,14 +296,14 @@ public static synchronized String nextCookie() {
* Properties supported by this driver.
*/
public enum Property {
TestProxyCookie(
TESTPROXYCOOKIE(
"String that uniquely identifies a proxy object via which to send "
+ "XMLA requests for testing purposes."),
Server("URL of HTTP server"),
Catalog("Catalog name"),
Database("Name of the database"),
Schema("Name of the schema"),
Cache("Class name of the SOAP cache implementation");
SERVER("URL of HTTP server"),
DATABASE("Name of the database"),
CATALOG("Catalog name"),
SCHEMA("Name of the schema"),
CACHE("Class name of the SOAP cache implementation");

/**
* Creates a property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ public byte[] get(
if (caches.containsKey(id)) {
return caches.get(id).get(url, request);
} else {
throw new RuntimeException(
"There are no configured caches of this name yet configured.");
throw new XmlaOlap4jInvalidStateException();
}
}
}
Expand All @@ -217,9 +216,7 @@ public void put(
if (caches.containsKey(id)) {
caches.get(id).put(url, request, response);
} else {
throw new RuntimeException(
"There are no configured caches of this name yet "
+ "configured.");
throw new XmlaOlap4jInvalidStateException();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void setCache(
try {
// Loads the cache class
Class clazz = Class.forName(config.get(
XmlaOlap4jDriver.Property.Cache.name()));
XmlaOlap4jDriver.Property.CACHE.name()));

// Instantiates it
this.cache = (XmlaOlap4jCache) clazz.newInstance();
Expand All @@ -129,23 +129,23 @@ public void setCache(
} catch (ClassNotFoundException e) {
throw helper.createException(
"The specified cache class name could not be found : "
+ config.get(XmlaOlap4jDriver.Property.Cache.name()), e);
+ config.get(XmlaOlap4jDriver.Property.CACHE.name()), e);
} catch (InstantiationException e) {
throw helper.createException(
"The specified cache class name could not be instanciated : "
+ config.get(XmlaOlap4jDriver.Property.Cache.name()), e);
+ config.get(XmlaOlap4jDriver.Property.CACHE.name()), e);
} catch (IllegalAccessException e) {
throw helper.createException(
"An error was encountered while instanciating the cache : "
+ config.get(XmlaOlap4jDriver.Property.Cache.name()), e);
+ config.get(XmlaOlap4jDriver.Property.CACHE.name()), e);
} catch (IllegalArgumentException e) {
throw helper.createException(
"An error was encountered while instanciating the cache : "
+ config.get(XmlaOlap4jDriver.Property.Cache.name()), e);
+ config.get(XmlaOlap4jDriver.Property.CACHE.name()), e);
} catch (SecurityException e) {
throw helper.createException(
"An error was encountered while instanciating the cache : "
+ config.get(XmlaOlap4jDriver.Property.Cache.name()), e);
+ config.get(XmlaOlap4jDriver.Property.CACHE.name()), e);
}
}

Expand Down
4 changes: 2 additions & 2 deletions testsrc/org/olap4j/ConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,15 +367,15 @@ public void testXmlaCatalogParameter() throws Exception {
assertEquals(0, axesList.size());

info.setProperty(
XmlaOlap4jDriver.Property.Catalog.name(), "FoodMart");
XmlaOlap4jDriver.Property.CATALOG.name(), "FoodMart");
connection =
DriverManager.getConnection(
tester.getURL().replaceFirst("\\;Catalog=FoodMart", ""),
info);
assertEquals("FoodMart", connection.getCatalog());

info.setProperty(
XmlaOlap4jDriver.Property.Catalog.name(), "FoodMartError");
XmlaOlap4jDriver.Property.CATALOG.name(), "FoodMartError");
try {
connection = DriverManager.getConnection(
tester.getURL().replaceFirst("\\;Catalog=FoodMart", ""),
Expand Down
2 changes: 1 addition & 1 deletion testsrc/org/olap4j/XmlaConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void testNoNonTrivalCallsOnConnect() throws Exception {
}
Properties info = new Properties();
info.setProperty(
XmlaOlap4jDriver.Property.Catalog.name(), "FoodMart");
XmlaOlap4jDriver.Property.CATALOG.name(), "FoodMart");
DriverManager.getConnection(
"jdbc:xmla:Server=http://foo;Catalog=FoodMart;TestProxyCookie="
+ cookie,
Expand Down
4 changes: 2 additions & 2 deletions testsrc/org/olap4j/XmlaTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Connection createConnection() throws SQLException {
}
Properties info = new Properties();
info.setProperty(
XmlaOlap4jDriver.Property.Catalog.name(), "FoodMart");
XmlaOlap4jDriver.Property.CATALOG.name(), "FoodMart");
connection =
DriverManager.getConnection(
getURL(),
Expand All @@ -107,7 +107,7 @@ public Connection createConnectionWithUserPassword() throws SQLException {
}
Properties info = new Properties();
info.setProperty(
XmlaOlap4jDriver.Property.Catalog.name(), "FoodMart");
XmlaOlap4jDriver.Property.CATALOG.name(), "FoodMart");
return DriverManager.getConnection(
getURL(), USER, PASSWORD);
}
Expand Down
4 changes: 1 addition & 3 deletions testsrc/org/olap4j/driver/xmla/cache/XmlaDatabaseCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import java.sql.Statement;
import java.util.Map;

import org.olap4j.impl.Base64;

/**
* This mock server cache is only used to save and load
* runs of the XMLA driver as a database table.
Expand Down Expand Up @@ -147,7 +145,7 @@ public void put(String id, URL url, byte[] request, byte[] response)
connection.prepareStatement(
Properties.QUERY_INSERT.getValueOrDefault(props));
try {
stm.setString(1,new String(request));
stm.setString(1, new String(request));
stm.setString(2, new String(response));
stm.execute();
} finally {
Expand Down
42 changes: 21 additions & 21 deletions testsrc/org/olap4j/driver/xmla/proxy/XmlaCachedProxyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public void testCacheConfig() throws Exception
Map<String, String> cacheProperties = new HashMap<String, String>();

driverParameters.put(
XmlaOlap4jDriver.Property.Server.name(),
XmlaOlap4jDriver.Property.SERVER.name(),
"http://example.com");
driverParameters.put(
XmlaOlap4jDriver.Property.Catalog.name(),
XmlaOlap4jDriver.Property.CATALOG.name(),
"CatalogName");
driverParameters.put(
XmlaOlap4jDriver.Property.Cache.name(),
XmlaOlap4jDriver.Property.CACHE.name(),
"org.olap4j.driver.xmla.cache.XmlaOlap4jNamedMemoryCache");
cacheProperties.put(
XmlaOlap4jNamedMemoryCache.Property.NAME.name(),
Expand Down Expand Up @@ -73,13 +73,13 @@ public void testCacheModeError() throws Exception {
Map<String, String> cacheProperties = new HashMap<String, String>();

driverParameters.put(
XmlaOlap4jDriver.Property.Server.name(),
XmlaOlap4jDriver.Property.SERVER.name(),
"http://example.com");
driverParameters.put(
XmlaOlap4jDriver.Property.Catalog.name(),
XmlaOlap4jDriver.Property.CATALOG.name(),
"CatalogName");
driverParameters.put(
XmlaOlap4jDriver.Property.Cache.name(),
XmlaOlap4jDriver.Property.CACHE.name(),
"org.olap4j.driver.xmla.cache.XmlaOlap4jNamedMemoryCache");
cacheProperties.put(
XmlaOlap4jNamedMemoryCache.Property.NAME.name(),
Expand Down Expand Up @@ -116,13 +116,13 @@ public void testCacheTimeoutError() throws Exception
Map<String, String> cacheProperties = new HashMap<String, String>();

driverParameters.put(
XmlaOlap4jDriver.Property.Server.name(),
XmlaOlap4jDriver.Property.SERVER.name(),
"http://example.com");
driverParameters.put(
XmlaOlap4jDriver.Property.Catalog.name(),
XmlaOlap4jDriver.Property.CATALOG.name(),
"CatalogName");
driverParameters.put(
XmlaOlap4jDriver.Property.Cache.name(),
XmlaOlap4jDriver.Property.CACHE.name(),
"org.olap4j.driver.xmla.cache.XmlaOlap4jNamedMemoryCache");
cacheProperties.put(
XmlaOlap4jNamedMemoryCache.Property.NAME.name(),
Expand Down Expand Up @@ -166,13 +166,13 @@ public void testCacheSizeError() throws Exception
Map<String, String> cacheProperties = new HashMap<String, String>();

driverParameters.put(
XmlaOlap4jDriver.Property.Server.name(),
XmlaOlap4jDriver.Property.SERVER.name(),
"http://example.com");
driverParameters.put(
XmlaOlap4jDriver.Property.Catalog.name(),
XmlaOlap4jDriver.Property.CATALOG.name(),
"CatalogName");
driverParameters.put(
XmlaOlap4jDriver.Property.Cache.name(),
XmlaOlap4jDriver.Property.CACHE.name(),
"org.olap4j.driver.xmla.cache.XmlaOlap4jNamedMemoryCache");
cacheProperties.put(
XmlaOlap4jNamedMemoryCache.Property.NAME.name(),
Expand Down Expand Up @@ -215,13 +215,13 @@ public void testCacheNameError() throws Exception
Map<String, String> cacheProperties = new HashMap<String, String>();

driverParameters.put(
XmlaOlap4jDriver.Property.Server.name(),
XmlaOlap4jDriver.Property.SERVER.name(),
"http://example.com");
driverParameters.put(
XmlaOlap4jDriver.Property.Catalog.name(),
XmlaOlap4jDriver.Property.CATALOG.name(),
"CatalogName");
driverParameters.put(
XmlaOlap4jDriver.Property.Cache.name(),
XmlaOlap4jDriver.Property.CACHE.name(),
"Class which doesn't exist");
cacheProperties.put(
XmlaOlap4jNamedMemoryCache.Property.NAME.name(),
Expand Down Expand Up @@ -262,13 +262,13 @@ public void testCacheSharing() throws Exception
Map<String, String> cacheProperties = new HashMap<String, String>();

driverParameters.put(
XmlaOlap4jDriver.Property.Server.name(),
XmlaOlap4jDriver.Property.SERVER.name(),
"http://example.com");
driverParameters.put(
XmlaOlap4jDriver.Property.Catalog.name(),
XmlaOlap4jDriver.Property.CATALOG.name(),
"CatalogName");
driverParameters.put(
XmlaOlap4jDriver.Property.Cache.name(),
XmlaOlap4jDriver.Property.CACHE.name(),
"org.olap4j.driver.xmla.cache.XmlaOlap4jNamedMemoryCache");
cacheProperties.put(
XmlaOlap4jNamedMemoryCache.Property.NAME.name(),
Expand All @@ -290,13 +290,13 @@ public void testCacheSharing() throws Exception
}

driverParameters.put(
XmlaOlap4jDriver.Property.Server.name(),
XmlaOlap4jDriver.Property.SERVER.name(),
"http://example2.com");
driverParameters.put(
XmlaOlap4jDriver.Property.Catalog.name(),
XmlaOlap4jDriver.Property.CATALOG.name(),
"CatalogName2");
driverParameters.put(
XmlaOlap4jDriver.Property.Cache.name(),
XmlaOlap4jDriver.Property.CACHE.name(),
"org.olap4j.driver.xmla.cache.XmlaOlap4jNamedMemoryCache");
cacheProperties.put(
XmlaOlap4jNamedMemoryCache.Property.NAME.name(),
Expand Down

0 comments on commit a640c01

Please sign in to comment.