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


Java MockResultSet.next方法代码示例

本文整理汇总了Java中com.mockrunner.mock.jdbc.MockResultSet.next方法的典型用法代码示例。如果您正苦于以下问题:Java MockResultSet.next方法的具体用法?Java MockResultSet.next怎么用?Java MockResultSet.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mockrunner.mock.jdbc.MockResultSet的用法示例。


在下文中一共展示了MockResultSet.next方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEmpty

import com.mockrunner.mock.jdbc.MockResultSet; //导入方法依赖的package包/类
@Test
public void testEmpty() throws Exception {
    MockResultSet resultSet = new MockResultSet("data");

    StringWriter stringWriter = new StringWriter();
    JsonWriter jsonWriter = new JsonWriter(stringWriter);
    jsonWriter.beginObject();

    MetricDataService.MetricDataRowCallbackHandler handler = new MetricDataService.MetricDataRowCallbackHandler(
        jsonWriter, 0, 3, 1
    );

    while (resultSet.next()) {
        handler.processRow(resultSet);
    }
    handler.finish();
    jsonWriter.endObject();

    Assert.assertEquals("{}", stringWriter.toString());

}
 
开发者ID:yandex,项目名称:graphouse,代码行数:22,代码来源:MetricDataRowCallbackHandlerTest.java

示例2: testHandler

import com.mockrunner.mock.jdbc.MockResultSet; //导入方法依赖的package包/类
@Test
public void testHandler() throws Exception {

    MockResultSet resultSet = new MockResultSet("data");
    resultSet.addColumn("metric", new String[]{"name1", "name1", "name2", "name2"});
    resultSet.addColumn("ts", new Integer[]{100, 160, 160, 220});
    resultSet.addColumn("value", new Double[]{33.33, 42.0, 32.0, 77.7});

    StringWriter stringWriter = new StringWriter();
    JsonWriter jsonWriter = new JsonWriter(stringWriter);
    jsonWriter.beginObject();

    MetricDataService.MetricDataRowCallbackHandler handler = new MetricDataService.MetricDataRowCallbackHandler(
        jsonWriter, 100, 280, 60
    );

    while (resultSet.next()) {
        handler.processRow(resultSet);
    }
    handler.finish();

    jsonWriter.endObject();

    JsonObject expected = new JsonObject();
    expected.add("name1", createMetric(100, 280, 60, 33.33, 42.0, Double.NaN));
    expected.add("name2", createMetric(100, 280, 60, Double.NaN, 32.0, 77.7));


    Assert.assertEquals(expected.toString(), stringWriter.toString());
}
 
开发者ID:yandex,项目名称:graphouse,代码行数:31,代码来源:MetricDataRowCallbackHandlerTest.java

示例3: testChNan

import com.mockrunner.mock.jdbc.MockResultSet; //导入方法依赖的package包/类
@Test
public void testChNan() throws Exception {

    MockResultSet resultSet = new MockResultSet("data");
    resultSet.addColumn("metric", new String[]{"name1", "name1", "name1"});
    resultSet.addColumn("ts", new Integer[]{0, 1, 2});
    resultSet.addColumn("value", new Double[]{0.0, Double.NaN, 2.0});

    StringWriter stringWriter = new StringWriter();
    JsonWriter jsonWriter = new JsonWriter(stringWriter);
    jsonWriter.beginObject();

    MetricDataService.MetricDataRowCallbackHandler handler = new MetricDataService.MetricDataRowCallbackHandler(
        jsonWriter, 0, 3, 1
    );

    while (resultSet.next()) {
        handler.processRow(resultSet);
    }
    handler.finish();

    jsonWriter.endObject();

    JsonObject expected = new JsonObject();
    expected.add("name1", createMetric(0, 3, 1, 0.0, Double.NaN, 2.0));

    Assert.assertEquals(expected.toString(), stringWriter.toString());
}
 
开发者ID:yandex,项目名称:graphouse,代码行数:29,代码来源:MetricDataRowCallbackHandlerTest.java


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