From b99838ac7e785e00d367a70d8ca347fc63b4b1d4 Mon Sep 17 00:00:00 2001 From: Rene Schneider Date: Fri, 12 Jul 2013 15:39:53 +0200 Subject: [PATCH] improved test resource provider creation for more flexibility --- .../runner/console/ConsoleTestExecutor.java | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/de.gebit.integrity.runner/src/de/gebit/integrity/runner/console/ConsoleTestExecutor.java b/de.gebit.integrity.runner/src/de/gebit/integrity/runner/console/ConsoleTestExecutor.java index ac2b02252..582de7e6e 100644 --- a/de.gebit.integrity.runner/src/de/gebit/integrity/runner/console/ConsoleTestExecutor.java +++ b/de.gebit.integrity.runner/src/de/gebit/integrity/runner/console/ConsoleTestExecutor.java @@ -162,7 +162,8 @@ public void run(String[] someArgs) { TransformHandling tempTransformHandling = evaluateTransformHandling(tempXsltOption); String tempExecutionName = tempNameOption.getValue("unnamed"); String tempRootSuiteName = getRootSuiteNameFrom(tempRemainingParameters); - TestResourceProvider tempResourceProvider = getResourceProviderAndPrintWarnings(tempRemainingParameters); + TestResourceProvider tempResourceProvider = createResourceProvider(getScriptsList(tempRemainingParameters)); + validateResourceProvider(tempResourceProvider); try { TestModel tempModel = TestModel.loadTestModel(tempResourceProvider, tempResolveAllReferences.isSet(), @@ -256,21 +257,23 @@ protected String getRootSuiteNameFrom(String[] someRemainingParameters) { } /** - * Gets an resource provider for the listed resources in the remaining parameter and warns about ignored references. + * Performs any validation steps on the provided resource provider, such as checking for ignored references in case + * of a {@link FilesystemTestResourceProvider}. What this method does is highly dependent on the capabilities of the + * method and the actual resource provider class. * - * @param someRemainingParameters - * Remaining parameter where to extract the script lists from. - * @return An resource provider + * @param aProvider + * The provider to validate */ - protected TestResourceProvider getResourceProviderAndPrintWarnings(String[] someRemainingParameters) { - FilesystemTestResourceProvider tempResourceProvider = createResourceProvider(getScriptsList(someRemainingParameters)); - if (tempResourceProvider.hasIgnoredReferences()) { - for (Entry tempIgnored : tempResourceProvider.getIgnoredReferencesWithReasons()) { - System.out.println("WARNING: Reference to resource '" + tempIgnored.getKey() - + "' was ignored because it " + tempIgnored.getValue()); + protected void validateResourceProvider(TestResourceProvider aProvider) { + if (aProvider instanceof FilesystemTestResourceProvider) { + FilesystemTestResourceProvider tempProvider = (FilesystemTestResourceProvider) aProvider; + if (tempProvider.hasIgnoredReferences()) { + for (Entry tempIgnored : tempProvider.getIgnoredReferencesWithReasons()) { + System.out.println("WARNING: Reference to resource '" + tempIgnored.getKey() + + "' was ignored because it " + tempIgnored.getValue()); + } } } - return tempResourceProvider; } /** @@ -343,7 +346,7 @@ protected void addParameterizedConstants(Map someParameterizedCo * the list with the test script paths * @return a resource provider instance */ - protected FilesystemTestResourceProvider createResourceProvider(List aPathList) { + protected TestResourceProvider createResourceProvider(List aPathList) { FilesystemTestResourceProvider tempResourceProvider = new FilesystemTestResourceProvider(); tempResourceProvider.addAllRecursively(aPathList); return tempResourceProvider;