Skip to content

Commit

Permalink
[test] Add tests for XQuery Update namespace binding conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
adamretter committed Aug 3, 2022
1 parent 0c6f19a commit e906b1e
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
32 changes: 32 additions & 0 deletions exist-core/src/test/java/xquery/update/UpdateTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
* info@exist-db.org
* http://www.exist-db.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package xquery.update;

import org.exist.test.runner.XSuite;
import org.junit.runner.RunWith;

@RunWith(XSuite.class)
@XSuite.XSuiteFiles({
"src/test/xquery/update"
})
public class UpdateTests {
}
64 changes: 64 additions & 0 deletions exist-core/src/test/xquery/update/namespace-binding.xqm
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
(:
: eXist-db Open Source Native XML Database
: Copyright (C) 2001 The eXist-db Authors
:
: info@exist-db.org
: http://www.exist-db.org
:
: This library is free software; you can redistribute it and/or
: modify it under the terms of the GNU Lesser General Public
: License as published by the Free Software Foundation; either
: version 2.1 of the License, or (at your option) any later version.
:
: This library is distributed in the hope that it will be useful,
: but WITHOUT ANY WARRANTY; without even the implied warranty of
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
: Lesser General Public License for more details.
:
: You should have received a copy of the GNU Lesser General Public
: License along with this library; if not, write to the Free Software
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
:)
xquery version "3.1";

module namespace unbt = "http://exist-db.org/xquery/update/namespace-binding-test";

import module namespace xmldb = "http://exist-db.org/xquery/xmldb";

declare namespace test = "http://exist-db.org/xquery/xqsuite";
declare namespace myns = "http://www.foo.com";

declare %private variable $unbt:test := document {
<x xmlns:myns="http://www.bar.com">
<z/>
</x>
};

declare
%test:setup
function unbt:setup() {
let $xml := fn:parse-xml('<x xmlns:myns="http://www.bar.com"><z/></x>')
return
xmldb:store("/db", "namespace-binding-test-1.xml", $xml)
,
xmldb:store("/db", "namespace-binding-test-2.xml", $unbt:test)
};

declare
%test:teardown
function unbt:teardown() {
xmldb:remove("/db/namespace-binding-test-1.xml"),
xmldb:remove("/db/namespace-binding-test-2.xml"),
};

declare
%test:assertError("XUDY0023")
function unbt:insert-namespaced-attribute-1() {
update insert attribute myns:baz { "qux" } into doc("/db/namespace-binding-test-1.xml")/x/z
};

declare
%test:assertError("XUDY0023")
function unbt:insert-namespaced-attribute-2() {
update insert attribute myns:baz { "qux" } into doc("/db/namespace-binding-test-2.xml")/x/z
};

0 comments on commit e906b1e

Please sign in to comment.