jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brus...@apache.org
Subject svn commit: r1696101 - in /jspwiki/trunk/jspwiki-war/src: main/webapp/XHRHtml2Markup.jsp test/java/org/apache/wiki/util/XmlUtilTest.java
Date Sat, 15 Aug 2015 21:30:53 GMT
Author: brushed
Date: Sat Aug 15 21:30:53 2015
New Revision: 1696101

URL: http://svn.apache.org/r1696101
Log:
Fixing XmlUtilTest

Added:
    jspwiki/trunk/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp
Modified:
    jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/util/XmlUtilTest.java

Added: jspwiki/trunk/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp?rev=1696101&view=auto
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp (added)
+++ jspwiki/trunk/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp Sat Aug 15 21:30:53 2015
@@ -0,0 +1,50 @@
+<%--
+    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.
+--%>
+
+<%@ page language="java" pageEncoding="UTF-8"%>
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.htmltowiki.HtmlStringToWikiTranslator" %>
+<%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%!
+  public void jspInit()
+  {
+    wiki = WikiEngine.getInstance( getServletConfig() );
+  }
+  //Logger log = Logger.getLogger("XHRHtml2Markup");
+  WikiEngine wiki;
+%>
+<%
+  WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW );
+
+  if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
+
+  response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+  //response.setHeader( "Cache-control", "max-age=0" );
+  //response.setDateHeader( "Expires", new Date().getTime() );
+  //response.setDateHeader( "Last-Modified", new Date().getTime() );
+
+  String htmlText = request.getParameter( "htmlPageText" );
+
+  if( htmlText != null )
+  {
+%><%= new HtmlStringToWikiTranslator().translate(htmlText, wikiContext) %><%
+  }
+%>
\ No newline at end of file

Modified: jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/util/XmlUtilTest.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/util/XmlUtilTest.java?rev=1696101&r1=1696100&r2=1696101&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/util/XmlUtilTest.java (original)
+++ jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/util/XmlUtilTest.java Sat Aug
15 21:30:53 2015
@@ -1,4 +1,4 @@
-/* 
+/*
     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
@@ -14,7 +14,7 @@
     "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.  
+    under the License.
  */
 package org.apache.wiki.util;
 
@@ -37,53 +37,53 @@ public class XmlUtilTest extends TestCas
     public static Test suite() {
         return new TestSuite( XmlUtilTest.class );
     }
-    
+
     public void testParseFromClasspath() {
     	List< Element > elements = XmlUtil.parse( ModuleManager.PLUGIN_RESOURCE_LOCATION,
"/modules/plugin" );
     	assertEquals( 4, elements.size() ); // 2 on src/main/resources, another 2 on src/test/resources
-    	
+
     	elements = XmlUtil.parse( ModuleManager.PLUGIN_RESOURCE_LOCATION, "/modules/filter"
);
      	assertEquals( 1, elements.size() );
-     	
+
      	elements = XmlUtil.parse( ModuleManager.PLUGIN_RESOURCE_LOCATION, "/modules/editor"
);
-     	assertEquals( 1, elements.size() );
-     	
+     	assertEquals( 2, elements.size() );
+
      	elements = XmlUtil.parse( ModuleManager.PLUGIN_RESOURCE_LOCATION, "/modules/heck" );
      	assertEquals( 0, elements.size() );
-     	
+
      	elements = XmlUtil.parse( "doesnt/exist.this", "/modules/editor" );
      	assertEquals( 0, elements.size() );
-     	
+
      	elements = XmlUtil.parse( ( String )null, "/modules/editor" );
      	assertEquals( 0, elements.size() );
-     	
+
      	elements = XmlUtil.parse( ModuleManager.PLUGIN_RESOURCE_LOCATION, null );
      	assertEquals( 0, elements.size() );
-     	
+
      	elements = XmlUtil.parse( ClassUtil.MAPPINGS, "/classmappings/mapping" );
      	assertEquals( 19, elements.size() );
     }
-    
+
     public void testParseFromStream() throws FileNotFoundException {
     	InputStream is = new FileInputStream( new File ("./src/test/resources/ini/jspwiki_module.xml"
) );
     	List< Element > elements = XmlUtil.parse( is, "/modules/plugin" );
-    	assertEquals( 2, elements.size() ); 
-    	
+    	assertEquals( 2, elements.size() );
+
     	elements = XmlUtil.parse( is, "/modules/filter" );
      	assertEquals( 0, elements.size() );
-     	
+
      	elements = XmlUtil.parse( is, "/modules/editor" );
      	assertEquals( 0, elements.size() );
-     	
+
      	elements = XmlUtil.parse( is, "/modules/heck" );
      	assertEquals( 0, elements.size() );
-     	
+
      	elements = XmlUtil.parse( ( InputStream )null, "/modules/editor" );
      	assertEquals( 0, elements.size() );
-     	
+
      	elements = XmlUtil.parse( is, null );
      	assertEquals( 0, elements.size() );
-     	
+
      	IOUtils.closeQuietly( is );
     }
 



Mime
View raw message