out.write(buf, -1, 1); fail("Expected Base32OutputStream.write(buf, -1, 1) to throw a IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException ioobe) { out.write(buf, 1, -1); fail("Expected Base32OutputStream.write(buf, 1, -1) to throw a IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException ioobe) { out.write(buf, buf.length + 1, 0); fail("Expected Base32OutputStream.write(buf, buf.length + 1, 0) to throw a IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException ioobe) { out.write(buf, buf.length - 1, 2); fail("Expected Base32OutputStream.write(buf, buf.length - 1, 2) to throw a IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException ioobe) {
/** * Tests Base32OutputStream.write(null). * * @throws Exception * for some failure scenarios. */ @Test public void testWriteToNullCoverage() throws Exception { final ByteArrayOutputStream bout = new ByteArrayOutputStream(); final Base32OutputStream out = new Base32OutputStream(bout); try { out.write(null, 0, 0); fail("Expcted Base32OutputStream.write(null) to throw a NullPointerException"); } catch (final NullPointerException e) { // Expected } out.close(); }
/** * Tests the problem reported in CODEC-130. Missing / wrong implementation of skip. */ @Test public void testCodec130() throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final Base32OutputStream base32os = new Base32OutputStream(bos); base32os.write(StringUtils.getBytesUtf8(STRING_FIXTURE)); base32os.close(); final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); final Base32InputStream ins = new Base32InputStream(bis); // we skip the first character read from the reader ins.skip(1); final byte[] decodedBytes = Base32TestData.streamToBytes(ins, new byte[64]); final String str = StringUtils.newStringUtf8(decodedBytes); assertEquals(STRING_FIXTURE.substring(1), str); }