Skip to content

Commit 5e95a37

Browse files
committed
[ignore] Small code cleanup to make tests more readable
1 parent 1b8e922 commit 5e95a37

3 files changed

Lines changed: 77 additions & 45 deletions

File tree

exist-core/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,7 @@
12721272
<include>src/main/java/org/exist/xquery/functions/fn/FunInsertBefore.java</include>
12731273
<include>src/main/java/org/exist/xquery/functions/fn/FunIRIToURI.java</include>
12741274
<include>src/main/java/org/exist/xquery/functions/fn/FunLang.java</include>
1275+
<include>src/test/java/org/exist/xquery/functions/fn/FunLangTest.java</include>
12751276
<include>src/main/java/org/exist/xquery/functions/fn/FunLast.java</include>
12761277
<include>src/main/java/org/exist/xquery/functions/fn/FunLocalName.java</include>
12771278
<include>src/main/java/org/exist/xquery/functions/fn/FunMax.java</include>
@@ -2061,6 +2062,7 @@
20612062
<exclude>src/main/java/org/exist/xquery/functions/fn/FunInsertBefore.java</exclude>
20622063
<exclude>src/main/java/org/exist/xquery/functions/fn/FunIRIToURI.java</exclude>
20632064
<exclude>src/main/java/org/exist/xquery/functions/fn/FunLang.java</exclude>
2065+
<exclude>src/test/java/org/exist/xquery/functions/fn/FunLangTest.java</exclude>
20642066
<exclude>src/main/java/org/exist/xquery/functions/fn/FunLast.java</exclude>
20652067
<exclude>src/main/java/org/exist/xquery/functions/fn/FunLocalName.java</exclude>
20662068
<exclude>src/main/java/org/exist/xquery/functions/fn/FunMax.java</exclude>

exist-core/src/test/java/org/exist/xquery/XPathQueryTest.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,11 +1100,17 @@ public void predicates2() throws XMLDBException, IOException, SAXException {
11001100
service.setProperty(OutputKeys.INDENT, "no");
11011101

11021102

1103-
String query = "let $t := <test>" + "<a> <s>A</s> 1 </a>"
1104-
+ "<a> <s>Z</s> 2 </a>" + "<a> <s>B</s> 3 </a>"
1105-
+ "<a> <s>Z</s> 4 </a>" + "<a> <s>C</s> 5 </a>"
1106-
+ "<a> <s>Z</s> 6 </a>" + "</test>"
1107-
+ "return $t//a[s='Z' and preceding-sibling::*[1]/s='B']";
1103+
String query = "let $t := " +
1104+
"<test>" +
1105+
"<a> <s>A</s> 1 </a>" +
1106+
"<a> <s>Z</s> 2 </a>" +
1107+
"<a> <s>B</s> 3 </a>" +
1108+
"<a> <s>Z</s> 4 </a>" +
1109+
"<a> <s>C</s> 5 </a>" +
1110+
"<a> <s>Z</s> 6 </a>" +
1111+
"</test>" +
1112+
"return " +
1113+
"$t//a[s = 'Z' and preceding-sibling::*[1]/s = 'B']";
11081114
ResourceSet result = queryResource(service, "numbers.xml", query, 1);
11091115
assertThat(result.getResource(0).getContent().toString(), CompareMatcher.isIdenticalTo("<a><s>Z</s> 4 </a>"));
11101116

exist-core/src/test/java/org/exist/xquery/functions/fn/FunLangTest.java

Lines changed: 64 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
2+
* Elemental
3+
* Copyright (C) 2024, Evolved Binary Ltd
4+
*
5+
* admin@evolvedbinary.com
6+
* https://www.evolvedbinary.com | https://www.elemental.xyz
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU Lesser General Public
10+
* License as published by the Free Software Foundation; version 2.1.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
* The original license header is included below.
23+
*
24+
* =====================================================================
25+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -43,57 +67,57 @@ public class FunLangTest {
4367

4468
@Test
4569
public void testFnLangWithContext() throws XMLDBException {
46-
final ResourceSet resourceSet = existEmbeddedServer.executeQuery(
47-
"let $doc-frag := " +
48-
"<desclist xml:lang=\"en\">" +
49-
"<desc xml:lang=\"en-US\" n=\"1\">" +
50-
"<line>The first line of the description.</line>" +
51-
"</desc>" +
52-
"<desc xml:lang=\"fr\" n=\"2\">"+
53-
"<line>La premi&#232;re ligne de la déscription.</line>" +
54-
"</desc>" +
55-
"</desclist>" +
56-
"return $doc-frag//desc[lang(\"en-US\")]"
57-
);
58-
70+
final String query =
71+
"let $doc-frag := " +
72+
"<desclist xml:lang=\"en\">" +
73+
"<desc xml:lang=\"en-US\" n=\"1\">" +
74+
"<line>The first line of the description.</line>" +
75+
"</desc>" +
76+
"<desc xml:lang=\"fr\" n=\"2\">"+
77+
"<line>La premi&#232;re ligne de la déscription.</line>" +
78+
"</desc>" +
79+
"</desclist>" +
80+
"return " +
81+
"$doc-frag//desc[lang(\"en-US\")]";
82+
final ResourceSet resourceSet = existEmbeddedServer.executeQuery(query);
5983
assertEquals(1, resourceSet.getSize());
6084
assertEquals("<desc xml:lang=\"en-US\" n=\"1\">\n <line>The first line of the description.</line>\n</desc>", resourceSet.getResource(0).getContent());
6185
}
6286

63-
@Test
87+
@Test
6488
public void testFnLangWithArgument() throws XMLDBException {
65-
final ResourceSet resourceSet = existEmbeddedServer.executeQuery(
66-
"let $doc-frag := " +
67-
"<desclist xml:lang=\"en\">" +
68-
"<desc xml:lang=\"en-US\" n=\"1\">" +
69-
"<line>The first line of the description.</line>" +
70-
"</desc>" +
71-
"<desc xml:lang=\"fr\" n=\"2\">"+
72-
"<line>La premi&#232;re ligne de la déscription.</line>" +
73-
"</desc>" +
74-
"</desclist>" +
75-
"return lang(\"en-US\", $doc-frag//desc[@n eq \"2\"])"
76-
);
77-
89+
final String query =
90+
"let $doc-frag := " +
91+
"<desclist xml:lang=\"en\">" +
92+
"<desc xml:lang=\"en-US\" n=\"1\">" +
93+
"<line>The first line of the description.</line>" +
94+
"</desc>" +
95+
"<desc xml:lang=\"fr\" n=\"2\">"+
96+
"<line>La premi&#232;re ligne de la déscription.</line>" +
97+
"</desc>" +
98+
"</desclist>" +
99+
"return " +
100+
"lang(\"en-US\", $doc-frag//desc[@n eq \"2\"])";
101+
final ResourceSet resourceSet = existEmbeddedServer.executeQuery(query);
78102
assertEquals(1, resourceSet.getSize());
79103
assertEquals("false", resourceSet.getResource(0).getContent());
80104
}
81105

82106
@Test
83107
public void testFnLangWithAttributeArgument() throws XMLDBException {
84-
final ResourceSet resourceSet = existEmbeddedServer.executeQuery(
85-
"let $doc-frag := " +
86-
"<desclist xml:lang=\"en\">" +
87-
"<desc xml:lang=\"en-US\" n=\"1\">" +
88-
"<line>The first line of the description.</line>" +
89-
"</desc>" +
90-
"<desc xml:lang=\"fr\" n=\"2\">"+
91-
"<line>La premi&#232;re ligne de la déscription.</line>" +
92-
"</desc>" +
93-
"</desclist>" +
94-
"return lang(\"en-US\", $doc-frag//desc/@n[. eq \"1\"])"
95-
);
96-
108+
final String query =
109+
"let $doc-frag := " +
110+
"<desclist xml:lang=\"en\">" +
111+
"<desc xml:lang=\"en-US\" n=\"1\">" +
112+
"<line>The first line of the description.</line>" +
113+
"</desc>" +
114+
"<desc xml:lang=\"fr\" n=\"2\">"+
115+
"<line>La premi&#232;re ligne de la déscription.</line>" +
116+
"</desc>" +
117+
"</desclist>" +
118+
"return " +
119+
"lang(\"en-US\", $doc-frag//desc/@n[. eq \"1\"])";
120+
final ResourceSet resourceSet = existEmbeddedServer.executeQuery(query);
97121
assertEquals(1, resourceSet.getSize());
98122
assertEquals("true", resourceSet.getResource(0).getContent());
99123
}

0 commit comments

Comments
 (0)