cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1509024 - in /cxf/web: ./ src/main/java/org/apache/cxf/cwiki/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/cxf/ src/test/java/org/apache/cxf/cwiki/ src/test/resources/
Date Wed, 31 Jul 2013 20:51:45 GMT
Author: dkulp
Date: Wed Jul 31 20:51:45 2013
New Revision: 1509024

URL: http://svn.apache.org/r1509024
Log:
[CXF-5149] Check the map insensitively to allow {code:JAVA} in addition to {code:java}
Heavily modified patch from Lukasz Lenart applied

Added:
    cxf/web/src/test/
    cxf/web/src/test/java/
    cxf/web/src/test/java/org/
    cxf/web/src/test/java/org/apache/
    cxf/web/src/test/java/org/apache/cxf/
    cxf/web/src/test/java/org/apache/cxf/cwiki/
    cxf/web/src/test/java/org/apache/cxf/cwiki/PageTest.java
    cxf/web/src/test/resources/
    cxf/web/src/test/resources/docs.cfg
    cxf/web/src/test/resources/page.xml
Modified:
    cxf/web/pom.xml
    cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java
    cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java

Modified: cxf/web/pom.xml
URL: http://svn.apache.org/viewvc/cxf/web/pom.xml?rev=1509024&r1=1509023&r2=1509024&view=diff
==============================================================================
--- cxf/web/pom.xml (original)
+++ cxf/web/pom.xml Wed Jul 31 20:51:45 2013
@@ -38,7 +38,7 @@
         <svn.arg2></svn.arg2>
         <site.output>${basedir}/content</site.output>
         <cxf.site.output>${site.output}</cxf.site.output>
-        <maven.test.skip>true</maven.test.skip>
+        <!--maven.test.skip>true</maven.test.skip-->
     </properties>
 
     <dependencies>
@@ -61,6 +61,19 @@
             <artifactId>tagsoup</artifactId>
             <version>1.2.1</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>6.8</version>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
     </dependencies>
 
     <build>

Modified: cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java
URL: http://svn.apache.org/viewvc/cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java?rev=1509024&r1=1509023&r2=1509024&view=diff
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java (original)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java Wed Jul 31 20:51:45 2013
@@ -27,6 +27,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeMap;
 import java.util.concurrent.CopyOnWriteArraySet;
 
 import javax.xml.datatype.DatatypeFactory;
@@ -42,7 +43,6 @@ import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 
-
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.ccil.cowan.tagsoup.Parser;
@@ -54,7 +54,7 @@ public class Page extends AbstractPage i
     
 
     private static final long serialVersionUID = 1L;
-    private static final Map<String, String> CODE_TYPE_MAP = new HashMap<String,
String>();
+    private static final Map<String, String> CODE_TYPE_MAP = new TreeMap<String,
String>(String.CASE_INSENSITIVE_ORDER);
     static {
         CODE_TYPE_MAP.put("applescript", "shBrushAppleScript.js");
         CODE_TYPE_MAP.put("actionscript3", "shBrushAS3.js");
@@ -248,10 +248,10 @@ public class Page extends AbstractPage i
                     String paramString = c.substring(idx, idx2);
                     String params[] = paramString.split("\\||=");
                     for (int x = 0; x < params.length; x++) {
-                        if ("type".equals(params[x])) {
+                        if ("type".equalsIgnoreCase(params[x])) {
                             type = params[x + 1];
                             x++;
-                        } else if (CODE_TYPE_MAP.containsKey(params[x])) {
+                        } else if (CODE_TYPE_MAP.containsKey(params[x].toLowerCase())) {
                             type = params[x];
                         }
                     }
@@ -275,10 +275,10 @@ public class Page extends AbstractPage i
                     String paramString = c.substring(idx, idx2);
                     String params[] = paramString.split("\\||=");
                     for (int x = 0; x < params.length; x++) {
-                        if ("lang".equals(params[x])) {
+                        if ("lang".equalsIgnoreCase(params[x])) {
                             type = params[x + 1];
                             x++;
-                        } else if (CODE_TYPE_MAP.containsKey(params[x])) {
+                        } else if (CODE_TYPE_MAP.containsKey(params[x].toLowerCase())) {
                             type = params[x];
                         }
                     }

Modified: cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
URL: http://svn.apache.org/viewvc/cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java?rev=1509024&r1=1509023&r2=1509024&view=diff
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java (original)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java Wed Jul 31 20:51:45 2013
@@ -274,7 +274,7 @@ public class SiteExporter implements Run
     }
         
     private void checkVersion() throws ParserConfigurationException, IOException {
-        Document doc = XMLUtils.newDocument();
+        Document doc = DOMUtils.createDocument();
         Element el = doc.createElementNS(SOAPNS, "ns1:getServerInfo");
         Element el2 = doc.createElement("in0");
         el.appendChild(el2);
@@ -490,7 +490,7 @@ public class SiteExporter implements Run
     }
     
     private void loadAttachments(AbstractPage p) throws Exception {
-        Document doc = XMLUtils.newDocument();
+        Document doc = DOMUtils.createDocument();
         Element el = doc.createElementNS(SOAPNS, "ns1:getAttachments");
         Element el2 = doc.createElement("in0");
         el.appendChild(el2);
@@ -762,7 +762,7 @@ public class SiteExporter implements Run
 
     private static synchronized void doLogin() throws Exception {
         if (loginToken == null) {
-            Document doc = XMLUtils.newDocument();
+            Document doc = DOMUtils.createDocument();
             Element el = doc.createElementNS(SOAPNS, "ns1:login");
             Element el2 = doc.createElement("in0");
             
@@ -827,7 +827,7 @@ public class SiteExporter implements Run
     }
     
     public void loadBlog() throws Exception {
-        Document doc = XMLUtils.newDocument();
+        Document doc = DOMUtils.createDocument();
         Element el = doc.createElementNS(SOAPNS, "ns1:getBlogEntries");
         Element el2 = doc.createElement("in0");
         el.appendChild(el2);

Added: cxf/web/src/test/java/org/apache/cxf/cwiki/PageTest.java
URL: http://svn.apache.org/viewvc/cxf/web/src/test/java/org/apache/cxf/cwiki/PageTest.java?rev=1509024&view=auto
==============================================================================
--- cxf/web/src/test/java/org/apache/cxf/cwiki/PageTest.java (added)
+++ cxf/web/src/test/java/org/apache/cxf/cwiki/PageTest.java Wed Jul 31 20:51:45 2013
@@ -0,0 +1,55 @@
+/**
+ * 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.cxf.cwiki;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+@Test
+public class PageTest {
+
+    @Test
+    public void shouldParseUpperCasedCodeMacro() throws Exception {
+        // given
+        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+        Document doc = docBuilder.parse("src/test/resources/page.xml");
+
+        SiteExporter se = new SiteExporter("src/test/resources/docs.cfg", true);
+        SiteExporter.apiVersion = 1;
+
+        Page p = new Page(doc, se);
+
+        // when
+        Set<String> codeScripts = new HashSet<String>(p.getCodeScripts());
+        Set<String> expected = new HashSet<String>(Arrays.asList("shBrushJava.js",
"shBrushXml.js", "shBrushPlain.js"));
+        
+        Assert.assertEquals(codeScripts, expected);
+    }
+
+}

Added: cxf/web/src/test/resources/docs.cfg
URL: http://svn.apache.org/viewvc/cxf/web/src/test/resources/docs.cfg?rev=1509024&view=auto
==============================================================================
--- cxf/web/src/test/resources/docs.cfg (added)
+++ cxf/web/src/test/resources/docs.cfg Wed Jul 31 20:51:45 2013
@@ -0,0 +1,2 @@
+
+

Added: cxf/web/src/test/resources/page.xml
URL: http://svn.apache.org/viewvc/cxf/web/src/test/resources/page.xml?rev=1509024&view=auto
==============================================================================
--- cxf/web/src/test/resources/page.xml (added)
+++ cxf/web/src/test/resources/page.xml Wed Jul 31 20:51:45 2013
@@ -0,0 +1,29 @@
+<page>
+    <body>
+        <modified>2013-07-19T08:27:39</modified>
+        <content>
+            {code:plain|title=Register.properties}
+            thankyou=Thank you for registering %{personBean.firstName}.
+            {code}
+
+            {code:html|title=textfield tag}
+            <s:textfield name="personBean.firstName" label="First name"/>
+            {code}
+
+            {code:html|title=link to register.jsp}
+            <p>
+                <a href="register.jsp">Please register</a>
+                for our prize drawing.
+            </p>
+            {code}
+
+            {code:XML|title=registerInput action node for struts.xml}
+            <action name="registerInput" class="org.apache.struts.register.action.Register"
method="input">
+                <result name="input">/register.jsp</result>
+            </action>
+            {code}
+        </content>
+        <attachments size="6"/>
+        <labels/>
+    </body>
+</page>
\ No newline at end of file



Mime
View raw message