Skip to content

Commit

Permalink
Code formatting issues
Browse files Browse the repository at this point in the history
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@132 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
lucboudreau committed Nov 3, 2008
1 parent 1f5271c commit 485ff4b
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 76 deletions.
2 changes: 1 addition & 1 deletion src/org/olap4j/driver/xmla/XmlaOlap4jCellSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void populate() throws OlapException {
*/
// TODO: log doc to logfile
throw OlapExceptionHelper.createException(
"XMLA provider gave exception: " +
"XMLA provider gave exception: " +
XmlaOlap4jUtil.prettyPrint(fault));
}
Element executeResponse =
Expand Down
2 changes: 1 addition & 1 deletion src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ Element xxx(String request) throws OlapException {
*/
// TODO: log doc to logfile
throw OlapExceptionHelper.createException(
"XMLA provider gave exception: " +
"XMLA provider gave exception: " +
XmlaOlap4jUtil.prettyPrint(fault)
+ "\n Request was: \n" + request);
}
Expand Down
121 changes: 58 additions & 63 deletions src/org/olap4j/driver/xmla/XmlaOlap4jUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private static void prettyPrintLoop(
}

private static void prettyPrintLoop(
Node node,
Node node,
StringBuilder string,
String indentation)
{
Expand All @@ -183,74 +183,69 @@ private static void prettyPrintLoop(
int type = node.getNodeType();

switch (type) {
case Node.DOCUMENT_NODE: {
string.append("\n");
prettyPrintLoop(node.getChildNodes(), string, indentation+"\t");
break;
}

case Node.ELEMENT_NODE: {
string.append(indentation);
string.append("<");
string.append(node.getNodeName());

int length = (node.getAttributes() != null) ?
node.getAttributes().getLength() : 0;
Attr attributes[] = new Attr[length];
for (int loopIndex = 0; loopIndex < length; loopIndex++) {
attributes[loopIndex] =
(Attr)node.getAttributes().item(loopIndex);
}

for (int loopIndex = 0; loopIndex < attributes.length;
loopIndex++)
{
Attr attribute = attributes[loopIndex];
string.append(" ");
string.append(attribute.getNodeName());
string.append("=\"");
string.append(attribute.getNodeValue());
string.append("\"");
}

string.append(">\n");

prettyPrintLoop(node.getChildNodes(), string, indentation+"\t");

string.append(indentation);
string.append("</");
string.append(node.getNodeName());
string.append(">\n");

break;
case Node.DOCUMENT_NODE:
string.append("\n");
prettyPrintLoop(node.getChildNodes(), string, indentation + "\t");
break;

case Node.ELEMENT_NODE:
string.append(indentation);
string.append("<");
string.append(node.getNodeName());

int length = (node.getAttributes() != null) ?
node.getAttributes().getLength() : 0;
Attr attributes[] = new Attr[length];
for (int loopIndex = 0; loopIndex < length; loopIndex++) {
attributes[loopIndex] =
(Attr)node.getAttributes().item(loopIndex);
}

case Node.TEXT_NODE: {
string.append(indentation);
string.append(node.getNodeValue().trim()+"\n");
//prettyPrintLoop(node, string, indentation+"\t");
break;
for (int loopIndex = 0; loopIndex < attributes.length;
loopIndex++)
{
Attr attribute = attributes[loopIndex];
string.append(" ");
string.append(attribute.getNodeName());
string.append("=\"");
string.append(attribute.getNodeValue());
string.append("\"");
}

case Node.PROCESSING_INSTRUCTION_NODE: {
string.append(indentation);
string.append("<?");
string.append(node.getNodeName());
String text = node.getNodeValue();
if (text != null && text.length() > 0) {
string.append(text);
}
string.append("?>\n");
break;
}
string.append(">\n");

case Node.CDATA_SECTION_NODE: {
string.append(indentation);
string.append("<![CDATA[");
string.append(node.getNodeValue());
string.append("]]>");
break;
}
prettyPrintLoop(node.getChildNodes(), string, indentation + "\t");

string.append(indentation);
string.append("</");
string.append(node.getNodeName());
string.append(">\n");

break;

case Node.TEXT_NODE:
string.append(indentation);
string.append(node.getNodeValue().trim() + "\n");
break;

case Node.PROCESSING_INSTRUCTION_NODE:
string.append(indentation);
string.append("<?");
string.append(node.getNodeName());
String text = node.getNodeValue();
if (text != null && text.length() > 0) {
string.append(text);
}
string.append("?>\n");
break;

case Node.CDATA_SECTION_NODE:
string.append(indentation);
string.append("<![CDATA[");
string.append(node.getNodeValue());
string.append("]]>");
break;
}
}

Expand Down
30 changes: 19 additions & 11 deletions testsrc/org/olap4j/XmlaConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,34 @@ private void checkup(String request) {
public void testNoNonTrivalCallsOnConnect() throws Exception {
String cookie = XmlaOlap4jDriver.nextCookie();
try {

XmlaOlap4jDriver.PROXY_MAP.put(cookie, new XmlaOlap4jProxyMock());

try {
Class.forName(DRIVER_CLASS_NAME);
} catch (ClassNotFoundException e) {
throw new RuntimeException("oops", e);
}
Properties info = new Properties();
info.setProperty(
XmlaOlap4jDriver.Property.Catalog.name(), "FoodMart");
DriverManager.getConnection(
"jdbc:xmla:Server=http://foo;Catalog=FoodMart;TestProxyCookie=" + cookie,
Class.forName(DRIVER_CLASS_NAME);
} catch (ClassNotFoundException e) {
throw new RuntimeException("oops", e);
}
Properties info = new Properties();
info.setProperty(
XmlaOlap4jDriver.Property.Catalog.name(), "FoodMart");
DriverManager.getConnection(
"jdbc:xmla:Server=http://foo;Catalog=FoodMart;TestProxyCookie=" + cookie,
info);
} catch (Throwable t) {
t.printStackTrace();
fail("Non-Trival Call executed during construction of XmlaOlap4j Connection");
}
}

/**
* If the same request
* is sent twice, an exception gets triggered. The only
* exception to this is the MDSCHEMA_CUBES query that is used to
* populate both the catalogs and the schemas associated to a
* given catalog. This was due to a flaw in SSAS; it doesn't
* return a SCHEMA_NAME column when asked to. We fixed it this
* way in some other revision.
* @throws Exception If the test fails.
*/
public void testNoDoubleQuerySubmission() throws Exception {
String oldValue = XmlaTester.getProxyClassName();
XmlaTester.setProxyClassName(
Expand Down

0 comments on commit 485ff4b

Please sign in to comment.