HTML and CSS Reference
In-Depth Information
@Test
public void testGibberishParagraphsRandomText() throws Exception {
RandomTextAPI.TextType type = RandomTextAPI.TextType.gibberish;
RandomTextAPI.OutputTag output = RandomTextAPI.OutputTag.p;
RandomTextAPI instance = new RandomTextAPI();
String result = instance.getRandomText(type, output, outputCount, wordCountLower,
wordCountUpper);
int paragraphCount = StringUtils.countMatches(result, "<p>");
assertEquals("Incorrect number of paragraphs", outputCount, paragraphCount);
}
@Test
public void testLoremIpsumParagraphsRandomText() throws Exception {
RandomTextAPI.TextType type = RandomTextAPI.TextType.lorem;
RandomTextAPI.OutputTag output = RandomTextAPI.OutputTag.p;
RandomTextAPI instance = new RandomTextAPI();
String result = instance.getRandomText(type, output, outputCount, wordCountLower,
wordCountUpper);
int paragraphCount = StringUtils.countMatches(result, "<p>");
boolean containsLoremIpsum = result.contains("Lorem ipsum");
assertEquals("Incorrect number of paragraphs", outputCount, paragraphCount);
assertTrue("Lorem Ipsum was not found in the result", containsLoremIpsum);
}
}
Step 2—Creating the Custom Component
Now that we have our logic in place, we can go on to implement the component. As mentioned previously, all components
must extend
UIComponent
or one of its subtypes.
UIComponentBase
is a subtype of
UIComponent. UIComponentBase
provides a default implementation of all abstract methods expect
getFamily()
. You would implement
UIComponent
when you need a complete custom solution that is not catered for in the
UIComponentBase
implementation. In most
situations you would want to implement
UIComponentBase
or one of the standard components such as
UIInput
for an
input component or
UIOutput
for an output component. In Figure
6-2
you can see a UML diagram of the
UIComponent
class hierarchy.