John Crygier
2012-05-07 08d86d5b8852cab1837a53cc2c56bb661da59499
tests/com/gitblit/tests/RepositoryModelTest.java
@@ -25,11 +25,11 @@
   public static void startGitBlit() throws Exception {
      wasStarted = GitBlitSuite.startGitblit() == false;
      
      oldSection = Constants.CUSTOM_DEFINED_PROP_SECTION;
      oldSubSection = Constants.CUSTOM_DEFINED_PROP_SUBSECTION;
      oldSection = Constants.CUSTOM_FIELDS_PROP_SECTION;
      oldSubSection = Constants.CUSTOM_FIELDS_PROP_SUBSECTION;
      
      Constants.CUSTOM_DEFINED_PROP_SECTION = "RepositoryModelTest";
      Constants.CUSTOM_DEFINED_PROP_SUBSECTION = "RepositoryModelTestSubSection";
      Constants.CUSTOM_FIELDS_PROP_SECTION = "RepositoryModelTest";
      Constants.CUSTOM_FIELDS_PROP_SUBSECTION = "RepositoryModelTestSubSection";
   }
   
   @AfterClass
@@ -37,8 +37,8 @@
      if (wasStarted == false)
         GitBlitSuite.stopGitblit();
      
      Constants.CUSTOM_DEFINED_PROP_SECTION = oldSection;
      Constants.CUSTOM_DEFINED_PROP_SUBSECTION = oldSubSection;
      Constants.CUSTOM_FIELDS_PROP_SECTION = oldSection;
      Constants.CUSTOM_FIELDS_PROP_SUBSECTION = oldSubSection;
   }
   
   @Before
@@ -46,9 +46,9 @@
      Repository r = GitBlitSuite.getHelloworldRepository();
      StoredConfig config = JGitUtils.readConfig(r);
      
      config.unsetSection(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION);
      config.setString(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION, "commitMessageRegEx", "\\d");
      config.setString(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION, "anotherProperty", "Hello");
      config.unsetSection(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION);
      config.setString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, "commitMessageRegEx", "\\d");
      config.setString(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION, "anotherProperty", "Hello");
      
      config.save();
   }
@@ -58,7 +58,7 @@
      Repository r = GitBlitSuite.getHelloworldRepository();
      StoredConfig config = JGitUtils.readConfig(r);
      
      config.unsetSection(Constants.CUSTOM_DEFINED_PROP_SECTION, Constants.CUSTOM_DEFINED_PROP_SUBSECTION);
      config.unsetSection(Constants.CUSTOM_FIELDS_PROP_SECTION, Constants.CUSTOM_FIELDS_PROP_SUBSECTION);
      config.save();
   }
@@ -67,8 +67,8 @@
      RepositoryModel model = GitBlit.self().getRepositoryModel(
            GitBlitSuite.getHelloworldRepository().getDirectory().getName());
      
      assertEquals("\\d", model.customDefinedProperties.get("commitMessageRegEx"));
      assertEquals("Hello", model.customDefinedProperties.get("anotherProperty"));
      assertEquals("\\d", model.customFields.get("commitMessageRegEx"));
      assertEquals("Hello", model.customFields.get("anotherProperty"));
   }
   
   @Test
@@ -76,17 +76,17 @@
      RepositoryModel model = GitBlit.self().getRepositoryModel(
            GitBlitSuite.getHelloworldRepository().getDirectory().getName());
      
      assertEquals("\\d", model.customDefinedProperties.get("commitMessageRegEx"));
      assertEquals("Hello", model.customDefinedProperties.get("anotherProperty"));
      assertEquals("\\d", model.customFields.get("commitMessageRegEx"));
      assertEquals("Hello", model.customFields.get("anotherProperty"));
      
      assertEquals("Hello", model.customDefinedProperties.put("anotherProperty", "GoodBye"));
      assertEquals("Hello", model.customFields.put("anotherProperty", "GoodBye"));
      GitBlit.self().updateRepositoryModel(model.name, model, false);
      
      model = GitBlit.self().getRepositoryModel(
            GitBlitSuite.getHelloworldRepository().getDirectory().getName());
      
      assertEquals("\\d", model.customDefinedProperties.get("commitMessageRegEx"));
      assertEquals("GoodBye", model.customDefinedProperties.get("anotherProperty"));
      assertEquals("\\d", model.customFields.get("commitMessageRegEx"));
      assertEquals("GoodBye", model.customFields.get("anotherProperty"));
   }
}