示例#1
0
  @Test
  public void verifyDropVersioningV10() throws SQLException {
    DB2Schema db2Schema = new DB2Schema(jdbcTemplate, dbSupport, "SCHEMA");

    // Just return an empty list for the other drop statements
    when(jdbcTemplate.queryForStringList(anyString())).thenReturn(Collections.<String>emptyList());
    ResultSet mockResultSet = mock(ResultSet.class);

    // Return empty resultset for Types
    when(jdbcTemplate.getMetaData().getUDTs(null, "SCHEMA", null, null)).thenReturn(mockResultSet);
    when(mockResultSet.next()).thenReturn(false);

    // Return a VERSIONED_TABLE when the SQL to find version tables is called.
    List<String> versionedTables = new ArrayList<String>();
    versionedTables.add("VERSIONED_TABLE");
    when(jdbcTemplate.queryForStringList(
            "select rtrim(TABNAME) from SYSCAT.TABLES where TEMPORALTYPE <> 'N' and TABSCHEMA = ?",
            "SCHEMA"))
        .thenReturn(versionedTables);

    when(dbSupport.getDb2MajorVersion()).thenReturn(10);
    when(dbSupport.quote("SCHEMA", "VERSIONED_TABLE")).thenReturn("SCHEMA.VERSIONED_TABLE");

    db2Schema.clean();

    // Verify the DROP VERSIONING SQL is called.
    verify(jdbcTemplate).execute("ALTER TABLE SCHEMA.VERSIONED_TABLE DROP VERSIONING");
  }
示例#2
0
  @Test
  public void verifyDropVersioningV9() throws SQLException {
    DB2Schema db2Schema = new DB2Schema(jdbcTemplate, dbSupport, "SCHEMA");

    // Just return an empty list for the other drop statements
    when(jdbcTemplate.queryForStringList(anyString())).thenReturn(Collections.<String>emptyList());
    ResultSet mockResultSet = mock(ResultSet.class);

    // Return empty resultset for Types
    when(jdbcTemplate.getMetaData().getUDTs(null, "SCHEMA", null, null)).thenReturn(mockResultSet);
    when(mockResultSet.next()).thenReturn(false);

    when(dbSupport.getDb2MajorVersion()).thenReturn(9);

    db2Schema.clean();

    verify(jdbcTemplate, never()).execute("ALTER TABLE SCHEMA.VERSIONED_TABLE DROP VERSIONING");
  }