[xwiki-notifications] r9611 - xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it

vmassol (SVN) notifications at xwiki.org
Fri May 2 10:18:58 CEST 2008


Author: vmassol
Date: 2008-05-02 10:18:58 +0200 (Fri, 02 May 2008)
New Revision: 9611

Added:
   xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/HTMLExportTest.java
Modified:
   xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/AllTests.java
   xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/PDFTest.java
Log:
XWIKI-2352: HTML export is broken

* Added missing functional test to prove that HTML export works
* Fixed bug

Merged from 1.4 branch (revs 9608, 9609)

Modified: xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/AllTests.java
===================================================================
--- xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/AllTests.java	2008-05-02 08:18:55 UTC (rev 9610)
+++ xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/AllTests.java	2008-05-02 08:18:58 UTC (rev 9611)
@@ -47,6 +47,7 @@
         // I think there are TestSuite that do this out there but I haven't looked for them yet.
 
         addTestCase(suite, PDFTest.class);
+        addTestCase(suite, HTMLExportTest.class);
 
         return new XWikiTestSetup(suite);
     }

Copied: xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/HTMLExportTest.java (from rev 9608, xwiki-products/xwiki-enterprise/branches/xwiki-enterprise-1.4/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/HTMLExportTest.java)
===================================================================
--- xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/HTMLExportTest.java	                        (rev 0)
+++ xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/HTMLExportTest.java	2008-05-02 08:18:58 UTC (rev 9611)
@@ -0,0 +1,68 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.it;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
+
+import org.apache.commons.io.IOUtils;
+
+import junit.framework.TestCase;
+
+public class HTMLExportTest extends TestCase
+{
+    /**
+     * Verify that the HTML export feature works on a single simple page by downloading the generated Zip.
+     */
+    public void testHTMLExport() throws Exception
+    {
+        URL url = new URL("http://localhost:8080/xwiki/bin/export/Main/WebHome?format=html");
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        InputStream is = connection.getInputStream();
+        ZipInputStream zis = new ZipInputStream(is);
+        ZipEntry entry;
+        boolean found = false;
+        // We must read the full stream as otherwise if we close it before we've fully read it
+        // then the server side will get a broken pipe since it's still trying to send data on it.
+        while ((entry = zis.getNextEntry()) != null) {
+        	if (entry.getName().equals("xwiki.Main.WebHome.html")) {
+        		String content = IOUtils.toString(zis); 
+        		// Verify that the content was rendered properly
+        		assertTrue("Should have contained 'Welcome to your wiki'", 
+        			content.contains("Welcome to your wiki"));
+        		// Ensure that the translations have been rendered properly
+        		assertFalse("$msg should have been expanded", 
+        			content.contains("$msg"));
+        		found = true;
+        	} else {
+        		IOUtils.readLines(zis);
+        	}
+        	zis.closeEntry();
+        }
+        assertTrue("Failed to find wiki.Main.WebHome.html entry", found);
+        zis.close();
+    }
+}

Modified: xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/PDFTest.java
===================================================================
--- xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/PDFTest.java	2008-05-02 08:18:55 UTC (rev 9610)
+++ xwiki-products/xwiki-enterprise/trunk/distribution-test/misc-tests/src/test/it/com/xpn/xwiki/it/PDFTest.java	2008-05-02 08:18:58 UTC (rev 9611)
@@ -1,3 +1,22 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package com.xpn.xwiki.it;
 
 import junit.framework.TestCase;



More information about the notifications mailing list