本文整理汇总了Java中com.mockrunner.mock.jdbc.MockResultSet类的典型用法代码示例。如果您正苦于以下问题:Java MockResultSet类的具体用法?Java MockResultSet怎么用?Java MockResultSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MockResultSet类属于com.mockrunner.mock.jdbc包,在下文中一共展示了MockResultSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例2: testVerifyPatchesTable
import com.mockrunner.mock.jdbc.MockResultSet; //导入依赖的package包/类
/**
* Validates that the system recognizes an existing patches table.
*
* @throws Exception if an unexpected error occurs
*/
public void testVerifyPatchesTable() throws Exception
{
// Test-specific setup
handler = conn.getPreparedStatementResultSetHandler();
MockResultSet rs = handler.createResultSet();
MockDatabaseMetaData mdmd = (MockDatabaseMetaData) conn.getMetaData();
MockResultSet mrs = handler.createResultSet();
mrs.addRow(new String[]{"", "", "", "system_name"});
mrs.addRow(new String[]{"", "", "", "patch_level"});
mdmd.setPrimaryKeys(mrs);
handler.prepareGlobalResultSet(rs);
rs.addRow(new Integer[] {new Integer(13)});
table.createPatchStoreIfNeeded();
commonVerifications();
verifyNotCommitted();
verifyPreparedStatementParameter(0, 1, "milestone");
verifyPreparedStatementNotPresent(table.getSql("patches.upgrade"));
verifyPreparedStatementNotPresent(table.getSql("patches.create"));
}
示例3: testVerifyAndUpgradePatchesTable
import com.mockrunner.mock.jdbc.MockResultSet; //导入依赖的package包/类
/**
* Validates that the system recognizes an existing patches table.
*
* @throws Exception if an unexpected error occurs
*/
public void testVerifyAndUpgradePatchesTable() throws Exception
{
// Test-specific setup
handler = conn.getPreparedStatementResultSetHandler();
MockResultSet rs = handler.createResultSet();
MockDatabaseMetaData mdmd = (MockDatabaseMetaData) conn.getMetaData();
MockResultSet mrs = handler.createResultSet();
mrs.addRow(new String[]{"", "", "", "system_name"});
mdmd.setPrimaryKeys(mrs);
handler.prepareGlobalResultSet(rs);
rs.addRow(new Integer[] {new Integer(13)});
table.createPatchStoreIfNeeded();
commonVerifications();
verifyCommitted();
verifyPreparedStatementParameter(0, 1, "milestone");
verifyPreparedStatementPresent(table.getSql("patches.upgrade"));
verifyPreparedStatementNotPresent(table.getSql("patches.create"));
}
示例4: testGetPatchLevel
import com.mockrunner.mock.jdbc.MockResultSet; //导入依赖的package包/类
/**
* Validates that <code>getPatchLevel</code> works on an existing system.
*
* @throws Exception if an unexpected error occurs
*/
public void testGetPatchLevel() throws Exception
{
// Test-specific setup
handler = conn.getPreparedStatementResultSetHandler();
MockDatabaseMetaData mdmd = (MockDatabaseMetaData) conn.getMetaData();
MockResultSet mrs = handler.createResultSet();
mrs.addRow(new String[]{"", "", "", "system_name"});
mrs.addRow(new String[]{"", "", "", "patch_level"});
mdmd.setPrimaryKeys(mrs);
MockResultSet rs = handler.createResultSet();
rs.addRow(new Integer[]{new Integer(13)});
handler.prepareGlobalResultSet(rs);
int i = table.getPatchLevel();
assertEquals(13, i);
commonVerifications();
verifyNotCommitted();
verifyPreparedStatementParameter(1, 1, "milestone");
verifyPreparedStatementNotPresent(table.getSql("patches.upgrade"));
verifyPreparedStatementNotPresent(table.getSql("level.create"));
}
示例5: testGetPatchLevelFirstTime
import com.mockrunner.mock.jdbc.MockResultSet; //导入依赖的package包/类
/**
* Validates that <code>getPatchLevel</code> works on a new system.
*
* @throws Exception if an unexpected error occurs
*/
public void testGetPatchLevelFirstTime() throws Exception
{
// Test-specific setup
handler = conn.getPreparedStatementResultSetHandler();
MockResultSet rs = handler.createResultSet();
// empty result set
handler.prepareResultSet(table.getSql("level.read"), rs);
handler.prepareThrowsSQLException(table.getSql("level.table.exists"));
int i = table.getPatchLevel();
assertEquals(0, i);
commonVerifications();
verifyPreparedStatementPresent(table.getSql("level.create"));
}
示例6: testUpdatePatchLevel
import com.mockrunner.mock.jdbc.MockResultSet; //导入依赖的package包/类
/**
* Validates that the patch level can be updated.
*
* @throws Exception if an unexpected error occurs
*/
public void testUpdatePatchLevel() throws Exception
{
handler = conn.getPreparedStatementResultSetHandler();
MockDatabaseMetaData mdmd = (MockDatabaseMetaData) conn.getMetaData();
MockResultSet mrs = handler.createResultSet();
mrs.addRow(new String[]{"", "", "", "system_name"});
mrs.addRow(new String[]{"", "", "", "patch_level"});
mdmd.setPrimaryKeys(mrs);
MockResultSet rs = handler.createResultSet();
rs.addRow(new Integer[]{new Integer(12)});
handler.prepareResultSet(table.getSql("level.read"), rs, new String[]{"milestone"});
table.updatePatchLevel(13);
verifyPreparedStatementParameter(table.getSql("level.update"), 1, new Integer(13));
verifyPreparedStatementParameter(table.getSql("level.update"), 2, "milestone");
commonVerifications();
verifyCommitted();
}
示例7: testIsPatchTableNotLocked
import com.mockrunner.mock.jdbc.MockResultSet; //导入依赖的package包/类
/**
* Validates that <code>isPatchTableLocked</code> works when no lock exists.
*
* @throws Exception if an unexpected error occurs
*/
public void testIsPatchTableNotLocked() throws Exception
{
// Test-specific setup
// Return a non-empty set in response to the patch lock query
handler = conn.getPreparedStatementResultSetHandler();
MockDatabaseMetaData mdmd = (MockDatabaseMetaData) conn.getMetaData();
MockResultSet mrs = handler.createResultSet();
mrs.addRow(new String[]{"", "", "", "system_name"});
mrs.addRow(new String[]{"", "", "", "patch_level"});
mdmd.setPrimaryKeys(mrs);
MockResultSet rs = handler.createResultSet();
rs.addRow(new String[]{"F"});
handler.prepareResultSet(table.getSql("lock.read"), rs, new String[]{"milestone", "milestone"});
assertFalse(table.isPatchStoreLocked());
commonVerifications();
verifyNotCommitted();
}
示例8: testIsPatchTableLocked
import com.mockrunner.mock.jdbc.MockResultSet; //导入依赖的package包/类
/**
* Validates that <code>isPatchTableLocked</code> works when a lock already exists.
*
* @throws Exception if an unexpected error occurs
*/
public void testIsPatchTableLocked() throws Exception
{
// Test-specific setup
// Return a non-empty set in response to the patch lock query
handler = conn.getPreparedStatementResultSetHandler();
MockDatabaseMetaData mdmd = (MockDatabaseMetaData) conn.getMetaData();
MockResultSet mrs = handler.createResultSet();
mrs.addRow(new String[]{"", "", "", "system_name"});
mrs.addRow(new String[]{"", "", "", "patch_level"});
mdmd.setPrimaryKeys(mrs);
MockResultSet rs = handler.createResultSet();
rs.addRow(new String[]{"T"});
handler.prepareResultSet(table.getSql("lock.read"), rs, new String[]{"milestone", "milestone"});
assertTrue(table.isPatchStoreLocked());
commonVerifications();
verifyNotCommitted();
}
示例9: testLockPatchTableWhenNotAlreadyLocked
import com.mockrunner.mock.jdbc.MockResultSet; //导入依赖的package包/类
/**
* Validates that the patches table can be locked as long as no other lock
* is in place.
*
* @throws Exception if an unexpected error occurs
*/
public void testLockPatchTableWhenNotAlreadyLocked() throws Exception
{
// Test-specific setup
// Return an empty set in response to the patch lock query
handler = conn.getPreparedStatementResultSetHandler();
MockDatabaseMetaData mdmd = (MockDatabaseMetaData) conn.getMetaData();
MockResultSet mrs = handler.createResultSet();
mrs.addRow(new String[]{"", "", "", "system_name"});
mrs.addRow(new String[]{"", "", "", "patch_level"});
mdmd.setPrimaryKeys(mrs);
MockResultSet rs = handler.createResultSet();
handler.prepareUpdateCount(table.getSql("lock.obtain"), 1, new String[] {"milestone", "milestone"});
table.lockPatchStore();
verifyPreparedStatementParameter(table.getSql("lock.obtain"), 1, "milestone");
verifyPreparedStatementParameter(table.getSql("lock.obtain"), 2, "milestone");
commonVerifications();
verifyCommitted();
}
示例10: testPatchRetrievesSetWithPatchesApplied
import com.mockrunner.mock.jdbc.MockResultSet; //导入依赖的package包/类
public void testPatchRetrievesSetWithPatchesApplied () throws SQLException, MigrationException {
handler = conn.getPreparedStatementResultSetHandler();
MockDatabaseMetaData mdmd = (MockDatabaseMetaData) conn.getMetaData();
MockResultSet mrs = handler.createResultSet();
mrs.addRow(new String[]{"", "", "", "system_name"});
mrs.addRow(new String[]{"", "", "", "patch_level"});
mdmd.setPrimaryKeys(mrs);
MockResultSet rs = handler.createResultSet();
rs.addColumn("patch_level", new Object[]{1, 2});
handler.prepareGlobalResultSet(rs);
Set<Integer> expected = new HashSet<Integer>();
expected.add(1);
expected.add(2);
assertEquals(expected, table.getPatchesApplied());
commonVerifications();
verifyPreparedStatementPresent(table.getSql("patches.all"));
}
示例11: 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());
}
示例12: 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());
}
示例13: testLockPatchTableWhenAlreadyLocked
import com.mockrunner.mock.jdbc.MockResultSet; //导入依赖的package包/类
/**
* Validates that an <code>IllegalStateException</code> is thrown when trying
* to lock an already locked patches table.
*
* @throws Exception if an unexpected error occurs
*/
public void testLockPatchTableWhenAlreadyLocked() throws Exception
{
// Test-specific setup
// Return a non-empty set in response to the patch lock query
handler = conn.getPreparedStatementResultSetHandler();
MockDatabaseMetaData mdmd = (MockDatabaseMetaData) conn.getMetaData();
MockResultSet mrs = handler.createResultSet();
mrs.addRow(new String[]{"", "", "", "system_name"});
mrs.addRow(new String[]{"", "", "", "patch_level"});
mdmd.setPrimaryKeys(mrs);
handler.prepareUpdateCount(table.getSql("lock.obtain"), 0, new String[] {"milestone", "milestone"});
try
{
table.lockPatchStore();
fail("Expected an IllegalStateException since a lock already exists.");
}
catch (IllegalStateException e)
{
// Expected
}
verifyPreparedStatementParameter(table.getSql("lock.obtain"), 1, "milestone");
verifyPreparedStatementParameter(table.getSql("lock.obtain"), 2, "milestone");
commonVerifications();
verifyCommitted();
}
示例14: testIsPatchApplied
import com.mockrunner.mock.jdbc.MockResultSet; //导入依赖的package包/类
public void testIsPatchApplied() throws MigrationException
{
handler = conn.getPreparedStatementResultSetHandler();
MockResultSet rs = handler.createResultSet();
rs.addRow(new Integer[]{new Integer(3)});
handler.prepareGlobalResultSet(rs);
assertEquals(true, table.isPatchApplied(3));
commonVerifications();
verifyPreparedStatementPresent(table.getSql("level.exists"));
}
示例15: testIsPatchAppliedWithMissingLevel
import com.mockrunner.mock.jdbc.MockResultSet; //导入依赖的package包/类
public void testIsPatchAppliedWithMissingLevel() throws MigrationException
{
handler = conn.getPreparedStatementResultSetHandler();
MockResultSet rs = handler.createResultSet();
handler.prepareGlobalResultSet(rs);
assertEquals(false, table.isPatchApplied(3));
commonVerifications();
verifyPreparedStatementPresent(table.getSql("level.exists"));
}