Java Code Examples for org.codehaus.groovy.runtime.StringGroovyMethods#normalize()

The following examples show how to use org.codehaus.groovy.runtime.StringGroovyMethods#normalize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroovyDocToolTest.java    From groovy with Apache License 2.0 6 votes vote down vote up
public void testAbstractMethods() throws Exception {
    final String base = "org/codehaus/groovy/tools/groovydoc/testfiles";
    htmlTool.add(Arrays.asList(
        base + "/GroovyClassWithMultipleInterfaces.groovy",
        base + "/JavaClassWithDiamond.java"
    ));

    final MockOutputTool output = new MockOutputTool();
    htmlTool.renderToOutput(output, MOCK_DIR);

    final String groovydoc = output.getText(MOCK_DIR + "/" + base + "/GroovyClassWithMultipleInterfaces.html");
    final String javadoc = StringGroovyMethods.normalize(output.getText(MOCK_DIR + "/" + base + "/JavaClassWithDiamond.html"));

    final Pattern methodSummary = Pattern.compile("<code>(public&nbsp;)?abstract&nbsp;void</code>");
    final Pattern methodDetails = Pattern.compile("<h4>(public&nbsp;)?abstract&nbsp;void <strong>link</strong>");

    assertTrue("The Groovy method summary should contain 'abstract'", methodSummary.matcher(groovydoc).find());
    assertTrue("The Java method summary should contain 'abstract'", methodSummary.matcher(javadoc).find());
    assertTrue("The Groovy method details should contain 'abstract'", methodDetails.matcher(groovydoc).find());
    assertTrue("The Java method details should contain 'abstract'", methodDetails.matcher(javadoc).find());
}
 
Example 2
Source File: GroovyDocToolTest.java    From groovy with Apache License 2.0 4 votes vote down vote up
public void testLinksToSamePackage() throws Exception {
    final String base = "org/codehaus/groovy/tools/groovydoc/testfiles";
    htmlTool.add(Arrays.asList(
            base + "/GroovyInterface1.groovy",
            base + "/JavaClassWithDiamond.java"
    ));

    final MockOutputTool output = new MockOutputTool();
    htmlTool.renderToOutput(output, MOCK_DIR);

    final String groovydoc = output.getText(MOCK_DIR + "/" + base + "/GroovyInterface1.html");
    final String javadoc = StringGroovyMethods.normalize(output.getText(MOCK_DIR + "/" + base + "/JavaClassWithDiamond.html"));

    final Matcher groovyClassComment = Pattern.compile(Pattern.quote(
            "<p> <a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/JavaClassWithDiamond.html#link()' title='Java'>Java</a> " +
                    "<DL><DT><B>See Also:</B></DT>" +
                    "<DD><a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/JavaClassWithDiamond.html' title='JavaClassWithDiamond'>JavaClassWithDiamond</a></DD>" +
                    "</DL></p>"
    )).matcher(groovydoc);
    final Matcher groovyMethodComment = Pattern.compile(Pattern.quote(
            "<p> <a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/JavaClassWithDiamond.html#link()' title='Java link'>Java link</a> " +
                    "<DL><DT><B>See Also:</B></DT>" +
                    "<DD><a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/JavaClassWithDiamond.html#link()' title='JavaClassWithDiamond.link'>JavaClassWithDiamond.link</a></DD>" +
                    "</DL></p>"
    )).matcher(groovydoc);
    final Matcher javaClassComment = Pattern.compile(Pattern.quote(
            "<p> <a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/GroovyInterface1.html#link()' title='Groovy link'>Groovy link</a>\n" +
                    "  <DL><DT><B>See Also:</B></DT>" +
                    "<DD><a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/GroovyInterface1.html' title='GroovyInterface1'>GroovyInterface1</a></DD>" +
                    "</DL></p>"
    )).matcher(javadoc);
    final Matcher javaMethodComment = Pattern.compile(Pattern.quote(
            "<p> <a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/GroovyInterface1.html#link()' title='Groovy link'>Groovy link</a>\n" +
                    "      <DL><DT><B>See Also:</B></DT>" +
                    "<DD><a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/GroovyInterface1.html#link()' title='GroovyInterface1.link'>GroovyInterface1.link</a></DD>" +
                    "</DL></p>"
    )).matcher(javadoc);

    assertTrue("The Groovy class comment should contain links", groovyClassComment.find());
    assertTrue("The Groovy method comment should contain links", groovyMethodComment.find());
    assertTrue("The Java class comment should contain links", javaClassComment.find());
    assertTrue("The Java method comment should contain links", javaMethodComment.find());
}