serverDef = XMLHelper.getServerDefinition( is, Constants.SERVER_FILE );
}
catch ( Throwable e ) {
String msg = "Failed to obtain test recorder server definition from XML";
log.error( msg, e );
throw new ConfigException( msg, e );
}
finally {
if ( is != null ) {
try {
is.close();
}
catch ( IOException e ) {
log.error( "Failed closing stream of server definition XML", e );
throw e;
}
}
}
if ( serverDef == null ) {
String msg = "Failed to obtain test recorder server definition from XML";
log.error( msg );
throw new ConfigException( msg );
}
// the schema insures that at least one webapp is defined
assert serverDef.getWebappCount() != 0 : "no webapps defined in server definition XML file" ;
String webappList = getWebappsProperty();
if ( webappList == null ) {
String msg = "ERROR: the '" + WEBAPPS_PROPERTY + "' property must be set.";
log.error( msg );
throw new ConfigException( msg );
}
webappList = webappList.trim();
WebappDefinition webapp = null;
TestDefinitions tests = null;
if ( webappList.equalsIgnoreCase( "all" ) ) {
WebappDefinition[] webappDefList = serverDef.getWebapps();
for ( int i = 0; i < webappDefList.length; i++ ) {
webapp = webappDefList[i];
tests = getTestDefinitions( webapp );
if ( tests == null ) {
continue;
}
serverDef.addTestDefinitions( webapp, tests );
}
}
else {
String webappName = null;
for ( StringTokenizer stringTokenizer = new StringTokenizer( webappList, "," );
stringTokenizer.hasMoreTokens(); ) {
webappName = stringTokenizer.nextToken().trim();
if ( webappName.length() == 0 ) {
continue;
}
webapp = serverDef.getWebapp( webappName );
if ( webapp == null ) {
String msg = "WARNING: no webapp found with name( " + webappName + " )";
if ( log.isErrorEnabled() ) {
log.error( msg );
}
System.err.println( msg );
continue;
}
if ( log.isDebugEnabled() ) {
log.debug( "retrieving test definition for webapp at( " + webapp.getContextRoot() + " )" );
}
tests = getTestDefinitions( webapp );
if ( tests == null ) {
continue;
}
serverDef.addTestDefinitions( webapp, tests );
}
}
if ( serverDef.getTestDefinitionsCount() == 0 ) {
String msg = "ERROR: no test definitions found";
log.error( msg );
throw new ConfigException( msg );
}
}