Simplified HTML header sections. Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/bed066ee Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/bed066ee Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/bed066ee
Branch: refs/heads/master Commit: bed066ee0a27e925d2dfe1d35222ba4a5299a47c Parents: 6e47b7f Author: JamesBognar <[email protected]> Authored: Mon Jul 10 21:20:41 2017 -0400 Committer: JamesBognar <[email protected]> Committed: Mon Jul 10 21:20:41 2017 -0400 ---------------------------------------------------------------------- .../apache/juneau/svl/vars/SwitchVarTest.java | 40 +-- .../juneau/html/HtmlDocSerializerContext.java | 153 +-------- .../juneau/html/HtmlDocSerializerSession.java | 43 +-- .../juneau/html/HtmlDocTemplateBasic.java | 18 +- .../org/apache/juneau/svl/DefaultingVar.java | 2 +- .../main/java/org/apache/juneau/svl/MapVar.java | 5 +- .../java/org/apache/juneau/svl/SimpleVar.java | 6 +- .../java/org/apache/juneau/svl/StreamedVar.java | 2 +- .../main/java/org/apache/juneau/svl/Var.java | 9 +- .../java/org/apache/juneau/svl/VarResolver.java | 2 +- .../apache/juneau/svl/VarResolverSession.java | 44 ++- .../apache/juneau/svl/vars/ConfigFileVar.java | 2 +- .../apache/juneau/svl/vars/EnvVariablesVar.java | 2 +- .../org/apache/juneau/svl/vars/SwitchVar.java | 16 +- .../juneau/svl/vars/SystemPropertiesVar.java | 2 +- .../utils/ExtendedMimetypesFileTypeMap.java | 88 +++++ .../org/apache/juneau/utils/ResourceFinder.java | 4 +- juneau-core/src/main/javadoc/overview.html | 60 +++- .../examples/rest/DockerRegistryResource.java | 9 +- .../examples/rest/RequestEchoResource.java | 3 - .../DockerRegistryResourceAside_en.html | 19 ++ .../juneau/microservice/Microservice.java | 4 +- .../microservice/resources/LogsResource.java | 4 - .../rest/test/HtmlPropertiesResource.java | 330 ------------------- .../java/org/apache/juneau/rest/test/Root.java | 1 - .../juneau/rest/test/HtmlPropertiesTest.java | 245 -------------- .../org/apache/juneau/rest/test/_TestSuite.java | 1 - .../java/org/apache/juneau/rest/CallMethod.java | 13 +- .../org/apache/juneau/rest/ReaderResource.java | 18 + .../java/org/apache/juneau/rest/RestConfig.java | 159 +-------- .../org/apache/juneau/rest/RestContext.java | 99 +++--- .../org/apache/juneau/rest/RestRequest.java | 27 +- .../org/apache/juneau/rest/RestResponse.java | 139 +------- .../apache/juneau/rest/RestServletDefault.java | 13 +- .../apache/juneau/rest/annotation/HtmlDoc.java | 127 +------ .../juneau/rest/annotation/MethodSwagger.java | 17 +- .../juneau/rest/annotation/ResourceSwagger.java | 23 +- .../juneau/rest/annotation/RestMethod.java | 6 +- .../juneau/rest/annotation/RestResource.java | 17 +- .../rest/jena/RestServletJenaDefault.java | 11 +- .../org/apache/juneau/rest/vars/FileVar.java | 87 +++++ .../juneau/rest/vars/LocalizationVar.java | 2 +- .../org/apache/juneau/rest/vars/RequestVar.java | 38 ++- .../rest/vars/SerializedRequestAttrVar.java | 32 +- .../juneau/rest/vars/ServletInitParamVar.java | 2 +- .../apache/juneau/rest/vars/UrlEncodeVar.java | 2 +- .../org/apache/juneau/rest/vars/UrlVar.java | 5 +- .../org/apache/juneau/rest/vars/WidgetVar.java | 13 +- .../juneau/rest/widget/QueryMenuItem.html | 4 +- 49 files changed, 520 insertions(+), 1448 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/SwitchVarTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/SwitchVarTest.java b/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/SwitchVarTest.java index decd342..62167dc 100644 --- a/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/SwitchVarTest.java +++ b/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/SwitchVarTest.java @@ -29,25 +29,25 @@ public class SwitchVarTest { System.setProperty("SwitchVarTest.test", "foobar"); - assertEquals("YES", vr.resolve("$SWITCH{$S{SwitchVarTest.test},foobar,YES}")); - assertEquals("YES", vr.resolve("$SWITCH{ $S{ SwitchVarTest.test } , foobar , YES }")); - assertEquals("", vr.resolve("$SWITCH{$S{SwitchVarTest.test},foobar2,YES}")); - assertEquals("NO", vr.resolve("$SWITCH{$S{SwitchVarTest.test},foobar2,YES,NO}")); - assertEquals("NO", vr.resolve("$SWITCH{ $S{ SwitchVarTest.test } , foobar2 , YES , NO }")); - - assertEquals("YES", vr.resolve("$SWITCH{$S{SwitchVarTest.test},foo*,YES,NO}")); - assertEquals("YES", vr.resolve("$SWITCH{$S{SwitchVarTest.test},*bar,YES,NO}")); - assertEquals("YES", vr.resolve("$SWITCH{$S{SwitchVarTest.test},*,YES,NO}")); - assertEquals("YES", vr.resolve("$SWITCH{$S{SwitchVarTest.test},??????,YES,NO}")); - - assertEquals("NO", vr.resolve("$SWITCH{$S{SwitchVarTest.test},foox*,YES,NO}")); - assertEquals("NO", vr.resolve("$SWITCH{$S{SwitchVarTest.test},*xbar,YES,NO}")); - assertEquals("NO", vr.resolve("$SWITCH{$S{SwitchVarTest.test},?????,YES,NO}")); - assertEquals("NO", vr.resolve("$SWITCH{$S{SwitchVarTest.test},???????,YES,NO}")); - - assertEquals("YES2", vr.resolve("$SWITCH{$S{SwitchVarTest.test},foox*,YES1,foo*,YES2}")); - assertEquals("YES2", vr.resolve("$SWITCH{$S{SwitchVarTest.test},foox*,YES1,foo*,YES2,NO}")); - - assertEquals("NO", vr.resolve("$SWITCH{$S{SwitchVarTest.test},foox*,YES1,fooy*,YES2,NO}")); + assertEquals("YES", vr.resolve("$SW{$S{SwitchVarTest.test},foobar,YES}")); + assertEquals("YES", vr.resolve("$SW{ $S{ SwitchVarTest.test } , foobar , YES }")); + assertEquals("", vr.resolve("$SW{$S{SwitchVarTest.test},foobar2,YES}")); + assertEquals("NO", vr.resolve("$SW{$S{SwitchVarTest.test},foobar2,YES,NO}")); + assertEquals("NO", vr.resolve("$SW{ $S{ SwitchVarTest.test } , foobar2 , YES , NO }")); + + assertEquals("YES", vr.resolve("$SW{$S{SwitchVarTest.test},foo*,YES,NO}")); + assertEquals("YES", vr.resolve("$SW{$S{SwitchVarTest.test},*bar,YES,NO}")); + assertEquals("YES", vr.resolve("$SW{$S{SwitchVarTest.test},*,YES,NO}")); + assertEquals("YES", vr.resolve("$SW{$S{SwitchVarTest.test},??????,YES,NO}")); + + assertEquals("NO", vr.resolve("$SW{$S{SwitchVarTest.test},foox*,YES,NO}")); + assertEquals("NO", vr.resolve("$SW{$S{SwitchVarTest.test},*xbar,YES,NO}")); + assertEquals("NO", vr.resolve("$SW{$S{SwitchVarTest.test},?????,YES,NO}")); + assertEquals("NO", vr.resolve("$SW{$S{SwitchVarTest.test},???????,YES,NO}")); + + assertEquals("YES2", vr.resolve("$SW{$S{SwitchVarTest.test},foox*,YES1,foo*,YES2}")); + assertEquals("YES2", vr.resolve("$SW{$S{SwitchVarTest.test},foox*,YES1,foo*,YES2,NO}")); + + assertEquals("NO", vr.resolve("$SW{$S{SwitchVarTest.test},foox*,YES1,fooy*,YES2,NO}")); } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java index b185829..46fbd21 100644 --- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java @@ -78,147 +78,6 @@ import org.apache.juneau.*; public final class HtmlDocSerializerContext extends HtmlSerializerContext { /** - * <b>Configuration property:</b> Page title. - * - * <ul> - * <li><b>Name:</b> <js>"HtmlDocSerializer.title"</js> - * <li><b>Data type:</b> <code>String</code> - * <li><b>Default:</b> <jk>null</jk> - * <li><b>Session-overridable:</b> <jk>true</jk> - * </ul> - * - * <p> - * Specifies the text for the title that shows up in the header section of the page generated by the basic template. - * - * <h5 class='section'>Example:</h5> - * <p> - * The <code>AddressBookResource</code> sample class uses this property... - * <p class='bcode'> - * <ja>@RestResource</ja>( - * messages=<js>"nls/AddressBookResource"</js>, - * properties={ - * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_title</jsf>, value=<js>"$L{title}"</js>) - * } - * ) - * <jk>public class</jk> AddressBookResource <jk>extends</jk> RestServletJenaDefault { - * </p> - * - * <p> - * ...with this property in <code>AddressBookResource.properties</code>... - * <p class='bcode'> - * title = <js>AddressBook sample resource</js> - * </p> - * <p> - * ...to produce this title on the HTML page... - * <img class='bordered' src='doc-files/HTML_TITLE.png'> - * - * <p> - * Shortcuts on <ja>@RestResource</ja> are also provided for this setting: - * <p class='bcode'> - * <jc>// Example if you want the swagger doc and HTML doc to share the same title.</jc> - * <ja>@RestResource</ja>( - * messages=<js>"nls/AddressBookResource"</js>, - * title=<js>"My title"</js> - * ) - * - * <jc>// Example if you want the swagger doc and HTML doc to share the same title.</jc> - * <ja>@RestResource</ja>( - * messages=<js>"nls/AddressBookResource"</js>, - * title=<js>"My title in Swagger"</js>, - * htmldoc=<ja>@HtmlDoc</ja>( - * title=<js>"My title in HTML"</js> - * ) - * ) - * </p> - * - * <p> - * A value of <js>"NONE"</js> can be used to represent no value to differentiate it from an empty string. - */ - public static final String HTMLDOC_title = "HtmlDocSerializer.title"; - - /** - * <b>Configuration property:</b> Page description. - * - * <ul> - * <li><b>Name:</b> <js>"HtmlDocSerializer.description"</js> - * <li><b>Data type:</b> <code>String</code> - * <li><b>Default:</b> <jk>null</jk> - * <li><b>Session-overridable:</b> <jk>true</jk> - * </ul> - * - * <p> - * Specifies the text for the subtitle that shows up in the header section of the page generated by the basic - * template. - * - * <h5 class='section'>Example:</h5> - * <p> - * The <code>AddressBookResource</code> sample class uses this property... - * </p> - * <p class='bcode'> - * <ja>@RestResource</ja>( - * messages=<js>"nls/AddressBookResource"</js>, - * properties={ - * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_description</jsf>, - alue=<js>"My description"</js>) - * } - * ) - * <jk>public class</jk> AddressBookResource <jk>extends</jk> RestServletJenaDefault { - * </p> - * - * <p> - * ...with this property in <code>AddressBookResource.properties</code>... - * <p class='bcode'> - * description = <js>Simple address book POJO sample resource</js> - * </p> - * - * <p> - * ...to produce this description on the HTML page... - * <img class='bordered' src='doc-files/HTML_DESCRIPTION.png'> - * - * <p> - * Shortcuts on <ja>@RestResource</ja> are also provided for this setting: - * <p class='bcode'> - * <jc>// Example if you want the swagger doc and HTML doc to share the same description.</jc> - * <ja>@RestResource</ja>( - * messages=<js>"nls/AddressBookResource"</js>, - * description=<js>"My description"</js> - * ) - * - * <jc>// Example if you want the swagger doc and HTML doc to share the same description.</jc> - * <ja>@RestResource</ja>( - * messages=<js>"nls/AddressBookResource"</js>, - * description=<js>"My description in Swagger"</js>, - * htmldoc=<ja>@HtmlDoc</ja>( - * description=<js>"My description in HTML"</js> - * ) - * ) - * </p> - * - * <p> - * A value of <js>"NONE"</js> can be used to represent no value to differentiate it from an empty string. - */ - public static final String HTMLDOC_description = "HtmlDocSerializer.description"; - - /** - * <b>Configuration property:</b> Page branding. - * - * <ul> - * <li><b>Name:</b> <js>"HtmlDocSerializer.branding"</js> - * <li><b>Data type:</b> <code>String</code> - * <li><b>Default:</b> <jk>null</jk> - * <li><b>Session-overridable:</b> <jk>true</jk> - * </ul> - * - * <p> - * Specifies arbitrary HTML for the header that can be used for adding custom branding to the page generated by the - * basic template. - * - * <p> - * A value of <js>"NONE"</js> can be used to represent no value to differentiate it from an empty string. - */ - public static final String HTMLDOC_branding = "HtmlDocSerializer.branding"; - - /** * <b>Configuration property:</b> Header section contents. * * <ul> @@ -244,10 +103,6 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext { * </p> * * <p> - * When this property is specified, the {@link #HTMLDOC_title} and {@link #HTMLDOC_description} properties are - * ignored. - * - * <p> * A value of <js>"NONE"</js> can be used to represent no value to differentiate it from an empty string. */ public static final String HTMLDOC_header = "HtmlDocSerializer.header"; @@ -608,7 +463,7 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext { final String[] style, stylesheet, script, links; - final String title, description, branding, header, nav, aside, footer, noResultsMessage; + final String header, nav, aside, footer, noResultsMessage; final boolean nowrap; final HtmlDocTemplate template; @@ -625,9 +480,6 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext { style = ps.getProperty(HTMLDOC_style, String[].class, new String[0]); stylesheet = ps.getProperty(HTMLDOC_stylesheet, String[].class, new String[0]); script = ps.getProperty(HTMLDOC_script, String[].class, new String[0]); - title = ps.getProperty(HTMLDOC_title, String.class, null); - description = ps.getProperty(HTMLDOC_description, String.class, null); - branding = ps.getProperty(HTMLDOC_branding, String.class, null); header = ps.getProperty(HTMLDOC_header, String.class, null); nav = ps.getProperty(HTMLDOC_nav, String.class, null); aside = ps.getProperty(HTMLDOC_aside, String.class, null); @@ -642,9 +494,6 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext { public ObjectMap asMap() { return super.asMap() .append("HtmlDocSerializerContext", new ObjectMap() - .append("title", title) - .append("text", description) - .append("branding", branding) .append("header", header) .append("nav", nav) .append("links", links) http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java index a7f3050..072bbd8 100644 --- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java @@ -34,7 +34,7 @@ import org.apache.juneau.serializer.*; */ public final class HtmlDocSerializerSession extends HtmlSerializerSession { - private final String title, description, branding, header, nav, aside, footer, noResultsMessage; + private final String header, nav, aside, footer, noResultsMessage; private final String[] style, stylesheet, script, links; private final boolean nowrap; private final HtmlDocTemplate template; @@ -67,9 +67,6 @@ public final class HtmlDocSerializerSession extends HtmlSerializerSession { Locale locale, TimeZone timeZone, MediaType mediaType, UriContext uriContext) { super(ctx, op, output, javaMethod, locale, timeZone, mediaType, uriContext); if (op == null || op.isEmpty()) { - title = ctx.title; - description = ctx.description; - branding = ctx.branding; header = ctx.header; nav = ctx.nav; aside = ctx.aside; @@ -82,9 +79,6 @@ public final class HtmlDocSerializerSession extends HtmlSerializerSession { noResultsMessage = ctx.noResultsMessage; template = ClassUtils.newInstance(HtmlDocTemplate.class, ctx.template); } else { - title = op.getString(HTMLDOC_title, ctx.title); - description = op.getString(HTMLDOC_description, ctx.description); - branding = op.getString(HTMLDOC_branding, ctx.branding); header = op.getString(HTMLDOC_header, ctx.nav); nav = op.getString(HTMLDOC_nav, ctx.nav); aside = op.getString(HTMLDOC_aside, ctx.aside); @@ -145,41 +139,6 @@ public final class HtmlDocSerializerSession extends HtmlSerializerSession { } /** - * Returns the {@link HtmlDocSerializerContext#HTMLDOC_title} setting value in this context. - * - * @return - * The {@link HtmlDocSerializerContext#HTMLDOC_title} setting value in this context. - * <jk>null</jk> if not specified. Never an empty string. - */ - public final String getTitle() { - return title; - } - - /** - * Returns the {@link HtmlDocSerializerContext#HTMLDOC_description} setting value in this context. - * - * @return - * The {@link HtmlDocSerializerContext#HTMLDOC_description} setting value in this context. - * <jk>null</jk> if not specified. - * Never an empty string. - */ - public final String getDescription() { - return description; - } - - /** - * Returns the {@link HtmlDocSerializerContext#HTMLDOC_branding} setting value in this context. - * - * @return - * The {@link HtmlDocSerializerContext#HTMLDOC_branding} setting value in this context. - * <jk>null</jk> if not specified. - * Never an empty string. - */ - public final String getBranding() { - return branding; - } - - /** * Returns the {@link HtmlDocSerializerContext#HTMLDOC_header} setting value in this context. * * @return http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java index b287458..a2101e7 100644 --- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java +++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java @@ -100,20 +100,8 @@ public class HtmlDocTemplateBasic implements HtmlDocTemplate { public void header(HtmlDocSerializerSession session, HtmlWriter w, HtmlDocSerializer s, Object o) throws Exception { // Write the title of the page. String header = session.getHeader(); - if (header != null) { - if (exists(header)) - w.append(3, header).nl(3); - } else { - String title = session.getTitle(); - String description = session.getDescription(); - String branding = session.getBranding(); - if (exists(title)) - w.oTag(3, "h1").append('>').append(title).eTag("h1").nl(3); - if (exists(description)) - w.oTag(3, "h2").append('>').append(description).eTag("h2").nl(3); - if (exists(branding)) - w.append(3, branding).nl(3); - } + if (exists(header)) + w.append(3, header).nl(3); } @@ -196,7 +184,7 @@ public class HtmlDocTemplateBasic implements HtmlDocTemplate { @Override /* HtmlDocTemplate */ public boolean hasHeader(HtmlDocSerializerSession session) { - return exists(session.getHeader()) || exists(session.getTitle()) || exists(session.getDescription()); + return exists(session.getHeader()); } @Override /* HtmlDocTemplate */ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/svl/DefaultingVar.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/DefaultingVar.java b/juneau-core/src/main/java/org/apache/juneau/svl/DefaultingVar.java index 6c2bcd6..2497f03 100644 --- a/juneau-core/src/main/java/org/apache/juneau/svl/DefaultingVar.java +++ b/juneau-core/src/main/java/org/apache/juneau/svl/DefaultingVar.java @@ -38,7 +38,7 @@ public abstract class DefaultingVar extends SimpleVar { } @Override /* Var*/ - public String doResolve(VarResolverSession session, String s) { + public String doResolve(VarResolverSession session, String s) throws Exception { int i = s.indexOf(','); if (i == -1) return resolve(session, s.trim()); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/svl/MapVar.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/MapVar.java b/juneau-core/src/main/java/org/apache/juneau/svl/MapVar.java index 85b830f..e13eeb6 100644 --- a/juneau-core/src/main/java/org/apache/juneau/svl/MapVar.java +++ b/juneau-core/src/main/java/org/apache/juneau/svl/MapVar.java @@ -16,6 +16,8 @@ import static org.apache.juneau.internal.ThrowableUtils.*; import java.util.*; +import org.apache.juneau.internal.*; + /** * A subclass of {@link DefaultingVar} that simply pulls values from a {@link Map}. * @@ -41,7 +43,6 @@ public abstract class MapVar extends DefaultingVar { @Override /* Var */ public String resolve(VarResolverSession session, String varVal) { - Object o = m.get(varVal); - return (o == null ? null : o.toString()); + return StringUtils.toString(m.get(varVal)); } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/svl/SimpleVar.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/SimpleVar.java b/juneau-core/src/main/java/org/apache/juneau/svl/SimpleVar.java index 3d926f4..ad74aa7 100644 --- a/juneau-core/src/main/java/org/apache/juneau/svl/SimpleVar.java +++ b/juneau-core/src/main/java/org/apache/juneau/svl/SimpleVar.java @@ -16,12 +16,12 @@ import java.io.*; /** * Abstract superclass of all Simple Var Language variables that resolve to simple returned string values. - * + * * <p> * Note the difference between this class and {@link StreamedVar} that streams values to writers. * Unlike the {@link StreamedVar} class, the returned value from this class can contain nested variables that will be * recursively resolved by {@link VarResolver}. - * + * * <p> * Subclasses must implement the {@link #resolve(VarResolverSession, String)} method. * @@ -39,7 +39,7 @@ public abstract class SimpleVar extends Var { } @Override /* Var */ - public void resolveTo(VarResolverSession session, Writer w, String arg) { + public void resolveTo(VarResolverSession session, Writer w, String arg) throws Exception { throw new UnsupportedOperationException("Cannot call streamTo() on SimpleVar class"); } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/svl/StreamedVar.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/StreamedVar.java b/juneau-core/src/main/java/org/apache/juneau/svl/StreamedVar.java index 7fc2ead..d94b93e 100644 --- a/juneau-core/src/main/java/org/apache/juneau/svl/StreamedVar.java +++ b/juneau-core/src/main/java/org/apache/juneau/svl/StreamedVar.java @@ -38,7 +38,7 @@ public abstract class StreamedVar extends Var { } @Override /* Var */ - public String resolve(VarResolverSession session, String arg) { + public String resolve(VarResolverSession session, String arg) throws Exception { throw new UnsupportedOperationException("Cannot call resolve() on StreamedVar class"); } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/svl/Var.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/Var.java b/juneau-core/src/main/java/org/apache/juneau/svl/Var.java index 7a0b6b9..3530e04 100644 --- a/juneau-core/src/main/java/org/apache/juneau/svl/Var.java +++ b/juneau-core/src/main/java/org/apache/juneau/svl/Var.java @@ -95,8 +95,9 @@ public abstract class Var { * @param session The session object used for a single instance of a string resolution. * @param arg The inside argument of the variable. * @return The resolved value. + * @throws Exception Any thrown exception will be serialized as <js>"{exceptionMessage}"</js> */ - protected String doResolve(VarResolverSession session, String arg) { + protected String doResolve(VarResolverSession session, String arg) throws Exception { return resolve(session, arg); } @@ -106,8 +107,9 @@ public abstract class Var { * @param session The session object used for a single instance of a var resolution. * @param arg The inside argument of the variable. * @return The resolved value. + * @throws Exception Any thrown exception will be serialized as <js>"{exceptionMessage}"</js> */ - public abstract String resolve(VarResolverSession session, String arg); + public abstract String resolve(VarResolverSession session, String arg) throws Exception; /** * The interface that needs to be implemented for subclasses of {@link StreamedVar}. @@ -115,6 +117,7 @@ public abstract class Var { * @param session The session object used for a single instance of a var resolution. * @param w The writer to send the resolved value to. * @param arg The inside argument of the variable. + * @throws Exception Any thrown exception will be serialized as <js>"{exceptionMessage}"</js> */ - public abstract void resolveTo(VarResolverSession session, Writer w, String arg); + public abstract void resolveTo(VarResolverSession session, Writer w, String arg) throws Exception; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/svl/VarResolver.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/VarResolver.java b/juneau-core/src/main/java/org/apache/juneau/svl/VarResolver.java index e7af243..54e987e 100644 --- a/juneau-core/src/main/java/org/apache/juneau/svl/VarResolver.java +++ b/juneau-core/src/main/java/org/apache/juneau/svl/VarResolver.java @@ -108,7 +108,7 @@ public class VarResolver { * <li><code>$S{key}</code>,<code>$S{key,default}</code> - System properties. * <li><code>$E{key}</code>,<code>$E{key,default}</code> - Environment variables. * <li><code>$IF{booleanValue,thenValue[,elseValue]}</code> - If-else patterns. - * <li><code>$SWITCH{test,matchPattern,thenValue[,matchPattern,thenValue][,elseValue]}</code> - Switch patterns. + * <li><code>$SW{test,matchPattern,thenValue[,matchPattern,thenValue][,elseValue]}</code> - Switch patterns. * </ul> * * @see SystemPropertiesVar http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/svl/VarResolverSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/VarResolverSession.java b/juneau-core/src/main/java/org/apache/juneau/svl/VarResolverSession.java index 0e4b8e1..2e24226 100644 --- a/juneau-core/src/main/java/org/apache/juneau/svl/VarResolverSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/svl/VarResolverSession.java @@ -90,15 +90,19 @@ public class VarResolverSession { String val = s.substring(s.indexOf('{')+1, s.length()-1); Var v = getVar(var); if (v != null) { - if (v.streamed) { - StringWriter sw = new StringWriter(); - v.resolveTo(this, sw, val); - return sw.toString(); + try { + if (v.streamed) { + StringWriter sw = new StringWriter(); + v.resolveTo(this, sw, val); + return sw.toString(); + } + s = v.doResolve(this, val); + if (s == null) + s = ""; + return resolve(s); + } catch (Exception e) { + return '{' + e.getLocalizedMessage() + '}'; } - s = v.doResolve(this, val); - if (s == null) - s = ""; - return resolve(s); } return s; } @@ -236,16 +240,20 @@ public class VarResolverSession { out.append(s, x2, i+1); x = i+1; } else { - if (r.streamed) - r.resolveTo(this, out, varVal); - else { - String replacement = r.doResolve(this, varVal); - if (replacement == null) - replacement = ""; - // If the replacement also contains variables, replace them now. - if (replacement.indexOf('$') != -1) - replacement = resolve(replacement); - out.append(replacement); + try { + if (r.streamed) + r.resolveTo(this, out, varVal); + else { + String replacement = r.doResolve(this, varVal); + if (replacement == null) + replacement = ""; + // If the replacement also contains variables, replace them now. + if (replacement.indexOf('$') != -1) + replacement = resolve(replacement); + out.append(replacement); + } + } catch (Exception e) { + out.append('{').append(e.getLocalizedMessage()).append('}'); } x = i+1; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/svl/vars/ConfigFileVar.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/vars/ConfigFileVar.java b/juneau-core/src/main/java/org/apache/juneau/svl/vars/ConfigFileVar.java index d253c6b..9512f58 100644 --- a/juneau-core/src/main/java/org/apache/juneau/svl/vars/ConfigFileVar.java +++ b/juneau-core/src/main/java/org/apache/juneau/svl/vars/ConfigFileVar.java @@ -19,7 +19,7 @@ import org.apache.juneau.svl.*; * Config file variable resolver. * * <p> - * The format for this var is <js>"$C{key}"</js> or <js>"$C{key,defaultValue}"</js>. + * The format for this var is <js>"$C{key[,defaultValue]}"</js>. * See {@link ConfigFile#getString(String)} for the format of the key. * * <p> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/svl/vars/EnvVariablesVar.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/vars/EnvVariablesVar.java b/juneau-core/src/main/java/org/apache/juneau/svl/vars/EnvVariablesVar.java index 60c0c13..7a78664 100644 --- a/juneau-core/src/main/java/org/apache/juneau/svl/vars/EnvVariablesVar.java +++ b/juneau-core/src/main/java/org/apache/juneau/svl/vars/EnvVariablesVar.java @@ -18,7 +18,7 @@ import org.apache.juneau.svl.*; * Environment variable variable resolver. * * <p> - * The format for this var is <js>"$E{envVar}"</js> or <js>"$E{envVar,defaultValue}"</js> + * The format for this var is <js>"$E{envVar[,defaultValue]}"</js>. * * <h5 class='section'>Example:</h5> * <p class='bcode'> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/svl/vars/SwitchVar.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/vars/SwitchVar.java b/juneau-core/src/main/java/org/apache/juneau/svl/vars/SwitchVar.java index e4f19b9..11dce68 100644 --- a/juneau-core/src/main/java/org/apache/juneau/svl/vars/SwitchVar.java +++ b/juneau-core/src/main/java/org/apache/juneau/svl/vars/SwitchVar.java @@ -24,10 +24,10 @@ import org.apache.juneau.svl.*; * <p> * The format for this var is one of the following: * <ul> - * <li><js>"$SWITCH{stringArg,pattern,thenValue}"</js> - * <li><js>"$SWITCH{stringArg,pattern,thenValue,elseValue}"</js> - * <li><js>"$SWITCH{stringArg,pattern,thenValue,pattern,thenValue}"</js> - * <li><js>"$SWITCH{stringArg,pattern,thenValue,pattern,thenValue,elsePattern}"</js> + * <li><js>"$SW{stringArg,pattern,thenValue}"</js> + * <li><js>"$SW{stringArg,pattern,thenValue,elseValue}"</js> + * <li><js>"$SW{stringArg,pattern,thenValue,pattern,thenValue}"</js> + * <li><js>"$SW{stringArg,pattern,thenValue,pattern,thenValue,elsePattern}"</js> * <li>... * </ul> * @@ -37,11 +37,11 @@ import org.apache.juneau.svl.*; * * <h5 class='section'>Example:</h5> * <p class='bcode'> - * <jc>// Create a variable resolver that resolves system properties and $SWITCH vars.</jc> + * <jc>// Create a variable resolver that resolves system properties and $SW vars.</jc> * VarResolver r = <jk>new</jk> VarResolver().addVars(SwitchVar.<jk>class</jk>, SystemPropertiesVar.<jk>class</jk>); * * <jc>// Use it!</jc> - * System.<jsf>out</jsf>.println(r.resolve(<js>"We are running on $SWITCH{$P{os.name},*win*,Windows,Something else}!"</js>)); + * System.<jsf>out</jsf>.println(r.resolve(<js>"We are running on $SW{$P{os.name},*win*,Windows,Something else}!"</js>)); * </p> * * <p> @@ -51,7 +51,7 @@ import org.apache.juneau.svl.*; public class SwitchVar extends MultipartVar { /** The name of this variable. */ - public static final String NAME = "SWITCH"; + public static final String NAME = "SW"; /** * Constructor. @@ -63,7 +63,7 @@ public class SwitchVar extends MultipartVar { @Override /* MultipartVar */ public String resolve(VarResolverSession session, String[] args) { if (args.length < 3) - illegalArg("Invalid number of arguments passed to $SWITCH var. Must have 3 or more arguments."); + illegalArg("Invalid number of arguments passed to $SW var. Must have 3 or more arguments."); String stringArg = args[0]; for (int i = 1; i < args.length;) { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/svl/vars/SystemPropertiesVar.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/vars/SystemPropertiesVar.java b/juneau-core/src/main/java/org/apache/juneau/svl/vars/SystemPropertiesVar.java index b151360..a147f39 100644 --- a/juneau-core/src/main/java/org/apache/juneau/svl/vars/SystemPropertiesVar.java +++ b/juneau-core/src/main/java/org/apache/juneau/svl/vars/SystemPropertiesVar.java @@ -18,7 +18,7 @@ import org.apache.juneau.svl.*; * System property variable resolver. * * <p> - * The format for this var is <js>"$S{systemProperty}"</js> or <js>"$S{systemProperty,defaultValue}"</js> + * The format for this var is <js>"$S{systemProperty[,defaultValue]}"</js></js> * * <h5 class='section'>Example:</h5> * <p class='bcode'> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/utils/ExtendedMimetypesFileTypeMap.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/utils/ExtendedMimetypesFileTypeMap.java b/juneau-core/src/main/java/org/apache/juneau/utils/ExtendedMimetypesFileTypeMap.java new file mode 100644 index 0000000..da5e656 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/utils/ExtendedMimetypesFileTypeMap.java @@ -0,0 +1,88 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.utils; + +import javax.activation.*; + +/** + * An extension of {@link javax.activation.MimetypesFileTypeMap} that includes many more media types. + */ +public class ExtendedMimetypesFileTypeMap extends MimetypesFileTypeMap { + + /** + * Reusable map since this object is somewhat expensive to create. + */ + public static final ExtendedMimetypesFileTypeMap DEFAULT = new ExtendedMimetypesFileTypeMap(); + + /** + * Constructor. + */ + public ExtendedMimetypesFileTypeMap() { + super(); + addMimeTypes("application/epub+zip epub"); + addMimeTypes("application/java-archive jar"); + addMimeTypes("application/javascript js"); + addMimeTypes("application/json json"); + addMimeTypes("application/msword doc"); + addMimeTypes("application/ogg ogx"); + addMimeTypes("application/pdf pdf"); + addMimeTypes("application/rtf rtf"); + addMimeTypes("application/vnd.amazon.ebook azw"); + addMimeTypes("application/vnd.apple.installer+xml mpkg"); + addMimeTypes("application/vnd.mozilla.xul+xml xul"); + addMimeTypes("application/vnd.ms-excel xls"); + addMimeTypes("application/vnd.ms-powerpoint ppt"); + addMimeTypes("application/vnd.oasis.opendocument.presentation odp"); + addMimeTypes("application/vnd.oasis.opendocument.spreadsheet ods"); + addMimeTypes("application/vnd.oasis.opendocument.text odt"); + addMimeTypes("application/vnd.visio vsd"); + addMimeTypes("application/x-7z-compressed 7z"); + addMimeTypes("application/x-abiword abw"); + addMimeTypes("application/x-bzip bz"); + addMimeTypes("application/x-bzip2 bz2"); + addMimeTypes("application/x-csh csh"); + addMimeTypes("application/x-rar-compressed rar"); + addMimeTypes("application/x-sh sh"); + addMimeTypes("application/x-shockwave-flash swf"); + addMimeTypes("application/x-tar tar"); + addMimeTypes("application/xhtml+xml xhtml"); + addMimeTypes("application/xml xml"); + addMimeTypes("application/zip zip"); + addMimeTypes("audio/aac aac"); + addMimeTypes("audio/midi mid midi"); + addMimeTypes("audio/ogg oga"); + addMimeTypes("audio/webm weba"); + addMimeTypes("audio/x-wav wav"); + addMimeTypes("font/ttf ttf"); + addMimeTypes("font/woff woff"); + addMimeTypes("font/woff2 woff2"); + addMimeTypes("image/gif gif"); + addMimeTypes("image/jpeg jpeg jpg"); + addMimeTypes("image/png png"); + addMimeTypes("image/svg+xml svg"); + addMimeTypes("image/tiff tif tiff"); + addMimeTypes("image/webp webp"); + addMimeTypes("image/x-icon ico"); + addMimeTypes("text/calendar ics"); + addMimeTypes("text/css css"); + addMimeTypes("text/csv csv"); + addMimeTypes("text/html htm html"); + addMimeTypes("text/plain txt"); + addMimeTypes("video/3gpp 3gp"); + addMimeTypes("video/3gpp2 3g2"); + addMimeTypes("video/mpeg mpeg"); + addMimeTypes("video/ogg ogv"); + addMimeTypes("video/webm webm"); + addMimeTypes("video/x-msvideo avi"); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/java/org/apache/juneau/utils/ResourceFinder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/utils/ResourceFinder.java b/juneau-core/src/main/java/org/apache/juneau/utils/ResourceFinder.java index e2496ba..343dd25 100644 --- a/juneau-core/src/main/java/org/apache/juneau/utils/ResourceFinder.java +++ b/juneau-core/src/main/java/org/apache/juneau/utils/ResourceFinder.java @@ -26,7 +26,7 @@ import org.apache.juneau.internal.*; * Utility class for finding resources for a class. * * <p> - * Same as {@link Class#getResourceAsStream(String)} except if it doesn't find the resource on this class, searches + * Same as {@link Class#getResourceAsStream(String)} except if it doesn't find the resource on this class, it searches * up the parent hierarchy chain. * * <p> @@ -200,7 +200,7 @@ public class ResourceFinder { if (url != null) { Resource r = cacheByUrl.get(url); if (r == null) { - r = new Resource(IOUtils.readBytes(c2.getResourceAsStream(key.name), 1024)); + r = new Resource(IOUtils.readBytes(c2.getResourceAsStream(n), 1024)); cacheByUrl.putIfAbsent(url, r); r = cacheByUrl.get(url); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-core/src/main/javadoc/overview.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/javadoc/overview.html b/juneau-core/src/main/javadoc/overview.html index a4e6420..b8c723e 100644 --- a/juneau-core/src/main/javadoc/overview.html +++ b/juneau-core/src/main/javadoc/overview.html @@ -6908,6 +6908,13 @@ New {@link org.apache.juneau.utils.ResourceFinder} utility class. Allows you to search for resources up the parent hierarchy chain. Also allows you to search for localized resources. + <li> + Eliminated the following properties from {@link org.apache.juneau.html.HtmlDocSerializerContext}: + <jsf>HTMLDOC_title</jsf>, <jsf>HTMLDOC_description</jsf>, <jsf>HTMLDOC_description</jsf> + <br>See below on changes to simplify HTML headers. + <li> + {@link org.apache.juneau.svl.Var} implementations can now throw exceptions and will be converted to + <js>""{exceptionMessage}"</js> values. </ul> <h6 class='topic'>org.apache.juneau.rest</h6> @@ -7037,8 +7044,37 @@ Eliminated the <code>@RestResource.stylesheet()</code> annotation. It's no longer needed now that you can easily specify styles via <ja>@Htmldoc</ja>. <li> - {@link org.apache.juneau.rest.annotation.HtmlDoc#title()} and {@link org.apache.juneau.rest.annotation.HtmlDoc#description()} - can now take HTML (phrasing content only since it's still inside H3 and H5 tags). + Eliminated the following annotations since they are now redundant with {@link org.apache.juneau.rest.annotation.HtmlDoc#header()}: + <ul> + <li><code>title()</code> + <li><code>description()</code> + <li><code>branding()</code> + </ul> + Instead, the {@link org.apache.juneau.rest.RestServletDefault} class defines the following default header + that can be easily overridden: + <p class='bcode'> + htmldoc=<ja>@HtmlDoc</ja>( + header={ + <js>"<h1>$R{servletTitle}</h1>"</js>, + <js>"<h2>$R{methodSummary,$R{servletDescription}}</h2>"</js>, + <js>"<a href='http://juneau.apache.org'><img src='$U{servlet:/htdocs/juneau.png}' style='position:absolute;top:5;right:5;background-color:transparent;height:30px'/></a>"</js> + } + ) + </p> + Note that the subtitle first tries using the method summary and then the servlet description. + <li> + New {@link org.apache.juneau.rest.vars.FileVar $F} variable resolver for resolving the contents of + files in the classpath. + <br>The <code>DockerRegistryResource</code> examples shows how it can be used to pull in a localized + file from the classpath to populate the aside section of a page. + <p class='bcode'> + htmldoc=<ja>@HtmlDoc</ja>( + <js>// Pull in aside contents from file.</js> + aside=<js>"$F{resources/DockerRegistryResourceAside.html}"</js> + ) + </p> + <li> + New {@link org.apache.juneau.rest.ReaderResource#toCommentStrippedString()} method. </ul> <h6 class='topic'>org.apache.juneau.rest.examples</h6> @@ -7187,9 +7223,9 @@ <br>Annotation can be applied to POJO classes and bean properties. <li>Several new properties for customizing parts of the HTML page: <ul> - <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_title} - <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_description} - <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_branding} + <li><code><del>HtmlDocSerializerContext.HTMLDOC_title</del></code> + <li><code><del>HtmlDocSerializerContext.HTMLDOC_description</del></code> + <li><code><del>HtmlDocSerializerContext.HTMLDOC_branding</del></code> <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_header} <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_nav} <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_aside} @@ -7369,9 +7405,9 @@ <li> New methods on {@link org.apache.juneau.rest.RestConfig}: <ul> - <li>{@link org.apache.juneau.rest.RestConfig#setHtmlTitle(String) setHtmlTitle(String)} - <li>{@link org.apache.juneau.rest.RestConfig#setHtmlDescription(String) setHtmlDescription(String)} - <li>{@link org.apache.juneau.rest.RestConfig#setHtmlBranding(String) setHtmlBranding(String)} + <li><code><del>setHtmlTitle(String)</del></code> + <li><code><del>setHtmlDescription(String)</del></code> + <li><code><del>setHtmlBranding(String)</del></code> <li>{@link org.apache.juneau.rest.RestConfig#setHtmlHeader(String) setHtmlHeader(String)} <li><code><del>setHtmlLinks(String)</del></code> <li>{@link org.apache.juneau.rest.RestConfig#setHtmlNav(String) setHtmlNav(String)} @@ -7388,9 +7424,9 @@ <li> New methods on {@link org.apache.juneau.rest.RestResponse}: <ul> - <li>{@link org.apache.juneau.rest.RestResponse#setHtmlTitle(Object) setHtmlTitle(Object)} - <li>{@link org.apache.juneau.rest.RestResponse#setHtmlDescription(Object) setHtmlDescription(Object)} - <li>{@link org.apache.juneau.rest.RestResponse#setHtmlBranding(Object) setHtmlBranding(Object)} + <li><code><del>setHtmlTitle(Object)</del></code> + <li><code><del>setHtmlDescription(Object)</del></code> + <li><code><del>setHtmlBranding(Object)</del></code> <li>{@link org.apache.juneau.rest.RestResponse#setHtmlHeader(Object) setHtmlHeader(Object)} <li><code><del>setHtmlLinks(Object)</del></code> <li>{@link org.apache.juneau.rest.RestResponse#setHtmlNav(Object) setHtmlNav(Object)} @@ -7528,7 +7564,7 @@ <li>Improvements to {@link org.apache.juneau.svl.VarResolver}. <ul> <li>New {@link org.apache.juneau.svl.vars.IfVar $IF} variable for if-else block logic. - <li>New {@link org.apache.juneau.svl.vars.SwitchVar $SWITCH} variable for switch block logic. + <li><code><del>$SWITCH</del></code> variable for switch block logic. <li>Whitespace wasn't being ignored in some cases. </ul> <li>{@link org.apache.juneau.html.HtmlParser} can now parse full body contents generated by {@link org.apache.juneau.html.HtmlDocSerializer}. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java index 4f6e5b5..1ec291d 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java @@ -27,18 +27,15 @@ import org.apache.juneau.rest.labels.*; @RestResource( path="/docker", title="Sample Docker resource", + description="Docker registry explorer", htmldoc=@HtmlDoc( links={ "up: request:/..", "options: servlet:/?method=OPTIONS", "source: $C{Source/gitHub}/org/apache/juneau/examples/rest/DockerRegistryResource.java" }, - aside={ - "<div style='min-width:200px' class='text'>", - " <p>REST API for searching Docker registries.</p>", - " <p>To use, you must first specify the Docker registry URL in the <code>[Docker]</code> section of the config file.</p>", - "</div>" - } + // Pull in aside contents from file. + aside="$F{resources/DockerRegistryResourceAside.html}" ) ) public class DockerRegistryResource extends Resource { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java index 41ed920..71adf97 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java @@ -71,9 +71,6 @@ public class RequestEchoResource extends Resource { /** GET request handler */ @RestMethod(name="*", path="/*", converters={Traversable.class,Queryable.class}, summary="Serializes the incoming HttpServletRequest object.") public HttpServletRequest doGet(RestRequest req, RestResponse res, @Properties ObjectMap properties) { - // Set the HtmlDocSerializer title programmatically. - res.setHtmlTitle("Contents of HttpServletRequest object"); - // Just echo the request back as the response. return req; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/resources/DockerRegistryResourceAside_en.html ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/resources/DockerRegistryResourceAside_en.html b/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/resources/DockerRegistryResourceAside_en.html new file mode 100644 index 0000000..395eea2 --- /dev/null +++ b/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/resources/DockerRegistryResourceAside_en.html @@ -0,0 +1,19 @@ +<!-- + *************************************************************************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + *************************************************************************************************************************** + --> +<div style='min-width:200px' class='text'> + <p>REST API for searching Docker registries.</p> + <p>To use, you must first specify the Docker registry URL in the <code>[Docker]</code> section of the config file.</p> +</div> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java ---------------------------------------------------------------------- diff --git a/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java b/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java index e4a556a..cfd30b6 100755 --- a/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java +++ b/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java @@ -234,8 +234,8 @@ public abstract class Microservice { * <li><code>$MF{key}</code>, <code>$MF{key,default}</code> - Manifest file entries. * <li><code>$ARG{key}</code>, <code>$ARG{key,default}</code> - Command-line arguments. * <li><code>$IF{boolArg,thenValue}</code>, <code>$IF{boolArg,thenValue,elseValue}</code> - If-block logic. - * <li><code>$SWITCH{stringArg,pattern,thenVal...}</code>, - * <code>$SWITCH{stringArg,pattern,thenVal,elseVal...}</code> - Switch-block logic. + * <li><code>$SW{stringArg,pattern,thenVal...}</code>, + * <code>$SW{stringArg,pattern,thenVal,elseVal...}</code> - Switch-block logic. * </ul> * * <p> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java ---------------------------------------------------------------------- diff --git a/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java b/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java index 32976f5..6403957 100755 --- a/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java +++ b/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java @@ -32,7 +32,6 @@ import org.apache.juneau.rest.annotation.*; import org.apache.juneau.rest.annotation.Properties; import org.apache.juneau.rest.converters.*; import org.apache.juneau.transforms.*; -import org.apache.juneau.utils.*; /** * REST resource for viewing and accessing log files. @@ -107,12 +106,9 @@ public class LogsResource extends Resource { l.add(new FileResource(fc, fUrl)); } } - res.setHtmlDescription(new StringMessage("Contents of {0}", f.getAbsolutePath())); - properties.put(HTMLDOC_description, "Contents of " + f.getAbsolutePath()); return l; } - res.setHtmlDescription(new StringMessage("File details on {0}", f.getAbsolutePath())); return new FileResource(f, new URI("servlet:/")); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/HtmlPropertiesResource.java ---------------------------------------------------------------------- diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/HtmlPropertiesResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/HtmlPropertiesResource.java deleted file mode 100644 index 8cfc1a1..0000000 --- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/HtmlPropertiesResource.java +++ /dev/null @@ -1,330 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.rest.test; - -import org.apache.juneau.html.*; -import org.apache.juneau.rest.*; -import org.apache.juneau.rest.annotation.*; - -/** - * JUnit automated testcase resource. - * Tests the various permutations of populating the HTML page titles, text, and links. - */ -@RestResource( - path="/testHtmlProperties", - children={ - HtmlPropertiesResource.Normal.class, - HtmlPropertiesResource.NormalInit.class, - HtmlPropertiesResource.NormalDefaulting.class, - HtmlPropertiesResource.NormalSubclassed1.class, - HtmlPropertiesResource.NormalSubclassed2.class, - HtmlPropertiesResource.LocalizedImplicit.class, - HtmlPropertiesResource.LocalizedExplicit.class - } -) -@SuppressWarnings("serial") -public class HtmlPropertiesResource extends RestServletGroupDefault { - private static final long serialVersionUID = 1L; - - - @RestResource( - path="/Normal", - htmldoc=@HtmlDoc( - title="Normal-title", - description="Normal-text" - ) - ) - public static class Normal extends RestServletDefault { - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX). - //---------------------------------------------------------------------------------------------------- - @RestMethod(name="GET", path="/test1") - public String test1() { - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX), overridden by @RestMethod(pageX) annotations. - //---------------------------------------------------------------------------------------------------- - @RestMethod( - path="/test2", - htmldoc=@HtmlDoc( - title="Normal.test2-title", - description="Normal.test2-text" - ) - ) - public String test2() { - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX), overridden by RestResponse.setPageX() methods. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test3") - public String test3(RestResponse res) { - res.setHtmlTitle("Normal.test3-title"); - res.setHtmlDescription("Normal.test3-text"); - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX), overridden by RestResponse.setProperty() method. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test4") - public String test4(RestResponse res) { - res.setProperty(HtmlDocSerializerContext.HTMLDOC_title, "Normal.test4-title"); - res.setProperty(HtmlDocSerializerContext.HTMLDOC_description, "Normal.test4-text"); - return "OK"; - } - } - - @RestResource( - path="/NormalInit" - ) - public static class NormalInit extends RestServletDefault { - - @Override - public void init(RestConfig config) throws Exception { - config.setHtmlTitle("NormalInit-title"); - config.setHtmlDescription("NormalInit-text"); - super.init(config); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from RestConfig.setX() methods. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test1") - public String test1() { - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from RestConfig.setX() methods, overridden by @RestMethod(pageX) annotations. - //---------------------------------------------------------------------------------------------------- - @RestMethod( - path="/test2", - htmldoc=@HtmlDoc( - title="NormalInit.test2-title", - description="NormalInit.test2-text" - ) - ) - public String test2() { - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from RestConfig.setX() methods, overridden by RestResponse.setPageX() methods. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test3") - public String test3(RestResponse res) { - res.setHtmlTitle("NormalInit.test3-title"); - res.setHtmlDescription("NormalInit.test3-text"); - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from RestConfig.setX() methods, overridden by RestResponse.setProperty() method. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test4") - public String test4(RestResponse res) { - res.setProperty(HtmlDocSerializerContext.HTMLDOC_title, "NormalInit.test4-title"); - res.setProperty(HtmlDocSerializerContext.HTMLDOC_description, "NormalInit.test4-text"); - return "OK"; - } - } - - @RestResource( - path="/NormalDefaulting", - title="NormalDefaulting-title", - description="NormalDefaulting-description" - ) - public static class NormalDefaulting extends RestServletDefault { - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(path/title). - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test1") - public String test1() { - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(path/title), overridden by @RestMethod(pageX) annotations. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test2", summary="NormalDefaulting.test2-summary") - public String test2() { - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(path/title), overridden by RestResponse.setPageX() methods. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test3") - public String test3(RestResponse res) { - res.setHtmlTitle("NormalDefaulting.test3-title"); - res.setHtmlDescription("NormalDefaulting.test3-text"); - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(path/title), overridden by RestResponse.setProperty() method. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test4") - public String test4(RestResponse res) { - res.setProperty(HtmlDocSerializerContext.HTMLDOC_title, "NormalDefaulting.test4-title"); - res.setProperty(HtmlDocSerializerContext.HTMLDOC_description, "NormalDefaulting.test4-text"); - return "OK"; - } - } - - - @RestResource( - path="/NormalSubclassed1" - ) - public static class NormalSubclassed1 extends Normal { - - //---------------------------------------------------------------------------------------------------- - // Values pulled from parent @RestResource(path/title). - //---------------------------------------------------------------------------------------------------- - @Override - @RestMethod(path="/test1") - public String test1() { - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from parent @RestResource(path/title), overridden by @RestMethod(pageX) annotations. - //---------------------------------------------------------------------------------------------------- - @Override - @RestMethod( - path="/test2", - htmldoc=@HtmlDoc( - title="NormalSubclassed1.test2-title", - description="NormalSubclassed1.test2-text" - ) - ) - public String test2() { - return "OK"; - } - } - - @RestResource( - path="/NormalSubclassed2", - htmldoc=@HtmlDoc( - title="NormalSubclassed2-title", - description="NormalSubclassed2-text" - ) - ) - public static class NormalSubclassed2 extends Normal { - - //---------------------------------------------------------------------------------------------------- - // Values pulled from parent @RestResource(path/title), overridden by child @RestResource(pageTitle/pageText). - //---------------------------------------------------------------------------------------------------- - @Override - @RestMethod(path="/test1") - public String test1() { - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from parent @RestResource(path/title), overridden by @RestMethod(pageX). - //---------------------------------------------------------------------------------------------------- - @Override - @RestMethod( - path="/test2", - htmldoc=@HtmlDoc( - title="NormalSubclassed2.test2-title", - description="NormalSubclassed2.test2-text" - ) - ) - public String test2() { - return "OK"; - } - } - - @RestResource( - path="/LocalizedExplicit", - messages="HtmlPropertiesResource", - htmldoc=@HtmlDoc( - title="$L{pageTitle}", - description="$L{pageText}" - ) - ) - public static class LocalizedExplicit extends RestServletDefault { - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX) with $L variables. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test1") - public String test1() { - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX) with $L variables, overridden by @RestMethod(pageX) with $L variables. - //---------------------------------------------------------------------------------------------------- - @RestMethod( - path="/test2", - htmldoc=@HtmlDoc( - title="$L{test2.pageTitle}", description="$L{test2.pageText}" - ) - ) - public String test2() { - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX) with $L variables, overridden by RestResponse.setPageX() with $L variables. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test3") - public String test3(RestResponse res) { - res.setHtmlTitle("$L{test3.pageTitle}"); - res.setHtmlDescription("$L{test3.pageText}"); - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX) with $L variables, overridden by RestResponse.setProperty() with $L variables. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test4") - public String test4(RestResponse res) { - res.setProperty(HtmlDocSerializerContext.HTMLDOC_title, "$L{test4.pageTitle}"); - res.setProperty(HtmlDocSerializerContext.HTMLDOC_description, "$L{test4.pageText}"); - return "OK"; - } - } - - @RestResource( - path="/LocalizedImplicit", - messages="HtmlPropertiesResource" - ) - public static class LocalizedImplicit extends RestServletDefault { - - //---------------------------------------------------------------------------------------------------- - // Values pulled from resource bundle. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test1") - public String test1() { - return "OK"; - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from resource bundle, overridden by values in resource bundle at method level. - //---------------------------------------------------------------------------------------------------- - @RestMethod(path="/test2") - public String test2() { - return "OK"; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/Root.java ---------------------------------------------------------------------- diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/Root.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/Root.java index 130611d..a8ef199 100644 --- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/Root.java +++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/Root.java @@ -37,7 +37,6 @@ import org.apache.juneau.rest.labels.*; GzipResource.TestGzipOff.class, GzipResource.TestGzipOn.class, HeadersResource.class, - HtmlPropertiesResource.class, InheritanceResource.TestEncoders.class, InheritanceResource.TestTransforms.class, InheritanceResource.TestParsers.class, http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/HtmlPropertiesTest.java ---------------------------------------------------------------------- diff --git a/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/HtmlPropertiesTest.java b/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/HtmlPropertiesTest.java deleted file mode 100644 index a9df966..0000000 --- a/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/HtmlPropertiesTest.java +++ /dev/null @@ -1,245 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.rest.test; - -import static org.junit.Assert.*; - -import org.apache.juneau.rest.client.*; -import org.junit.*; - -/** - * Tests HTML page titles, text, and links. - */ -public class HtmlPropertiesTest extends RestTestcase { - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX). - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalTest1() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/Normal/test1").accept("text/html").getResponseAsString(); - assertTrue(s.contains("Normal-title")); - assertTrue(s.contains("Normal-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX), overridden by @RestMethod(pageX) annotations. - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalTest2() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/Normal/test2").accept("text/html").getResponseAsString(); - assertTrue(s.contains("Normal.test2-title")); - assertTrue(s.contains("Normal.test2-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX), overridden by RestResponse.setPageX() methods. - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalTest3() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/Normal/test3").accept("text/html").getResponseAsString(); - assertTrue(s.contains("Normal.test3-title")); - assertTrue(s.contains("Normal.test3-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX), overridden by RestResponse.setProperty() method. - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalTest4() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/Normal/test4").accept("text/html").getResponseAsString(); - assertTrue(s.contains("Normal.test4-title")); - assertTrue(s.contains("Normal.test4-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from RestConfig.setX() methods. - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalInitTest1() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/NormalInit/test1").accept("text/html").getResponseAsString(); - assertTrue(s.contains("NormalInit-title")); - assertTrue(s.contains("NormalInit-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from RestConfig.setX() methods, overridden by @RestMethod(pageX) annotations. - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalInitTest2() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/NormalInit/test2").accept("text/html").getResponseAsString(); - assertTrue(s.contains("NormalInit.test2-title")); - assertTrue(s.contains("NormalInit.test2-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from RestConfig.setX() methods, overridden by RestResponse.setPageX() methods. - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalInitTest3() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/NormalInit/test3").accept("text/html").getResponseAsString(); - assertTrue(s.contains("NormalInit.test3-title")); - assertTrue(s.contains("NormalInit.test3-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from RestConfig.setX() methods, overridden by RestResponse.setProperty() method. - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalInitTest4() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/NormalInit/test4").accept("text/html").getResponseAsString(); - assertTrue(s.contains("NormalInit.test4-title")); - assertTrue(s.contains("NormalInit.test4-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(path/title). - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalDefaultingTest1() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/NormalDefaulting/test1").accept("text/html").getResponseAsString(); - assertTrue(s.contains("NormalDefaulting-title")); - assertTrue(s.contains("NormalDefaulting-description")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(path/title), overridden by @RestMethod(pageX) annotations. - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalDefaultingTest2() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/NormalDefaulting/test2").accept("text/html").getResponseAsString(); - assertTrue(s.contains("NormalDefaulting-title")); - assertTrue(s.contains("NormalDefaulting.test2-summary")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(path/title), overridden by RestResponse.setPageX() methods. - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalDefaultingTest3() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/NormalDefaulting/test3").accept("text/html").getResponseAsString(); - assertTrue(s.contains("NormalDefaulting.test3-title")); - assertTrue(s.contains("NormalDefaulting.test3-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(path/title), overridden by RestResponse.setProperty() method. - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalDefaultingTest4() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/NormalDefaulting/test4").accept("text/html").getResponseAsString(); - assertTrue(s.contains("NormalDefaulting.test4-title")); - assertTrue(s.contains("NormalDefaulting.test4-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from parent @RestResource(path/title). - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalSubclassed1Test1() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/NormalSubclassed1/test1").accept("text/html").getResponseAsString(); - assertTrue(s.contains("Normal-title")); - assertTrue(s.contains("Normal-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from parent @RestResource(path/title), overridden by @RestMethod(pageX) annotations. - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalSubclassed1Test2() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/NormalSubclassed1/test2").accept("text/html").getResponseAsString(); - assertTrue(s.contains("NormalSubclassed1.test2-title")); - assertTrue(s.contains("NormalSubclassed1.test2-text")); - - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from parent @RestResource(path/title), overridden by child @RestResource(pageTitle/pageText). - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalSubclassed2Test1() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/NormalSubclassed2/test1").accept("text/html").getResponseAsString(); - assertTrue(s.contains("NormalSubclassed2-title")); - assertTrue(s.contains("NormalSubclassed2-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from parent @RestResource(path/title), overridden by @RestMethod(pageX). - //---------------------------------------------------------------------------------------------------- - @Test - public void testNormalSubclassed2Test2() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/NormalSubclassed2/test2").accept("text/html").getResponseAsString(); - assertTrue(s.contains("NormalSubclassed2.test2-title")); - assertTrue(s.contains("NormalSubclassed2.test2-text")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX) with $L variables. - //---------------------------------------------------------------------------------------------------- - @Test - public void testLocalizedExplicitTest1() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/LocalizedExplicit/test1").accept("text/html").getResponseAsString(); - assertTrue(s.contains("LocalizedExplicit.nls.pageTitle")); - assertTrue(s.contains("LocalizedExplicit.nls.pageText")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX) with $L variables, overridden by @RestMethod(pageX) with $L variables. - //---------------------------------------------------------------------------------------------------- - @Test - public void testLocalizedExplicitTest2() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/LocalizedExplicit/test2").accept("text/html").getResponseAsString(); - assertTrue(s.contains("LocalizedExplicit.test2.nls.pageTitle")); - assertTrue(s.contains("LocalizedExplicit.test2.nls.pageText")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX) with $L variables, overridden by RestResponse.setPageX() with $L variables. - //---------------------------------------------------------------------------------------------------- - @Test - public void testLocalizedExplicitTest3() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/LocalizedExplicit/test3").accept("text/html").getResponseAsString(); - assertTrue(s.contains("LocalizedExplicit.test3.nls.pageTitle")); - assertTrue(s.contains("LocalizedExplicit.test3.nls.pageText")); - } - - //---------------------------------------------------------------------------------------------------- - // Values pulled from @RestResource(pageX) with $L variables, overridden by RestResponse.setProperty() with $L variables. - //---------------------------------------------------------------------------------------------------- - @Test - public void testLocalizedExplicitTest4() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - String s = client.doGet("/testHtmlProperties/LocalizedExplicit/test4").accept("text/html").getResponseAsString(); - assertTrue(s.contains("LocalizedExplicit.test4.nls.pageTitle")); - assertTrue(s.contains("LocalizedExplicit.test4.nls.pageText")); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bed066ee/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java ---------------------------------------------------------------------- diff --git a/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java b/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java index 485fbed..48dbe5a 100644 --- a/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java +++ b/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java @@ -38,7 +38,6 @@ import org.junit.runners.Suite.*; GroupsTest.class, GzipTest.class, HeadersTest.class, - HtmlPropertiesTest.class, InheritanceTest.class, InterfaceProxyTest.class, JacocoDummyTest.class,
