@@ -64,8 +64,7 @@ private void testBase58EmptyInputStream(final int chuckSize) throws Exception {
6464 /**
6565 * Tests the Base58InputStream implementation against empty input.
6666 *
67- * @throws Exception
68- * for some failure scenarios.
67+ * @throws Exception for some failure scenarios.
6968 */
7069 @ Test
7170 void testBase58EmptyInputStreamMimeChuckSize () throws Exception {
@@ -75,8 +74,7 @@ void testBase58EmptyInputStreamMimeChuckSize() throws Exception {
7574 /**
7675 * Tests the Base58InputStream implementation against empty input.
7776 *
78- * @throws Exception
79- * for some failure scenarios.
77+ * @throws Exception for some failure scenarios.
8078 */
8179 @ Test
8280 void testBase58EmptyInputStreamPemChuckSize () throws Exception {
@@ -89,7 +87,6 @@ void testBase58InputStreamByChunk() throws Exception {
8987 byte [] decoded = StringUtils .getBytesUtf8 (STRING_FIXTURE );
9088 byte [] encoded = new Base58 ().encode (decoded );
9189 testByChunk (encoded , decoded , BaseNCodec .MIME_CHUNK_SIZE , CRLF );
92-
9390 // test random data of sizes 0 through 150
9491 final BaseNCodec codec = new Base58 ();
9592 for (int i = 0 ; i <= 150 ; i ++) {
@@ -106,7 +103,6 @@ void testBase58InputStreamByteByByte() throws Exception {
106103 byte [] decoded = StringUtils .getBytesUtf8 (STRING_FIXTURE );
107104 byte [] encoded = new Base58 ().encode (decoded );
108105 testByteByByte (encoded , decoded , BaseNCodec .MIME_CHUNK_SIZE , CRLF );
109-
110106 // test random data of sizes 0 through 150
111107 final BaseNCodec codec = new Base58 ();
112108 for (int i = 0 ; i <= 150 ; i ++) {
@@ -126,38 +122,31 @@ void testBuilder() {
126122 * Tests method does three tests on the supplied data: 1. encoded ---[DECODE]--> decoded 2. decoded ---[ENCODE]--> encoded 3. decoded
127123 * ---[WRAP-WRAP-WRAP-etc...] --> decoded
128124 * <p/>
129- * By "[WRAP-WRAP-WRAP-etc...]" we mean situation where the Base58InputStream wraps itself in encode and decode mode over and over
130- * again.
125+ * By "[WRAP-WRAP-WRAP-etc...]" we mean situation where the Base58InputStream wraps itself in encode and decode mode over and over again.
131126 *
132- * @param encoded
133- * base58 encoded data
134- * @param decoded
135- * the data from above, but decoded
136- * @param chunkSize
137- * chunk size (line-length) of the base58 encoded data.
138- * @param separator
139- * Line separator in the base58 encoded data.
140- * @throws Exception
141- * Usually signifies a bug in the Base58 commons-codec implementation.
127+ * @param encoded base58 encoded data
128+ * @param decoded the data from above, but decoded
129+ * @param chunkSize chunk size (line-length) of the base58 encoded data.
130+ * @param separator Line separator in the base58 encoded data.
131+ * @throws Exception Usually signifies a bug in the Base58 commons-codec implementation.
142132 */
143133 private void testByChunk (final byte [] encoded , final byte [] decoded , final int chunkSize , final byte [] separator ) throws Exception {
144- try (InputStream in = new Base58InputStream ( new ByteArrayInputStream (decoded ), true )) {
134+ try (InputStream in = Base58InputStream . builder (). setInputStream ( new ByteArrayInputStream (decoded )). setEncode ( true ). get ( )) {
145135 final byte [] output = BaseNTestData .streamToBytes (in );
146136 assertEquals (-1 , in .read (), "EOF" );
147137 assertEquals (-1 , in .read (), "Still EOF" );
148138 assertArrayEquals (encoded , output , "Streaming base58 encode" );
149139 }
150140 try (InputStream in = new Base58InputStream (new ByteArrayInputStream (encoded ))) {
151141 final byte [] output = BaseNTestData .streamToBytes (in );
152-
153142 assertEquals (-1 , in .read (), "EOF" );
154143 assertEquals (-1 , in .read (), "Still EOF" );
155144 assertArrayEquals (decoded , output , "Streaming base58 decode" );
156145 }
157146 InputStream in = new ByteArrayInputStream (decoded );
158147 for (int i = 0 ; i < 10 ; i ++) {
159- in = new Base58InputStream ( in , true );
160- in = new Base58InputStream ( in , false );
148+ in = Base58InputStream . builder (). setInputStream ( in ). setEncode ( true ). get ( );
149+ in = Base58InputStream . builder (). setInputStream ( in ). setEncode ( false ). get ( );
161150 }
162151 final byte [] output = BaseNTestData .streamToBytes (in );
163152 assertEquals (-1 , in .read (), "EOF" );
@@ -170,45 +159,34 @@ private void testByChunk(final byte[] encoded, final byte[] decoded, final int c
170159 * Tests method does three tests on the supplied data: 1. encoded ---[DECODE]--> decoded 2. decoded ---[ENCODE]--> encoded 3. decoded
171160 * ---[WRAP-WRAP-WRAP-etc...] --> decoded
172161 * <p/>
173- * By "[WRAP-WRAP-WRAP-etc...]" we mean situation where the Base58InputStream wraps itself in encode and decode mode over and over
174- * again.
162+ * By "[WRAP-WRAP-WRAP-etc...]" we mean situation where the Base58InputStream wraps itself in encode and decode mode over and over again.
175163 *
176- * @param encoded
177- * base58 encoded data
178- * @param decoded
179- * the data from above, but decoded
180- * @param chunkSize
181- * chunk size (line-length) of the base58 encoded data.
182- * @param separator
183- * Line separator in the base58 encoded data.
184- * @throws Exception
185- * Usually signifies a bug in the Base58 commons-codec implementation.
164+ * @param encoded base58 encoded data
165+ * @param decoded the data from above, but decoded
166+ * @param chunkSize chunk size (line-length) of the base58 encoded data.
167+ * @param separator Line separator in the base58 encoded data.
168+ * @throws Exception Usually signifies a bug in the Base58 commons-codec implementation.
186169 */
187170 private void testByteByByte (final byte [] encoded , final byte [] decoded , final int chunkSize , final byte [] separator ) throws Exception {
188171 InputStream in ;
189- in = new Base58InputStream ( new ByteArrayInputStream (decoded ), true );
172+ in = Base58InputStream . builder (). setInputStream ( new ByteArrayInputStream (decoded )). setEncode ( true ). get ( );
190173 byte [] output = BaseNTestData .streamToBytes (in );
191-
192174 assertEquals (-1 , in .read (), "EOF" );
193175 assertEquals (-1 , in .read (), "Still EOF" );
194176 assertArrayEquals (encoded , output , "Streaming base58 encode" );
195-
196177 in .close ();
197178 in = new Base58InputStream (new ByteArrayInputStream (encoded ));
198179 output = BaseNTestData .streamToBytes (in );
199-
200180 assertEquals (-1 , in .read (), "EOF" );
201181 assertEquals (-1 , in .read (), "Still EOF" );
202182 assertArrayEquals (decoded , output , "Streaming base58 decode" );
203-
204183 in .close ();
205184 in = new ByteArrayInputStream (decoded );
206185 for (int i = 0 ; i < 10 ; i ++) {
207- in = new Base58InputStream ( in , true );
208- in = new Base58InputStream ( in , false );
186+ in = Base58InputStream . builder (). setInputStream ( in ). setEncode ( true ). get ( );
187+ in = Base58InputStream . builder (). setInputStream ( in ). setEncode ( false ). get ( );
209188 }
210189 output = BaseNTestData .streamToBytes (in );
211-
212190 assertEquals (-1 , in .read (), "EOF" );
213191 assertEquals (-1 , in .read (), "Still EOF" );
214192 assertArrayEquals (decoded , output , "Streaming base58 wrap-wrap-wrap!" );
@@ -217,14 +195,13 @@ private void testByteByByte(final byte[] encoded, final byte[] decoded, final in
217195 /**
218196 * Tests markSupported.
219197 *
220- * @throws Exception
221- * for some failure scenarios.
198+ * @throws Exception for some failure scenarios.
222199 */
223200 @ Test
224201 void testMarkSupported () throws Exception {
225202 final byte [] decoded = StringUtils .getBytesUtf8 (STRING_FIXTURE );
226203 final ByteArrayInputStream bin = new ByteArrayInputStream (decoded );
227- try (Base58InputStream in = new Base58InputStream ( bin , true )) {
204+ try (Base58InputStream in = Base58InputStream . builder (). setInputStream ( bin ). setEncode ( true ). get ( )) {
228205 // Always returns false for now.
229206 assertFalse (in .markSupported (), "Base58InputStream.markSupported() is false" );
230207 }
@@ -233,16 +210,15 @@ void testMarkSupported() throws Exception {
233210 /**
234211 * Tests read returning 0
235212 *
236- * @throws Exception
237- * for some failure scenarios.
213+ * @throws Exception for some failure scenarios.
238214 */
239215 @ Test
240216 void testRead0 () throws Exception {
241217 final byte [] decoded = StringUtils .getBytesUtf8 (STRING_FIXTURE );
242218 final byte [] buf = new byte [1024 ];
243219 int bytesRead = 0 ;
244220 final ByteArrayInputStream bin = new ByteArrayInputStream (decoded );
245- try (Base58InputStream in = new Base58InputStream ( bin , true )) {
221+ try (Base58InputStream in = Base58InputStream . builder (). setInputStream ( bin ). setEncode ( true ). get ( )) {
246222 bytesRead = in .read (buf , 0 , 0 );
247223 assertEquals (0 , bytesRead , "Base58InputStream.read(buf, 0, 0) returns 0" );
248224 }
@@ -251,30 +227,28 @@ void testRead0() throws Exception {
251227 /**
252228 * Tests read with null.
253229 *
254- * @throws Exception
255- * for some failure scenarios.
230+ * @throws Exception for some failure scenarios.
256231 */
257232 @ Test
258233 void testReadNull () throws Exception {
259234 final byte [] decoded = StringUtils .getBytesUtf8 (STRING_FIXTURE );
260235 final ByteArrayInputStream bin = new ByteArrayInputStream (decoded );
261- try (Base58InputStream in = new Base58InputStream ( bin , true )) {
236+ try (Base58InputStream in = Base58InputStream . builder (). setInputStream ( bin ). setEncode ( true ). get ( )) {
262237 assertThrows (NullPointerException .class , () -> in .read (null , 0 , 0 ));
263238 }
264239 }
265240
266241 /**
267242 * Tests read throwing IndexOutOfBoundsException
268243 *
269- * @throws Exception
270- * for some failure scenarios.
244+ * @throws Exception for some failure scenarios.
271245 */
272246 @ Test
273247 void testReadOutOfBounds () throws Exception {
274248 final byte [] decoded = StringUtils .getBytesUtf8 (STRING_FIXTURE );
275249 final byte [] buf = new byte [1024 ];
276250 final ByteArrayInputStream bin = new ByteArrayInputStream (decoded );
277- try (Base58InputStream in = new Base58InputStream ( bin , true )) {
251+ try (Base58InputStream in = Base58InputStream . builder (). setInputStream ( bin ). setEncode ( true ). get ( )) {
278252 assertThrows (IndexOutOfBoundsException .class , () -> in .read (buf , -1 , 0 ), "Base58InputStream.read(buf, -1, 0)" );
279253 assertThrows (IndexOutOfBoundsException .class , () -> in .read (buf , 0 , -1 ), "Base58InputStream.read(buf, 0, -1)" );
280254 assertThrows (IndexOutOfBoundsException .class , () -> in .read (buf , buf .length + 1 , 0 ), "Base58InputStream.read(buf, buf.length + 1, 0)" );
@@ -285,8 +259,7 @@ void testReadOutOfBounds() throws Exception {
285259 /**
286260 * Tests skipping number of characters larger than the internal buffer.
287261 *
288- * @throws Throwable
289- * for some failure scenarios.
262+ * @throws Throwable for some failure scenarios.
290263 */
291264 @ Test
292265 void testSkipBig () throws Throwable {
@@ -303,8 +276,7 @@ void testSkipBig() throws Throwable {
303276 /**
304277 * Tests skipping as a noop
305278 *
306- * @throws Throwable
307- * for some failure scenarios.
279+ * @throws Throwable for some failure scenarios.
308280 */
309281 @ Test
310282 void testSkipNone () throws Throwable {
@@ -323,8 +295,7 @@ void testSkipNone() throws Throwable {
323295 /**
324296 * Tests skipping past the end of a stream.
325297 *
326- * @throws Throwable
327- * for some failure scenarios.
298+ * @throws Throwable for some failure scenarios.
328299 */
329300 @ Test
330301 void testSkipPastEnd () throws Throwable {
@@ -342,8 +313,7 @@ void testSkipPastEnd() throws Throwable {
342313 /**
343314 * Tests skipping to the end of a stream.
344315 *
345- * @throws Throwable
346- * for some failure scenarios.
316+ * @throws Throwable for some failure scenarios.
347317 */
348318 @ Test
349319 void testSkipToEnd () throws Throwable {
@@ -359,8 +329,7 @@ void testSkipToEnd() throws Throwable {
359329 /**
360330 * Tests if negative arguments to skip are handled correctly.
361331 *
362- * @throws Throwable
363- * for some failure scenarios.
332+ * @throws Throwable for some failure scenarios.
364333 */
365334 @ Test
366335 void testSkipWrongArgument () throws Throwable {
0 commit comments