@@ -17,6 +17,7 @@ public class Base64Test {
17
17
private byte []helloWorldTwoLinesAndNewLineBytes ;
18
18
private byte []helloWorldDifferentCharsBytes ;
19
19
private byte []bytes ;
20
+ private byte []allBytes ;
20
21
21
22
@ Before
22
23
public void setUp ()throws UnsupportedEncodingException {
@@ -55,6 +56,19 @@ public void setUp() throws UnsupportedEncodingException {
55
56
103 ,73 , -30 ,120 , -15 ,104 , -9 ,110 , -24 , -127 ,14 , -57 , -44 ,67 ,9 ,80 ,120 ,42 ,94 ,107 , -81 , -109 ,101 ,
56
57
-1 ,91 };
57
58
59
+ allBytes =new byte []{-128 , -127 , -126 , -125 , -124 , -123 , -122 , -121 , -120 , -119 , -118 , -117 , -116 , -115 , -114 ,
60
+ -113 , -112 , -111 , -110 , -109 , -108 , -107 , -106 , -105 , -104 , -103 , -102 , -101 , -100 , -99 , -98 , -97 , -96 , -95 ,
61
+ -94 , -93 , -92 , -91 , -90 , -89 , -88 , -87 , -86 , -85 , -84 , -83 , -82 , -81 , -80 , -79 , -78 , -77 , -76 , -75 , -74 ,
62
+ -73 , -72 , -71 , -70 , -69 , -68 , -67 , -66 , -65 , -64 , -63 , -62 , -61 , -60 , -59 , -58 , -57 , -56 , -55 , -54 , -53 ,
63
+ -52 , -51 , -50 , -49 , -48 , -47 , -46 , -45 , -44 , -43 , -42 , -41 , -40 , -39 , -38 , -37 , -36 , -35 , -34 , -33 , -32 ,
64
+ -31 , -30 , -29 , -28 , -27 , -26 , -25 , -24 , -23 , -22 , -21 , -20 , -19 , -18 , -17 , -16 , -15 , -14 , -13 , -12 , -11 ,
65
+ -10 , -9 , -8 , -7 , -6 , -5 , -4 , -3 , -2 , -1 ,0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,
66
+ 19 ,20 ,21 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,40 ,41 ,42 ,43 ,44 ,45 ,
67
+ 46 ,47 ,48 ,49 ,50 ,51 ,52 ,53 ,54 ,55 ,56 ,57 ,58 ,59 ,60 ,61 ,62 ,63 ,64 ,65 ,66 ,67 ,68 ,69 ,70 ,71 ,72 ,
68
+ 73 ,74 ,75 ,76 ,77 ,78 ,79 ,80 ,81 ,82 ,83 ,84 ,85 ,86 ,87 ,88 ,89 ,90 ,91 ,92 ,93 ,94 ,95 ,96 ,97 ,98 ,99 ,
69
+ 100 ,101 ,102 ,103 ,104 ,105 ,106 ,107 ,108 ,109 ,110 ,111 ,112 ,113 ,114 ,115 ,116 ,117 ,118 ,119 ,120 ,
70
+ 121 ,122 ,123 ,124 ,125 ,126 ,127 };
71
+
58
72
java8Base64 =new Java8Base64 ();
59
73
commonsCodecBase64 =new CommonsCodecBase64 ();
60
74
jaxbBase64 =new JaxbBase64 ();
@@ -93,32 +107,41 @@ public void testEncode() {
93
107
+"wJ3juUsVtujV23SnH43iMggXT7m82STpPGam1hPfmqu2Z0niePFo927ogQ7H1EMJ"
94
108
+"UHgqXmuvk2X/Ww==" ;
95
109
110
+ final String allBytesStr ="gIGCg4SFhoeIiYqLjI2Oj5CRkpOUlZaXmJmam5ydnp+goaKjpKWmp6ipqqusra6vsLGys7S1tre4ubq7vL2"
111
+ +"+v8DBwsPExcbHyMnKy8zNzs/Q0dLT1NXW19jZ2tvc3d7f4OHi4+Tl5ufo6err7O3u7/Dx8vP09fb3+Pn6+/z9/v8AAQIDBAUGBwg"
112
+ +"JCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSYnKCkqKywtLi8wMTIzNDU2Nzg5Ojs8PT4/QEFCQ0RFRkdISUpLTE1OT1BRUlN"
113
+ +"UVVZXWFlaW1xdXl9gYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXp7fH1+fw==" ;
114
+
96
115
assertEquals (helloWorldEncoded ,java8Base64 .internalEncode (helloWorldBytes ));
97
116
assertEquals (helloWorldTwoLinesEncoded ,java8Base64 .internalEncode (helloWorldTwoLinesBytes ));
98
117
assertEquals (helloWorldTwoLinesAndNewLineEncoded ,
99
118
java8Base64 .internalEncode (helloWorldTwoLinesAndNewLineBytes ));
100
119
assertEquals (helloWorldDifferentCharsEncoded ,java8Base64 .internalEncode (helloWorldDifferentCharsBytes ));
101
120
assertEquals (str ,java8Base64 .internalEncode (bytes ));
121
+ assertEquals (allBytesStr ,java8Base64 .internalEncode (allBytes ));
102
122
103
123
assertEquals (helloWorldEncoded ,commonsCodecBase64 .internalEncode (helloWorldBytes ));
104
124
assertEquals (helloWorldTwoLinesEncoded ,commonsCodecBase64 .internalEncode (helloWorldTwoLinesBytes ));
105
125
assertEquals (helloWorldTwoLinesAndNewLineEncoded ,
106
126
commonsCodecBase64 .internalEncode (helloWorldTwoLinesAndNewLineBytes ));
107
127
assertEquals (helloWorldDifferentCharsEncoded ,commonsCodecBase64 .internalEncode (helloWorldDifferentCharsBytes ));
108
128
assertEquals (str ,commonsCodecBase64 .internalEncode (bytes ));
129
+ assertEquals (allBytesStr ,commonsCodecBase64 .internalEncode (allBytes ));
109
130
110
131
assertEquals (helloWorldEncoded ,jaxbBase64 .internalEncode (helloWorldBytes ));
111
132
assertEquals (helloWorldTwoLinesEncoded ,jaxbBase64 .internalEncode (helloWorldTwoLinesBytes ));
112
133
assertEquals (helloWorldTwoLinesAndNewLineEncoded ,jaxbBase64 .internalEncode (helloWorldTwoLinesAndNewLineBytes ));
113
134
assertEquals (helloWorldDifferentCharsEncoded ,jaxbBase64 .internalEncode (helloWorldDifferentCharsBytes ));
114
135
assertEquals (str ,jaxbBase64 .internalEncode (bytes ));
136
+ assertEquals (allBytesStr ,jaxbBase64 .internalEncode (allBytes ));
115
137
116
138
assertEquals (helloWorldEncoded ,jaxb230Base64 .internalEncode (helloWorldBytes ));
117
139
assertEquals (helloWorldTwoLinesEncoded ,jaxb230Base64 .internalEncode (helloWorldTwoLinesBytes ));
118
140
assertEquals (helloWorldTwoLinesAndNewLineEncoded ,
119
141
jaxb230Base64 .internalEncode (helloWorldTwoLinesAndNewLineBytes ));
120
142
assertEquals (helloWorldDifferentCharsEncoded ,jaxb230Base64 .internalEncode (helloWorldDifferentCharsBytes ));
121
143
assertEquals (str ,jaxb230Base64 .internalEncode (bytes ));
144
+ assertEquals (allBytesStr ,jaxb230Base64 .internalEncode (allBytes ));
122
145
}
123
146
124
147
@ Test
@@ -145,13 +168,19 @@ public void testEncodeUrlWithoutPadding() {
145
168
+"wJ3juUsVtujV23SnH43iMggXT7m82STpPGam1hPfmqu2Z0niePFo927ogQ7H1EMJ"
146
169
+"UHgqXmuvk2X_Ww" ;
147
170
171
+ final String allBytesStr ="gIGCg4SFhoeIiYqLjI2Oj5CRkpOUlZaXmJmam5ydnp-goaKjpKWmp6ipqqusra6vsLGys7S1tre4ubq7vL2"
172
+ +"-v8DBwsPExcbHyMnKy8zNzs_Q0dLT1NXW19jZ2tvc3d7f4OHi4-Tl5ufo6err7O3u7_Dx8vP09fb3-Pn6-_z9_v8AAQIDBAUGBwg"
173
+ +"JCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSYnKCkqKywtLi8wMTIzNDU2Nzg5Ojs8PT4_QEFCQ0RFRkdISUpLTE1OT1BRUlN"
174
+ +"UVVZXWFlaW1xdXl9gYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXp7fH1-fw" ;
175
+
148
176
assertEquals (helloWorldEncoded ,java8Base64 .internalEncodeUrlWithoutPadding (helloWorldBytes ));
149
177
assertEquals (helloWorldTwoLinesEncoded ,java8Base64 .internalEncodeUrlWithoutPadding (helloWorldTwoLinesBytes ));
150
178
assertEquals (helloWorldTwoLinesAndNewLineEncoded ,
151
179
java8Base64 .internalEncodeUrlWithoutPadding (helloWorldTwoLinesAndNewLineBytes ));
152
180
assertEquals (helloWorldDifferentCharsEncoded ,
153
181
java8Base64 .internalEncodeUrlWithoutPadding (helloWorldDifferentCharsBytes ));
154
182
assertEquals (str ,java8Base64 .internalEncodeUrlWithoutPadding (bytes ));
183
+ assertEquals (allBytesStr ,java8Base64 .internalEncodeUrlWithoutPadding (allBytes ));
155
184
156
185
assertEquals (helloWorldEncoded ,commonsCodecBase64 .internalEncodeUrlWithoutPadding (helloWorldBytes ));
157
186
assertEquals (helloWorldTwoLinesEncoded ,
@@ -161,6 +190,7 @@ public void testEncodeUrlWithoutPadding() {
161
190
assertEquals (helloWorldDifferentCharsEncoded ,
162
191
commonsCodecBase64 .internalEncodeUrlWithoutPadding (helloWorldDifferentCharsBytes ));
163
192
assertEquals (str ,commonsCodecBase64 .internalEncodeUrlWithoutPadding (bytes ));
193
+ assertEquals (allBytesStr ,commonsCodecBase64 .internalEncodeUrlWithoutPadding (allBytes ));
164
194
165
195
assertEquals (helloWorldEncoded ,jaxbBase64 .internalEncodeUrlWithoutPadding (helloWorldBytes ));
166
196
assertEquals (helloWorldTwoLinesEncoded ,jaxbBase64 .internalEncodeUrlWithoutPadding (helloWorldTwoLinesBytes ));
@@ -169,6 +199,7 @@ public void testEncodeUrlWithoutPadding() {
169
199
assertEquals (helloWorldDifferentCharsEncoded ,
170
200
jaxbBase64 .internalEncodeUrlWithoutPadding (helloWorldDifferentCharsBytes ));
171
201
assertEquals (str ,jaxbBase64 .internalEncodeUrlWithoutPadding (bytes ));
202
+ assertEquals (allBytesStr ,jaxbBase64 .internalEncodeUrlWithoutPadding (allBytes ));
172
203
173
204
assertEquals (helloWorldEncoded ,jaxb230Base64 .internalEncodeUrlWithoutPadding (helloWorldBytes ));
174
205
assertEquals (helloWorldTwoLinesEncoded ,jaxb230Base64 .internalEncodeUrlWithoutPadding (helloWorldTwoLinesBytes ));
@@ -177,5 +208,6 @@ public void testEncodeUrlWithoutPadding() {
177
208
assertEquals (helloWorldDifferentCharsEncoded ,
178
209
jaxb230Base64 .internalEncodeUrlWithoutPadding (helloWorldDifferentCharsBytes ));
179
210
assertEquals (str ,jaxb230Base64 .internalEncodeUrlWithoutPadding (bytes ));
211
+ assertEquals (allBytesStr ,jaxb230Base64 .internalEncodeUrlWithoutPadding (allBytes ));
180
212
}
181
213
}