Skip to content

Commit

Permalink
Fixed typo and added test case.
Browse files Browse the repository at this point in the history
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@257 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
lucboudreau committed Jul 2, 2009
1 parent 7ef5ea4 commit 54196f0
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/org/olap4j/driver/xmla/XmlaOlap4jDimension.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Hierarchy getDefaultHierarchy() {
return hierarchies.get(0);
}

public boolean equeals(Object obj) {
public boolean equals(Object obj) {
return (obj instanceof XmlaOlap4jDimension) &&
this.uniqueName.equals(
((XmlaOlap4jDimension)obj).getUniqueName());
Expand Down
2 changes: 1 addition & 1 deletion src/org/olap4j/driver/xmla/XmlaOlap4jElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public int hashCode() {

// Keep this declaration abstract as a reminder to
// overriding classes.
abstract public boolean equeals(Object obj);
abstract public boolean equals(Object obj);
}

// End XmlaOlap4jElement.java
2 changes: 1 addition & 1 deletion src/org/olap4j/driver/xmla/XmlaOlap4jHierarchy.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public NamedList<Member> getRootMembers() throws OlapException {
return Olap4jUtil.cast(list);
}

public boolean equeals(Object obj) {
public boolean equals(Object obj) {
return (obj instanceof XmlaOlap4jHierarchy) &&
this.uniqueName.equals(
((XmlaOlap4jHierarchy)obj).getUniqueName());
Expand Down
2 changes: 1 addition & 1 deletion src/org/olap4j/driver/xmla/XmlaOlap4jLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public int getCardinality() {
return cardinality;
}

public boolean equeals(Object obj) {
public boolean equals(Object obj) {
return (obj instanceof XmlaOlap4jLevel) &&
this.uniqueName.equals(
((XmlaOlap4jLevel)obj).getUniqueName());
Expand Down
2 changes: 1 addition & 1 deletion src/org/olap4j/driver/xmla/XmlaOlap4jProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public ContentType getContentType() {
return contentType;
}

public boolean equeals(Object obj) {
public boolean equals(Object obj) {
return (obj instanceof XmlaOlap4jProperty) &&
this.uniqueName.equals(
((XmlaOlap4jProperty)obj).getUniqueName());
Expand Down
77 changes: 77 additions & 0 deletions testsrc/org/olap4j/OlapTreeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
// $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.
// Copyright (C) 2007-2009 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package org.olap4j;

import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;

import org.olap4j.metadata.Cube;
import org.olap4j.metadata.Dimension;
import org.olap4j.metadata.Hierarchy;
import org.olap4j.metadata.Schema;
import org.olap4j.test.TestContext;

import junit.framework.TestCase;

/**
* Tests some particularities of the OLAP tree objects.
* @author Luc Boudreau
*/
public class OlapTreeTest extends TestCase {

private final TestContext.Tester tester =
TestContext.instance().getTester();

/**
* Simple strategy to prevent connection leaks: each test that needs a
* connection assigns it to this field, and {@link #tearDown()} closes it
* if it is not already closed.
*/
private Connection connection;

protected void tearDown() throws Exception {
// Simple strategy to prevent connection leaks
if (connection != null
&& !connection.isClosed())
{
connection.close();
connection = null;
}
}

/**
* Tests if olap objects can be included in collections and
* retrieved properly.
*/
public void testHashCompatibility() throws Exception {
connection = tester.createConnection();
OlapConnection olapConnection =
tester.getWrapper().unwrap(connection, OlapConnection.class);
Schema schema = olapConnection.getSchema();
Cube cube = schema.getCubes().get("Sales");

Map<Dimension,String> dimensionMap =
new HashMap<Dimension,String>();
Dimension dim1 = cube.getDimensions().get("Promotion Media");
dimensionMap.put(dim1, "Test1");
assertTrue(dimensionMap.containsKey(dim1));
assertEquals("Test1", dimensionMap.get(dim1));

Map<Hierarchy,String> hierarchyMap =
new HashMap<Hierarchy, String>();
Hierarchy hchy1 = dim1.getDefaultHierarchy();
hierarchyMap.put(hchy1, "Test2");
assertTrue(hierarchyMap.containsKey(hchy1));
assertEquals("Test2", hierarchyMap.get(hchy1));
assertTrue(dimensionMap.containsKey(hchy1.getDimension()));
}
}
// End OlapTreeTest.java

0 comments on commit 54196f0

Please sign in to comment.