Beispiel #1
0
  @Override
  protected void setUpInternal() throws Exception {
    super.setUpInternal();

    List<Class> classes =
        TestUtilities.getHierarchyClassesToHandle(
            getClass(), new Class[] {TestDictionaryConfig.class}, new HashSet<String>());

    // if annotation is present then initialize test data dictionary (setup once per suite)
    if (!classes.isEmpty()) {
      ConfigurableApplicationContext context =
          new ClassPathXmlApplicationContext("TestDataDictionary.xml");
      dd = (DataDictionary) context.getBean("testDataDictionary");

      // add any additional dictionary files required by the test
      for (Class c : classes) {
        if (c.isAnnotationPresent(TestDictionaryConfig.class)) {
          TestDictionaryConfig testDictionaryConfig =
              (TestDictionaryConfig) c.getAnnotation(TestDictionaryConfig.class);

          String namespaceCode = testDictionaryConfig.namespaceCode();
          String dictionaryFileString = testDictionaryConfig.dataDictionaryFiles();

          String[] dictionaryFiles = StringUtils.split(dictionaryFileString, ",");
          for (String dictionaryFile : dictionaryFiles) {
            LOG.info("Adding test data dictionary file: " + dictionaryFile);

            dd.addConfigFileLocation(namespaceCode, dictionaryFile);
          }
        }
      }

      dd.parseDataDictionaryConfigurationFiles(false);
      dd.validateDD(
          false); // Validation performs some necessary post-processing of the beans - we need to
                  // run this each time we add new files
      dd.performBeanOverrides();
    }
  }
 /**
  * @see org.kuali.rice.krad.service.DataDictionaryService#addDataDictionaryLocations(
  *     java.lang.String, java.util.List<java.lang.String>)
  */
 public void addDataDictionaryLocations(String namespaceCode, List<String> locations)
     throws IOException {
   for (String location : locations) {
     dataDictionary.addConfigFileLocation(namespaceCode, location);
   }
 }