Repository: olingo-odata2 Updated Branches: refs/heads/OLINGO-231_PocForAndroid 696288d17 -> cb1ba4685
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cb1ba468/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/commons/BaseNCodec.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/commons/BaseNCodec.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/commons/BaseNCodec.java new file mode 100644 index 0000000..f8097c5 --- /dev/null +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/commons/BaseNCodec.java @@ -0,0 +1,350 @@ +/* + * 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.olingo.odata2.core.commons; + +import java.io.UnsupportedEncodingException; + +/** + * Abstract superclass for Base-N encoders and decoders. + * + * <p> + * This class is not thread-safe. + * Each thread should use its own instance. + * </p> + */ +public abstract class BaseNCodec { + + /** + * MIME chunk size per RFC 2045 section 6.8. + * + * <p> + * The {@value} character limit does not count the trailing CRLF, but counts all other characters, including any + * equal signs. + * </p> + * + * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 6.8</a> + */ + public static final int MIME_CHUNK_SIZE = 76; + + private static final int DEFAULT_BUFFER_RESIZE_FACTOR = 2; + + /** + * Defines the default buffer size - currently {@value} + * - must be large enough for at least one encoded block+separator + */ + private static final int DEFAULT_BUFFER_SIZE = 8192; + + /** Mask used to extract 8 bits, used in decoding bytes */ + protected static final int MASK_8BITS = 0xff; + + /** + * Byte used to pad output. + */ + protected static final byte PAD_DEFAULT = '='; // Allow static access to default + + protected final byte PAD = PAD_DEFAULT; // instance variable just in case it needs to vary later + + /** Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 for Base32 */ + private final int unencodedBlockSize; + + /** Number of bytes in each full block of encoded data, e.g. 3 for Base64 and 8 for Base32 */ + private final int encodedBlockSize; + + /** + * Chunksize for encoding. Not used when decoding. + * A value of zero or less implies no chunking of the encoded data. + * Rounded down to nearest multiple of encodedBlockSize. + */ + protected final int lineLength; + + /** + * Size of chunk separator. Not used unless {@link #lineLength} > 0. + */ + private final int chunkSeparatorLength; + + /** + * Buffer for streaming. + */ + protected byte[] buffer; + + /** + * Position where next character should be written in the buffer. + */ + protected int pos; + + /** + * Position where next character should be read from the buffer. + */ + private int readPos; + + /** + * Boolean flag to indicate the EOF has been reached. Once EOF has been reached, this object becomes useless, + * and must be thrown away. + */ + protected boolean eof; + + /** + * Variable tracks how many characters have been written to the current line. Only used when encoding. We use it to + * make sure each encoded line never goes beyond lineLength (if lineLength > 0). + */ + protected int currentLinePos; + + /** + * Writes to the buffer only occur after every 3/5 reads when encoding, and every 4/8 reads when decoding. + * This variable helps track that. + */ + protected int modulus; + + /** + * Note <code>lineLength</code> is rounded down to the nearest multiple of {@link #encodedBlockSize} + * If <code>chunkSeparatorLength</code> is zero, then chunking is disabled. + * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) + * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) + * @param lineLength if > 0, use chunking with a length <code>lineLength</code> + * @param chunkSeparatorLength the chunk separator length, if relevant + */ + protected BaseNCodec(int unencodedBlockSize, int encodedBlockSize, int lineLength, int chunkSeparatorLength){ + this.unencodedBlockSize = unencodedBlockSize; + this.encodedBlockSize = encodedBlockSize; + this.lineLength = (lineLength > 0 && chunkSeparatorLength > 0) ? + (lineLength / encodedBlockSize) * encodedBlockSize + : 0; + this.chunkSeparatorLength = chunkSeparatorLength; + } + + /** + * Returns the amount of buffered data available for reading. + * + * @return The amount of buffered data available for reading. + */ + int available() { // package protected for access from I/O streams + return buffer != null ? pos - readPos : 0; + } + + /** + * Get the default buffer size. Can be overridden. + * + * @return {@link #DEFAULT_BUFFER_SIZE} + */ + protected int getDefaultBufferSize() { + return DEFAULT_BUFFER_SIZE; + } + + /** Increases our buffer by the {@link #DEFAULT_BUFFER_RESIZE_FACTOR}. */ + private void resizeBuffer() { + if (buffer == null) { + buffer = new byte[getDefaultBufferSize()]; + pos = 0; + readPos = 0; + } else { + byte[] b = new byte[buffer.length * DEFAULT_BUFFER_RESIZE_FACTOR]; + System.arraycopy(buffer, 0, b, 0, buffer.length); + buffer = b; + } + } + + /** + * Ensure that the buffer has room for <code>size</code> bytes + * + * @param size minimum spare space required + */ + protected void ensureBufferSize(int size){ + if ((buffer == null) || (buffer.length < pos + size)){ + resizeBuffer(); + } + } + + /** + * Extracts buffered data into the provided byte[] array, starting at position bPos, + * up to a maximum of bAvail bytes. Returns how many bytes were actually extracted. + * + * @param b + * byte[] array to extract the buffered data into. + * @param bPos + * position in byte[] array to start extraction at. + * @param bAvail + * amount of bytes we're allowed to extract. We may extract fewer (if fewer are available). + * @return The number of bytes successfully extracted into the provided byte[] array. + */ + int readResults(byte[] b, int bPos, int bAvail) { // package protected for access from I/O streams + if (buffer != null) { + int len = Math.min(available(), bAvail); + System.arraycopy(buffer, readPos, b, bPos, len); + readPos += len; + if (readPos >= pos) { + buffer = null; // so hasData() will return false, and this method can return -1 + } + return len; + } + return eof ? -1 : 0; + } + + /** + * Checks if a byte value is whitespace or not. + * Whitespace is taken to mean: space, tab, CR, LF + * @param byteToCheck + * the byte to check + * @return true if byte is whitespace, false otherwise + */ + protected static boolean isWhiteSpace(byte byteToCheck) { + switch (byteToCheck) { + case ' ' : + case '\n' : + case '\r' : + case '\t' : + return true; + default : + return false; + } + } + + /** + * Resets this object to its initial newly constructed state. + */ + private void reset() { + buffer = null; + pos = 0; + readPos = 0; + currentLinePos = 0; + modulus = 0; + eof = false; + } + + + public static String newStringUtf8(byte[] content) { + try { + return new String(content, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("UTF-8 is always supported."); + } + } + + /** + * Decodes a String containing characters in the Base-N alphabet. + * + * @param pArray + * A String containing Base-N character data + * @return a byte array containing binary data + */ + public byte[] decode(String pArray) { + return decode(getBytesUtf8(pArray)); + } + + /** + * Decodes a byte[] containing characters in the Base-N alphabet. + * + * @param pArray + * A byte array containing Base-N character data + * @return a byte array containing binary data + */ + public byte[] decode(byte[] pArray) { + reset(); + if (pArray == null || pArray.length == 0) { + return pArray; + } + decode(pArray, 0, pArray.length); + decode(pArray, 0, -1); // Notify decoder of EOF. + byte[] result = new byte[pos]; + readResults(result, 0, result.length); + return result; + } + + /** + * Encodes a byte[] containing binary data, into a byte[] containing characters in the alphabet. + * + * @param pArray + * a byte array containing binary data + * @return A byte array containing only the basen alphabetic character data + */ + public byte[] encode(byte[] pArray) { + reset(); + if (pArray == null || pArray.length == 0) { + return pArray; + } + encode(pArray, 0, pArray.length); + encode(pArray, 0, -1); // Notify encoder of EOF. + byte[] buf = new byte[pos - readPos]; + readResults(buf, 0, buf.length); + return buf; + } + + abstract void encode(byte[] pArray, int i, int length); // package protected for access from I/O streams + + abstract void decode(byte[] pArray, int i, int length); // package protected for access from I/O streams + + /** + * Returns whether or not the <code>octet</code> is in the current alphabet. + * Does not allow whitespace or pad. + * + * @param value The value to test + * + * @return <code>true</code> if the value is defined in the current alphabet, <code>false</code> otherwise. + */ + protected abstract boolean isInAlphabet(byte value); + + public static byte[] getBytesUtf8(String content) { + if(content == null) { + return new byte[0]; + } + try { + return content.getBytes("UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("UTF-8 is always supported."); + } + } + + /** + * Tests a given byte array to see if it contains any characters within the alphabet or PAD. + * + * Intended for use in checking line-ending arrays + * + * @param arrayOctet + * byte array to test + * @return <code>true</code> if any byte is a valid character in the alphabet or PAD; <code>false</code> otherwise + */ + protected boolean containsAlphabetOrPad(byte[] arrayOctet) { + if (arrayOctet == null) { + return false; + } + for (byte element : arrayOctet) { + if (PAD == element || isInAlphabet(element)) { + return true; + } + } + return false; + } + + /** + * Calculates the amount of space needed to encode the supplied array. + * + * @param pArray byte[] array which will later be encoded + * + * @return amount of space needed to encoded the supplied array. + * Returns a long since a max-len array will require > Integer.MAX_VALUE + */ + public long getEncodedLength(byte[] pArray) { + // Calculate non-chunked size - rounded up to allow for padding + // cast to long is needed to avoid possibility of overflow + long len = ((pArray.length + unencodedBlockSize-1) / unencodedBlockSize) * (long) encodedBlockSize; + if (lineLength > 0) { // We're using chunking + // Round up to nearest multiple + len += ((len + lineLength-1) / lineLength) * chunkSeparatorLength; + } + return len; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cb1ba468/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/commons/Hex.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/commons/Hex.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/commons/Hex.java new file mode 100644 index 0000000..ef640b1 --- /dev/null +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/commons/Hex.java @@ -0,0 +1,124 @@ +/* + * 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.olingo.odata2.core.commons; + +import java.io.IOException; + +/** + * Converts hexadecimal Strings. + * + * @author Apache Software Foundation + * @version $Id: Hex.java 1157192 2011-08-12 17:27:38Z ggregory $ + * @since 1.1 + */ +public class Hex { + + /** + * Used to build output as Hex + */ + private static final char[] DIGITS_LOWER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', + 'e', 'f'}; + + /** + * Used to build output as Hex + */ + private static final char[] DIGITS_UPPER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', + 'E', 'F'}; + + /** + * Converts an array of characters representing hexadecimal values into an array of bytes of those same values. The + * returned array will be half the length of the passed array, as it takes two characters to represent any given + * byte. An exception is thrown if the passed char array has an odd number of elements. + * + * @param data An array of characters containing hexadecimal digits + * @return A byte array containing binary data decoded from the supplied char array. + * @throws IOException Thrown if an odd number or illegal of characters is supplied + */ + public static byte[] decodeHex(char[] data) throws IOException { + + int len = data.length; + + if ((len & 0x01) != 0) { + throw new IOException("Odd number of characters."); + } + + byte[] out = new byte[len >> 1]; + + // two characters form the hex value. + for (int i = 0, j = 0; j < len; i++) { + int f = toDigit(data[j], j) << 4; + j++; + f = f | toDigit(data[j], j); + j++; + out[i] = (byte) (f & 0xFF); + } + + return out; + } + + /** + * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order. + * The returned array will be double the length of the passed array, as it takes two characters to represent any + * given byte. + * + * @param data a byte[] to convert to Hex characters + * @param toLowerCase <code>true</code> converts to lowercase, <code>false</code> to uppercase + * @return A char[] containing hexadecimal characters + * @since 1.4 + */ + public static char[] encodeHex(byte[] data, boolean toLowerCase) { + return encodeHex(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER); + } + + /** + * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order. + * The returned array will be double the length of the passed array, as it takes two characters to represent any + * given byte. + * + * @param data a byte[] to convert to Hex characters + * @param toDigits the output alphabet + * @return A char[] containing hexadecimal characters + * @since 1.4 + */ + protected static char[] encodeHex(byte[] data, char[] toDigits) { + int l = data.length; + char[] out = new char[l << 1]; + // two characters form the hex value. + for (int i = 0, j = 0; i < l; i++) { + out[j++] = toDigits[(0xF0 & data[i]) >>> 4]; + out[j++] = toDigits[0x0F & data[i]]; + } + return out; + } + + /** + * Converts a hexadecimal character to an integer. + * + * @param ch A character to convert to an integer digit + * @param index The index of the character in the source + * @return An integer + * @throws IOException Thrown if ch is an illegal hex character + */ + protected static int toDigit(char ch, int index) throws IOException { + int digit = Character.digit(ch, 16); + if (digit == -1) { + throw new IOException("Illegal hexadecimal character " + ch + " at index " + index); + } + return digit; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cb1ba468/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/DebugInfoBody.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/DebugInfoBody.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/DebugInfoBody.java index 4954c75..696234f 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/DebugInfoBody.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/debug/DebugInfoBody.java @@ -32,11 +32,11 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -import org.apache.commons.codec.binary.Base64; import org.apache.olingo.odata2.api.commons.HttpContentType; import org.apache.olingo.odata2.api.ep.EntityProviderException; import org.apache.olingo.odata2.api.processor.ODataResponse; import org.apache.olingo.odata2.core.ep.BasicEntityProvider; +import org.apache.olingo.odata2.core.commons.Base64; import org.apache.olingo.odata2.core.ep.util.JsonStreamWriter; import com.google.gson.GsonBuilder; http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cb1ba468/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmBinary.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmBinary.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmBinary.java index 9922cb0..81f86d5 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmBinary.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/EdmBinary.java @@ -18,12 +18,13 @@ ******************************************************************************/ package org.apache.olingo.odata2.core.edm; -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.codec.binary.Hex; import org.apache.olingo.odata2.api.edm.EdmFacets; import org.apache.olingo.odata2.api.edm.EdmLiteralKind; import org.apache.olingo.odata2.api.edm.EdmSimpleTypeException; +import org.apache.olingo.odata2.core.commons.Base64; +import org.apache.olingo.odata2.core.commons.Hex; + +import java.io.IOException; /** * Implementation of the EDM simple type Binary. @@ -102,7 +103,7 @@ public class EdmBinary extends AbstractSimpleType { if (literalKind == EdmLiteralKind.URI) { try { result = Hex.decodeHex(value.substring(value.startsWith("X") ? 2 : 7, value.length() - 1).toCharArray()); - } catch (final DecoderException e) { + } catch (final IOException e) { throw new EdmSimpleTypeException(EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value), e); } } else { http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cb1ba468/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java index 0221dcb..0188741 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java @@ -18,31 +18,24 @@ ******************************************************************************/ package org.apache.olingo.odata2.core.edm.provider; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.List; - import org.apache.olingo.odata2.api.ODataServiceVersion; import org.apache.olingo.odata2.api.edm.EdmEntitySetInfo; import org.apache.olingo.odata2.api.edm.EdmServiceMetadata; -import org.apache.olingo.odata2.api.edm.provider.DataServices; -import org.apache.olingo.odata2.api.edm.provider.EdmProvider; -import org.apache.olingo.odata2.api.edm.provider.EntityContainer; -import org.apache.olingo.odata2.api.edm.provider.EntitySet; -import org.apache.olingo.odata2.api.edm.provider.EntityType; -import org.apache.olingo.odata2.api.edm.provider.Property; -import org.apache.olingo.odata2.api.edm.provider.Schema; +import org.apache.olingo.odata2.api.edm.provider.*; import org.apache.olingo.odata2.api.ep.EntityProviderException; import org.apache.olingo.odata2.api.exception.ODataException; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.ep.producer.XmlMetadataProducer; import org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer; -import org.apache.olingo.odata2.api.xml.XMLStreamException; -import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.xml.XmlStreamFactory; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; + /** * */ http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cb1ba468/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java index 8d830f0..85fe7dd 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java @@ -18,29 +18,11 @@ ******************************************************************************/ package org.apache.olingo.odata2.core.ep; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.nio.charset.Charset; -import java.util.List; -import java.util.Map; - -import javax.xml.stream.FactoryConfigurationError; - import org.apache.olingo.odata2.api.ODataServiceVersion; import org.apache.olingo.odata2.api.commons.HttpContentType; import org.apache.olingo.odata2.api.commons.HttpStatusCodes; import org.apache.olingo.odata2.api.commons.ODataHttpHeaders; -import org.apache.olingo.odata2.api.edm.EdmException; -import org.apache.olingo.odata2.api.edm.EdmLiteralKind; -import org.apache.olingo.odata2.api.edm.EdmProperty; -import org.apache.olingo.odata2.api.edm.EdmSimpleType; -import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; +import org.apache.olingo.odata2.api.edm.*; import org.apache.olingo.odata2.api.edm.provider.DataServices; import org.apache.olingo.odata2.api.edm.provider.EntityType; import org.apache.olingo.odata2.api.edm.provider.Property; @@ -48,12 +30,17 @@ import org.apache.olingo.odata2.api.edm.provider.Schema; import org.apache.olingo.odata2.api.ep.EntityProviderException; import org.apache.olingo.odata2.api.processor.ODataResponse; import org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.ep.producer.XmlMetadataProducer; import org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer; -import org.apache.olingo.odata2.api.xml.XMLStreamException; -import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.xml.XmlStreamFactory; +import javax.xml.stream.FactoryConfigurationError; +import java.io.*; +import java.nio.charset.Charset; +import java.util.List; +import java.util.Map; + /** * Provider for all basic (content type independent) entity provider methods. * http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cb1ba468/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/DebugInfoBodyTest.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/DebugInfoBodyTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/DebugInfoBodyTest.java index 0d99059..453a220 100644 --- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/DebugInfoBodyTest.java +++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/debug/DebugInfoBodyTest.java @@ -27,9 +27,9 @@ import java.io.IOException; import java.io.StringWriter; import java.io.Writer; -import org.apache.commons.codec.binary.Base64; import org.apache.olingo.odata2.api.commons.HttpContentType; import org.apache.olingo.odata2.api.processor.ODataResponse; +import org.apache.olingo.odata2.core.commons.Base64; import org.apache.olingo.odata2.core.ep.util.JsonStreamWriter; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cb1ba468/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestTokenizer.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestTokenizer.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestTokenizer.java index 5be6fc3..560420b 100644 --- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestTokenizer.java +++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestTokenizer.java @@ -20,11 +20,12 @@ package org.apache.olingo.odata2.core.uri.expression; import static org.junit.Assert.fail; -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.codec.binary.Hex; +import org.apache.olingo.odata2.core.commons.Base64; +import org.apache.olingo.odata2.core.commons.Hex; import org.junit.Test; +import java.io.IOException; + public class TestTokenizer { @Test @@ -73,7 +74,7 @@ public class TestTokenizer { try { bArr = Hex.decodeHex(hex.toCharArray()); base64 = Base64.encodeBase64String(bArr); - } catch (DecoderException e) { + } catch (IOException e) { fail("Error in Unittest preparation ( HEX->base64"); } return base64; http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cb1ba468/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/xml/JavaxStaxStreamFactoryTest.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/xml/JavaxStaxStreamFactoryTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/xml/JavaxStaxStreamFactoryTest.java index ba93731..c12ef69 100644 --- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/xml/JavaxStaxStreamFactoryTest.java +++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/xml/JavaxStaxStreamFactoryTest.java @@ -20,29 +20,22 @@ package org.apache.olingo.odata2.core.xml; import junit.framework.Assert; import org.apache.olingo.odata2.api.edm.Edm; -import org.apache.olingo.odata2.api.edm.EdmEntitySet; -import org.apache.olingo.odata2.api.ep.EntityProvider; import org.apache.olingo.odata2.api.ep.EntityProviderException; -import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; -import org.apache.olingo.odata2.api.ep.entry.ODataEntry; -import org.apache.olingo.odata2.api.xml.XMLStreamConstants; -import org.apache.olingo.odata2.api.xml.XMLStreamException; import org.apache.olingo.odata2.api.xml.XMLStreamReader; import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.ep.AbstractXmlProducerTestHelper; import org.apache.olingo.odata2.testutil.helper.StringHelper; -import org.apache.olingo.odata2.testutil.mock.MockFacade; import org.custommonkey.xmlunit.SimpleNamespaceContext; import org.custommonkey.xmlunit.XMLUnit; import org.junit.Before; import org.junit.Test; -import java.io.*; -import java.util.Calendar; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.StringWriter; import java.util.HashMap; import java.util.Map; -import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static org.apache.olingo.odata2.api.xml.XMLStreamReaderFactory.XML_STREAM_READER_FACTORY_CLASS; import static org.apache.olingo.odata2.api.xml.XMLStreamWriterFactory.XML_STREAM_WRITER_FACTORY_CLASS; http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cb1ba468/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 910d2de..3460f2b 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,6 @@ <httpcore.version>4.2.3</httpcore.version> <slf4j.version>1.7.1</slf4j.version> <log4j.version>1.2.17</log4j.version> - <commonscodec.version>1.6</commonscodec.version> <commonslang.version>3.1</commonslang.version> <gson.version>2.2.2</gson.version>
