Skip to content

Commit

Permalink
(citrusframework/citrus-db#28) Added Base64 encoding to binary data t…
Browse files Browse the repository at this point in the history
…o be able to compare values without triggering citrus variable substitution
  • Loading branch information
svettwer committed Apr 15, 2019
1 parent 8a7f079 commit b90bdfc
Showing 1 changed file with 6 additions and 3 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.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.ClassPathResource;
import org.testng.Assert;
Expand Down Expand Up @@ -331,10 +332,10 @@ public void testBlobIntegration() throws IOException {
final String sql = "{? = CALL someClobFunction(?)}";

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

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

//WHEN + THEN
async().actions(new AbstractTestAction() {
Expand All @@ -353,7 +354,9 @@ public void doExecute(final TestContext context) {

final Blob responseBlob = resultSet.getBlob(1);

assertEquals(blobReturnValue.getInputStream(), responseBlob.getBinaryStream());
assertEquals(
IOUtils.toString(blobReturnValue.getInputStream(), "UTF8"),
IOUtils.toString(responseBlob.getBinaryStream(),"UTF8"));
}
} catch (final SQLException | AssertionError | IOException e) {
throw new CitrusRuntimeException(e);
Expand Down

0 comments on commit b90bdfc

Please sign in to comment.