use of com.microsoft.sqlserver.testframework.DBInvalidUtil in project mssql-jdbc by Microsoft.
the class lobsTest method createLob.
private Object createLob(Class lobClass) {
// Randomly indicate negative length
streamLength = ThreadLocalRandom.current().nextInt(3) < 2 ? datasize : -1 - ThreadLocalRandom.current().nextInt(datasize);
// For streams -1 means any length, avoid to ensure that an exception is always thrown
if (streamLength == -1 && (lobClass == DBCharacterStream.class || lobClass == DBBinaryStream.class))
streamLength = datasize;
log.fine("Length passed into update : " + streamLength);
byte[] data = new byte[datasize];
ThreadLocalRandom.current().nextBytes(data);
if (lobClass == DBCharacterStream.class)
return new DBInvalidUtil().new InvalidCharacterStream(new String(data), streamLength < -1);
else if (lobClass == DBBinaryStream.class)
return new DBInvalidUtil().new InvalidBinaryStream(data, streamLength < -1);
if (lobClass == Clob.class) {
ArrayList<SqlType> types = Utils.types();
SqlType type = Utils.find(String.class);
Object expected = type.createdata(String.class, data);
return new DBInvalidUtil().new InvalidClob(expected, false);
} else {
ArrayList<SqlType> types = Utils.types();
SqlType type = Utils.find(byte[].class);
Object expected = type.createdata(type.getClass(), data);
return new DBInvalidUtil().new InvalidBlob(expected, false);
}
}
Aggregations