コード例 #1
0
  @BeforeClass
  public static void initializeData() throws Exception {

    Config.loadProperties();

    String datasource = Config.getDatasource();
    ConnectionPool pool = ConnectionPoolFactory.getConnectionPool(datasource);

    handler = new SQLHandler(pool);
    DAOFactory factory = new DAOFactory(datasource);

    Connection connection = pool.getConnection();

    workspaceDAO = factory.getWorkspaceDao(connection);
    userDao = factory.getUserDao(connection);

    user1 = new User(UUID.randomUUID(), "tester1", "tester1", "AUTH_12312312", "[email protected]", 100, 0);

    userDao.add(user1);
    Workspace workspace1 = new Workspace(null, 1, user1, false, false);
    workspaceDAO.add(workspace1);

    user2 = new User(UUID.randomUUID(), "tester1", "tester1", "AUTH_12312312", "[email protected]", 100, 0);

    userDao.add(user2);
    Workspace workspace2 = new Workspace(null, 1, user2, false, false);
    workspaceDAO.add(workspace2);
  }
コード例 #2
0
  @BeforeClass
  public static void initializeData() {

    try {
      Config.loadProperties();
      String datasource = Config.getDatasource();

      pool = ConnectionPoolFactory.getConnectionPool(datasource);
      reader = new JSONParser();

      DAOFactory factory = new DAOFactory(datasource);

      workspaceDAO = factory.getWorkspaceDao(connection);
      userDao = factory.getUserDao(connection);
      deviceDao = factory.getDeviceDAO(connection);
      objectDao = factory.getItemDAO(connection);
      oversionDao = factory.getItemVersionDAO(connection);

      User user = new User(user1, "tester1", "tester1", "AUTH_12312312", "[email protected]", 100L, 0L, 0L);
      userDao.add(user);

      Workspace workspace = new Workspace(null, 1, user, false, false);
      workspaceDAO.add(workspace);

      Device device = new Device(null, "junitdevice", user);
      deviceDao.add(device);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }