Skip to content

Commit

Permalink
improved test resource provider creation for more flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
S1artie committed Jul 12, 2013
1 parent 3897748 commit b99838a
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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<String, String> 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<String, String> tempIgnored : tempProvider.getIgnoredReferencesWithReasons()) {
System.out.println("WARNING: Reference to resource '" + tempIgnored.getKey()
+ "' was ignored because it " + tempIgnored.getValue());
}
}
}
return tempResourceProvider;
}

/**
Expand Down Expand Up @@ -343,7 +346,7 @@ protected void addParameterizedConstants(Map<String, String> someParameterizedCo
* the list with the test script paths
* @return a resource provider instance
*/
protected FilesystemTestResourceProvider createResourceProvider(List<File> aPathList) {
protected TestResourceProvider createResourceProvider(List<File> aPathList) {
FilesystemTestResourceProvider tempResourceProvider = new FilesystemTestResourceProvider();
tempResourceProvider.addAllRecursively(aPathList);
return tempResourceProvider;
Expand Down

0 comments on commit b99838a

Please sign in to comment.