本文整理汇总了Java中com.cloudera.sqoop.testutil.MockResultSet类的典型用法代码示例。如果您正苦于以下问题:Java MockResultSet类的具体用法?Java MockResultSet怎么用?Java MockResultSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockResultSet类属于com.cloudera.sqoop.testutil包,在下文中一共展示了MockResultSet类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReadClobRef
import com.cloudera.sqoop.testutil.MockResultSet; //导入依赖的package包/类
public void testReadClobRef()
throws IOException, InterruptedException, SQLException {
// This should give us an inline CLOB.
ResultSet resultSet = new MockResultSet();
ClobRef clob = loader.readClobRef(0, resultSet);
assertNotNull(clob);
assertFalse(clob.isExternal());
assertEquals(MockResultSet.CLOB_DATA, clob.toString());
// LOBs bigger than 4 bytes are now external.
conf.setLong(LargeObjectLoader.MAX_INLINE_LOB_LEN_KEY, 4);
clob = loader.readClobRef(0, resultSet);
assertNotNull(clob);
assertTrue(clob.isExternal());
loader.close();
Reader r = clob.getDataStream(conf, outDir);
char [] buf = new char[4096];
int chars = r.read(buf, 0, 4096);
r.close();
String str = new String(buf, 0, chars);
assertEquals(MockResultSet.CLOB_DATA, str);
}
示例2: testReadBlobRef
import com.cloudera.sqoop.testutil.MockResultSet; //导入依赖的package包/类
public void testReadBlobRef()
throws IOException, InterruptedException, SQLException {
// This should give us an inline BLOB.
ResultSet resultSet = new MockResultSet();
BlobRef blob = loader.readBlobRef(0, resultSet);
assertNotNull(blob);
assertFalse(blob.isExternal());
byte [] data = blob.getData();
byte [] blobData = MockResultSet.blobData();
assertEquals(blobData.length, data.length);
for (int i = 0; i < data.length; i++) {
assertEquals(blobData[i], data[i]);
}
// LOBs bigger than 4 bytes are now external.
conf.setLong(LargeObjectLoader.MAX_INLINE_LOB_LEN_KEY, 4);
blob = loader.readBlobRef(0, resultSet);
assertNotNull(blob);
assertTrue(blob.isExternal());
loader.close();
InputStream is = blob.getDataStream(conf, outDir);
byte [] buf = new byte[4096];
int bytes = is.read(buf, 0, 4096);
is.close();
assertEquals(blobData.length, bytes);
for (int i = 0; i < bytes; i++) {
assertEquals(blobData[i], buf[i]);
}
}