Browse Source

Merge pull request #1308 from ericbn/master

Java: Update activeweb's activejdbc code
Hamilton Turner 10 years ago
parent
commit
a996a8e093
36 changed files with 494 additions and 381 deletions
  1. 3 1
      deployment/vagrant-common/core.rb
  2. 6 6
      deployment/vagrant-production/Vagrantfile
  3. 18 14
      frameworks/Java/activeweb/benchmark_config
  4. 48 11
      frameworks/Java/activeweb/pom.xml
  5. 14 14
      frameworks/Java/activeweb/source_code
  6. 2 4
      frameworks/Java/activeweb/src/main/java/app/config/AppBootstrap.java
  7. 2 2
      frameworks/Java/activeweb/src/main/java/app/config/AppControllerConfig.java
  8. 0 30
      frameworks/Java/activeweb/src/main/java/app/config/FreeMarkerConfig.java
  9. 1 4
      frameworks/Java/activeweb/src/main/java/app/config/RouteConfig.java
  10. 0 39
      frameworks/Java/activeweb/src/main/java/app/controllers/DatabaseController.java
  11. 40 0
      frameworks/Java/activeweb/src/main/java/app/controllers/DbController.java
  12. 16 19
      frameworks/Java/activeweb/src/main/java/app/controllers/FortunesController.java
  13. 24 33
      frameworks/Java/activeweb/src/main/java/app/controllers/JsonController.java
  14. 15 22
      frameworks/Java/activeweb/src/main/java/app/controllers/PlaintextController.java
  15. 26 32
      frameworks/Java/activeweb/src/main/java/app/controllers/QueriesController.java
  16. 18 21
      frameworks/Java/activeweb/src/main/java/app/controllers/UpdatesController.java
  17. 1 1
      frameworks/Java/activeweb/src/main/java/app/models/Fortune.java
  18. 38 0
      frameworks/Java/activeweb/src/main/java/app/models/Message.java
  19. 19 17
      frameworks/Java/activeweb/src/main/java/app/models/World.java
  20. 1 0
      frameworks/Java/activeweb/src/main/resources/activeweb.properties
  21. 0 20
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/fortunes/index.ftl
  22. 1 0
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/fortunes/index.html
  23. 0 0
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/home/index.html
  24. 1 0
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/json/index.html
  25. 10 5
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/default_layout.html
  26. 0 3
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/footer.ftl
  27. 0 4
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/header.ftl
  28. 0 7
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/queries/index.ftl
  29. 1 0
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/queries/index.html
  30. 0 0
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/system/404.html
  31. 0 0
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/system/error.html
  32. 0 46
      frameworks/Java/activeweb/src/test/java/app/controllers/DatabaseControllerSpec.java
  33. 66 0
      frameworks/Java/activeweb/src/test/java/app/controllers/DbControllerSpec.java
  34. 48 0
      frameworks/Java/activeweb/src/test/java/app/controllers/FortunesControllerSpec.java
  35. 33 26
      frameworks/Java/activeweb/src/test/java/app/controllers/JsonControllerSpec.java
  36. 42 0
      frameworks/Java/activeweb/src/test/java/app/controllers/PlaintextControllerSpec.java

+ 3 - 1
deployment/vagrant-common/core.rb

@@ -77,7 +77,9 @@ def provider_aws(config, role, ip_address='172.16.0.16')
   end
 end
 
-def provider_virtualbox(config, role)
+def provider_virtualbox(config, role, ip_address='172.16.0.16')
+  config.vm.network "private_network", ip: ip_address
+  
   config.vm.provider :virtualbox do |vb, override|
     override.vm.hostname = "TFB-#{role}"
 

+ 6 - 6
deployment/vagrant-production/Vagrantfile

@@ -8,9 +8,9 @@ check_provider_needs(provider)
 
 Vagrant.configure("2") do |config|
 
-  server_ip = ENV.fetch('TFB_AWS_LOAD_IP', '172.16.0.16')
-  client_ip = ENV.fetch('TFB_AWS_DB_IP', '172.16.0.17')
-  databa_ip = ENV.fetch('TFB_AWS_APP_IP', '172.16.0.18')
+  server_ip = ENV.fetch('TFB_AWS_APP_IP', '172.16.0.16')
+  client_ip = ENV.fetch('TFB_AWS_LOAD_IP', '172.16.0.17')
+  databa_ip = ENV.fetch('TFB_AWS_DB_IP', '172.16.0.18')
   
   # Put the keys inside each box
   Dir['keys/*'].each do |fname|
@@ -28,20 +28,20 @@ Vagrant.configure("2") do |config|
   config.vm.define "client" do |client|
     provision_bootstrap(client, "client")
     provider_aws(client, "loadgen", client_ip)
-    provider_virtualbox(client, "client")
+    provider_virtualbox(client, "client", client_ip)
   end
 
   config.vm.define "db" do |db|
     provision_bootstrap(db, "database")
     provider_aws(db, "database", databa_ip)
-    provider_virtualbox(db, "database")
+    provider_virtualbox(db, "database", databa_ip)
   end
 
   # Define the app server as the primary VM
   config.vm.define "app", primary: true do |app|
     provision_bootstrap(app, "server")
     provider_aws(app, "appserver", server_ip)
-    provider_virtualbox(app, "server")
+    provider_virtualbox(app, "server", server_ip)
   end
 
 end

+ 18 - 14
frameworks/Java/activeweb/benchmark_config

@@ -4,15 +4,19 @@
     "default": {
       "setup_file": "setup",
       "json_url": "/activeweb/json",
+      "db_url": "/activeweb/db",
+      "query_url": "/activeweb/queries?queries=",
+      "fortune_url": "/activeweb/fortunes",
+      "update_url": "/activeweb/updates?queries=",
       "plaintext_url": "/activeweb/plaintext",
       "port": 8080,
       "approach": "Realistic",
-      "classification": "Platform",
-      "database": "None",
+      "classification": "Fullstack",
+      "database": "MySQL",
       "framework": "activeweb",
       "language": "Java",
-      "orm": "Raw",
-      "platform": "ActiveWeb",
+      "orm": "Micro",
+      "platform": "Servlet",
       "webserver": "Resin",
       "os": "Linux",
       "database_os": "Linux",
@@ -20,24 +24,24 @@
       "notes": "",
       "versus": "servlet"
     },
-    "raw": {
+    "jackson": {
       "setup_file": "setup",
-      "db_url": "/activeweb/db",
-      "query_url": "/activeweb/queries?queries=",
-      "fortune_url": "/activeweb/fortunes",
-      "update_url": "/activeweb/updates?queries=",
+      "json_url": "/activeweb/json/jackson",
+      "db_url": "/activeweb/db/jackson",
+      "query_url": "/activeweb/queries/jackson?queries=",
+      "update_url": "/activeweb/updates/jackson?queries=",
       "port": 8080,
       "approach": "Realistic",
-      "classification": "Platform",
+      "classification": "Fullstack",
       "database": "MySQL",
-      "framework": "ActiveWeb",
+      "framework": "activeweb",
       "language": "Java",
-      "orm": "Raw",
-      "platform": "ActiveWeb",
+      "orm": "Micro",
+      "platform": "Servlet",
       "webserver": "Resin",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "activeweb",
+      "display_name": "ActiveWeb",
       "notes": "",
       "versus": "servlet"
     }

+ 48 - 11
frameworks/Java/activeweb/pom.xml

@@ -9,7 +9,8 @@
     <name>ActiveWeb Benchmark App</name>
 
     <properties>
-        <activeweb.version>1.9</activeweb.version>
+        <activeweb.version>1.11</activeweb.version>
+        <activejdbc.version>1.4.10</activejdbc.version>
     </properties>
 
     <build>
@@ -18,7 +19,7 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
-                <version>2.14.1</version>
+                <version>2.18.1</version>
                 <configuration>
                     <reportFormat>brief</reportFormat>
                     <trimStackTrace>true</trimStackTrace>
@@ -51,12 +52,18 @@
                             <maxIdleTime>1000</maxIdleTime>
                         </connector>
                     </connectors>
+                    <!--<systemProperties>-->
+                        <!--<systemProperty>-->
+                            <!--<name>active_reload</name>-->
+                            <!--<value>true</value>-->
+                        <!--</systemProperty>-->
+                    <!--</systemProperties>-->
                 </configuration>
             </plugin>
             <plugin>
                 <groupId>org.javalite</groupId>
                 <artifactId>activejdbc-instrumentation</artifactId>
-                <version>1.4.9</version>
+                <version>${activejdbc.version}</version>
                 <executions>
                     <execution>
                         <phase>process-classes</phase>
@@ -73,7 +80,7 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <version>4.8.1</version>
+            <version>4.12</version>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -81,6 +88,11 @@
             <artifactId>activeweb</artifactId>
             <version>${activeweb.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.javalite</groupId>
+            <artifactId>activejdbc</artifactId>
+            <version>${activejdbc.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.javalite</groupId>
             <artifactId>activeweb-testing</artifactId>
@@ -98,18 +110,43 @@
             <artifactId>slf4j-simple</artifactId>
             <version>1.7.5</version>
         </dependency>
-
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-core</artifactId>
-            <version>2.3.1</version>
+            <version>2.4.4</version>
         </dependency>
-
         <dependency>
-          <groupId>com.fasterxml.jackson.core</groupId>
-          <artifactId>jackson-databind</artifactId>
-          <version>2.3.1</version>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.4.4</version>
         </dependency>
-
     </dependencies>
+
+    <repositories>
+        <repository>
+            <id>javaLite-snapshots</id>
+            <name>JavaLite Snapshots</name>
+            <url>http://repo.javalite.io/</url>
+            <releases>
+                <enabled>false</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+    <pluginRepositories>
+        <pluginRepository>
+            <id>javaLite-plugin-snapshots</id>
+            <name>JavaLite Plugin Snapshots</name>
+            <url>http://repo.javalite.io/</url>
+            <releases>
+                <enabled>false</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </pluginRepository>
+    </pluginRepositories>
+
 </project>

+ 14 - 14
frameworks/Java/activeweb/source_code

@@ -1,14 +1,14 @@
-./src/main/java/app/config/AppControllerConfig.java
-./src/main/java/app/config/RouteConfig.java
-./src/main/java/app/config/FreeMarkerConfig.java
-./src/main/java/app/config/DbConfig.java
-./src/main/java/app/config/AppBootstrap.java
-./src/main/java/app/models/World.java
-./src/main/java/app/models/Fortune.java
-./src/main/java/app/controllers/PlaintextController.java
-./src/main/java/app/controllers/JsonController.java
-./src/main/java/app/controllers/DatabaseController.java
-./src/main/java/app/controllers/FortunesController.java
-./src/main/java/app/controllers/QueriesController.java
-./src/main/java/app/controllers/HomeController.java
-./src/main/java/app/controllers/UpdatesController.java
+./activeweb/src/main/java/app/config/AppBootstrap.java
+./activeweb/src/main/java/app/config/AppControllerConfig.java
+./activeweb/src/main/java/app/config/DbConfig.java
+./activeweb/src/main/java/app/config/RouteConfig.java
+./activeweb/src/main/java/app/controllers/DbController.java
+./activeweb/src/main/java/app/controllers/FortunesController.java
+./activeweb/src/main/java/app/controllers/HomeController.java
+./activeweb/src/main/java/app/controllers/JsonController.java
+./activeweb/src/main/java/app/controllers/PlaintextController.java
+./activeweb/src/main/java/app/controllers/QueriesController.java
+./activeweb/src/main/java/app/controllers/UpdatesController.java
+./activeweb/src/main/java/app/models/Fortune.java
+./activeweb/src/main/java/app/models/Message.java
+./activeweb/src/main/java/app/models/World.java

+ 2 - 4
frameworks/Java/activeweb/src/main/java/app/config/AppBootstrap.java

@@ -17,15 +17,13 @@ package app.config;
 
 import org.javalite.activeweb.AppContext;
 import org.javalite.activeweb.Bootstrap;
-
-import com.google.inject.Guice;
-import org.javalite.activeweb.Configuration;
+import org.javalite.templator.TemplatorConfig;
 
 /**
  * @author Igor Polevoy
  */
 public class AppBootstrap extends Bootstrap {
     public void init(AppContext context) {
-        Configuration.setUseDefaultLayoutForErrors(true);
+        TemplatorConfig.instance().cacheTemplates(true);
     }
 }

+ 2 - 2
frameworks/Java/activeweb/src/main/java/app/config/AppControllerConfig.java

@@ -16,7 +16,7 @@ limitations under the License.
 package app.config;
 
 
-import app.controllers.DatabaseController;
+import app.controllers.DbController;
 import app.controllers.FortunesController;
 import app.controllers.QueriesController;
 import app.controllers.UpdatesController;
@@ -33,7 +33,7 @@ public class AppControllerConfig extends AbstractControllerConfig {
     public void init(AppContext context) {
 //        addGlobalFilters(new TimingFilter()); for speed - not sure how logging is configured
 
-        add(new DBConnectionFilter()).to(DatabaseController.class, QueriesController.class,
+        add(new DBConnectionFilter()).to(DbController.class, QueriesController.class,
                 FortunesController.class, UpdatesController.class);
     }
 }

+ 0 - 30
frameworks/Java/activeweb/src/main/java/app/config/FreeMarkerConfig.java

@@ -1,30 +0,0 @@
-/*
-Copyright 2009-2010 Igor Polevoy 
-
-Licensed 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 app.config;
-
-import org.javalite.activeweb.freemarker.AbstractFreeMarkerConfig;
-
-/**
- * @author Igor Polevoy
- */
-public class FreeMarkerConfig extends org.javalite.activeweb.freemarker.AbstractFreeMarkerConfig {
-    @Override
-    public void init() {
-        //this is to override a strange FreeMarker default processing of numbers 
-        getConfiguration().setNumberFormat("0.##");
-    }
-}

+ 1 - 4
frameworks/Java/activeweb/src/main/java/app/config/RouteConfig.java

@@ -20,13 +20,10 @@ limitations under the License.
 
 package app.config;
 
-import app.controllers.DatabaseController;
 import org.javalite.activeweb.AbstractRouteConfig;
 import org.javalite.activeweb.AppContext;
 
 public class RouteConfig extends AbstractRouteConfig {
-    @Override
-    public void init(AppContext appContext) {
-        route("/db").to(DatabaseController.class);
+    @Override public void init(AppContext appContext) {
     }
 }

+ 0 - 39
frameworks/Java/activeweb/src/main/java/app/controllers/DatabaseController.java

@@ -1,39 +0,0 @@
-/*
-Copyright 2009-2010 Igor Polevoy 
-
-Licensed 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. 
-*/
-
-/**
- * @author Igor Polevoy: 12/18/13 4:36 PM
- */
-
-package app.controllers;
-
-import app.models.World;
-import org.javalite.activeweb.AppController;
-
-import java.util.Date;
-import java.util.Random;
-import java.util.concurrent.ThreadLocalRandom;
-
-public class DatabaseController extends AppController {
-    public void index() {
-
-        String json = World.findById(ThreadLocalRandom.current().nextInt(10000)).toJson(false, "id", "randomNumber");
-
-        respond(json).contentType("application/json")
-                .header("Content-Length", String.valueOf(json.length()))
-                .header("Date", new Date().toString());
-    }
-}

+ 40 - 0
frameworks/Java/activeweb/src/main/java/app/controllers/DbController.java

@@ -0,0 +1,40 @@
+/*
+Copyright 2009-2015 Igor Polevoy
+
+Licensed 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 app.controllers;
+
+import app.models.World;
+import java.io.IOException;
+import org.javalite.activeweb.AppController;
+
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * @author Igor Polevoy: 12/18/13 4:36 PM
+ * @author Eric Nielsen
+ */
+public class DbController extends AppController {
+    public void index() {
+        respond(World.findById(randomNumber()).toJson(false, "id", "randomNumber")).contentType("application/json");
+    }
+
+    public void jackson() throws IOException {
+        JsonController.WRITER.writeValue(outputStream("application/json"), World.findById(randomNumber()));
+    }
+
+    protected int randomNumber(){
+        return ThreadLocalRandom.current().nextInt(10000) + 1;
+    }
+}

+ 16 - 19
frameworks/Java/activeweb/src/main/java/app/controllers/FortunesController.java

@@ -1,23 +1,18 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed 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 
+Licensed 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 
+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. 
+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.
 */
-
-/**
- * @author Igor Polevoy: 12/18/13 9:11 PM
- */
-
 package app.controllers;
 
 import app.models.Fortune;
@@ -25,17 +20,19 @@ import org.javalite.activeweb.AppController;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
+/**
+ * @author Igor Polevoy: 12/18/13 9:11 PM
+ * @author Eric Nielsen
+ */
 public class FortunesController extends AppController {
-
     public void index() {
         List<Fortune> dbFortunes = Fortune.findAll();
         List<Fortune> fortunes = new ArrayList<Fortune>(dbFortunes);
-        fortunes.add((Fortune) Fortune.create("id", 0, "message", "Additional fortune added at request time."));
+        fortunes.add(Fortune.<Fortune>create("id", 0, "message", "Additional fortune added at request time."));
         Collections.sort(fortunes);
         view("fortunes", fortunes);
-        render().noLayout();
+        render("/fortunes/index").noLayout();
     }
 }

+ 24 - 33
frameworks/Java/activeweb/src/main/java/app/controllers/JsonController.java

@@ -1,49 +1,40 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed 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 
+Licensed 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 
+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. 
+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.
 */
-
-/**
- * @author Igor Polevoy: 12/18/13 3:51 PM
- */
-
 package app.controllers;
 
+import app.models.Message;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+import java.io.IOException;
 import org.javalite.activeweb.AppController;
 
-import java.io.IOException;
-import java.util.Date;
 
+/**
+ * @author Igor Polevoy: 12/18/13 3:51 PM
+ * @author Eric Nielsen
+ */
 public class JsonController extends AppController {
-    public void index() throws IOException {
-        String json = new ObjectMapper().writeValueAsString(new Message("Hello, World!"));
-        respond(json)
-                .contentType("application/json")
-                .header("Content-Length", String.valueOf(json.length()))
-                .header("Date", new Date().toString());
-    }
-
-    public static final class Message {
-        private final String message;
+    static final ObjectWriter WRITER = new ObjectMapper().writer();
 
-        private Message(String message) {
-            this.message = message;
-        }
+    public void index() {
+        view("message", new Message("Hello, World!"));
+        render("/json/index").noLayout().contentType("application/json");
+    }
 
-        public String getMessage() {
-            return message;
-        }
+    public void jackson() throws IOException {
+        WRITER.writeValue(outputStream("application/json"), new Message("Hello, World!"));
     }
 }

+ 15 - 22
frameworks/Java/activeweb/src/main/java/app/controllers/PlaintextController.java

@@ -1,35 +1,28 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed 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 
+Licensed 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 
+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. 
+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.
 */
-
-/**
- * @author Igor Polevoy: 12/19/13 1:23 AM
- */
-
 package app.controllers;
 
 import org.javalite.activeweb.AppController;
 
-import java.util.Date;
-
+/**
+ * @author Igor Polevoy: 12/19/13 1:23 AM
+ * @author Eric Nielsen
+ */
 public class PlaintextController extends AppController {
     public void index() {
-        String message = "Hello, World!";
-        respond(message)
-                .contentType("text/plain")
-                .header("Content-Length", String.valueOf(message.length()))
-                .header("Date", new Date().toString());
+        respond("Hello, World!").contentType("text/plain");
     }
 }

+ 26 - 32
frameworks/Java/activeweb/src/main/java/app/controllers/QueriesController.java

@@ -1,40 +1,42 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed 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 
+Licensed 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 
+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. 
+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.
 */
-
-/**
- * @author Igor Polevoy: 12/18/13 4:36 PM
- */
-
 package app.controllers;
 
 import app.models.World;
-import org.javalite.activeweb.AppController;
+import java.io.IOException;
 
 import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedList;
 import java.util.List;
-import java.util.concurrent.ThreadLocalRandom;
 
-public class QueriesController extends AppController {
+/**
+ * @author Igor Polevoy: 12/18/13 4:36 PM
+ * @author Eric Nielsen
+ */
+public class QueriesController extends DbController {
+    @Override public void index() {
+        view("worlds", getWorlds());
+        render("/queries/index").contentType("application/json");
+    }
 
-    public void index() {
+    @Override public void jackson() throws IOException {
+        JsonController.WRITER.writeValue(outputStream("application/json"), getWorlds());
+    }
 
-        view("worlds", getWorlds());
-        render().contentType("application/json").header("Date", new Date().toString());
+    @Override protected String getLayout() {
+        return null;
     }
 
     protected List<World> getWorlds() {
@@ -46,7 +48,7 @@ public class QueriesController extends AppController {
         return worlds;
     }
 
-    public int getQueries() {
+    protected int getQueries() {
         int queries;
         try {
             queries = Integer.parseInt(param("queries"));
@@ -60,12 +62,4 @@ public class QueriesController extends AppController {
         }
         return queries;
     }
-    protected int randomNumber(){
-        return ThreadLocalRandom.current().nextInt(10000) + 1;
-    }
-
-    @Override
-    protected String getLayout() {
-        return null;
-    }
 }

+ 18 - 21
frameworks/Java/activeweb/src/main/java/app/controllers/UpdatesController.java

@@ -1,38 +1,35 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed 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 
+Licensed 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 
+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. 
+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.
 */
-
-/**
- * @author Igor Polevoy: 12/18/13 9:51 PM
- */
-
 package app.controllers;
 
 import app.models.World;
-import org.javalite.activeweb.AppController;
 
 import java.util.List;
-import java.util.concurrent.ThreadLocalRandom;
 
+/**
+ * @author Igor Polevoy: 12/18/13 9:51 PM
+ * @author Eric Nielsen
+ */
 public class UpdatesController extends QueriesController {
-    public void index() {
-        List<World> worlds = getWorlds();
+
+    @Override protected List<World> getWorlds() {
+        List<World> worlds = super.getWorlds();
         for (World world : worlds) {
             world.set("randomNumber", randomNumber()).saveIt();
         }
-        view("worlds", worlds);
-        render("/queries/index"); //same template
+        return worlds;
     }
 }

+ 1 - 1
frameworks/Java/activeweb/src/main/java/app/models/Fortune.java

@@ -25,7 +25,7 @@ import org.javalite.activejdbc.annotations.Table;
 
 @Table("Fortune")
 public class Fortune extends Model implements Comparable<Fortune> {
-    public int compareTo(Fortune other) {
+    @Override public int compareTo(Fortune other) {
         return getString("message").compareTo(other.getString("message"));
     }
 }

+ 38 - 0
frameworks/Java/activeweb/src/main/java/app/models/Message.java

@@ -0,0 +1,38 @@
+/*
+Copyright 2009-2015 Igor Polevoy
+
+Licensed 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 app.models;
+
+/**
+ * @author Eric Nielsen
+ */
+public class Message {
+    private String message;
+
+    public Message() {
+    }
+
+    public Message(String message) {
+        this.message = message;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+}

+ 19 - 17
frameworks/Java/activeweb/src/main/java/app/models/World.java

@@ -1,30 +1,32 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed 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 
+Licensed 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 
+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. 
+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.
 */
-
-/**
- * @author Igor Polevoy: 12/18/13 4:32 PM
- */
-
 package app.models;
 
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import org.javalite.activejdbc.Model;
 import org.javalite.activejdbc.annotations.Table;
 
-
+/**
+ * @author Igor Polevoy: 12/18/13 4:32 PM
+ * @author Eric Nielsen
+ */
 @Table("World")
+@JsonIgnoreProperties({"frozen", "idName", "longId", "new", "valid"})
 public class World extends Model {
-
+    public Object getRandomNumber() {
+        return get("randomNumber");
+    }
 }

+ 1 - 0
frameworks/Java/activeweb/src/main/resources/activeweb.properties

@@ -0,0 +1 @@
+templateManager=org.javalite.activeweb.templator.TemplatorManager

+ 0 - 20
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/fortunes/index.ftl

@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head><title>Fortunes</title></head>
-<body>
-<table>
-    <tr>
-        <th>id</th>
-        <th>message</th>
-    </tr>
-
-<#list fortunes as fortune>
-    <tr>
-        <td>${fortune.id}</td>
-        <td>${fortune.message?html}</td>
-    </tr>
-</#list>
-
-</table>
-</body>
-</html>

+ 1 - 0
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/fortunes/index.html

@@ -0,0 +1 @@
+<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr><#list fortunes as fortune ><tr><td>${fortune.id}</td><td>${fortune.message esc}</td></tr></#list></table></body></html>

+ 0 - 0
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/home/index.ftl → frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/home/index.html


+ 1 - 0
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/json/index.html

@@ -0,0 +1 @@
+{"message":"${message.message}"}

+ 10 - 5
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/default_layout.ftl → frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/default_layout.html

@@ -1,21 +1,26 @@
-<#setting url_escaping_charset='ISO-8859-1'>
-
 <html>
 <head>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
     <LINK href="${context_path}/css/main.css" rel="stylesheet" type="text/css"/>
     <script src="${context_path}/js/jquery-1.4.2.min.js" type="text/javascript"></script>
     <script src="${context_path}/js/aw.js" type="text/javascript"></script>
-    <title>ActiveWeb - <@yield to="title"/></title>
+    <title>ActiveWeb</title>
 </head>
 <body>
 
 <div class="main">
-<#include "header.ftl" >
+    <div class="header">
+        <h1><a href="${context_path}">ActiveWeb Benchmark Application</a></h1>
+    </div>
+
+
     <div class="content">
     ${page_content}
     </div>
-<#include "footer.ftl" >
+    <div class='footer'>
+        <p>2010 - 2015 Active Web.</p>
+    </div>
+
 </div>
 
 </body>

+ 0 - 3
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/footer.ftl

@@ -1,3 +0,0 @@
-<div class='footer'>
-    <p>2010 - 2013 Active Web. No Rights Reserved.</p>
-</div>

+ 0 - 4
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/header.ftl

@@ -1,4 +0,0 @@
-<div class="header">
-    <h1><a href="${context_path}">ActiveWeb Benchmark Application</a></h1>
-</div>
-

+ 0 - 7
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/queries/index.ftl

@@ -1,7 +0,0 @@
-<@compress single_line=true>
-[<#list worlds as w>
-{"id":${w.id},"randomNumber":${w.randomNumber}}
-<#if w_has_next>,</#if>
-</#list>
-]
-</@compress>

+ 1 - 0
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/queries/index.html

@@ -0,0 +1 @@
+[<#list worlds as w >{"id":${w.id},"randomNumber":${w.randomNumber}}<#if w_has_next >,</#if></#list>]

+ 0 - 0
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/system/404.ftl → frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/system/404.html


+ 0 - 0
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/system/error.ftl → frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/system/error.html


+ 0 - 46
frameworks/Java/activeweb/src/test/java/app/controllers/DatabaseControllerSpec.java

@@ -1,46 +0,0 @@
-/*
-Copyright 2009-2010 Igor Polevoy 
-
-Licensed 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. 
-*/
-
-/**
- * @author Igor Polevoy: 12/18/13 4:42 PM
- */
-
-package app.controllers;
-
-
-import org.javalite.activeweb.DBControllerSpec;
-import org.junit.Test;
-
-import java.util.Map;
-
-public class DatabaseControllerSpec extends DBControllerSpec {
-
-    @Test
-    public void shouldRenderOneRecord(){
-
-        //execute controller
-        request().get("index");
-
-        //process result
-        Map result = JsonHelper.toMap(responseContent());
-
-        //test result
-        a(result.size()).shouldBeEqual(2);
-        a(result.get("id")).shouldNotBeNull();
-        a(result.get("randomNumber")).shouldNotBeNull();
-        a(contentType()).shouldBeEqual("application/json");
-    }
-}

+ 66 - 0
frameworks/Java/activeweb/src/test/java/app/controllers/DbControllerSpec.java

@@ -0,0 +1,66 @@
+/*
+Copyright 2009-2015 Igor Polevoy
+
+Licensed 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 app.controllers;
+
+import org.junit.Test;
+
+import java.util.Map;
+import org.junit.Ignore;
+
+/**
+ * @author Igor Polevoy: 12/18/13 4:42 PM
+ * @author Eric Nielsen
+ */
+public class DbControllerSpec extends org.javalite.activeweb.DBControllerSpec {
+
+    @Test
+    public void shouldRenderOneRecord() {
+        //execute controller
+        request().get("index");
+        //process result
+        System.out.println(responseContent());
+        Map result = JsonHelper.toMap(responseContent());
+        //test result
+        a(result.size()).shouldBeEqual(2);
+        a(result.get("id")).shouldNotBeNull();
+        a(result.get("randomNumber")).shouldNotBeNull();
+        a(contentType()).shouldBeEqual("application/json");
+    }
+
+
+    @Test
+    public void shouldRenderOneRecordWithJackson() {
+        //execute controller
+        request().get("jackson");
+        //process result
+        System.out.println(responseContent());
+        Map result = JsonHelper.toMap(responseContent());
+        //test result
+        a(result.size()).shouldBeEqual(2);
+        a(result.get("id")).shouldNotBeNull();
+        a(result.get("randomNumber")).shouldNotBeNull();
+        a(contentType()).shouldBeEqual("application/json");
+    }
+
+    @Ignore
+    public void shouldRenderResponseOneMinute() {
+        long endMillis = System.currentTimeMillis() + 60*1000;
+        do {
+            request().get("index");
+            responseContent();
+        } while (System.currentTimeMillis() < endMillis);
+    }
+}

+ 48 - 0
frameworks/Java/activeweb/src/test/java/app/controllers/FortunesControllerSpec.java

@@ -0,0 +1,48 @@
+/*
+Copyright 2009-2015 Igor Polevoy
+
+Licensed 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 app.controllers;
+
+import org.javalite.activeweb.DBControllerSpec;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Eric Nielsen
+ */
+public class FortunesControllerSpec extends DBControllerSpec {
+
+    @Test
+    public void shouldRenderHtml() {
+        request().integrateViews().get("index");
+        System.out.print(responseContent());
+        the(responseContent()).shouldContain(
+                "<tr><td>11</td><td>&lt;script&gt;alert(&quot;This should not be displayed in a browser alert box.&quot;);&lt;/script&gt;</td></tr>"
+                + "<tr><td>4</td><td>A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1</td></tr>"
+                + "<tr><td>5</td><td>A computer program does what you tell it to do, not what you want it to do.</td></tr>"
+                + "<tr><td>2</td><td>A computer scientist is someone who fixes things that aren&apos;t broken.</td></tr>");
+    }
+
+    @Ignore
+    @Test
+    public void shouldRenderHtmlOneMinute() {
+        long endMillis = System.currentTimeMillis() + 60*1000;
+        do {
+            request().integrateViews().get("index");
+            responseContent();
+        } while (System.currentTimeMillis() < endMillis);
+    }
+}

+ 33 - 26
frameworks/Java/activeweb/src/test/java/app/controllers/JsonControllerSpec.java

@@ -1,45 +1,52 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed 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 
+Licensed 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 
+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. 
+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.
 */
-
-/**
- * @author Igor Polevoy: 12/18/13 3:59 PM
- */
-
 package app.controllers;
 
-import org.javalite.activeweb.Configuration;
 import org.javalite.activeweb.ControllerSpec;
+import org.junit.Ignore;
 import org.junit.Test;
 
-import java.util.Map;
 
+/**
+ * @author Igor Polevoy: 12/18/13 3:59 PM
+ * @author Eric Nielsen
+ */
 public class JsonControllerSpec extends ControllerSpec {
 
     @Test
     public void shouldRenderMessage() {
+        request().integrateViews().get("index");
+        the(responseContent()).shouldBeEqual("{\"message\":\"Hello, World!\"}");
+        the(contentType()).shouldBeEqual("application/json");
+    }
 
-        System.out.println("ACTIVE_ENV value ============>>>>" + Configuration.getEnv());
-        //execute controller
-        request().get("index");
-
-        //process result
-        Map result = JsonHelper.toMap(responseContent());
+    @Test
+    public void shouldRenderMessageWithJackson() {
+        request().get("jackson");
+        the(responseContent()).shouldBeEqual("{\"message\":\"Hello, World!\"}");
+        the(contentType()).shouldBeEqual("application/json");
+    }
 
-        //test result
-        a(result.get("message")).shouldBeEqual("Hello, World!");
-        a(contentType()).shouldBeEqual("application/json");
+    @Ignore
+    @Test
+    public void shouldRenderMessageOneMinute() {
+        long endMillis = System.currentTimeMillis() + 60*1000;
+        do {
+            request().integrateViews().get("index");
+            responseContent();
+        } while (System.currentTimeMillis() < endMillis);
     }
 }

+ 42 - 0
frameworks/Java/activeweb/src/test/java/app/controllers/PlaintextControllerSpec.java

@@ -0,0 +1,42 @@
+/*
+Copyright 2009-2015 Igor Polevoy
+
+Licensed 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 app.controllers;
+
+import org.javalite.activeweb.ControllerSpec;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Eric Nielsen
+ */
+public class PlaintextControllerSpec extends ControllerSpec {
+
+    @Test
+    public void shouldRenderResponse() {
+        request().get("index");
+        the(responseContent()).shouldBeEqual("Hello, World!");
+    }
+
+    @Ignore
+    public void shouldRenderHtmlOneMinute() {
+        long endMillis = System.currentTimeMillis() + 60*1000;
+        do {
+            request().get("index");
+            responseContent();
+        } while (System.currentTimeMillis() < endMillis);
+    }
+}