Example #1
0
  /**
   * Create a new site entry with no faulty values. Site object will be created step by step by
   * calling the appropriate methods.
   */
  private static void runTest_Stepped() {
    Number newSiteId = -1;

    Testing.so("All legal site creation in single steps", Format.HEADER);
    Testing.so("These tests should run without any errors.", Format.HEADERSUB);
    Testing.so("Creating a new Site object", Format.STEP);
    try {
      SiteTest.site = new Site();
    } catch (Exception e) {
      Testing.err(e);
    }
    // run tests
    SiteTest.testLanguage();
    SiteTest.testCountryCode();
    SiteTest.testURL();
    SiteTest.testCategory();
    SiteTest.testRootFile();
    SiteTest.testTitle();
    SiteTest.testTimestamp();
    SiteTest.testStorage();
    Testing.so("Writing data..", Format.STEPFINAL);
    try {
      newSiteId = SiteTest.site.write();
    } catch (Exception e) {
      Testing.err(e);
    }
    Testing.so("All legal site creation in single steps: final check", Format.HEADER);
    SiteTest.checkTest(newSiteId);
  }
Example #2
0
  /**
   * Create a new site entry with no faulty values. Site object will be created in one step with the
   * appropriate constructor.
   *
   * @throws ConfigManagerException
   * @throws SQLException
   */
  private static void runTest_Single() {
    Number newSiteId = -1;

    // test one
    Testing.so("All legal site creation in one step", Format.HEADER);
    // gather data
    try {
      SiteTest.properties.put("url", SiteTest.getAURL());
      SiteTest.properties.put("languagecode", SiteTest.getALanguageName());
      SiteTest.properties.put("countrycode", SiteTest.getACountryName());
    } catch (Exception e) {
      Testing.err(e);
    }
    SiteTest.properties.put("rootfile", SiteTest.getARootFileName());
    SiteTest.properties.put("title", SiteTest.getATitle());
    SiteTest.properties.put("category", SiteTest.getACategoryName());
    SiteTest.properties.put("subcategory", SiteTest.getACategoryName());
    SiteTest.properties.put("subsubcategory", SiteTest.getACategoryName());
    SiteTest.properties.put("storage", SiteTest.getAStoragePath());
    // create site object
    try {
      Site site =
          new Site( //
              SiteTest.properties.get("url").toString(), //
              SiteTest.properties.get("languagecode").toString(), //
              SiteTest.properties.get("countrycode").toString(), //
              SiteTest.properties.get("rootfile").toString(), //
              // SiteTest.properties.get("title").toString(),//
              SiteTest.properties.get("category").toString(), //
              SiteTest.properties.get("subcategory").toString(), //
              SiteTest.properties.get("subsubcategory").toString(), //
              SiteTest.properties.get("storage").toString() //
              );
      newSiteId = site.getNewSiteId();
    } catch (Exception e) {
      Testing.err(e);
    }
    SiteTest.checkTest(newSiteId);

    // test two
    Testing.so("Bogous site creation in one step", Format.HEADER);
    Testing.so(
        "Country and Language shouldn't be resolvable and result in unknown or in an error, depending on the Site behaviour setting.",
        Format.STEPINFO);
    // just pass random junk
    SiteTest.properties.put("countrycode", "scrambled");
    SiteTest.properties.put("languagecode", "zizzlebizz");
    // create site object
    try {
      Site site =
          new Site( //
              SiteTest.properties.get("url").toString(), //
              SiteTest.properties.get("languagecode").toString(), //
              SiteTest.properties.get("countrycode").toString(), //
              SiteTest.properties.get("rootfile").toString(), //
              // SiteTest.properties.get("title").toString(),//
              SiteTest.properties.get("category").toString(), //
              SiteTest.properties.get("subcategory").toString(), //
              SiteTest.properties.get("subsubcategory").toString(), //
              SiteTest.properties.get("storage").toString() //
              );
      newSiteId = site.getNewSiteId();
    } catch (Exception e) {
      Testing.err(e);
    }
    SiteTest.checkTest(newSiteId);
  }