You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/02/24 19:36:58 UTC
incubator-juneau git commit: Clean up examples.
Repository: incubator-juneau
Updated Branches:
refs/heads/master d473b4b30 -> 9a0c872f0
Clean up examples.
Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/9a0c872f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/9a0c872f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/9a0c872f
Branch: refs/heads/master
Commit: 9a0c872f0311634dec04800ae44203876130b912
Parents: d473b4b
Author: JamesBognar <ja...@apache.org>
Authored: Fri Feb 24 14:36:56 2017 -0500
Committer: JamesBognar <ja...@apache.org>
Committed: Fri Feb 24 14:36:56 2017 -0500
----------------------------------------------------------------------
juneau-examples-rest/examples.cfg | 9 +-
.../juneau/examples/rest/AtomFeedResource.java | 2 +-
.../examples/rest/CodeFormatterResource.java | 31 ++++-
.../juneau/examples/rest/DirectoryResource.java | 2 +-
.../examples/rest/DockerRegistryResource.java | 2 +-
.../examples/rest/HelloWorldResource.java | 2 +-
.../examples/rest/JsonSchemaResource.java | 2 +-
.../examples/rest/MethodExampleResource.java | 2 +-
.../juneau/examples/rest/PhotosResource.java | 2 +-
.../examples/rest/RequestEchoResource.java | 2 +-
.../juneau/examples/rest/RootResources.java | 3 +-
.../examples/rest/SampleRemoteableServlet.java | 3 +-
.../juneau/examples/rest/SourceResource.java | 112 -------------------
.../juneau/examples/rest/SqlQueryResource.java | 48 +++++++-
.../examples/rest/SystemPropertiesResource.java | 5 +-
.../juneau/examples/rest/TempDirResource.java | 14 ++-
.../examples/rest/TumblrParserResource.java | 2 +-
.../examples/rest/UrlEncodedFormResource.java | 49 +++++++-
.../rest/addressbook/AddressBookResource.java | 2 +-
.../src/main/resources/examples.cfg | 6 +-
.../juneau/examples/rest/SqlQueryResource.html | 66 -----------
.../juneau/examples/rest/TempDirUploadPage.html | 34 ------
.../juneau/examples/rest/UrlEncodedForm.html | 62 ----------
.../examples/rest/AddressBookResourceTest.java | 17 ++-
.../rest/CT_AddressBookResource_test0.json | 26 -----
25 files changed, 174 insertions(+), 331 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/examples.cfg
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/examples.cfg b/juneau-examples-rest/examples.cfg
index fd89bfa..bee6b91 100755
--- a/juneau-examples-rest/examples.cfg
+++ b/juneau-examples-rest/examples.cfg
@@ -138,8 +138,15 @@ url = http://docker.apache.org:5000/v1
#================================================================================
[SqlQueryResource]
driver = org.apache.derby.jdbc.EmbeddedDriver
-connectionUrl = jdbc:derby:C:/testDB;create=true
+directory = $SWITCH{$S{os.name},*win*,C:/testDB,/tmp/testDB}
+connectionUrl = jdbc:derby:$C{SqlQueryResource/directory};create=true
allowTempUpdates = true
includeRowNums = true
+#================================================================================
+# Source code location
+#================================================================================
+[Source]
+gitHub = https://github.com/apache/incubator-juneau/blob/master/juneau-examples-rest/src/main/java
+
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java
index 3b8e25b..54e7937 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java
@@ -34,7 +34,7 @@ import org.apache.juneau.rest.annotation.*;
@Property(name=SERIALIZER_quoteChar, value="'"),
@Property(name=RDF_rdfxml_tab, value="5"),
@Property(name=RDF_addRootProperty, value="true"),
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.AtomFeedResource)'}")
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/AtomFeedResource.java'}")
},
encoders=GzipEncoder.class
)
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java
index b0daf7e..5bf4187 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java
@@ -30,7 +30,7 @@ import org.apache.juneau.rest.annotation.*;
properties={
@Property(name=HTMLDOC_title, value="Code Formatter"),
@Property(name=HTMLDOC_description, value="Add syntax highlighting tags to source code"),
- @Property(name=HTMLDOC_links, value="{options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.CodeFormatterResource)'}"),
+ @Property(name=HTMLDOC_links, value="{options:'?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/CodeFormatterResource.java'}"),
}
)
@SuppressWarnings("serial")
@@ -42,9 +42,34 @@ public class CodeFormatterResource extends Resource {
return req.getReaderResource("CodeFormatterResource.html", true);
}
- /** [POST /] - Execute SQL query. */
+ /** [POST /] - Add syntax highlighting to input. */
@RestMethod(name="POST", path="/")
public String executeQuery(@FormData("code") String code, @FormData("lang") String lang) throws Exception {
- return SourceResource.highlight(code, lang);
+ return highlight(code, lang);
+ }
+
+ private String highlight(String code, String lang) throws Exception {
+ if (lang.equalsIgnoreCase("xml")) {
+ code = code.replaceAll("&", "&");
+ code = code.replaceAll("<", "<");
+ code = code.replaceAll(">", ">");
+ code = code.replaceAll("(<[^\\s&]+>)", "<xt>$1</xt>");
+ code = code.replaceAll("(<[^\\s&]+)(\\s)", "<xt>$1</xt>$2");
+ code = code.replaceAll("(['\"])(/?>)", "$1<xt>$2</xt>");
+ code = code.replaceAll("([\\S]+)=", "<xa>$1</xa>=");
+ code = code.replaceAll("=(['\"][^'\"]+['\"])", "=<xs>$1</xs>");
+ } else if (lang.equalsIgnoreCase("java")) {
+ code = code.replaceAll("&", "&");
+ code = code.replaceAll("<", "<");
+ code = code.replaceAll(">", ">");
+ code = code.replaceAll("(?s)(\\/\\*\\*.*?\\*\\/)", "<jd>$1</jd>"); // javadoc comments
+ code = code.replaceAll("(@\\w+)", "<ja>$1</ja>"); // annotations
+ code = code.replaceAll("(?s)(?!\\/)(\\/\\*.*?\\*\\/)", "<jc>$1</jc>"); // C style comments
+ code = code.replaceAll("(?m)(\\/\\/.*)", "<jc>$1</jc>"); // C++ style comments
+ code = code.replaceAll("(?m)('[^'\n]*'|\"[^\"\n]*\")", "<js>$1</js>"); // quotes
+ code = code.replaceAll("(?<!@)(import|package|boolean|byte|char|double|float|final|static|transient|synchronized|private|protected|public|int|long|short|abstract|class|interface|extends|implements|null|true|false|void|break|case|catch|continue|default|do|else|finally|for|goto|if|instanceof|native|new|return|super|switch|this|threadsafe|throws|throw|try|while)(?=\\W)", "<jk>$1</jk>"); // quotes
+ code = code.replaceAll("<\\/jk>(\\s+)<jk>", "$1"); // quotes
+ }
+ return code;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java
index 9a2b84b..a21f521 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java
@@ -39,7 +39,7 @@ import org.apache.juneau.utils.*;
messages="nls/DirectoryResource",
properties={
@Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.DirectoryResource)'}"),
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/DirectoryResource.java'}"),
@Property(name=REST_allowMethodParam, value="*"),
@Property(name="rootDir", value="$S{java.io.tmpdir}"),
@Property(name="allowViews", value="false"),
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/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 bb078af..34ae3bc 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
@@ -32,7 +32,7 @@ import org.apache.juneau.rest.labels.*;
path="/docker",
title="Sample Docker resource",
properties={
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.AtomFeedResource)'}")
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/DockerRegistryResource.java'}")
}
)
public class DockerRegistryResource extends Resource {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/HelloWorldResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/HelloWorldResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/HelloWorldResource.java
index 4a519a8..5b5fae8 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/HelloWorldResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/HelloWorldResource.java
@@ -24,7 +24,7 @@ import org.apache.juneau.rest.annotation.*;
messages="nls/HelloWorldResource",
path="/helloWorld",
properties={
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS'}")
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/HelloWorldResource.java'}")
}
)
public class HelloWorldResource extends Resource {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java
index c531bb1..ae17734 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java
@@ -26,7 +26,7 @@ import org.apache.juneau.rest.annotation.*;
messages="nls/JsonSchemaResource",
properties={
@Property(name=HTMLDOC_title, value="Sample JSON-Schema document"),
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.JsonSchemaResource)'}")
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/JsonSchemaResource.java'}")
}
)
public class JsonSchemaResource extends ResourceJena {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java
index c056a09..ee0a0b9 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java
@@ -27,7 +27,7 @@ import org.apache.juneau.rest.annotation.*;
path="/methodExample",
messages="nls/MethodExampleResource",
properties={
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.MethodExampleResource)'}")
+ @Property(name=HTMLDOC_links, value="{up:'$R{servletParentURI}',options:'?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/MethodExampleResource.java'}")
}
)
public class MethodExampleResource extends Resource {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java
index 81bfe9c..782a72b 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java
@@ -40,7 +40,7 @@ import org.apache.juneau.serializer.*;
properties={
@Property(name=HTMLDOC_title, value="Photo REST service"),
@Property(name=HTMLDOC_description, value="Use a tool like Poster to upload and retrieve jpeg and png images."),
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.PhotosResource)'}"),
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/PhotosResource.java'}"),
// Resolve all relative URIs so that they're relative to this servlet!
@Property(name=SERIALIZER_relativeUriBase, value="$R{servletURI}"),
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/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 354ed8d..5cbd34f 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
@@ -33,7 +33,7 @@ import org.apache.juneau.transforms.*;
properties={
@Property(name=SERIALIZER_maxDepth, value="5"),
@Property(name=SERIALIZER_detectRecursions, value="true"),
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.RequestEchoResource)'}")
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/RequestEchoResource.java'}")
},
beanFilters={
// Interpret these as their parent classes, not subclasses
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
index b193217..ce51c81 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
@@ -26,7 +26,7 @@ import org.apache.juneau.rest.annotation.*;
path="/",
messages="nls/RootResources",
properties={
- @Property(name=HTMLDOC_links, value="{options:'$R{servletURI}?method=OPTIONS',source:'$R{servletURI}/source?classes=(org.apache.juneau.examples.rest.RootResources)'}")
+ @Property(name=HTMLDOC_links, value="{options:'$R{servletURI}?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/RootResources.java'}")
},
children={
HelloWorldResource.class,
@@ -43,7 +43,6 @@ import org.apache.juneau.rest.annotation.*;
TumblrParserResource.class,
CodeFormatterResource.class,
UrlEncodedFormResource.class,
- SourceResource.class,
ConfigResource.class,
LogsResource.class,
DockerRegistryResource.class,
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java
index 4eb38dd..68f457b 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java
@@ -31,10 +31,11 @@ import org.apache.juneau.rest.remoteable.*;
properties={
@Property(name=HTMLDOC_title, value="Remoteable Service Proxy API"),
@Property(name=HTMLDOC_description, value="Sample class showing how to use remoteable proxies. The list below are exposed services that can be retrieved using RestClient.getProxyInterface(Class)."),
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.SampleRemoteableServlet)'}"),
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/SampleRemoteableServlet.java'}"),
// Allow us to use method=POST from a browser.
@Property(name=REST_allowMethodParam, value="*")
},
+ config="$S{juneau.configFile}", // So we can resolve $C{Source/gitHub} above.
stylesheet="styles/devops.css"
)
public class SampleRemoteableServlet extends RemoteableServlet {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SourceResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SourceResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SourceResource.java
deleted file mode 100644
index ba4550e..0000000
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SourceResource.java
+++ /dev/null
@@ -1,112 +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.examples.rest;
-
-import static org.apache.juneau.html.HtmlDocSerializerContext.*;
-
-import java.io.*;
-import java.util.*;
-
-import org.apache.juneau.html.annotation.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.microservice.*;
-import org.apache.juneau.rest.annotation.*;
-
-/**
- * Servlet for viewing source code on classes whose Java files are present on the classpath.
- * <p>
- * This class is by no means perfect but is pretty much the best you can get using only regular expression matching.
- */
-@SuppressWarnings("serial")
-@RestResource(
- path="/source",
- messages="nls/SourceResource",
- properties={
- @Property(name=HTMLDOC_title, value="Source code viewer"),
- @Property(name=HTMLDOC_cssImports, value="$R{servletURI}/htdocs/code-highlighting.css"),
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.SourceResource)'}"),
- }
-)
-public class SourceResource extends Resource {
-
- /** View source on the specified classes. */
- @RestMethod(name="GET", path="/")
- public Object getSource(@Query("classes") String[] classes) throws Exception {
- if (classes == null)
- return "Specify classes using ?classes=(class1,class2,....) attribute";
- List<Object> l = new LinkedList<Object>();
- for (String c : classes) {
- try {
- l.add(new Source(Class.forName(c)));
- } catch (ClassNotFoundException e) {
- l.add("Class " + c + " not found");
- } catch (Exception e) {
- l.add(e.getLocalizedMessage());
- }
- }
- return l;
- }
-
- /**
- * POJO that allows us to serialize HTML directly to the output.
- */
- @Html(asPlainText=true)
- public static class Source {
- private Class<?> c;
- private Source(Class<?> c) {
- this.c = c;
- }
- @Override /* Object */
- public String toString() {
- String filename = c.getSimpleName() + ".java";
- InputStream is = c.getResourceAsStream('/' + c.getPackage().getName().replace('.','/') + '/' + filename);
- if (is == null)
- return "Source for class " + c.getName() + " not found";
- StringBuilder sb = new StringBuilder();
- try {
- sb.append("<h3>").append(c.getSimpleName()).append(".java").append("</h3>");
- sb.append("<p class='bcode'>");
- sb.append(highlight(IOUtils.read(is), "java"));
- sb.append("</p>");
- } catch (Exception e) {
- return e.getLocalizedMessage();
- }
- return sb.toString();
- }
- }
-
- public static String highlight(String code, String lang) throws Exception {
- if (lang.equalsIgnoreCase("xml")) {
- code = code.replaceAll("&", "&");
- code = code.replaceAll("<", "<");
- code = code.replaceAll(">", ">");
- code = code.replaceAll("(<[^\\s&]+>)", "<xt>$1</xt>");
- code = code.replaceAll("(<[^\\s&]+)(\\s)", "<xt>$1</xt>$2");
- code = code.replaceAll("(['\"])(/?>)", "$1<xt>$2</xt>");
- code = code.replaceAll("([\\S]+)=", "<xa>$1</xa>=");
- code = code.replaceAll("=(['\"][^'\"]+['\"])", "=<xs>$1</xs>");
- } else if (lang.equalsIgnoreCase("java")) {
- code = code.replaceAll("&", "&");
- code = code.replaceAll("<", "<");
- code = code.replaceAll(">", ">");
- code = code.replaceAll("(?s)(\\/\\*\\*.*?\\*\\/)", "<jd>$1</jd>"); // javadoc comments
- code = code.replaceAll("(@\\w+)", "<ja>$1</ja>"); // annotations
- code = code.replaceAll("(?s)(?!\\/)(\\/\\*.*?\\*\\/)", "<jc>$1</jc>"); // C style comments
- code = code.replaceAll("(?m)(\\/\\/.*)", "<jc>$1</jc>"); // C++ style comments
- code = code.replaceAll("(?m)('[^'\n]*'|\"[^\"\n]*\")", "<js>$1</js>"); // quotes
- code = code.replaceAll("(?<!@)(import|package|boolean|byte|char|double|float|final|static|transient|synchronized|private|protected|public|int|long|short|abstract|class|interface|extends|implements|null|true|false|void|break|case|catch|continue|default|do|else|finally|for|goto|if|instanceof|native|new|return|super|switch|this|threadsafe|throws|throw|try|while)(?=\\W)", "<jk>$1</jk>"); // quotes
- code = code.replaceAll("<\\/jk>(\\s+)<jk>", "$1"); // quotes
- }
- return code;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java
index 3c42557..b055f27 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java
@@ -14,17 +14,20 @@ package org.apache.juneau.examples.rest;
import static javax.servlet.http.HttpServletResponse.*;
import static org.apache.juneau.html.HtmlDocSerializerContext.*;
+import static org.apache.juneau.dto.html5.HtmlBuilder.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import org.apache.juneau.dto.*;
+import org.apache.juneau.dto.html5.*;
import org.apache.juneau.ini.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.microservice.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.annotation.Body;
/**
* Sample resource that shows how Juneau can serialize ResultSets.
@@ -35,7 +38,7 @@ import org.apache.juneau.rest.annotation.*;
properties={
@Property(name=HTMLDOC_title, value="SQL query service"),
@Property(name=HTMLDOC_description, value="Executes queries against the local derby '$C{SqlQueryResource/connectionUrl}' database"),
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.SqlQueryResource)'}"),
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/SqlQueryResource.java'}"),
}
)
public class SqlQueryResource extends Resource {
@@ -61,8 +64,45 @@ public class SqlQueryResource extends Resource {
/** GET request handler - Display the query entry page. */
@RestMethod(name="GET", path="/")
- public ReaderResource doGet(RestRequest req) throws IOException {
- return req.getReaderResource("SqlQueryResource.html", true);
+ public Div doGet(RestRequest req) throws IOException {
+ return div(
+ script("text/javascript",
+ "\n // Quick and dirty function to allow tabs in textarea."
+ +"\n function checkTab(e) {"
+ +"\n if (e.keyCode == 9) {"
+ +"\n var t = e.target;"
+ +"\n var ss = t.selectionStart, se = t.selectionEnd;"
+ +"\n t.value = t.value.slice(0,ss).concat('\\t').concat(t.value.slice(ss,t.value.length));"
+ +"\n e.preventDefault();"
+ +"\n }"
+ +"\n }"
+ +"\n // Load results from IFrame into this document."
+ +"\n function loadResults(b) {"
+ +"\n var doc = b.contentDocument || b.contentWindow.document;"
+ +"\n var data = doc.getElementById('data') || doc.getElementsByTagName('body')[0];"
+ +"\n document.getElementById('results').innerHTML = data.innerHTML;"
+ +"\n }"
+ ),
+ form("sqlQuery").method("POST").target("buf").children(
+ table(
+ tr(
+ th("Position (1-10000):"),
+ td(input().name("pos").type("number").value(1)),
+ th("Limit (1-10000):"),
+ td(input().name("limit").type("number").value(100)),
+ td(button("submit", "Submit"), button("reset", "Reset"))
+ ),
+ tr(
+ td().colspan(5).children(
+ textarea().name("sql").style("width:100%;height:200px;font-family:Courier;font-size:9pt;").onkeydown("checkTab(event)")
+ )
+ )
+ )
+ ),
+ br(),
+ div().id("results"),
+ iframe().name("buf").style("display:none").onload("parent.loadResults(this)")
+ );
}
/** POST request handler - Execute the query. */
@@ -74,6 +114,8 @@ public class SqlQueryResource extends Resource {
// Don't try to submit empty input.
if (StringUtils.isEmpty(in.sql))
return results;
+
+ System.err.println("SQL=["+in.sql+"]");
if (in.pos < 1 || in.pos > 10000)
throw new RestException(SC_BAD_REQUEST, "Invalid value for position. Must be between 1-10000");
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
index 8e4dd0b..93748c9 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
@@ -18,6 +18,7 @@ import java.util.*;
import org.apache.juneau.dto.swagger.*;
import org.apache.juneau.encoders.*;
+import org.apache.juneau.microservice.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
@@ -27,7 +28,7 @@ import org.apache.juneau.rest.annotation.*;
description="REST interface for performing CRUD operations on system properties.",
properties={
@Property(name=SERIALIZER_quoteChar, value="'"),
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS'}"),
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/SystemPropertiesResource.java'}"),
},
stylesheet="styles/devops.css",
encoders=GzipEncoder.class,
@@ -38,7 +39,7 @@ import org.apache.juneau.rest.annotation.*;
tags="[{name:'Java',description:'Java utility',externalDocs:{description:'Home page',url:'http://juneau.apache.org'}}]",
externalDocs="{description:'Home page',url:'http://juneau.apache.org'}"
)
-public class SystemPropertiesResource extends RestServletDefault {
+public class SystemPropertiesResource extends Resource {
private static final long serialVersionUID = 1L;
@RestMethod(
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java
index 3753c17..9851b94 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java
@@ -13,11 +13,13 @@
package org.apache.juneau.examples.rest;
import static org.apache.juneau.html.HtmlDocSerializerContext.*;
+import static org.apache.juneau.dto.html5.HtmlBuilder.*;
import java.io.*;
import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.servlet.*;
+import org.apache.juneau.dto.html5.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.utils.*;
@@ -33,7 +35,7 @@ import org.apache.juneau.utils.*;
@Property(name="allowViews", value="true"),
@Property(name="allowDeletes", value="true"),
@Property(name="allowPuts", value="false"),
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',upload:'upload',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.TempDirResource,org.apache.juneau.examples.rest.DirectoryResource)'}"),
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',upload:'upload',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/TempDirResource.java'}"),
},
stylesheet="styles/devops.css"
)
@@ -44,8 +46,14 @@ public class TempDirResource extends DirectoryResource {
* [GET /upload] - Display the form entry page for uploading a file to the temp directory.
*/
@RestMethod(name="GET", path="/upload")
- public ReaderResource getUploadPage(RestRequest req) throws IOException {
- return req.getReaderResource("TempDirUploadPage.html", true);
+ public Form getUploadForm(RestRequest req) throws IOException {
+ return
+ form().id("form").action(req.getServletURI() + "/upload").method("POST").enctype("multipart/form-data")
+ .children(
+ input().name("contents").type("file"),
+ button("submit", "Submit")
+ )
+ ;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java
index d6f43e4..72b03a2 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java
@@ -28,7 +28,7 @@ import org.apache.juneau.rest.client.*;
path="/tumblrParser",
messages="nls/TumblrParserResource",
properties={
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.TumblrParserResource)'}"),
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/TumblrParserResource.java'}"),
@Property(name=HTMLDOC_title, value="Tumblr parser service"),
@Property(name=HTMLDOC_description, value="Specify a URL to a Tumblr blog and parse the results.")
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java
index e3da795..d836395 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java
@@ -12,13 +12,18 @@
// ***************************************************************************************************************************
package org.apache.juneau.examples.rest;
+import static org.apache.juneau.dto.html5.HtmlBuilder.*;
+import static org.apache.juneau.html.HtmlDocSerializerContext.*;
+
import java.io.*;
import java.util.*;
import org.apache.juneau.annotation.*;
+import org.apache.juneau.dto.html5.*;
import org.apache.juneau.microservice.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.annotation.Body;
import org.apache.juneau.transforms.*;
/**
@@ -26,15 +31,53 @@ import org.apache.juneau.transforms.*;
*/
@RestResource(
path="/urlEncodedForm",
- messages="nls/UrlEncodedFormResource"
+ messages="nls/UrlEncodedFormResource",
+ properties={
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/UrlEncodedFormResource.java'}"),
+ @Property(name=HTMLDOC_title, value="Tumblr parser service"),
+ @Property(name=HTMLDOC_description, value="Specify a URL to a Tumblr blog and parse the results.")
+ }
)
public class UrlEncodedFormResource extends Resource {
private static final long serialVersionUID = 1L;
/** GET request handler */
@RestMethod(name="GET", path="/")
- public ReaderResource doGet(RestRequest req) throws IOException {
- return req.getReaderResource("UrlEncodedForm.html", true);
+ public Div doGet(RestRequest req) throws IOException {
+ return div(
+ script("text/javascript",
+ "\n // Load results from IFrame into this document."
+ +"\n function loadResults(buff) {"
+ +"\n var doc = buff.contentDocument || buff.contentWindow.document;"
+ +"\n var buffBody = doc.getElementById('data');"
+ +"\n document.getElementById('results').innerHTML = buffBody.innerHTML;"
+ +"\n }"
+ ),
+ form().id("form").action(req.getServletURI()).method("POST").target("buff").children(
+ table(
+ tr(
+ th(req.getMessage("aString")),
+ td(input().name("aString").type("text"))
+ ),
+ tr(
+ th(req.getMessage("aNumber")),
+ td(input().name("aNumber").type("number"))
+ ),
+ tr(
+ th(req.getMessage("aDate")),
+ td(input().name("aDate").type("datetime"), " (ISO8601, e.g. ", code("2001-07-04T15:30:45Z"), " )")
+ ),
+ tr(
+ td().colspan(2).style("text-align:right").children(
+ button("submit", req.getMessage("submit"))
+ )
+ )
+ )
+ ),
+ br(),
+ div().id("results"),
+ iframe().name("buff").style("display:none").onload("parent.loadResults(this)")
+ );
}
/** POST request handler */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
index f66a5bc..e077abf 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
@@ -48,7 +48,7 @@ import org.apache.juneau.utils.*;
@Property(name=SERIALIZER_quoteChar, value="'"),
@Property(name=RDF_rdfxml_tab, value="5"),
@Property(name=RDF_addRootProperty, value="true"),
- @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.examples.rest.addressbook.AddressBookResource,org.apache.juneau.examples.addressbook.Address,org.apache.juneau.examples.addressbook.AddressBook,org.apache.juneau.examples.addressbook.CreateAddress,org.apache.juneau.examples.addressbook.CreatePerson,org.apache.juneau.examples.addressbook.IAddressBook,org.apache.juneau.examples.addressbook.Person)'}"),
+ @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java'}"),
// Resolve all relative URIs so that they're relative to this servlet!
@Property(name=SERIALIZER_relativeUriBase, value="$R{servletURI}"),
},
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/resources/examples.cfg
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/resources/examples.cfg b/juneau-examples-rest/src/main/resources/examples.cfg
index 758e6b8..5c429a7 100755
--- a/juneau-examples-rest/src/main/resources/examples.cfg
+++ b/juneau-examples-rest/src/main/resources/examples.cfg
@@ -140,4 +140,8 @@ connectionUrl = jdbc:derby:C:/testDB;create=true
allowTempUpdates = true
includeRowNums = true
-
+#================================================================================
+# Source code location
+#================================================================================
+[Source]
+gitHub = https://github.com/apache/incubator-juneau/blob/master/juneau-examples-rest/src/main/java
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/SqlQueryResource.html
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/SqlQueryResource.html b/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/SqlQueryResource.html
deleted file mode 100644
index 1119400..0000000
--- a/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/SqlQueryResource.html
+++ /dev/null
@@ -1,66 +0,0 @@
-<!DOCTYPE HTML>
-<!--
-/***************************************************************************************************************************
- * 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.
- *
- ***************************************************************************************************************************/
- -->
-<html>
-<head>
- <style type='text/css'>
- @import '$R{servletURI}/style.css';
- </style>
- <script>
- // Quick and dirty function to allow tabs in textarea.
- function checkTab(e) {
- if (e.keyCode == 9) {
- var t = e.target;
- var ss = t.selectionStart, se = t.selectionEnd;
- t.value = t.value.slice(0,ss).concat('\t').concat(t.value.slice(ss,t.value.length));
- e.preventDefault();
- }
- }
- // Load results from IFrame into this document.
- function loadResults(b) {
- var doc = b.contentDocument || b.contentWindow.document;
- var data = doc.getElementById('data') || doc.getElementsByTagName('body')[0];
- document.getElementById('results').innerHTML = data.innerHTML;
- }
- </script>
-</head>
-<body>
- <h3 class='title'>SQL Query API</h3>
- <div class='data'>
- <form action='sqlQuery' method='POST' target='buf'>
- <table>
- <tr>
- <th>Position (1-10000):</th>
- <td><input name='pos' type='number' value='1'></td>
- <th>Limit (1-10000):</th>
- <td><input name='limit' type='number' value='100'></td>
- <td><button type='submit'>Submit</button><button type='reset'>Reset</button></td>
- </tr>
- <tr>
- <td colspan="5">
- <textarea name='sql' style='width:100%;height:200px;font-family:Courier;font-size:9pt;' onkeydown='checkTab(event)'></textarea>
- </td>
- </tr>
- </table>
- </form>
- <br>
- <div id='results'>
- </div>
- </div>
- <iframe name='buf' style='display:none' onload="parent.loadResults(this)"></iframe>
-</body>
-</html>
-
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/TempDirUploadPage.html
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/TempDirUploadPage.html b/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/TempDirUploadPage.html
deleted file mode 100644
index 947f8bf..0000000
--- a/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/TempDirUploadPage.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML>
-<!--
-/***************************************************************************************************************************
- * 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.
- *
- ***************************************************************************************************************************/
- -->
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <style type='text/css'>
- @import '$R{servletURI}/style.css';
- </style>
-</head>
-<body>
- <h3 class='title'>$R{servletTitle}</h3>
- <h5 class="description">$R{servletDescription}</h5>
- <div class='data'>
- <form id='form' action='$R{servletURI}/upload' method='POST' target='buff' enctype="multipart/form-data">
- <input name="contents" type="file"><button type="submit">Submit</button>
- </form>
- </div>
-</body>
-</html>
-
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/UrlEncodedForm.html
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/UrlEncodedForm.html b/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/UrlEncodedForm.html
deleted file mode 100644
index 0c2d039..0000000
--- a/juneau-examples-rest/src/main/resources/org/apache/juneau/examples/rest/UrlEncodedForm.html
+++ /dev/null
@@ -1,62 +0,0 @@
-<!DOCTYPE HTML>
-<!--
-/***************************************************************************************************************************
- * 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.
- *
- ***************************************************************************************************************************/
- -->
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <style type='text/css'>
- @import '$R{servletURI}/style.css';
- </style>
- <script type="text/javascript">
- // Load results from IFrame into this document.
- function loadResults(buff) {
- var doc = buff.contentDocument || buff.contentWindow.document;
- var buffBody = doc.getElementById('data');
- document.getElementById('results').innerHTML = buffBody.innerHTML;
- }
- </script>
-</head>
-<body>
- <h3 class='title'>$R{servletTitle}</h3>
- <h5 class="description">$R{servletDescription}</h5>
- <div class='data'>
- <form id='form' action='$R{servletURI}' method='POST' target='buff'>
- <table>
- <tr>
- <th>$L{aString}</th>
- <td><input name="aString" type="text"></td>
- </tr>
- <tr>
- <th>$L{aNumber}</th>
- <td><input name="aNumber" type="number"></td>
- </tr>
- <tr>
- <th>$L{aDate}</th>
- <td><input name="aDate" type="datetime"> (ISO8601, e.g. "<code>2001-07-04T15:30:45Z</code>")</td>
- </tr>
- <tr>
- <td colspan='2' align='right'><button type="submit">$L{submit}</button></td>
- </tr>
- </table>
- </form>
- <br>
- <div id='results'>
- </div>
- </div>
- <iframe name='buff' style='display:none' onload="parent.loadResults(this)"></iframe>
-</body>
-</html>
-
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/AddressBookResourceTest.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/AddressBookResourceTest.java b/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/AddressBookResourceTest.java
index dbb736a..da66ac3 100644
--- a/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/AddressBookResourceTest.java
+++ b/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/AddressBookResourceTest.java
@@ -21,7 +21,6 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.examples.addressbook.*;
import org.apache.juneau.html.*;
-import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
import org.apache.juneau.rest.client.*;
import org.apache.juneau.transforms.*;
@@ -62,7 +61,21 @@ public class AddressBookResourceTest extends RestTestcase {
//====================================================================================================
@Test
public void testBasic() throws Exception {
- String in = IOUtils.read(getClass().getResourceAsStream("/org/apache/juneau/server/test/AddressBookResource_test0Test.json"));
+ String in = ""
+ +"{"
+ +"\n name: \"Bill Clinton\", "
+ +"\n age: 66, "
+ +"\n birthDate: \"Aug 19, 1946\", "
+ +"\n addresses: ["
+ +"\n {"
+ +"\n street: \"a3\", "
+ +"\n city: \"b3\", "
+ +"\n state: \"c3\", "
+ +"\n zip: 3, "
+ +"\n isCurrent: false"
+ +"\n }"
+ +"\n ]"
+ +"\n}";
JsonParser p = new JsonParser().addPojoSwaps(CalendarSwap.DateMedium.class);
Person person = p.parse(in, Person.class);
if (debug) System.err.println(person);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/9a0c872f/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/CT_AddressBookResource_test0.json
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/CT_AddressBookResource_test0.json b/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/CT_AddressBookResource_test0.json
deleted file mode 100644
index f8cc23f..0000000
--- a/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/CT_AddressBookResource_test0.json
+++ /dev/null
@@ -1,26 +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. *
-// ***************************************************************************************************************************
-{
- name: "Bill Clinton",
- age: 66,
- birthDate: "Aug 19, 1946",
- addresses: [
- {
- street: "a3",
- city: "b3",
- state: "c3",
- zip: 3,
- isCurrent: false
- }
- ]
-}
\ No newline at end of file