|
1 | 1 | /* |
| 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 | + * |
2 | 26 | * eXist-db Open Source Native XML Database |
3 | 27 | * Copyright (C) 2001 The eXist-db Authors |
4 | 28 | * |
@@ -43,57 +67,57 @@ public class FunLangTest { |
43 | 67 |
|
44 | 68 | @Test |
45 | 69 | 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è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è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); |
59 | 83 | assertEquals(1, resourceSet.getSize()); |
60 | 84 | assertEquals("<desc xml:lang=\"en-US\" n=\"1\">\n <line>The first line of the description.</line>\n</desc>", resourceSet.getResource(0).getContent()); |
61 | 85 | } |
62 | 86 |
|
63 | | - @Test |
| 87 | + @Test |
64 | 88 | 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è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è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); |
78 | 102 | assertEquals(1, resourceSet.getSize()); |
79 | 103 | assertEquals("false", resourceSet.getResource(0).getContent()); |
80 | 104 | } |
81 | 105 |
|
82 | 106 | @Test |
83 | 107 | 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è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è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); |
97 | 121 | assertEquals(1, resourceSet.getSize()); |
98 | 122 | assertEquals("true", resourceSet.getResource(0).getContent()); |
99 | 123 | } |
|
0 commit comments