From: <bo...@us...> - 2007-03-30 03:50:00
|
Revision: 164 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=164&view=rev Author: bodewig Date: 2007-03-29 20:50:01 -0700 (Thu, 29 Mar 2007) Log Message: ----------- refactor DoctypeReader/InputStream Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeInputStream.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeReader.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/Validator.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DoctypeInputStream.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DoctypeReader.java Added Paths: ----------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/util/ trunk/xmlunit/src/java/org/custommonkey/xmlunit/util/IntegerBuffer.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractDoctypeTests.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/util/ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/util/test_IntegerBuffer.java Removed Paths: ------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeConstants.java Deleted: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeConstants.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeConstants.java 2007-03-29 07:19:41 UTC (rev 163) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeConstants.java 2007-03-30 03:50:01 UTC (rev 164) @@ -1,45 +0,0 @@ -/* -****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of the xmlunit.sourceforge.net nor the names - of its contributors may be used to endorse or promote products - derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -****************************************************************** -*/ - -package org.custommonkey.xmlunit; - -interface DoctypeConstants { - String DOCTYPE_OPEN_DECL = "<!"; - int DECL_LENGTH = DOCTYPE_OPEN_DECL.length(); - String DOCTYPE_CLOSE_DECL = ">"; - String DOCTYPE = "DOCTYPE "; - String SYSTEM = " SYSTEM \""; -} \ No newline at end of file Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeInputStream.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeInputStream.java 2007-03-29 07:19:41 UTC (rev 163) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeInputStream.java 2007-03-30 03:50:01 UTC (rev 164) @@ -51,21 +51,11 @@ * <br />Examples and more at <a href="http://xmlunit.sourceforge.net"/>xmlunit.sourceforge.net</a> */ public class DoctypeInputStream extends InputStream { + + private final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); private final InputStream wrappedStream; + private final DoctypeSupport support; - private static final byte[] DOCTYPE_BYTES = { - 'D', 'O', 'C', 'T', 'Y', 'P', 'E', ' ' - }; - - private byte[] readAheadBeforeDeclBuffer = null; - private int readAheadBeforeDeclOffset = 0; - private byte[] readAheadAfterDeclBuffer = null; - private int readAheadAfterDeclOffset = 0; - - private final DoctypeSupport docType; - private boolean writeDecl = false; - - /** * Create an InputStream whose XML content is provided by the * originalSource with the exception of the DOCTYPE which is @@ -74,143 +64,44 @@ * @param doctypeName * @param systemID */ - public DoctypeInputStream(InputStream originalSource, String doctypeName, - String systemID) { + public DoctypeInputStream(InputStream originalSource, String encoding, + String doctypeName, String systemID) { wrappedStream = originalSource instanceof BufferedInputStream ? originalSource : new BufferedInputStream(originalSource); - docType = new DoctypeSupport(doctypeName, systemID); + support = + new DoctypeSupport(doctypeName, systemID, + new DoctypeSupport.Readable() { + public int read() throws IOException { + return wrappedStream.read(); + } + }, + false, encoding); } /** - * Read DOCTYPE-replaced content from the wrapped Reader + * @return the content of the original source, without amendments or + * substitutions. Safe to call multiple times. + * @throws IOException if thrown while reading from the original source */ - public int read() throws IOException { - int nextByte = -1; - - if (writeDecl) { - // currently writing our own DOCTYPE declaration - nextByte = docType.read(); - if (nextByte == -1) { - writeDecl = false; - } else { - return nextByte; + protected String getContent(String encoding) throws IOException { + if (baos.size() == 0) { + byte[] buffer = new byte[8192]; + int bytesRead = -1; + while ((bytesRead = wrappedStream.read(buffer)) > -1) { + baos.write(buffer, 0, bytesRead); } } - - if (readAheadBeforeDeclBuffer != null) { - // in part of original document before our DOCTYPE - this - // has already been read - nextByte = readAheadBeforeDeclBuffer[readAheadBeforeDeclOffset++]; - if (readAheadBeforeDeclOffset >= readAheadBeforeDeclBuffer.length) { - readAheadBeforeDeclBuffer = null; - writeDecl = true; - } - } else if (!docType.hasBeenRead()) { - // DOCTYPE not written, yet, need to see where it should go - - // read ahead until we find a good place to insert the doctype, - // store bytes in readAheadBuffers - ByteArrayOutputStream beforeDecl = new ByteArrayOutputStream(); - ByteArrayOutputStream afterDecl = new ByteArrayOutputStream(); - int current; - boolean ready = false; - while (!ready && (current = wrappedStream.read()) != -1) { - byte c = (byte) current; - if (c >= 0 && Character.isWhitespace((char) c)) { - beforeDecl.write(c); - } else if (c == '<') { - // could be XML declaration, comment, PI, DOCTYPE - // or the first element - byte[] elementOrDeclOr = readUntilCloseCharacterIsReached(); - if (elementOrDeclOr.length > 0) { - if (elementOrDeclOr[0] == '?') { - // XML declaration or PI - beforeDecl.write('<'); - beforeDecl.write(elementOrDeclOr, 0, - elementOrDeclOr.length); - } else if (elementOrDeclOr[0] != '!') { - // first element - afterDecl.write('<'); - afterDecl.write(elementOrDeclOr, 0, - elementOrDeclOr.length); - ready = true; - } else { - // comment or doctype - if (indexOfDoctype(elementOrDeclOr) == -1) { - afterDecl.write('<'); - afterDecl.write(elementOrDeclOr, 0, - elementOrDeclOr.length); - } // else swallow old declaration - ready = true; - } - } - - } else { - afterDecl.write(c); - ready = true; - } - } - readAheadBeforeDeclBuffer = beforeDecl.size() > 0 - ? beforeDecl.toByteArray() : null; - readAheadAfterDeclBuffer = afterDecl.size() > 0 - ? afterDecl.toByteArray() : null; - writeDecl = (readAheadBeforeDeclBuffer == null); - return read(); - } else if (readAheadAfterDeclBuffer != null) { - // in part of original document read ahead after our DOCTYPE - nextByte = readAheadAfterDeclBuffer[readAheadAfterDeclOffset++]; - if (readAheadAfterDeclOffset >= readAheadAfterDeclBuffer.length) { - readAheadAfterDeclBuffer = null; - } - } else { - nextByte = wrappedStream.read(); - } - return nextByte; + return encoding == null ? baos.toString() : baos.toString(encoding); } - private byte[] readUntilCloseCharacterIsReached() throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - int byteRead = -1; - int openCount = 1; - while (openCount > 0 && (byteRead = wrappedStream.read()) != -1) { - byte c = (byte) byteRead; - baos.write(c); - if (c == '<') { - openCount++; - } - if (c == '>') { - openCount--; - } - } - return baos.toByteArray(); + /** + * Read DOCTYPE-replaced content from the wrapped InputStream + */ + public int read() throws IOException { + return support.read(); } - + public void close() throws IOException { wrappedStream.close(); } - - /** - * Could be faster when searching from the other end, but should do. - */ - private static int indexOfDoctype(byte[] b) { - int index = -1; - for (int i = 0; i < b.length - DOCTYPE_BYTES.length + 1; i++) { - if (b[i] == DOCTYPE_BYTES[0]) { - boolean found = false; - int j = 1; - for (; !found && j < DOCTYPE_BYTES.length; j++) { - if (b[i + j] != DOCTYPE_BYTES[j]) { - found = true; - } - } - if (found) { - index = i; - break; - } else { - i += j - 1; - } - } - } - return index; - } } \ No newline at end of file Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeReader.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeReader.java 2007-03-29 07:19:41 UTC (rev 163) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeReader.java 2007-03-30 03:50:01 UTC (rev 164) @@ -49,19 +49,13 @@ * document against a DTD. * <br />Examples and more at <a href="http://xmlunit.sourceforge.net"/>xmlunit.sourceforge.net</a> */ -public class DoctypeReader extends Reader implements DoctypeConstants { +public class DoctypeReader extends Reader { private final Reader originalReader; private final StringBuffer sourceBuffer = new StringBuffer(1024); - private char[] readAheadBeforeDeclBuffer = null; - private int readAheadBeforeDeclOffset = 0; - private char[] readAheadAfterDeclBuffer = null; - private int readAheadAfterDeclOffset = 0; + private final DoctypeSupport support; - private final DoctypeSupport docType; - private boolean writeDecl = false; - /** * Create a Reader whose XML content is provided by the originalSource with * the exception of the DOCTYPE which is provided by the doctypeName @@ -74,18 +68,23 @@ String systemID) { originalReader = originalSource instanceof BufferedReader ? originalSource : new BufferedReader(originalSource); - docType = new DoctypeSupport(doctypeName, systemID); + support = + new DoctypeSupport(doctypeName, systemID, + new DoctypeSupport.Readable() { + public int read() throws IOException { + return originalReader.read(); + } + }, + true, null); } /** * @return the content of the original source, without amendments or * substitutions. Safe to call multiple times. * @throws IOException if thrown while reading from the original source - * @deprecated this method is only here for BWC, it is no longer - * used by this class */ protected String getContent() throws IOException { - return obsoleteGetContent(originalReader).toString(); + return getContent(originalReader).toString(); } /** @@ -93,7 +92,7 @@ * @return the contents of the originalSource within a StringBuffer * @throws IOException if thrown while reading from the original source */ - private StringBuffer obsoleteGetContent(Reader originalSource) + private StringBuffer getContent(Reader originalSource) throws IOException { if (sourceBuffer.length() == 0) { BufferedReader bufferedReader; @@ -163,19 +162,22 @@ public String replaceDoctype(StringBuffer withinContent, String doctypeName, String systemId) { String content = withinContent.toString(); - int startDoctype = content.indexOf(DOCTYPE); + int startDoctype = content.indexOf(DoctypeSupport.DOCTYPE); boolean noCurrentDoctype = false; if (startDoctype == -1) { startDoctype = obsoleteFindStartDoctype(withinContent); noCurrentDoctype = true; } - int endDoctype = startDoctype + DOCTYPE.length(); + int endDoctype = startDoctype + DoctypeSupport.DOCTYPE.length(); if (noCurrentDoctype) { - withinContent.insert(startDoctype, DOCTYPE_OPEN_DECL); - withinContent.insert(startDoctype + DECL_LENGTH, DOCTYPE); - endDoctype += DECL_LENGTH; + withinContent.insert(startDoctype, + DoctypeSupport.DOCTYPE_OPEN_DECL); + withinContent.insert(startDoctype + + DoctypeSupport.DOCTYPE_OPEN_DECL.length(), + DoctypeSupport.DOCTYPE); + endDoctype += DoctypeSupport.DOCTYPE_OPEN_DECL.length(); } else { int startInternalDecl = content.indexOf('[', endDoctype); if (startInternalDecl > 0) { @@ -190,14 +192,14 @@ int atPos = endDoctype; withinContent.insert(atPos, doctypeName); atPos += doctypeName.length(); - withinContent.insert(atPos, SYSTEM); - atPos += SYSTEM.length(); + withinContent.insert(atPos, DoctypeSupport.SYSTEM); + atPos += DoctypeSupport.SYSTEM.length(); withinContent.insert(atPos, systemId); atPos += systemId.length(); withinContent.insert(atPos, '"'); if (noCurrentDoctype) { - withinContent.insert(++atPos, DOCTYPE_CLOSE_DECL); + withinContent.insert(++atPos, DoctypeSupport.DOCTYPE_CLOSE_DECL); } return withinContent.toString(); } @@ -224,102 +226,9 @@ * Read DOCTYPE-replaced content from the wrapped Reader */ public int read() throws IOException { - int nextChar = -1; - - if (writeDecl) { - // currently writing our own DOCTYPE declaration - nextChar = docType.read(); - if (nextChar == -1) { - writeDecl = false; - } else { - return nextChar; - } - } - - if (readAheadBeforeDeclBuffer != null) { - // in part of original document before our DOCTYPE - this - // has already been read - nextChar = readAheadBeforeDeclBuffer[readAheadBeforeDeclOffset++]; - if (readAheadBeforeDeclOffset >= readAheadBeforeDeclBuffer.length) { - readAheadBeforeDeclBuffer = null; - writeDecl = true; - } - } else if (!docType.hasBeenRead()) { - // DOCTYPE not written, yet, need to see where it should go - - // read ahead until we find a good place to insert the doctype, - // store characters in readAheadBuffers - StringBuffer beforeDecl = new StringBuffer(); - StringBuffer afterDecl = new StringBuffer(); - int current; - boolean ready = false; - while (!ready && (current = originalReader.read()) != -1) { - char c = (char) current; - if (Character.isWhitespace(c)) { - beforeDecl.append(c); - } else if (c == '<') { - // could be XML declaration, comment, PI, DOCTYPE - // or the first element - String elementOrDeclOr = readUntilCloseCharacterIsReached(); - if (elementOrDeclOr.length() > 0) { - if (elementOrDeclOr.charAt(0) == '?') { - // XML declaration or PI - beforeDecl.append('<').append(elementOrDeclOr); - } else if (elementOrDeclOr.charAt(0) != '!') { - // first element - afterDecl.append('<').append(elementOrDeclOr); - ready = true; - } else { - // comment or doctype - if (elementOrDeclOr.indexOf(DOCTYPE) == -1) { - afterDecl.append('<').append(elementOrDeclOr); - } // else swallow old declaration - ready = true; - } - } - - } else { - afterDecl.append(c); - ready = true; - } - } - readAheadBeforeDeclBuffer = beforeDecl.length() > 0 - ? beforeDecl.toString().toCharArray() - : null; - readAheadAfterDeclBuffer = afterDecl.length() > 0 - ? afterDecl.toString().toCharArray() - : null; - writeDecl = (readAheadBeforeDeclBuffer == null); - return read(); - } else if (readAheadAfterDeclBuffer != null) { - // in part of original document read ahead after our DOCTYPE - nextChar = readAheadAfterDeclBuffer[readAheadAfterDeclOffset++]; - if (readAheadAfterDeclOffset >= readAheadAfterDeclBuffer.length) { - readAheadAfterDeclBuffer = null; - } - } else { - nextChar = originalReader.read(); - } - return nextChar; + return support.read(); } - private String readUntilCloseCharacterIsReached() throws IOException { - StringBuffer sb = new StringBuffer(); - int characterRead = -1; - int openCount = 1; - while (openCount > 0 && (characterRead = originalReader.read()) != -1) { - char c = (char) characterRead; - sb.append(c); - if (c == '<') { - openCount++; - } - if (c == '>') { - openCount--; - } - } - return sb.toString(); - } - public void close() throws IOException { originalReader.close(); } Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java 2007-03-29 07:19:41 UTC (rev 163) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java 2007-03-30 03:50:01 UTC (rev 164) @@ -36,39 +36,231 @@ package org.custommonkey.xmlunit; +import java.io.IOException; + +import org.custommonkey.xmlunit.exceptions.XMLUnitRuntimeException; +import org.custommonkey.xmlunit.util.IntegerBuffer; + /** * Contains some common code for DoctypeReader and DoctypeInputStream. * * <p>When used with DoctypeInputStream it assumes that the whole * DOCTYPE declaration consists of US-ASCII characters.</p> */ -final class DoctypeSupport implements DoctypeConstants { +final class DoctypeSupport { - private final String decl; - private int offset = 0; + static interface Readable { + int read() throws IOException; + } + final static String DOCTYPE_OPEN_DECL = "<!"; + final static String DOCTYPE_CLOSE_DECL = ">"; + final static String DOCTYPE = "DOCTYPE "; + final static String SYSTEM = " SYSTEM \""; + private final static int[] DOCTYPE_INTS = { + 'D', 'O', 'C', 'T', 'Y', 'P', 'E', ' ' + }; + + private boolean hasSplit; + private final Readable original; + private Readable decl; + private Readable beforeDoctype; + private Readable afterDoctype; + /** * Encapsulates a DOCTYPE declaration for the given name and system id. */ - DoctypeSupport(String name, String systemId) { + DoctypeSupport(String name, String systemId, Readable original, + boolean characters, String encoding) { + this.original = original; + StringBuffer sb = new StringBuffer(DOCTYPE_OPEN_DECL); sb.append(DOCTYPE).append(name).append(SYSTEM) .append(systemId).append("\"").append(DOCTYPE_CLOSE_DECL); - decl = sb.toString(); + String s = sb.toString(); + IntegerBuffer buf = + new IntegerBuffer(s.length() * (characters ? 1 : 2)); + + if (characters) { + char[] c = s.toCharArray(); + for (int i = 0; i < c.length; i++) { + buf.append(c[i]); + } + } else { + try { + byte[] b = encoding == null + ? s.getBytes() : s.getBytes(encoding); + for (int i = 0; i < b.length; i++) { + buf.append(b[i] & 0xFF); + } + } catch (java.io.UnsupportedEncodingException use) { + throw new XMLUnitRuntimeException("Unsupported encoding", use); + } + } + + decl = new IntBufferReadable(buf); } /** - * Whether anybody has started to read the declaration. + * Reads the next character from the declaration. + * @return -1 if the end of the declaration has been reached. */ - boolean hasBeenRead() { - return offset != 0; + int read() throws IOException { + int nextInt = -1; + if (!hasSplit) { + split(); + } + if (beforeDoctype != null) { + nextInt = beforeDoctype.read(); + if (nextInt == -1) { + beforeDoctype = null; + } + } + if (nextInt == -1 && decl != null) { + nextInt = decl.read(); + if (nextInt == -1) { + decl = null; + } + } + if (nextInt == -1 && afterDoctype != null) { + nextInt = afterDoctype.read(); + if (nextInt == -1) { + afterDoctype = null; + } + } + if (nextInt == -1) { + nextInt = original.read(); + } + return nextInt; } /** - * Reads the next character from the declaration. - * @return -1 if the end of the declaration has been reached. + * Reads enough of the original Readable to know where to place + * the declaration. Fills beforeDecl and afterDecl from the data + * read ahead. Swallows the original DOCTYPE if there is one. */ - int read() { - return offset >= decl.length() ? -1 : decl.charAt(offset++); + private void split() throws IOException { + hasSplit = true; + IntegerBuffer before = new IntegerBuffer(); + IntegerBuffer after = new IntegerBuffer(); + + int current; + boolean ready = false; + boolean stillNeedToSeeDoctype = true; + while (!ready && (current = original.read()) != -1) { + if (Character.isWhitespace((char) current)) { + before.append(current); + } else if (current == '<') { + // could be XML declaration, comment, PI, DOCTYPE + // or the first element + int[] elementOrDeclOr = readUntilCloseCharIsReached(); + if (elementOrDeclOr.length > 0) { + if (elementOrDeclOr[0] == '?') { + // XML declaration or PI + before.append('<'); + before.append(elementOrDeclOr); + } else if (elementOrDeclOr[0] != '!') { + // first element + after.append('<'); + after.append(elementOrDeclOr); + stillNeedToSeeDoctype = false; + ready = true; + } else { + // comment or doctype + IntegerBuffer b = + new IntegerBuffer(elementOrDeclOr.length); + b.append(elementOrDeclOr); + if (b.indexOf(DOCTYPE_INTS) == -1) { + after.append('<'); + after.append(elementOrDeclOr); + } else { + // swallow old declaration + stillNeedToSeeDoctype = false; + } + ready = true; + } + } else { + after.append('<'); + stillNeedToSeeDoctype = false; + ready = true; + } + } else { + after.append(current); + stillNeedToSeeDoctype = false; + ready = true; + } + } + + // need to eliminate original DOCTYPE if it exists + while (stillNeedToSeeDoctype && (current = original.read()) != -1) { + if (Character.isWhitespace((char) current)) { + after.append(current); + } else if (current == '<') { + int[] elementOrDeclOr = readUntilCloseCharIsReached(); + if (elementOrDeclOr.length > 0) { + if (elementOrDeclOr[0] == '?') { + // PI + after.append('<'); + after.append(elementOrDeclOr); + } else if (elementOrDeclOr[0] != '!') { + // first element + after.append('<'); + after.append(elementOrDeclOr); + stillNeedToSeeDoctype = false; + } else { + // comment or doctype + IntegerBuffer b = + new IntegerBuffer(elementOrDeclOr.length); + b.append(elementOrDeclOr); + if (b.indexOf(DOCTYPE_INTS) == -1) { + after.append('<'); + after.append(elementOrDeclOr); + } else { + // swallow old declaration + stillNeedToSeeDoctype = false; + } + } + } else { + after.append('<'); + stillNeedToSeeDoctype = false; + } + } else { + after.append(current); + stillNeedToSeeDoctype = false; + } + } + + beforeDoctype = before.size() > 0 + ? new IntBufferReadable(before) : null; + afterDoctype = after.size() > 0 + ? new IntBufferReadable(after) : null; } + + private int[] readUntilCloseCharIsReached() throws IOException { + IntegerBuffer i = new IntegerBuffer(); + int intRead = -1; + int openCount = 1; + while (openCount > 0 && (intRead = original.read()) != -1) { + i.append(intRead); + if (intRead == '<') { + openCount++; + } + if (intRead == '>') { + openCount--; + } + } + return i.toIntArray(); + } + + private static class IntBufferReadable implements Readable { + private final int[] buf; + private int off; + IntBufferReadable(IntegerBuffer b) { + buf = b.toIntArray(); + } + public int read() { + return off >= buf.length ? -1 : buf[off++]; + } + } + } \ No newline at end of file Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/Validator.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Validator.java 2007-03-29 07:19:41 UTC (rev 163) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/Validator.java 2007-03-30 03:50:01 UTC (rev 164) @@ -258,6 +258,8 @@ doctype, systemID)) : new InputSource(new DoctypeInputStream(sourceForValidation .getByteStream(), + sourceForValidation + .getEncoding(), doctype, systemID)), systemID, true); } @@ -382,7 +384,7 @@ } else if (usingDoctypeReader) { try { messages.append("\nContent was: ") - .append(readFully(validationInputSource)); + .append(getOriginalContent(validationInputSource)); } catch (IOException e) { // silent but deadly? } @@ -492,30 +494,11 @@ schemaSource); } - private static String readFully(InputSource s) throws IOException { - return s.getCharacterStream() != null - ? readFully(s.getCharacterStream()) : readFully(s.getByteStream()); + private static String getOriginalContent(InputSource s) + throws IOException { + return s.getCharacterStream() instanceof DoctypeReader + ? ((DoctypeReader) s.getCharacterStream()).getContent() + : ((DoctypeInputStream) s.getByteStream()) + .getContent(s.getEncoding()); } - - private static String readFully(Reader r) throws IOException { - StringBuffer sb = new StringBuffer(); - char[] buffer = new char[4096]; - int charsRead = -1; - while ((charsRead = r.read(buffer)) > -1) { - sb.append(buffer, 0, charsRead); - } - return sb.toString(); - } - - private static String readFully(java.io.InputStream is) throws IOException { - java.io.ByteArrayOutputStream baos = - new java.io.ByteArrayOutputStream(); - byte[] buffer = new byte[8192]; - int bytesRead = -1; - while ((bytesRead = is.read(buffer)) > -1) { - baos.write(buffer, 0, bytesRead); - } - return new String(baos.toByteArray()); - } - } Added: trunk/xmlunit/src/java/org/custommonkey/xmlunit/util/IntegerBuffer.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/util/IntegerBuffer.java (rev 0) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/util/IntegerBuffer.java 2007-03-30 03:50:01 UTC (rev 164) @@ -0,0 +1,146 @@ +/* +****************************************************************** +Copyright (c) 2001, Jeff Martin, Tim Bacon +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the xmlunit.sourceforge.net nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +****************************************************************** +*/ + +package org.custommonkey.xmlunit.util; + +/** + * Simplistic dynamically growing buffer of integers used by DoctypeSupport. + * + * <p>No attempt has been made to make this class thread-safe at all. + * The append methods and indexOf are not too efficient either, but + * work for what we need.</p> + */ +public class IntegerBuffer { + + // should be big enough for the DoctypeSupport use case + private static final int INITIAL_SIZE = 512; + + private int[] buffer; + private int currentSize; + + /** + * Creates a new buffer. + */ + public IntegerBuffer() { + this(INITIAL_SIZE); + } + + /** + * Creates a new buffer with the given initial capacity. + */ + public IntegerBuffer(int capacity) { + buffer = new int[capacity]; + } + + /** + * Returns the current size. + */ + public int size() { + return currentSize; + } + + /** + * Returns the current capacity (the size the buffer can use + * before it needs to grow). + */ + public int capacity() { + return buffer.length; + } + + /** + * Appends a single int. + */ + public void append(int i) { + // could simply delegate to the other append methods, but this + // (avoiding arraycopy) is more efficient. + while (currentSize >= buffer.length) { + grow(); + } + buffer[currentSize++] = i; + } + + /** + * Appends an array of ints. + */ + public void append(int[] i) { + // could simply delegate to the other append methods, but this + // (avoiding repeated comparisions) is more efficient. + while (currentSize + i.length > buffer.length) { + grow(); + } + System.arraycopy(i, 0, buffer, currentSize, i.length); + currentSize += i.length; + } + + /** + * Returns an arry view of this buffer's content. + */ + public int[] toIntArray() { + int[] i = new int[currentSize]; + System.arraycopy(buffer, 0, i, 0, currentSize); + return i; + } + + /** + * finds sequence in current buffer. + * + * @return index of sequence or -1 if not found + */ + public int indexOf(int[] sequence) { + int index = -1; + for (int i = 0; index == -1 && i <= currentSize - sequence.length; + i++) { + if (buffer[i] == sequence[0]) { + boolean matches = true; + for (int j = 1; matches && j < sequence.length; j++) { + if (buffer[i + j] != sequence[j]) { + matches = false; + } + } + if (matches) { + index = i; + } + } + } + return index; + } + + private void grow() { + int[] i = new int[buffer.length * 2 + 1]; + System.arraycopy(buffer, 0, i, 0, buffer.length); + buffer = i; + } +} \ No newline at end of file Property changes on: trunk/xmlunit/src/java/org/custommonkey/xmlunit/util/IntegerBuffer.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractDoctypeTests.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractDoctypeTests.java (rev 0) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractDoctypeTests.java 2007-03-30 03:50:01 UTC (rev 164) @@ -0,0 +1,121 @@ +/* +****************************************************************** +Copyright (c) 200, Jeff Martin, Tim Bacon +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the xmlunit.sourceforge.net nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +****************************************************************** +*/ + +package org.custommonkey.xmlunit; + +import java.io.IOException; + +import junit.framework.TestCase; + +/** + * JUnit test for DoctypeReader and DoctypeInputStream + */ +public abstract class AbstractDoctypeTests extends TestCase { + + private static final String COMMENT = "<!-- comment -->"; + protected static final String NO_DTD = + "<document><element>one</element></document>"; + + public abstract void testGetContent() throws IOException; + + protected abstract void assertEquals(String expected, String input, + String docType, String systemId) + throws IOException; + + public void testRead() throws IOException { + String oz = "Chirurgische Verbesserungen sind g\u00fcnstig"; + assertEquals("<!DOCTYPE Kylie SYSTEM \"bumJob\">" + oz, + oz, "Kylie", "bumJob"); + } + + public void testInternalDTD() throws IOException { + assertEquals("<!DOCTYPE ni SYSTEM \"shrubbery\">", + test_Constants.CHUCK_JONES_RIP_DTD_DECL, "ni", + "shrubbery"); + } + + public void testExternalDTD() throws IOException { + assertEquals("<!DOCTYPE ni SYSTEM \"shrubbery\">", + "<! DOCTYPE PUBLIC \"yak\" SYSTEM \"llama\">", "ni", + "shrubbery"); + } + + public void testNoDTD() throws IOException { + assertEquals("<!DOCTYPE ni SYSTEM \"shrubbery\">" + NO_DTD, + NO_DTD, "ni", "shrubbery"); + } + + public void testNoDTDButXMLDecl() throws IOException { + assertEquals(test_Constants.XML_DECLARATION + + "<!DOCTYPE ni SYSTEM \"shrubbery\">" + NO_DTD, + test_Constants.XML_DECLARATION + NO_DTD, + "ni", "shrubbery"); + } + + public void testInternalDTDWithComment() throws IOException { + assertEquals(test_Constants.XML_DECLARATION + + "<!DOCTYPE ni SYSTEM \"shrubbery\">" + + COMMENT, + test_Constants.XML_DECLARATION + + COMMENT + + test_Constants.CHUCK_JONES_RIP_DTD_DECL, + "ni", "shrubbery"); + } + + public void testExternalDTDWithComment() throws IOException { + assertEquals("<!DOCTYPE ni SYSTEM \"shrubbery\">" + + COMMENT, + COMMENT + "<! DOCTYPE PUBLIC \"yak\" SYSTEM \"llama\">", + "ni", "shrubbery"); + } + + public void testNoDTDWithComment() throws IOException { + assertEquals("<!DOCTYPE ni SYSTEM \"shrubbery\">" + COMMENT + NO_DTD, + COMMENT + NO_DTD, "ni", "shrubbery"); + } + + public void testNoDTDButXMLDeclWithComment() throws IOException { + assertEquals(test_Constants.XML_DECLARATION + + "<!DOCTYPE ni SYSTEM \"shrubbery\">" + COMMENT + NO_DTD, + test_Constants.XML_DECLARATION + COMMENT + NO_DTD, + "ni", "shrubbery"); + } + + public AbstractDoctypeTests(String name) { + super(name); + } +} + Property changes on: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractDoctypeTests.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DoctypeInputStream.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DoctypeInputStream.java 2007-03-29 07:19:41 UTC (rev 163) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DoctypeInputStream.java 2007-03-30 03:50:01 UTC (rev 164) @@ -49,10 +49,8 @@ /** * JUnit test for DoctypeInputStream */ -public class test_DoctypeInputStream extends TestCase { +public class test_DoctypeInputStream extends AbstractDoctypeTests { - private static final String NEWLINE = System.getProperty("line.separator"); - private static final String NO_DTD = "<document><element>one</element></document>"; private File testFile; public void tearDown() { @@ -85,13 +83,13 @@ return buf.toString(); } - private void assertEquals(String expected, String input, String docType, - String systemId) throws IOException { + protected void assertEquals(String expected, String input, String docType, + String systemId) throws IOException { FileInputStream fis = null; try { fis = testDocument(input); DoctypeInputStream doctypeInputStream = - new DoctypeInputStream(fis, docType, systemId); + new DoctypeInputStream(fis, "ISO-8859-1", docType, systemId); assertEquals(expected, readFully(doctypeInputStream)); } finally { @@ -101,42 +99,18 @@ } } - public void testRead() throws IOException { - String oz = "Chirurgische Verbesserungen sind g\u00fcnstig"; - assertEquals("<!DOCTYPE Kylie SYSTEM \"bumJob\">" + oz, - oz, "Kylie", "bumJob"); + public void testGetContent() throws IOException { + String source = "WooPDeDoO!\nGooRanga!\n plIng! "; + DoctypeInputStream dis = + new DoctypeInputStream(new java.io.StringBufferInputStream(source), + null, "nonsense", "words"); + assertEquals(source, dis.getContent(null)); + // can get content indefinitely from this stream + assertEquals(source, dis.getContent("UTF-8")); } - public void testReplaceDoctypeInternalDTD() throws IOException { - assertEquals("<!DOCTYPE ni SYSTEM \"shrubbery\">", - test_Constants.CHUCK_JONES_RIP_DTD_DECL, "ni", - "shrubbery"); - } - - public void XtestReplaceDoctypeExternalDTD() throws IOException { - assertEquals("<!DOCTYPE ni SYSTEM \"shrubbery\">", - "<! DOCTYPE PUBLIC \"yak\" SYSTEM \"llama\">", "ni", - "shrubbery"); - } - - public void testReplaceDoctypeNoDTD() throws IOException { - assertEquals("<!DOCTYPE ni SYSTEM \"shrubbery\">" + NO_DTD, - NO_DTD, "ni", "shrubbery"); - } - - public void testReplaceDoctypeNoDTDButXMLDecl() throws IOException { - assertEquals(test_Constants.XML_DECLARATION - + "<!DOCTYPE ni SYSTEM \"shrubbery\">" + NO_DTD, - test_Constants.XML_DECLARATION + NO_DTD, - "ni", "shrubbery"); - } - public test_DoctypeInputStream(String name) { super(name); } - - public static TestSuite suite() { - return new TestSuite(test_DoctypeInputStream.class); - } } Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DoctypeReader.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DoctypeReader.java 2007-03-29 07:19:41 UTC (rev 163) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DoctypeReader.java 2007-03-30 03:50:01 UTC (rev 164) @@ -36,7 +36,7 @@ package org.custommonkey.xmlunit; - +import java.io.IOException; import java.io.StringReader; import junit.framework.TestCase; @@ -45,29 +45,12 @@ /** * JUnit test for DoctypeReader */ -public class test_DoctypeReader extends TestCase { +public class test_DoctypeReader extends AbstractDoctypeTests { private DoctypeReader doctypeReader; private StringReader sourceReader; private static final String NEWLINE = System.getProperty("line.separator"); - private static final String NO_DTD = "<document><element>one</element></document>"; - public void testRead() throws Exception { - String oz = "Surgical enhancement is cheap"; - StringReader reader = new StringReader(oz); - doctypeReader = new DoctypeReader(reader, "Kylie", "bumJob"); - - StringBuffer buf = new StringBuffer(); - String expected = "<!DOCTYPE Kylie SYSTEM \"bumJob\">" + oz; - char[] ch = new char[expected.length()]; - int numChars; - while ((numChars = doctypeReader.read(ch))!=-1) { - buf.append(ch); - } - - assertEquals(expected, buf.toString()); - } - - public void testGetContent() throws Exception { + public void testGetContent() throws IOException { String source = "WooPDeDoO!" + NEWLINE + "GooRanga!" + NEWLINE + " plIng! "; sourceReader = new StringReader(source); @@ -115,12 +98,27 @@ doctypeReader.replaceDoctype(buf, "ni", "shrubbery")); } - public test_DoctypeReader(String name) { - super(name); + private static String readFully(DoctypeReader reader) + throws IOException { + StringBuffer buf = new StringBuffer(); + char[] ch = new char[1024]; + int numChars; + while ((numChars = reader.read(ch))!=-1) { + buf.append(ch, 0, numChars); + } + return buf.toString(); } - public static TestSuite suite() { - return new TestSuite(test_DoctypeReader.class); + protected void assertEquals(String expected, String input, String docType, + String systemId) throws IOException { + DoctypeReader doctypeReader = + new DoctypeReader(new StringReader(expected), docType, + systemId); + assertEquals(expected, readFully(doctypeReader)); } + + public test_DoctypeReader(String name) { + super(name); + } } Added: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/util/test_IntegerBuffer.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/util/test_IntegerBuffer.java (rev 0) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/util/test_IntegerBuffer.java 2007-03-30 03:50:01 UTC (rev 164) @@ -0,0 +1,168 @@ +/* +****************************************************************** +Copyright (c) 200, Jeff Martin, Tim Bacon +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the xmlunit.sourceforge.net nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +****************************************************************** +*/ + +package org.custommonkey.xmlunit.util; + +import junit.framework.TestCase; + +/** + * Tests for IntegerBuffer + */ +public class test_IntegerBuffer extends TestCase { + + public void testToArrayEmpty() { + assertNotNull((new IntegerBuffer()).toIntArray()); + assertEquals(0, (new IntegerBuffer()).toIntArray().length); + } + + public void testSingleIntAppend() { + IntegerBuffer b = new IntegerBuffer(); + b.append(1); + assertNotNull(b.toIntArray()); + assertEquals(1, b.toIntArray().length); + assertEquals(1, b.toIntArray()[0]); + } + + public void testArrayAppend() { + IntegerBuffer b = new IntegerBuffer(); + b.append(new int[] {1, 2}); + assertNotNull(b.toIntArray()); + assertEquals(2, b.toIntArray().length); + for (int i = 0; i < 2; i++) { + assertEquals(i + 1, b.toIntArray()[i]); + } + } + + public void testSingleIntAppendWithGrowth() { + IntegerBuffer b = new IntegerBuffer(1); + for (int i = 0; i < 2; i++) { + b.append(i); + } + assertNotNull(b.toIntArray()); + assertEquals(2, b.toIntArray().length); + for (int i = 0; i < 2; i++) { + assertEquals(i, b.toIntArray()[i]); + } + } + + public void testArrayAppendWithGrowth() { + IntegerBuffer b = new IntegerBuffer(1); + b.append(new int[] {1, 2}); + assertNotNull(b.toIntArray()); + assertEquals(2, b.toIntArray().length); + for (int i = 0; i < 2; i++) { + assertEquals(i + 1, b.toIntArray()[i]); + } + } + + public void testSize() { + IntegerBuffer b = new IntegerBuffer(); + assertEquals(0, b.size()); + b.append(0); + assertEquals(1, b.size()); + b.append(new int[] {1, 2}); + assertEquals(3, b.size()); + } + + public void testCapacity() { + IntegerBuffer b = new IntegerBuffer(1); + assertEquals(1, b.capacity()); + b.append(0); + assertEquals(1, b.capacity()); + b.append(0); + assertTrue(b.capacity() > 1); + } + + public void testIndexOfSimple() { + IntegerBuffer b = new IntegerBuffer(); + int[] test = new int[] {1, 2, 3}; + assertEquals(-1, b.indexOf(test)); + b.append(test); + assertEquals(0, b.indexOf(test)); + b.append(test); + assertEquals(0, b.indexOf(test)); + } + + public void testIndexOfWithOffset() { + IntegerBuffer b = new IntegerBuffer(); + int[] test = new int[] {1, 2, 3}; + b.append(0); + assertEquals(-1, b.indexOf(test)); + b.append(test); + assertEquals(1, b.indexOf(test)); + } + + public void testIndexOfWithRepeatedInts() { + IntegerBuffer b = new IntegerBuffer(); + int[] test = new int[] {1, 2, 3}; + b.append(1); + assertEquals(-1, b.indexOf(test)); + b.append(test); + assertEquals(1, b.indexOf(test)); + } + + public void testIndexOfSupSequenceIsThere() { + IntegerBuffer b = new IntegerBuffer(); + int[] test = new int[] {1, 2, 3}; + b.append(new int[] {1, 2}); + b.append(4); + assertEquals(-1, b.indexOf(test)); + } + + public void testAllBytes() { + IntegerBuffer buf = new IntegerBuffer(); + for (byte b = Byte.MIN_VALUE; b < Byte.MAX_VALUE; b++) { + buf.append(b); + } + buf.append(Byte.MAX_VALUE); + int[] is = buf.toIntArray(); + for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) { + assertEquals((byte) i, is[i + Math.abs(Byte.MIN_VALUE)]); + } + } + + public void testAllChars() { + IntegerBuffer buf = new IntegerBuffer(); + for (char c = Character.MIN_VALUE; c < Character.MAX_VALUE; c++) { + buf.append(c); + } + buf.append(Character.MAX_VALUE); + int[] is = buf.toIntArray(); + for (int i = Character.MIN_VALUE; i <= Character.MAX_VALUE; i++) { + assertEquals((char) i, is[i + Math.abs(Character.MIN_VALUE)]); + } + } +} \ No newline at end of file Property changes on: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/util/test_IntegerBuffer.java ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |