Author: nbelaevski
Date: 2009-04-09 11:17:58 -0400 (Thu, 09 Apr 2009)
New Revision: 13472
Modified:
trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
trunk/framework/test/src/main/java/org/ajax4jsf/tests/TestFileUtils.java
Log:
TestFileUtils: encoding problem fixed
Modified:
trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
===================================================================
---
trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2009-04-09
14:54:28 UTC (rev 13471)
+++
trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2009-04-09
15:17:58 UTC (rev 13472)
@@ -25,20 +25,12 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintStream;
-import java.io.RandomAccessFile;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileLock;
-import java.nio.channels.OverlappingFileLockException;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
@@ -64,8 +56,6 @@
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.ajax4jsf.context.AjaxContext;
@@ -93,10 +83,8 @@
import org.richfaces.skin.SkinBean;
import org.richfaces.skin.SkinFactory;
import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
import com.gargoylesoftware.htmlunit.MockWebConnection;
import com.gargoylesoftware.htmlunit.Page;
@@ -634,13 +622,7 @@
String respons = htmlPage.getWebResponse().getContentAsString();
int index = respons.lastIndexOf("<!DOCTYPE");
String response = respons.substring(index);
- InputStream is = htmlPage.getWebResponse().getContentAsStream();
-
- byte[] b = new byte[response.length()];
- is.skip(index);
- is.read(b);
- ByteArrayInputStream stream = new ByteArrayInputStream(b);
- TestFileUtils.checkXHTML(new EntityResolverImpl(), response, stream);
+ TestFileUtils.checkXHTML(new EntityResolverImpl(), response);
}
/**
Modified: trunk/framework/test/src/main/java/org/ajax4jsf/tests/TestFileUtils.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/TestFileUtils.java 2009-04-09
14:54:28 UTC (rev 13471)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/TestFileUtils.java 2009-04-09
15:17:58 UTC (rev 13472)
@@ -24,14 +24,10 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
-import java.io.RandomAccessFile;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileLock;
-import java.nio.channels.OverlappingFileLockException;
+import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
@@ -41,6 +37,7 @@
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -63,13 +60,13 @@
throw new UnsupportedOperationException();
}
- static void checkXHTML(EntityResolver resolver, String response, InputStream is){
+ static void checkXHTML(EntityResolver resolver, String response){
final List<String> messagesList = new ArrayList<String>();
try{
DocumentBuilder documentBuilder = createDocumentBuilder();
documentBuilder.setEntityResolver(resolver);
setupBuilder(messagesList, documentBuilder);
- TestFileUtils.parseResponse(is, documentBuilder);
+ TestFileUtils.parseResponse(new InputSource(new StringReader(response)),
documentBuilder);
TestFileUtils.printXHTMLValidationError(response, messagesList);
}catch(ParserConfigurationException pce){
System.err.println(pce.getLocalizedMessage());
@@ -146,7 +143,7 @@
return isCheckXHTML;
}
- static void parseResponse(InputStream is, DocumentBuilder documentBuilder) {
+ static void parseResponse(InputSource is, DocumentBuilder documentBuilder) {
try {
documentBuilder.parse(is);
} catch (SAXException e) {
Show replies by date