Skip to content

Commit

Permalink
(#28) Added getAsciiStream implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
svettwer committed Mar 11, 2019
1 parent 1e18d47 commit 1096e91
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.consol.citrus.db.driver.data;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
Expand Down Expand Up @@ -37,18 +38,14 @@ public String getSubString(final long pos, final int length) {
return null;
}

private long applyOffset(long pos) {
return pos - 1;
}

@Override
public Reader getCharacterStream() {
return new StringReader(stringBuilder.toString());
}

@Override
public InputStream getAsciiStream() throws SQLException {
return null;
public InputStream getAsciiStream() {
return new ByteArrayInputStream(stringBuilder.toString().getBytes());
}

@Override
Expand Down Expand Up @@ -126,4 +123,8 @@ public final int hashCode() {
private boolean fitsInInt(final long value) {
return (int)value == value;
}

private long applyOffset(final long pos) {
return pos - 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.io.InputStream;
import java.nio.charset.Charset;
import java.sql.Clob;
import java.sql.SQLException;

Expand Down Expand Up @@ -86,6 +88,20 @@ public void testSubStringWithLongPositionReturnsNull() throws SQLException {
assertNull(subString);
}

@Test
public void testGetAsciiStream() throws Exception{

//GIVEN
citrusClob.setString(1, sampleText);

//WHEN
final InputStream asciiStream = citrusClob.getAsciiStream();

//THEN
final String clob = IOUtils.toString(asciiStream, Charset.forName("UTF8"));
assertEquals(clob, sampleText);
}

@Test
public void testEqualsContract(){
final StringBuilder one = new StringBuilder();
Expand Down

0 comments on commit 1096e91

Please sign in to comment.