1+ /****************************************************************************/
2+ /* File: SaxonSequenceTest.java */
3+ /* Author: A. Retter - adamretter.org.uk */
4+ /* Date: 2024-06-28 */
5+ /* Tags: */
6+ /* Copyright (c) 2024 Adam Retter (see end of file.) */
7+ /* ------------------------------------------------------------------------ */
8+
9+
10+ package org .expath .tools .saxon .model ;
11+
12+ import net .sf .saxon .trans .XPathException ;
13+ import org .expath .tools .ToolsException ;
14+ import org .junit .Test ;
15+
16+ import javax .xml .namespace .QName ;
17+ import javax .xml .transform .OutputKeys ;
18+ import java .util .Properties ;
19+
20+ import static javax .xml .XMLConstants .NULL_NS_URI ;
21+ import static org .junit .Assert .assertEquals ;
22+
23+ public class SaxonSequenceTest {
24+
25+ @ Test
26+ public void setOutputKeyNullNs () throws XPathException , ToolsException {
27+ final SaxonSequence saxonSequence = new SaxonSequence (null , null );
28+
29+ final Properties properties = new Properties ();
30+
31+ QName expected = new QName ("xml" );
32+ saxonSequence .setOutputKey (properties , OutputKeys .METHOD , expected );
33+ assertEquals (expected .getLocalPart (), properties .get (OutputKeys .METHOD ));
34+
35+ expected = new QName (NULL_NS_URI , "xml" );
36+ saxonSequence .setOutputKey (properties , OutputKeys .METHOD , expected );
37+ assertEquals (expected .getLocalPart (), properties .get (OutputKeys .METHOD ));
38+
39+ expected = new QName (null , "xml" );
40+ saxonSequence .setOutputKey (properties , OutputKeys .METHOD , expected );
41+ assertEquals (expected .getLocalPart (), properties .get (OutputKeys .METHOD ));
42+ }
43+
44+ @ Test (expected = ToolsException .class )
45+ public void setOutputKeyNonNullNs () throws XPathException , ToolsException {
46+ final SaxonSequence saxonSequence = new SaxonSequence (null , null );
47+
48+ final Properties properties = new Properties ();
49+
50+ final QName expected = new QName ("urn:test:ns" , "xml" );
51+ saxonSequence .setOutputKey (properties , OutputKeys .METHOD , expected );
52+ }
53+ }
54+
55+
56+ /* ------------------------------------------------------------------------ */
57+ /* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS COMMENT. */
58+ /* */
59+ /* The contents of this file are subject to the Mozilla Public License */
60+ /* Version 1.0 (the "License"); you may not use this file except in */
61+ /* compliance with the License. You may obtain a copy of the License at */
62+ /* http://www.mozilla.org/MPL/. */
63+ /* */
64+ /* Software distributed under the License is distributed on an "AS IS" */
65+ /* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */
66+ /* the License for the specific language governing rights and limitations */
67+ /* under the License. */
68+ /* */
69+ /* The Original Code is: all this file. */
70+ /* */
71+ /* The Initial Developer of the Original Code is Adam Retter. */
72+ /* */
73+ /* Contributor(s): none. */
74+ /* ------------------------------------------------------------------------ */
0 commit comments