コード例 #1
0
ファイル: BaseTestCase.java プロジェクト: Cherisher/dhcp
  public BaseTestCase(String schemaType, int schemaVersion) {

    DhcpServerConfiguration.configFilename = configFilename;
    if (config == null) {
      try {
        config = DhcpServerConfiguration.getInstance();

        DhcpServerPolicies.setProperty(Property.DATABASE_SCHEMA_TYTPE, schemaType);
        DhcpServerPolicies.setProperty(
            Property.DATABASE_SCHEMA_VERSION, Integer.toString(schemaVersion));
        if (schemaType.contains("derby")) {
          // start with a fresh database
          System.out.println("Cleaning db/derby...");
          FileUtils.cleanDirectory(new File("db/derby"));
        } else if (schemaType.contains("h2")) {
          // start with a fresh database
          System.out.println("Cleaning db/h2...");
          FileUtils.cleanDirectory(new File("db/h2"));
        } else if (schemaType.contains("sqlite")) {
          // start with a fresh database
          System.out.println("Cleaning db/sqlite...");
          FileUtils.cleanDirectory(new File("db/sqlite"));
        }
        String[] appContext = JagornetDhcpServer.getAppContextFiles(schemaType, schemaVersion);

        ctx = new ClassPathXmlApplicationContext(appContext);

        IaManager iaMgr = (IaManager) ctx.getBean("iaManager");
        iaMgr.init();
        config.setIaMgr(iaMgr);

        V6NaAddrBindingManager v6NaAddrBindingMgr =
            (V6NaAddrBindingManager) ctx.getBean("v6NaAddrBindingManager");
        v6NaAddrBindingMgr.init();
        config.setNaAddrBindingMgr(v6NaAddrBindingMgr);

        V6TaAddrBindingManager v6TaAddrBindingMgr =
            (V6TaAddrBindingManager) ctx.getBean("v6TaAddrBindingManager");
        v6TaAddrBindingMgr.init();
        config.setTaAddrBindingMgr(v6TaAddrBindingMgr);

        V6PrefixBindingManager v6PrefixBindingMgr =
            (V6PrefixBindingManager) ctx.getBean("v6PrefixBindingManager");
        v6PrefixBindingMgr.init();
        config.setPrefixBindingMgr(v6PrefixBindingMgr);

        V4AddrBindingManager v4AddrBindingMgr =
            (V4AddrBindingManager) ctx.getBean("v4AddrBindingManager");
        v4AddrBindingMgr.init();
        config.setV4AddrBindingMgr(v4AddrBindingMgr);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  }
コード例 #2
0
ファイル: BaseTestCase.java プロジェクト: Cherisher/dhcp
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   // wipe the database before each test
   config.getIaMgr().deleteAllIAs();
 }