View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.jxpath.ri.model;
18  
19  import org.apache.commons.jxpath.JXPathContext;
20  import org.apache.commons.jxpath.JXPathTestCase;
21  import org.apache.commons.jxpath.xml.DocumentContainer;
22  
23  /**
24   * Test for uppercase element matching, etc. showing JXPATH-136 is not reproducible.
25   * 
26   * @author Matt Benson
27   * @version $Revision: 918701 $ $Date: 2010-03-03 22:25:01 +0100 (Mi, 03 Mär 2010) $
28   */
29  public class XMLUpperCaseElementsTest extends JXPathTestCase {
30      protected JXPathContext context;
31  
32      protected DocumentContainer createDocumentContainer(String model) {
33          return new DocumentContainer(JXPathTestCase.class.getResource("VendorUpper.xml"), model);
34      }
35  
36      protected JXPathContext createContext(String model) {
37          JXPathContext context = JXPathContext.newContext(createDocumentContainer(model));
38          return context;
39      }
40  
41      protected void doTest(String id, String model, String expectedValue) {
42          JXPathContext context = JXPathContext.newContext(createDocumentContainer(model));
43          assertEquals(context.getValue("test/text[@id='" + id + "']"), expectedValue);
44      }
45  
46      public void testBasicGetDOM() {
47          assertXPathValue(createContext(DocumentContainer.MODEL_DOM), "/Vendor[1]/Contact[1]",
48                  "John");
49      }
50  
51      public void testBasicGetJDOM() {
52          assertXPathValue(createContext(DocumentContainer.MODEL_JDOM), "/Vendor[1]/Contact[1]",
53                  "John");
54      }
55  
56      public void testBasicIterateDOM() {
57          assertXPathValueIterator(createContext(DocumentContainer.MODEL_DOM), "/Vendor/Contact",
58                  list("John", "Jack", "Jim", "Jack Black"));
59      }
60  
61      public void testBasicIterateJDOM() {
62          assertXPathValueIterator(createContext(DocumentContainer.MODEL_JDOM), "/Vendor/Contact",
63                  list("John", "Jack", "Jim", "Jack Black"));
64      }
65  }