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
 private static void testCategory() {
   MultilanguageContent mCategory = SiteTest.getACategoryMultiName();
   MultilanguageContent mSubCategory = SiteTest.getACategoryMultiName();
   MultilanguageContent mSubSubCategory = SiteTest.getACategoryMultiName();
   Testing.so("Setting category: " + mCategory, Format.STEP);
   try {
     SiteTest.site.setCategory(mCategory, mSubCategory, mSubSubCategory);
     SiteTest.properties.put("category", mCategory.toString());
     SiteTest.properties.put("subcategory", mSubCategory.toString());
     SiteTest.properties.put("subsubcategory", mSubSubCategory.toString());
   } catch (Exception e) {
     Testing.err(e);
   }
 }
Example #3
0
  /** @param args */
  public static void main(String[] args) {
    Testing.so("Initialize", Format.HEADER);
    Testing.so("These tests should run without any errors.", Format.HEADERSUB);
    Testing.so("Opening database", Format.STEP);

    try {
      SiteTest.db = gimmi.database.Database.getInstance();
    } catch (Exception e) {
      Testing.err(e);
    }

    // simple create test - multiple steps
    SiteTest.runTest_Stepped();
    // simple create test - one step
    SiteTest.runTest_Single();
  }
Example #4
0
 private static void testRootFile() {
   String file = SiteTest.getARootFileName();
   Testing.so("Setting root-file: " + file, Format.STEP);
   try {
     SiteTest.site.setRootFile(file);
     SiteTest.properties.put("rootfile", file);
   } catch (Exception e) {
     Testing.err(e);
   }
 }
Example #5
0
 private static void testTitle() {
   String title = SiteTest.getATitle();
   Testing.so("Setting title: " + title, Format.STEP);
   try {
     SiteTest.site.setTitle(title);
     SiteTest.properties.put("title", title);
   } catch (Exception e) {
     Testing.err(e);
   }
 }
Example #6
0
 private static void testURL() {
   try {
     URL url = SiteTest.getAURL();
     Testing.so("Setting URL: " + url.toString(), Format.STEP);
     SiteTest.site.setURL(url);
     SiteTest.properties.put("url", url.toString());
   } catch (Exception e) {
     Testing.err(e);
   }
 }
Example #7
0
 private static void testStorage() {
   String store = SiteTest.getAStoragePath();
   SiteTest.site.setStoragePath(store);
   SiteTest.properties.put("storage", store);
 }
Example #8
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);
  }