Class Base64SupportTest
- java.lang.Object
-
- net.shibboleth.utilities.java.support.codec.Base64SupportTest
-
public class Base64SupportTest extends Object
Base64Supportunit test.
-
-
Field Summary
Fields Modifier and Type Field Description private static StringCHUNCKED_ENCODED_TEXTprivate static StringEMPTY_STRINGEmpty string.private static StringINVALID_BASE64Invalid base64, should not produce a result.private static StringINVALID_BASE64_TRAILINGInvalid base64 string as it has invalid trailing digits.private static byte[]PLAIN_BYTESprivate static StringPLAIN_TEXTA plain text string to be encoded.private static StringUNCHUNCKED_ENCODED_BYTESprivate static StringUNCHUNCKED_ENCODED_TEXTEncoded version of the plain text.private static StringURLSAFE_UNCHUNCKED_ENCODED_BYTESprivate static StringURLSAFE_UNCHUNCKED_ENCODED_TEXT
-
Constructor Summary
Constructors Constructor Description Base64SupportTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsetUp()voidtestDecode()Test Base64 decoding content.voidtestDecodeInvalidInput()Test that an invalid base64 input string does not return a response, instead throwing aDecodingException.voidtestDecodeInvalidTrailingBitsInput()Test that when the last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible value, aDecodingExceptionis thrown.voidtestDecodeNullInput()Test a null string argument violates the method contract and throws aConstraintViolationException.voidtestDecodeURLSafe()Test Base64 decoding content.voidtestEmptyDecodedOutput()Test that an empty input produces a byte array of 0 length.voidtestEncode()Test Base64 encoding content.voidtestEncodeEmptyByteArray()Test encoding an empty byte array produces an empty string and does not throw any exceptions.voidtestEncodeNullInput()Test a null byte array argument violates the method contract and throws aConstraintViolationException.voidtestEncodeURLSafe()Test Base64 encoding content.
-
-
-
Field Detail
-
PLAIN_TEXT
private static final String PLAIN_TEXT
A plain text string to be encoded.- See Also:
- Constant Field Values
-
UNCHUNCKED_ENCODED_TEXT
private static final String UNCHUNCKED_ENCODED_TEXT
Encoded version of the plain text.- See Also:
- Constant Field Values
-
CHUNCKED_ENCODED_TEXT
private static final String CHUNCKED_ENCODED_TEXT
- See Also:
- Constant Field Values
-
URLSAFE_UNCHUNCKED_ENCODED_TEXT
private static final String URLSAFE_UNCHUNCKED_ENCODED_TEXT
- See Also:
- Constant Field Values
-
PLAIN_BYTES
private static byte[] PLAIN_BYTES
-
UNCHUNCKED_ENCODED_BYTES
private static final String UNCHUNCKED_ENCODED_BYTES
- See Also:
- Constant Field Values
-
URLSAFE_UNCHUNCKED_ENCODED_BYTES
private static final String URLSAFE_UNCHUNCKED_ENCODED_BYTES
- See Also:
- Constant Field Values
-
INVALID_BASE64_TRAILING
private static final String INVALID_BASE64_TRAILING
Invalid base64 string as it has invalid trailing digits. Correctly fails with commons-codec 1.14 and greater.- See Also:
- CODEC-270, Constant Field Values
-
INVALID_BASE64
private static final String INVALID_BASE64
Invalid base64, should not produce a result.- See Also:
- Constant Field Values
-
EMPTY_STRING
private static final String EMPTY_STRING
Empty string.- See Also:
- Constant Field Values
-
-
Method Detail
-
setUp
@BeforeClass public void setUp() throws org.apache.commons.codec.DecoderException- Throws:
org.apache.commons.codec.DecoderException
-
testEncode
public void testEncode() throws EncodingExceptionTest Base64 encoding content.- Throws:
EncodingException- on encoding failure
-
testEncodeEmptyByteArray
public void testEncodeEmptyByteArray() throws EncodingExceptionTest encoding an empty byte array produces an empty string and does not throw any exceptions.- Throws:
EncodingException- on encoding failure. Should not happen.
-
testEncodeNullInput
public void testEncodeNullInput() throws EncodingExceptionTest a null byte array argument violates the method contract and throws aConstraintViolationException.- Throws:
EncodingException- on encoding failure.
-
testDecodeNullInput
public void testDecodeNullInput() throws DecodingExceptionTest a null string argument violates the method contract and throws aConstraintViolationException.- Throws:
DecodingException- on decoding failure.
-
testDecode
public void testDecode() throws DecodingExceptionTest Base64 decoding content.- Throws:
DecodingException- on decoding failure.
-
testDecodeInvalidInput
public void testDecodeInvalidInput() throws DecodingExceptionTest that an invalid base64 input string does not return a response, instead throwing aDecodingException.- Throws:
DecodingException- on decoding failure.
-
testEmptyDecodedOutput
public void testEmptyDecodedOutput() throws DecodingExceptionTest that an empty input produces a byte array of 0 length.- Throws:
DecodingException- on decoding failure.
-
testDecodeInvalidTrailingBitsInput
public void testDecodeInvalidTrailingBitsInput() throws DecodingExceptionTest that when the last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible value, aDecodingExceptionis thrown.- Throws:
DecodingException- on decoding failure.
-
testEncodeURLSafe
public void testEncodeURLSafe() throws EncodingExceptionTest Base64 encoding content.- Throws:
EncodingException- thrown if failure to base64 encode
-
testDecodeURLSafe
public void testDecodeURLSafe() throws DecodingExceptionTest Base64 decoding content.- Throws:
DecodingException- on decoding failure.
-
-