// Private Methods ---------------------------------------------------------
private TestResult doGenericLocaleRequiredFields(PortletConfig config,
PortletRequest request,
Locale locale) {
TestResult result = new TestResult();
result.setDescription("Retrieve the title and ensure it's set properly "
+ "under local " + locale);
// Retrieve title, short title and keywords from portlet resource bundle.
ResourceBundle bundle = config.getResourceBundle(locale);
if (bundle == null) {
result.setReturnCode(TestResult.WARNING);
result.setResultMessage("A function upon which this test depends "
+ "failed to execute as expected. "
+ "Check the other test results in this test suite.");
return result;
}
String title = bundle.getString(TITLE_KEY);
String shortTitle = bundle.getString(SHORT_TITLE_KEY);
String keywords = bundle.getString(KEYWORDS_KEY);
// Retrieve expected title, short title and keywords from test config.
String suffix = isBundleDeclared() ? ("_" + locale.getLanguage()) : "";
Map initParams = getInitParameters();
String expectedTitle = (String) initParams.get(
TITLE_PARAM + suffix);
String expectedShortTitle = (String) initParams.get(
SHORT_TITLE_PARAM + suffix);
String expectedKeywords = (String) initParams.get(
KEYWORDS_PARAM + suffix);
// Assert that values retrieved from resource bundler are expected.
boolean inconsistent = false;
StringBuffer buffer = new StringBuffer();
buffer.append("The following information is not correct: ");
if (title == null || expectedTitle == null
|| !title.trim().equals(expectedTitle.trim())) {
inconsistent = true;
buffer.append("Inconsistent title: '")
.append(title).append("' != '")
.append(expectedTitle).append("'; ");
}
if (shortTitle == null || expectedShortTitle == null
|| !shortTitle.trim().equals(expectedShortTitle.trim())) {
inconsistent = true;
buffer.append("Inconsistent short title: '")
.append(shortTitle).append("' != '")
.append(expectedShortTitle).append("'; ");
}
if (keywords == null || expectedKeywords == null
|| !keywords.trim().equals(expectedKeywords.trim())) {
inconsistent = true;
buffer.append("Inconsistent keywords: '")
.append(keywords).append("' != '")
.append(expectedKeywords).append("'; ");
}
if (!inconsistent) {
result.setReturnCode(TestResult.PASSED);
} else {
result.setReturnCode(TestResult.FAILED);
result.setResultMessage(buffer.toString());
}
return result;
}