Author: mbenson
Date: Mon May 21 11:37:59 2007
New Revision: 540225
URL: http://svn.apache.org/viewvc?view=rev&rev=540225
Log:
more xml:space tests
Added:
jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/XmlPreserveSpace.xml
(with props)
jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLPreserveSpaceTest.java
(with props)
Added:
jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/XmlPreserveSpace.xml
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/XmlPreserveSpace.xml?view=auto&rev=540225
==============================================================================
---
jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/XmlPreserveSpace.xml
(added)
+++
jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/XmlPreserveSpace.xml
Mon May 21 11:37:59 2007
@@ -0,0 +1,47 @@
+<?xml version="1.0" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!DOCTYPE test [
+ <!ELEMENT test (text)>
+ <!ELEMENT text ANY>
+ <!ATTLIST text xml:space (default|preserve) 'preserve'>
+]>
+
+<test>
+ <text id="unspecified"> foo </text>
+ <text id="default" xml:space="default"> foo </text>
+ <text id="preserve" xml:space="preserve"> foo </text>
+ <text id="nested" xml:space="default">
+ <text> foo </text>
+ <text>;</text>
+ <text xml:space="default"> bar </text>
+ <text>;</text>
+ <text xml:space="preserve"> baz </text>
+ </text>
+ <text id="nested-with-comments" xml:space="default">
+ <text> foo </text>
+ <!-- comment 1 -->
+ <text>;</text>
+ <!-- comment 2 -->
+ <text xml:space="default"> bar </text>
+ <!-- comment 3 -->
+ <text>;</text>
+ <!-- comment 4 -->
+ <text xml:space="preserve"> baz </text>
+ </text>
+</test>
\ No newline at end of file
Propchange:
jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/XmlPreserveSpace.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLPreserveSpaceTest.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLPreserveSpaceTest.java?view=auto&rev=540225
==============================================================================
---
jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLPreserveSpaceTest.java
(added)
+++
jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLPreserveSpaceTest.java
Mon May 21 11:37:59 2007
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.jxpath.ri.model;
+
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.jxpath.JXPathTestCase;
+import org.apache.commons.jxpath.xml.DocumentContainer;
+
+/**
+ * Test for text trimming from JXPATH-83.
+ *
+ * @author Matt Benson
+ * @version $Revision:$ $Date:$
+ */
+public class XMLPreserveSpaceTest extends JXPathTestCase {
+ protected JXPathContext context;
+
+ /**
+ * Construct a new instance of this test case.
+ *
+ * @param name Name of the test case
+ */
+ public XMLPreserveSpaceTest(String name) {
+ super(name);
+ }
+
+ protected DocumentContainer createDocumentContainer(String model) {
+ return new DocumentContainer(JXPathTestCase.class
+ .getResource("XmlPreserveSpace.xml"), model);
+ }
+
+ protected JXPathContext createContext(String model) {
+ JXPathContext context = JXPathContext
+ .newContext(createDocumentContainer(model));
+ return context;
+ }
+
+ protected void doTest(String id, String model, String expectedValue) {
+ JXPathContext context = JXPathContext
+ .newContext(createDocumentContainer(model));
+ assertEquals(context.getValue("test/[EMAIL PROTECTED]'" + id + "']"),
expectedValue);
+ }
+
+ public void testUnspecifiedDOM() {
+ doTest("unspecified", DocumentContainer.MODEL_DOM, " foo ");
+ }
+
+ public void testDefaultDOM() {
+ doTest("default", DocumentContainer.MODEL_DOM, "foo");
+ }
+
+ public void testPreserveDOM() {
+ doTest("preserve", DocumentContainer.MODEL_DOM, " foo ");
+ }
+
+ public void testNestedDOM() {
+ doTest("nested", DocumentContainer.MODEL_DOM, " foo ;bar; baz ");
+ }
+
+ public void testNestedWithCommentsDOM() {
+ doTest("nested-with-comments", DocumentContainer.MODEL_DOM, " foo
;bar; baz ");
+ }
+
+ public void testUnspecifiedJDOM() {
+ doTest("unspecified", DocumentContainer.MODEL_JDOM, " foo ");
+ }
+
+ public void testDefaultJDOM() {
+ doTest("default", DocumentContainer.MODEL_JDOM, "foo");
+ }
+
+ public void testPreserveJDOM() {
+ doTest("preserve", DocumentContainer.MODEL_JDOM, " foo ");
+ }
+
+ public void testNestedJDOM() {
+ doTest("nested", DocumentContainer.MODEL_JDOM, " foo ;bar; baz ");
+ }
+
+ public void testNestedWithCommentsJDOM() {
+ doTest("nested-with-comments", DocumentContainer.MODEL_JDOM, " foo
;bar; baz ");
+ }
+}
\ No newline at end of file
Propchange:
jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLPreserveSpaceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLPreserveSpaceTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]