public void testGetText() {
ElementDetails elementDetails = MenuModelHelper.createElementDetails();
ConcreteMenuText text = new ConcreteMenuText(elementDetails);
ConcreteMenuIcon icon = new ConcreteMenuIcon(elementDetails);
MenuLabel label;
text.setText(testText);
icon.setNormalURL(testIcon);
// Test illegal configurations
try {
label = createTestInstance(MenuModelHelper.createElementDetails(),
null,
null);
fail("The creation of a class should have caused an exception");
} catch (IllegalArgumentException iae) {
// Test passes - exception gets thrown :-)
}
try {
label = createTestInstance(MenuModelHelper.createElementDetails(),
null,
icon);
fail("The creation of a class should have caused an exception");
} catch (IllegalArgumentException iae) {
// Test passes - exception gets thrown :-)
}
// Test legal configuration
text.setText(testText);
label = createTestInstance(MenuModelHelper.createElementDetails(),
text,
icon);
MenuText testMenuText = label.getText();
assertNotNull("Menu text should not be null", testMenuText);
assertEquals("The menu texts should be the same", text, testMenuText);
// Test method
OutputBuffer secondTestText = new DOMOutputBuffer();
ConcreteMenuText secondText = new ConcreteMenuText(elementDetails);
secondText.setText(secondTestText);
((ConcreteMenuLabel)label).setText(secondText);
testMenuText = label.getText();
assertNotNull("Menu text should not be null", testMenuText);
assertEquals("The menu texts should be the same",
secondText, testMenuText);
}