[OLINGO-318]client should base64encode edm.binary data, not as URLSafeString
This commit is contained in:
parent
80c2f83acc
commit
5959dfb02a
|
@ -19,6 +19,7 @@
|
||||||
package org.apache.olingo.commons.core.edm.primitivetype;
|
package org.apache.olingo.commons.core.edm.primitivetype;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.commons.codec.binary.StringUtils;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,6 +125,10 @@ public class EdmBinary extends SingletonPrimitiveType {
|
||||||
"EdmPrimitiveTypeException.VALUE_FACETS_NOT_MATCHED.addContent(value, facets)");
|
"EdmPrimitiveTypeException.VALUE_FACETS_NOT_MATCHED.addContent(value, facets)");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Base64.encodeBase64URLSafeString(byteArrayValue);
|
return base64EncodeToString(byteArrayValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String base64EncodeToString(byte[] bytes){
|
||||||
|
return StringUtils.newStringUtf8(Base64.encodeBase64(bytes, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,12 +66,12 @@ public class EdmBinaryTest extends PrimitiveTypeBaseTest {
|
||||||
public void valueToString() throws Exception {
|
public void valueToString() throws Exception {
|
||||||
final byte[] binary = new byte[]{(byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF};
|
final byte[] binary = new byte[]{(byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF};
|
||||||
|
|
||||||
assertEquals("qrvM3e7_", instance.valueToString(binary, null, null, null, null, null));
|
assertEquals("qrvM3e7/", instance.valueToString(binary, null, null, null, null, null));
|
||||||
|
|
||||||
assertEquals("qrvM3e7_", instance.valueToString(binary, null, 6, null, null, null));
|
assertEquals("qrvM3e7/", instance.valueToString(binary, null, 6, null, null, null));
|
||||||
assertEquals("qrvM3e7_", instance.valueToString(binary, null, Integer.MAX_VALUE, null, null, null));
|
assertEquals("qrvM3e7/", instance.valueToString(binary, null, Integer.MAX_VALUE, null, null, null));
|
||||||
|
|
||||||
assertEquals("qg", instance.valueToString(new Byte[]{new Byte((byte) 170)}, null, null, null, null, null));
|
assertEquals("qg==", instance.valueToString(new Byte[]{new Byte((byte) 170)}, null, null, null, null, null));
|
||||||
|
|
||||||
expectFacetsErrorInValueToString(instance, binary, null, 3, null, null, null);
|
expectFacetsErrorInValueToString(instance, binary, null, 3, null, null, null);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue