Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 141461 Details for
Bug 283214
[xpath2] Conditional Expressions cause XpathParserException
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Updated test cases with more success than failure
patch-283214-tests.txt (text/plain), 10.38 KB, created by
Jesper Moller
on 2009-07-13 19:13:02 EDT
(
hide
)
Description:
Updated test cases with more success than failure
Filename:
MIME Type:
Creator:
Jesper Moller
Created:
2009-07-13 19:13:02 EDT
Size:
10.38 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.xml.xpath2.processor.tests >Index: src/org/eclipse/wst/xml/xpath2/processor/testsuite/core/CondExprTest.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/tests/org.eclipse.wst.xml.xpath2.processor.tests/src/org/eclipse/wst/xml/xpath2/processor/testsuite/core/CondExprTest.java,v >retrieving revision 1.2 >diff -u -r1.2 CondExprTest.java >--- src/org/eclipse/wst/xml/xpath2/processor/testsuite/core/CondExprTest.java 6 Jun 2009 00:43:33 -0000 1.2 >+++ src/org/eclipse/wst/xml/xpath2/processor/testsuite/core/CondExprTest.java 13 Jul 2009 23:12:36 -0000 >@@ -26,7 +26,7 @@ > String inputFile = "/TestSources/emptydoc.xml"; > String xqFile = "/Queries/XQuery/Expressions/CondExpr/CondExpr006.xq"; > String resultFile = "/ExpectedTestResults/Expressions/CondExpr/CondExpr006.xml"; >- String expectedResult = getExpectedResult(resultFile); >+ String expectedResult = getExpectedResult(resultFile, "out"); > URL fileURL = bundle.getEntry(inputFile); > loadDOMDocument(fileURL); > >@@ -35,7 +35,7 @@ > > DynamicContext dc = setupDynamicContext(schema); > >- String xpath = "if (1 != 0) then if (4 != 5) then 1 else 2 else 3"; >+ String xpath = extractXPathExpression(xqFile, inputFile, "out"); > String actual = null; > try { > XPath path = compileXPath(dc, xpath); >@@ -43,8 +43,8 @@ > Evaluator eval = new DefaultEvaluator(dc, domDoc); > ResultSequence rs = eval.evaluate(path); > >- actual = "<out>" + buildResultString(rs) + "</out>"; >- >+ actual = buildResultString(rs); >+ > } catch (XPathParserException ex) { > actual = ex.code(); > } catch (StaticError ex) { >@@ -63,7 +63,7 @@ > String inputFile = "/TestSources/emptydoc.xml"; > String xqFile = "/Queries/XQuery/Expressions/CondExpr/CondExpr010.xq"; > String resultFile = "/ExpectedTestResults/Expressions/CondExpr/CondExpr010.xml"; >- String expectedResult = getExpectedResult(resultFile); >+ String expectedResult = getExpectedResult(resultFile, "out"); > URL fileURL = bundle.getEntry(inputFile); > loadDOMDocument(fileURL); > >@@ -72,7 +72,7 @@ > > DynamicContext dc = setupDynamicContext(schema); > >- String xpath = "if (2 != 4) then 1 else 0"; >+ String xpath = extractXPathExpression(xqFile, inputFile, "out"); > String actual = null; > try { > XPath path = compileXPath(dc, xpath); >@@ -80,8 +80,8 @@ > Evaluator eval = new DefaultEvaluator(dc, domDoc); > ResultSequence rs = eval.evaluate(path); > >- actual = "<out>" + buildResultString(rs) + "</out>"; >- >+ actual = buildResultString(rs); >+ > } catch (XPathParserException ex) { > actual = ex.code(); > } catch (StaticError ex) { >@@ -100,7 +100,7 @@ > String inputFile = "/TestSources/emptydoc.xml"; > String xqFile = "/Queries/XQuery/Expressions/CondExpr/CondExpr011.xq"; > String resultFile = "/ExpectedTestResults/Expressions/CondExpr/CondExpr011.xml"; >- String expectedResult = getExpectedResult(resultFile); >+ String expectedResult = getExpectedResult(resultFile, "out"); > URL fileURL = bundle.getEntry(inputFile); > loadDOMDocument(fileURL); > >@@ -109,7 +109,7 @@ > > DynamicContext dc = setupDynamicContext(schema); > >- String xpath = "fn:string-length(if (2 != 3) then 'foo' else 'expanded-foo')"; >+ String xpath = extractXPathExpression(xqFile, inputFile, "out"); > String actual = null; > try { > XPath path = compileXPath(dc, xpath); >@@ -117,8 +117,8 @@ > Evaluator eval = new DefaultEvaluator(dc, domDoc); > ResultSequence rs = eval.evaluate(path); > >- actual = "<out>" + buildResultString(rs) + "</out>"; >- >+ actual = buildResultString(rs); >+ > } catch (XPathParserException ex) { > actual = ex.code(); > } catch (StaticError ex) { >@@ -137,7 +137,7 @@ > String inputFile = "/TestSources/xq311A.xml"; > String xqFile = "/Queries/XQuery/Expressions/CondExpr/CondExpr012.xq"; > String resultFile = "/ExpectedTestResults/Expressions/CondExpr/CondExpr012.xml"; >- String expectedResult = getExpectedResult(resultFile); >+ String expectedResult = getExpectedResult(resultFile, "out"); > URL fileURL = bundle.getEntry(inputFile); > loadDOMDocument(fileURL); > >@@ -146,7 +146,7 @@ > > DynamicContext dc = setupDynamicContext(schema); > >- String xpath = extractXPathExpression(xqFile, inputFile); >+ String xpath = extractXPathExpression(xqFile, inputFile, "out"); > String actual = null; > try { > XPath path = compileXPath(dc, xpath); >@@ -174,7 +174,7 @@ > String inputFile = "/TestSources/xq311A.xml"; > String xqFile = "/Queries/XQuery/Expressions/CondExpr/CondExpr013.xq"; > String resultFile = "/ExpectedTestResults/Expressions/CondExpr/CondExpr013.xml"; >- String expectedResult = getExpectedResult(resultFile); >+ String expectedResult = getExpectedResult(resultFile, "out"); > URL fileURL = bundle.getEntry(inputFile); > loadDOMDocument(fileURL); > >@@ -183,7 +183,7 @@ > > DynamicContext dc = setupDynamicContext(schema); > >- String xpath = extractXPathExpression(xqFile, inputFile); >+ String xpath = extractXPathExpression(xqFile, inputFile, "out"); > String actual = null; > try { > XPath path = compileXPath(dc, xpath); >@@ -211,7 +211,7 @@ > String inputFile = "/TestSources/xq311A.xml"; > String xqFile = "/Queries/XQuery/Expressions/CondExpr/CondExpr014.xq"; > String resultFile = "/ExpectedTestResults/Expressions/CondExpr/CondExpr014.xml"; >- String expectedResult = getExpectedResult(resultFile); >+ String expectedResult = getExpectedResult(resultFile, "out"); > URL fileURL = bundle.getEntry(inputFile); > loadDOMDocument(fileURL); > >@@ -220,7 +220,7 @@ > > DynamicContext dc = setupDynamicContext(schema); > >- String xpath = extractXPathExpression(xqFile, inputFile); >+ String xpath = extractXPathExpression(xqFile, inputFile, "out"); > String actual = null; > try { > XPath path = compileXPath(dc, xpath); >@@ -248,7 +248,7 @@ > String inputFile = "/TestSources/emptydoc.xml"; > String xqFile = "/Queries/XQuery/Expressions/CondExpr/CondExpr015.xq"; > String resultFile = "/ExpectedTestResults/Expressions/CondExpr/CondExpr015.xml"; >- String expectedResult = getExpectedResult(resultFile); >+ String expectedResult = getExpectedResult(resultFile, "out"); > URL fileURL = bundle.getEntry(inputFile); > loadDOMDocument(fileURL); > >@@ -257,7 +257,7 @@ > > DynamicContext dc = setupDynamicContext(schema); > >- String xpath = extractXPathExpression(xqFile, inputFile); >+ String xpath = extractXPathExpression(xqFile, inputFile, "out"); > String actual = null; > try { > XPath path = compileXPath(dc, xpath); >@@ -322,7 +322,7 @@ > String inputFile = "/TestSources/fsx.xml"; > String xqFile = "/Queries/XQuery/Expressions/CondExpr/CondExpr017.xq"; > String resultFile = "/ExpectedTestResults/Expressions/CondExpr/CondExpr017.xml"; >- String expectedResult = getExpectedResult(resultFile); >+ String expectedResult = getExpectedResult(resultFile, "out"); > URL fileURL = bundle.getEntry(inputFile); > loadDOMDocument(fileURL); > >@@ -331,7 +331,8 @@ > > DynamicContext dc = setupDynamicContext(schema); > >- String xpath = extractXPathExpression(xqFile, inputFile); >+ String xpath = extractXPathExpression(xqFile, inputFile, "out"); >+ > String actual = null; > try { > XPath path = compileXPath(dc, xpath); >@@ -354,7 +355,7 @@ > > } > >- //If where branches return different valid types. >+//If where branches return different valid types. > public void test_CondExpr018() throws Exception { > String inputFile = "/TestSources/fsx.xml"; > String xqFile = "/Queries/XQuery/Expressions/CondExpr/CondExpr018.xq"; >Index: src/org/eclipse/wst/xml/xpath2/processor/test/AbstractPsychoPathTest.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/tests/org.eclipse.wst.xml.xpath2.processor.tests/src/org/eclipse/wst/xml/xpath2/processor/test/AbstractPsychoPathTest.java,v >retrieving revision 1.18 >diff -u -r1.18 AbstractPsychoPathTest.java >--- src/org/eclipse/wst/xml/xpath2/processor/test/AbstractPsychoPathTest.java 13 Jul 2009 13:51:54 -0000 1.18 >+++ src/org/eclipse/wst/xml/xpath2/processor/test/AbstractPsychoPathTest.java 13 Jul 2009 23:12:36 -0000 >@@ -217,6 +217,14 @@ > return content; > } > >+ public String unwrapResult(String expectedResult, String elemName) { >+ return trimSurrounding(expectedResult, "<"+ elemName + ">", "</" + elemName + ">"); >+ } >+ >+ protected String getExpectedResult(String resultFile, String elemName) { >+ return unwrapResult(getExpectedResult(resultFile), elemName); >+ } >+ > public String extractXPathExpression(String xqFile, String inputFile) { > // get the xpath2 expr from xq file, first > char[] cbuf = new char[2048];// >@@ -247,8 +255,7 @@ > // > assertTrue(content.lastIndexOf(S_COMMENT2) != -1);// assert to get > xpath2Expr = content.substring(content.lastIndexOf(S_COMMENT2) + 2) >- .trim(); >- >+ .trim(); > xqreader.close(); > isxq.close(); > } catch (IOException e) { >@@ -258,6 +265,31 @@ > return xpath2Expr; > } > >+ protected String extractXPathExpression(String xqFile, String inputFile, >+ String tagName) { >+ return unwrapQuery(extractXPathExpression(xqFile, inputFile), tagName); >+ } >+ >+ protected String unwrapQuery(String xpath2Expr, String tag) { >+ String str = "<" + tag + ">"; >+ String endStr = "</" + tag + ">"; >+ String withoutTag = trimSurrounding(xpath2Expr, str, endStr); >+ if (withoutTag != xpath2Expr) { >+ // also trim off the braces { } >+ xpath2Expr = trimSurrounding(withoutTag, "{", "}"); >+ } >+ return xpath2Expr; >+ } >+ >+ protected String trimSurrounding(String xpath2Expr, String str, String endStr) { >+ int indexOfStart = xpath2Expr.indexOf(str); >+ int indexOfEnd = xpath2Expr.indexOf(endStr); >+ if (indexOfStart >= 0 && indexOfEnd >= 0) { >+ xpath2Expr = xpath2Expr.substring(indexOfStart + str.length(), indexOfEnd).trim(); >+ } >+ return xpath2Expr; >+ } >+ > protected void setupNamespace(String content) { > Pattern p = Pattern.compile(REGEX_DN); > Matcher m = p.matcher(content);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
d_a_carver
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 283214
:
141460
| 141461 |
141462
|
141583