public void testGetColumn() throws Exception {
    Column[] cols =
        new Column[] {new Column("COL1", DataType.UNKNOWN), new Column("COL2", DataType.UNKNOWN)};
    DefaultTable table = new DefaultTable("MY_TABLE", cols);
    table.addRow(new Object[] {"value1", "value2"});

    // Filter COL1
    ITable tableFiltered = DefaultColumnFilter.excludedColumnsTable(table, new String[] {"COL1"});

    DefaultFailureHandler failureHandler = new DefaultFailureHandler(cols);
    String info = failureHandler.getAdditionalInfo(tableFiltered, tableFiltered, 0, "COL1");

    String expectedInfo =
        "Additional row info: ('COL1': expected=<value1>, actual=<value1>) ('COL2': expected=<value2>, actual=<value2>)";
    assertEquals(expectedInfo, info);
  }
예제 #2
0
 protected void assertExpTable() throws Exception {
   String table = expected.getTableMetaData().getTableName();
   actual = databaseConnection.createQueryTable(table, query);
   try {
     assertEquals(expected, actual);
   } finally {
     databaseConnection.close();
   }
 }
예제 #3
0
 protected void expRow(Object... values) throws DataSetException {
   expected.addRow(values);
 }
예제 #4
0
  public JavaDataSet() throws DataSetException {
    DefaultTable persons =
        new DefaultTable(
            "persons",
            new Column[] { //
              new Column("id", DataType.BIGINT), //
              new Column("first_name", DataType.VARCHAR), //
              new Column("name", DataType.VARCHAR), //
              new Column("team_id", DataType.BIGINT), //
            });
    persons.addRow(
        new Object[] { //
          Parameters.Persons.DENNIS, //
          "Dennis", //
          "Kaulbersch", //
          Parameters.Teams.QUALITY_ASSURANCE, //
        });
    persons.addRow(
        new Object[] { //
          Parameters.Persons.JULIEN, //
          "Julien", //
          "Guitton", //
          Parameters.Teams.QUALITY_ASSURANCE, //
        });
    persons.addRow(
        new Object[] { //
          Parameters.Persons.CHRISTIAN, //
          "Christian", //
          "Baranowski", //
          Parameters.Teams.QUALITY_ASSURANCE, //
        });

    DefaultTable jobs =
        new DefaultTable(
            "jobs",
            new Column[] { //
              new Column("id", DataType.BIGINT), //
              new Column("title", DataType.VARCHAR), //
              new Column("description", DataType.VARCHAR), //
            });

    jobs.addRow(
        new Object[] { //
          Parameters.Jobs.SOFTWARE_DEVELOPER, //
          "Software Developer", //
          "Creating software", //
        });

    jobs.addRow(
        new Object[] { //
          Parameters.Jobs.SOFTWARE_TESTER, //
          "Software Tester", //
          "Testing software", //
        });

    jobs.addRow(
        new Object[] { //
          Parameters.Jobs.TEAM_MANAGER, //
          "Team Manager", //
          "Makes the world go round", //
        });

    DefaultTable teams =
        new DefaultTable(
            "teams",
            new Column[] { //
              new Column("id", DataType.BIGINT), //
              new Column("title", DataType.VARCHAR), //
              new Column("description", DataType.VARCHAR), //
              new Column("membersize", DataType.BIGINT), //
            });

    teams.addRow(
        new Object[] { //
          Parameters.Teams.QUALITY_ASSURANCE, //
          "Quality Assurance", //
          "Verifies software", //
          3, //
        });

    DefaultTable personJobs =
        new DefaultTable(
            "person_job",
            new Column[] { //
              new Column("person_id", DataType.BIGINT), //
              new Column("job_id", DataType.BIGINT), //
              new Column("engagement_start", DataType.DATE), //
            });

    personJobs.addRow(
        new Object[] { //
          Parameters.Persons.DENNIS, //
          Parameters.Jobs.SOFTWARE_DEVELOPER, //
          DateUtil.getDate(2013, 4, 1, 14, 0, 0),
        });

    personJobs.addRow(
        new Object[] { //
          Parameters.Persons.JULIEN, //
          Parameters.Jobs.SOFTWARE_TESTER, //
          null,
        });

    personJobs.addRow(
        new Object[] { //
          Parameters.Persons.CHRISTIAN, //
          Parameters.Jobs.TEAM_MANAGER, //
          null,
        });

    addTable(jobs);
    addTable(teams);
    addTable(persons);
    addTable(personJobs);
  }
  /**
   * 测试启动前方法.
   *
   * @throws java.lang.Exception 普通异常.
   */
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    // 获取原数据库内容
    IDataSet backupDataset = TestDBHelper.backupDataBase();
    // 构建测试用的数据
    // 指定测试用到的表
    DefaultTable userTable =
        new DefaultTable(
            "t_user", backupDataset.getTable("t_user").getTableMetaData().getColumns());
    DefaultTable roleTable =
        new DefaultTable(
            "t_role", backupDataset.getTable("t_role").getTableMetaData().getColumns());
    DefaultTable menuItemTable =
        new DefaultTable(
            "t_menuitem", backupDataset.getTable("t_menuitem").getTableMetaData().getColumns());
    DefaultTable rolemenuitemmapTable =
        new DefaultTable(
            "t_rolemenuitemmap",
            backupDataset.getTable("t_rolemenuitemmap").getTableMetaData().getColumns());

    // 写入数据
    Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2012-01-12 23:30:20");
    Object[] userData1 = {
      Long.valueOf("1"),
      "user1",
      "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      date,
      Long.valueOf("1"),
      null,
      null,
      Byte.valueOf("0"),
      Byte.valueOf("0"),
      Long.valueOf("0")
    };
    userTable.addRow(userData1);

    Object[] roleData1 = {
      Long.valueOf("1"),
      "访客",
      date,
      Long.valueOf("1"),
      null,
      null,
      Byte.valueOf("0"),
      Byte.valueOf("0"),
      Long.valueOf("0")
    };
    roleTable.addRow(roleData1);
    Object[] roleData2 = {
      Long.valueOf("2"),
      "超级管理员",
      date,
      Long.valueOf("1"),
      null,
      null,
      Byte.valueOf("0"),
      Byte.valueOf("0"),
      Long.valueOf("0")
    };
    roleTable.addRow(roleData2);

    Object[] roleData4 = {
      Long.valueOf("4"),
      "role4",
      date,
      Long.valueOf("1"),
      null,
      null,
      Byte.valueOf("0"),
      Byte.valueOf("0"),
      Long.valueOf("0")
    };
    roleTable.addRow(roleData4);
    // testEditRole使用
    Object[] roleData5 = {
      Long.valueOf("5"),
      "role5",
      date,
      Long.valueOf("1"),
      null,
      null,
      Byte.valueOf("0"),
      Byte.valueOf("0"),
      Long.valueOf("0")
    };
    roleTable.addRow(roleData5);
    // testPageRole使用
    Object[] roleData6 = {
      Long.valueOf("6"),
      "page",
      date,
      Long.valueOf("1"),
      null,
      null,
      Byte.valueOf("0"),
      Byte.valueOf("0"),
      Long.valueOf("0")
    };
    roleTable.addRow(roleData6);

    Object[] menuItemData1 = {
      1,
      "MenuName",
      "menuItemName1",
      "icon1",
      1,
      "sfds",
      "sdf",
      "sdf",
      0,
      "2015-06-15 15:15:27",
      "1",
      "2015-06-15 15:15:27",
      null,
      '0',
      '0',
      0
    };
    menuItemTable.addRow(menuItemData1);
    Object[] menuItemData2 = {
      2,
      "MenuName",
      "menuItemName2",
      "icon1",
      1,
      "sfds",
      "sdf",
      "sdf",
      0,
      "2015-06-15 15:15:27",
      "1",
      "2015-06-15 15:15:27",
      null,
      '0',
      '0',
      0
    };
    menuItemTable.addRow(menuItemData2);
    Object[] menuItemData3 = {
      Long.valueOf("3"),
      "MenuName",
      "menuItemName3",
      "icon1",
      1,
      "sfds",
      "sdf",
      "sdf",
      0,
      "2015-06-15 15:15:27",
      "1",
      "2015-06-15 15:15:27",
      null,
      '0',
      '0',
      0
    };
    menuItemTable.addRow(menuItemData3);
    Object[] menuItemData4 = {
      Long.valueOf("4"),
      "MenuName",
      "menuItemName4",
      "icon1",
      1,
      "sfds",
      "sdf",
      "sdf",
      0,
      "2015-06-15 15:15:27",
      "1",
      "2015-06-15 15:15:27",
      null,
      '0',
      '0',
      0
    };
    menuItemTable.addRow(menuItemData4);

    Object[] rolemenuitemmapData1 = {
      1, 1, 1, "2015-06-15 15:16:40", 1, "2015-06-15 15:15:27", null, 0, 0, 0
    };
    rolemenuitemmapTable.addRow(rolemenuitemmapData1);
    Object[] rolemenuitemmapData2 = {
      2, 2, 1, "2015-06-15 15:16:40", 1, "2015-06-15 15:15:27", null, 0, 0, 0
    };
    rolemenuitemmapTable.addRow(rolemenuitemmapData2);
    Object[] rolemenuitemmapData3 = {
      Long.valueOf("3"), 1, 2, "2015-06-15 15:16:40", 1, "2015-06-15 15:15:27", 0, 0, 0, null
    };
    rolemenuitemmapTable.addRow(rolemenuitemmapData3);
    Object[] rolemenuitemmapData4 = {
      Long.valueOf("4"),
      2,
      Long.valueOf("3"),
      "2015-06-15 15:16:40",
      1,
      "2015-06-15 15:15:27",
      null,
      0,
      0,
      0
    };
    rolemenuitemmapTable.addRow(rolemenuitemmapData4);
    Object[] rolemenuitemmapData5 = {
      Long.valueOf("5"),
      2,
      Long.valueOf("4"),
      "2015-06-15 15:16:40",
      1,
      "2015-06-15 15:15:27",
      null,
      0,
      0,
      0
    };
    rolemenuitemmapTable.addRow(rolemenuitemmapData5);

    // 组合表
    DefaultTable[] tables = {userTable, roleTable, menuItemTable, rolemenuitemmapTable};
    // 创建测试数据库的引用以准备写入数据库中
    IDataSet tempDataSet = new DefaultDataSet(tables);
    // 写入数据库
    DatabaseOperation.CLEAN_INSERT.execute(TestDBHelper.getConn(), tempDataSet);
  }