当前位置: 首页>>代码示例>>Java>>正文


Java MockResultSet类代码示例

本文整理汇总了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);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:23,代码来源:TestLargeObjectLoader.java

示例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]);
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:31,代码来源:TestLargeObjectLoader.java


注:本文中的com.cloudera.sqoop.testutil.MockResultSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。