ContentTable scriptsListingTable = ejtt.tabMenu.getTabContentBox().getFirstTable();
// Go through the dir, and check whether each *.sh file is listed in the page.
File binDir = new File(ejtt.getJBossHomeDir());
if( !binDir.isDirectory() )
throw new EmbJoprTestException(binDir.getAbsolutePath()+" is not a directory.");
// Get the list of .sh files in the <JBOSS_HOME>/bin dir.
log.info("Scanning directory "+binDir.getAbsolutePath());
//File scriptFiles[] = binDir.listFiles(new FilenameSuffixFilter("sh"));
File scriptFiles[] = binDir.listFiles((FilenameFilter)new SuffixFileFilter(".sh"));
/*
List<String> notListedScripts = new ArrayList();
for( File file : scriptFiles ) {
// Go to the scripts node.
ejtt.navTree.getNodeByLabel(NAV_SCRIPTS).click();
// Check whether the script is listed (on any page).
ContentTableRow row = ejtt.getTabMenu().getTabContentBox().findLinkRowInDataTableUsingPagination(file.getName());
if( null == row )
notListedScripts.add("");
}
/*/
// Faster method.
List<String> notListedScripts = new ArrayList();
for( File file : scriptFiles ) {
notListedScripts.add(file.getName());
log.info("Script in bin/ : "+file.getName());
}
// Go to the scripts node.
ejtt.navTree.getNodeByLabel(NAV_SCRIPTS).click();
int curPage = 1;
do {
log.info("Scanning scripts listing, page "+curPage);
// Remove all scripts listed on this page from the not-listed list.
ContentTable scriptListingTable = ejtt.getTabMenu().getTabContentBox().getDefaultTable();
for( ContentTableRow row : scriptListingTable.getRows() ) {
String scriptName = row.getCell(0).getTextContent().trim();
notListedScripts.remove(scriptName);
log.info("Listed script: '"+scriptName+"'");
}
// Go to the next page. If there's no next page, quit the loop.
Page originalPage = ejtt.getClient().getContentPage();
boolean wentNext = ejtt.getTabMenu().getTabContentBox().getPagination().goNext();
if( !wentNext )
break;
if( originalPage.equals( ejtt.getClient().getContentPage() ) )
break;
} while( true );
/**/
// If some of the scripts from the <JBOSS_HOME>/bin directory are not listed, throw.
if( 0 < notListedScripts.size() ){
throw new EmbJoprTestException("Following <JBOSS_HOME>/bin/*.sh files are not listed: "+notListedScripts.toArray( new String[0] ) );
}
}