Skip to content

Commit

Permalink
(citrusframework/citrus-db#28) Added getBlob to JdbcResultSet + Alter…
Browse files Browse the repository at this point in the history
…ed Blob IT
  • Loading branch information
svettwer committed Apr 12, 2019
1 parent 8ee4c03 commit 8a7f079
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.consol.citrus.jdbc.message.JdbcMessage;
import com.consol.citrus.jdbc.server.JdbcServer;
import com.consol.citrus.message.MessageType;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.ClassPathResource;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
Expand Down Expand Up @@ -328,9 +329,12 @@ public void testBlobIntegration() throws IOException {

//GIVEN
final String sql = "{? = CALL someClobFunction(?)}";

final ClassPathResource blobRequestValue = new ClassPathResource("jdbc/RequestBlob.pdf");
final ClassPathResource blobReturnValue = new ClassPathResource("jdbc/ResponseBlob.pdf");
final String requestBlobContent = IOUtils.toString(blobRequestValue.getInputStream(), "UTF8");

final ClassPathResource blobReturnValue = new ClassPathResource("jdbc/ResponseBlob.pdf");
final String responseBlobContent = IOUtils.toString(blobReturnValue.getInputStream(), "UTF8");

//WHEN + THEN
async().actions(new AbstractTestAction() {
Expand All @@ -341,7 +345,7 @@ public void doExecute(final TestContext context) {
Assert.assertNotNull(connection);
try(final PreparedStatement statement = connection.prepareStatement(sql)){

statement.setBinaryStream(1, blobRequestValue.getInputStream());
statement.setBlob(1, blobRequestValue.getInputStream());
statement.execute();

final ResultSet resultSet = statement.getResultSet();
Expand All @@ -359,14 +363,14 @@ public void doExecute(final TestContext context) {
);

receive(jdbcServer)
.message(JdbcMessage.execute("{? = CALL someClobFunction(?)} - ("+blobRequestValue+")"));
.message(JdbcMessage.execute("{? = CALL someClobFunction(?)} - ("+requestBlobContent+")"));

send(jdbcServer)
.messageType(MessageType.XML)
.message(JdbcMessage.success().dataSet("" +
"<dataset>" +
"<row>" +
"<RETURN_BLOB>"+blobReturnValue.getInputStream()+"</RETURN_BLOB>"+
"<RETURN_BLOB>"+responseBlobContent+"</RETURN_BLOB>"+
"</row>" +
"</dataset>"));
}
Expand Down

0 comments on commit 8a7f079

Please sign in to comment.