/** * Load only the given set of context files. * * @param contextFiles The set of context file to be loaded. * @throws IllegalArgumentException If one of the given files has an invalid name. */ public void loadContexts(Set<File> contextFiles) { for (File file : contextFiles) { ContextConfiguration contextConfiguration; String[] split = file.getName().split("\\."); if (split.length < 3 || !(split[0].equals(FILE_PREFIX)) || !(split[split.length - 1].equals(FILE_POSTFIX))) { throw new IllegalArgumentException("Wrong file format"); } try { contextConfiguration = ContextConfiguration.loadFromFile(file); } catch (InvalidConfigurationException e) { throw new IllegalStateException("Invalid configuration in file: " + file.getName(), e); } catch (FileNotFoundException e) { throw new IllegalStateException( "No context file with given name found: " + file.getName(), e); } List<String> id = Arrays.asList(split).subList(1, split.length - 1); testContexts.insertIntoTree( id.iterator(), new TestContext( Joiner.on("").join(id), this.distributionResolver, this.distributionExtractor, contextConfiguration)); } }