Browse Source

first implementation of the ninja framework test

Kpacha 12 years ago
parent
commit
55e090a3fa

+ 20 - 0
ninja/.gitignore

@@ -0,0 +1,20 @@
+.DS_Store
+*.pyc
+installs/
+*.log
+*.lock
+node_modules/
+*.war
+target/
+*.out
+*.class
+mods/
+/.settings
+/.buildpath
+/.project
+*.iml
+.idea/
+.hsenv/
+azure.err
+*~
+/.classpath

+ 26 - 0
ninja/README.md

@@ -0,0 +1,26 @@
+# Ninja Framework Benchmarking Test
+
+This is the [Ninja](http://www.ninjaframework.org/) portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
+
+## Test URLs
+### JSON Encoding Test
+
+http://localhost:8080/ninja/json
+
+### Single Query Test
+
+http://localhost:8080/ninja/db
+
+### Multiple Queries Test
+
+http://localhost:8080/ninja/queries/5
+
+### Fortunes Test
+
+http://localhost:8080/ninja/fotunes
+
+### Plaintext Test
+
+http://localhost:8080/ninja/plaintext
+
+

+ 0 - 0
ninja/__init__.py


+ 27 - 0
ninja/benchmark_config

@@ -0,0 +1,27 @@
+{
+  "framework": "ninja",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/ninja/json",
+      "db_url": "/ninja/db",
+      "query_url": "/ninja/queries/",
+      "fortune_url": "/ninja/fortunes",
+      "plaintext_url": "/ninja/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "MySQL",
+      "framework": "ninja",
+      "language": "Java",
+      "orm": "Full",
+      "platform": "Servlet",
+      "webserver": "Resin",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "ninja",
+      "notes": "",
+      "versus": "servlet"
+    }
+  }]
+}

+ 157 - 0
ninja/pom.xml

@@ -0,0 +1,157 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>helo.world</groupId>
+	<artifactId>hello-ninja</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<name>Ninja Framework Test Project</name>
+	<description>Nnja test for the TechEmpower/FrameworkBenchmarks project</description>
+
+	<properties>
+		<java-version>1.7</java-version>
+		<ninja.version>2.0.1</ninja.version>
+		<mysql.version>5.1.26</mysql.version>
+		<jetty.version>9.0.5.v20130815</jetty.version>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.ninjaframework</groupId>
+			<artifactId>ninja-servlet</artifactId>
+			<version>${ninja.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>3.0.1</version>
+			<scope>provided</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.ninjaframework</groupId>
+			<artifactId>ninja-test-utilities</artifactId>
+			<version>${ninja.version}</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+			<version>${mysql.version}</version>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>3.1</version>
+				<configuration>
+					<source>${java-version}</source>
+					<target>${java-version}</target>
+				</configuration>
+			</plugin>
+			
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <configuration>
+                    <warName>ninja</warName>
+                </configuration>
+            </plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-enforcer-plugin</artifactId>
+				<version>1.0</version>
+				<executions>
+					<execution>
+						<id>enforce-banned-dependencies</id>
+						<goals>
+							<goal>enforce</goal>
+						</goals>
+						<configuration>
+							<rules>
+								<bannedDependencies>
+									<excludes>
+										<exclude>commons-logging</exclude>
+									</excludes>
+								</bannedDependencies>
+							</rules>
+							<fail>true</fail>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+
+			<plugin>
+				<groupId>org.eclipse.jetty</groupId>
+				<artifactId>jetty-maven-plugin</artifactId>
+				<version>${jetty.version}</version>
+				<configuration>
+					<contextPath>/</contextPath>
+					<stopKey>stop</stopKey>
+					<stopPort>8889</stopPort>
+					<scanIntervalSeconds>1</scanIntervalSeconds>
+					<reload>automatic</reload>
+					<scanTargetPatterns>
+						<scanTargetPattern>
+							<directory>target/classes</directory>
+							<includes>
+								<include>**/*</include>
+							</includes>
+							<excludes>
+								<exclude>**/*.ftl.html</exclude>
+								<exclude>assets/**</exclude>
+							</excludes>
+						</scanTargetPattern>
+					</scanTargetPatterns>
+				</configuration>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-deploy-plugin</artifactId>
+				<version>2.7</version>
+				<configuration>
+					<skip>true</skip>
+				</configuration>
+			</plugin>
+
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<version>2.4</version>
+				<configuration>
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+					<archive>
+						<manifest>
+							<mainClass>ninja.standalone.NinjaJetty</mainClass>
+						</manifest>
+					</archive>
+				</configuration>
+			</plugin>
+		</plugins>
+
+		<resources>
+			<resource>
+				<directory>src/main/java</directory>
+				<includes>
+					<include>**/*</include>
+				</includes>
+				<excludes>
+					<exclude>**/*.java</exclude>
+				</excludes>
+			</resource>
+			<resource>
+				<directory>src/main/resources</directory>
+				<includes>
+					<include>**/*</include>
+				</includes>
+			</resource>
+		</resources>
+	</build>
+</project>

+ 32 - 0
ninja/setup.py

@@ -0,0 +1,32 @@
+import subprocess
+import sys
+import setup_util
+import os
+
+def start(args):
+  setup_util.replace_text("ninja/src/main/webapp/WEB-INF/resin-web.xml", "mysql:\/\/.*:3306", "mysql://" + args.database_host + ":3306")
+  
+  try:
+    subprocess.check_call("mvn clean compile war:war", shell=True, cwd="ninja")
+
+    if os.name == 'nt':
+      subprocess.check_call('rmdir /S /Q "%RESIN_HOME%\\webapps\\"', shell=True)
+      subprocess.check_call('mkdir "%RESIN_HOME%\\webapps\\"', shell=True)
+      subprocess.check_call('copy ninja\\target\\ninja.war "%RESIN_HOME%\\webapps\\ninja.war"', shell=True)
+      subprocess.check_call('"%RESIN_HOME%\\bin\\start.bat"', shell=True)
+    else:
+      subprocess.check_call("rm -rf $RESIN_HOME/webapps/*", shell=True)
+      subprocess.check_call("cp ninja/target/ninja.war $RESIN_HOME/webapps/ninja.war", shell=True)
+      subprocess.check_call("$RESIN_HOME/bin/resinctl start", shell=True)
+    return 0
+  except subprocess.CalledProcessError:
+    return 1
+def stop():
+  try:
+    if os.name == 'nt':
+      subprocess.check_call('"%RESIN_HOME%\\bin\\stop.bat"', shell=True)
+    else:
+      subprocess.check_call("$RESIN_HOME/bin/resinctl shutdown", shell=True)
+    return 0
+  except subprocess.CalledProcessError:
+    return 1

+ 35 - 0
ninja/source_code

@@ -0,0 +1,35 @@
+./ninja/src/
+./ninja/src/main/
+./ninja/src/main/java/
+./ninja/src/main/java/conf
+./ninja/src/main/java/conf/Routes.java
+./ninja/src/main/java/conf/application.conf
+./ninja/src/main/java/conf/messages.properties
+./ninja/src/main/java/hello/
+./ninja/src/main/java/hello/controllers/
+./ninja/src/main/java/hello/controllers/HelloDbController.java
+./ninja/src/main/java/hello/controllers/HelloFortuneController.java
+./ninja/src/main/java/hello/controllers/HelloJsonController.java
+./ninja/src/main/java/hello/controllers/HelloPlaintextController.java
+./ninja/src/main/java/hello/dao/
+./ninja/src/main/java/hello/dao/FortuneDao.java
+./ninja/src/main/java/hello/dao/WorldDao.java
+./ninja/src/main/java/hello/model/
+./ninja/src/main/java/hello/model/Fortune.java
+./ninja/src/main/java/hello/model/World.java
+./ninja/src/main/java/hello/views/
+./ninja/src/main/java/hello/views/HelloFortuneController/
+./ninja/src/main/java/hello/views/HelloFortuneController/index.ftl.html
+./ninja/src/main/resources/
+./ninja/src/main/resources/META-INF/
+./ninja/src/main/resources/META-INF/persistence.xml
+./ninja/src/main/resources/conf/
+./ninja/src/main/resources/conf/application.conf
+./ninja/src/main/resources/conf/messages.properties
+./ninja/src/main/resources/ehcache.xml
+./ninja/src/main/resources/logback.xml
+./ninja/src/main/webapp/
+./ninja/src/main/webapp/WEB-INF/
+./ninja/src/main/webapp/WEB-INF/resin-web.xml
+./ninja/src/main/webapp/WEB-INF/web.xml
+

+ 26 - 0
ninja/src/main/java/conf/Routes.java

@@ -0,0 +1,26 @@
+package conf;
+
+import hello.controllers.HelloDbController;
+import hello.controllers.HelloFortuneController;
+import hello.controllers.HelloJsonController;
+import hello.controllers.HelloPlaintextController;
+import ninja.Router;
+import ninja.application.ApplicationRoutes;
+
+public class Routes implements ApplicationRoutes {
+
+    @Override
+    public void init(Router router) {
+
+	router.GET().route("/").with(HelloPlaintextController.class, "index");
+	router.GET().route("/plaintext")
+		.with(HelloPlaintextController.class, "index");
+	router.GET().route("/json").with(HelloJsonController.class, "index");
+	router.GET().route("/queries/{queries}")
+		.with(HelloDbController.class, "multiGet");
+	router.GET().route("/db").with(HelloDbController.class, "singleGet");
+	router.GET().route("/fortunes")
+		.with(HelloFortuneController.class, "index");
+
+    }
+}

+ 38 - 0
ninja/src/main/java/conf/application.conf

@@ -0,0 +1,38 @@
+##############################################################################
+# The main properties file to configure your application
+#
+# Properties can be prefixed by "%".
+# "%"" matches a mode you can set as system property. For instance when you
+# are using maven you can do: mvn -Dmode=test jetty:run
+#
+# Using that the following property:
+# %test.myproperty=test property
+# would overwrite the property
+# myproperty=my property
+#
+# You can define as many environments as you want. Simply set them in the mode.
+##############################################################################
+application.name=ninja test application
+
+application.cookie.prefix=NINJA
+
+#ISO Language Code, optionally followed by a valid ISO Country Code. 
+application.languages=en,de
+
+application.session.expire_time_in_seconds=3600
+application.session.send_only_if_changed=true
+application.session.transferred_over_https_only=false
+
+
+##############################################################################
+# Configure JPA
+# simply tell Ninja which persistence unit to use.
+# The persistence units are defined at META-INF/persistence.xml
+##############################################################################
+ninja.migration.run=false
+ninja.jpa.persistence_unit_name = mysql
+
+db.connection.url=jdbc:mysql://localhost/hello_world
+db.connection.username=benchmarkdbuser
+db.connection.password=benchmarkdbpass
+application.secret = b9z4AQO0huDRrJXFVjNiNXmSVqPSbcqjEiNjdPVBApb8n9GnxVjWBr9jp8tRfe73

+ 36 - 0
ninja/src/main/java/conf/messages.properties

@@ -0,0 +1,36 @@
+#
+# Copyright (C) 2012 the original author or authors.
+#
+# 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.
+#
+
+# This file is utf-8
+header.title=Ninja \u2764 JPA
+header.home=Home
+header.new=New
+header.login=Login
+header.logout=Logout
+
+login.username=Username / Email
+login.password=Password
+login.loginNowButton=Sign in
+
+login.errorLogin=Error. Username / password not valid.
+login.loginSuccessful=Login successful.
+login.logoutSuccessful=Logout successful.
+
+articleNew.pageTitle=Create new article
+articleNew.newArticle=New article
+articleNew.title=Title
+articleNew.content=Content
+articleNew.postNewArticle=Post now

+ 50 - 0
ninja/src/main/java/hello/controllers/HelloDbController.java

@@ -0,0 +1,50 @@
+package hello.controllers;
+
+import hello.dao.WorldDao;
+import hello.model.World;
+
+import java.util.Random;
+import java.util.concurrent.ThreadLocalRandom;
+
+import ninja.Result;
+import ninja.Results;
+import ninja.params.PathParam;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+@Singleton
+public class HelloDbController {
+
+    private static final int DB_ROWS = 10000;
+    private final Random random = ThreadLocalRandom.current();
+
+    @Inject
+    WorldDao worldDao;
+
+    public Result singleGet() {
+	return Results.json().render(getRandomWorld());
+    }
+
+    public Result multiGet(@PathParam("queries") Integer queries) {
+	if (queries == null || queries < 1) {
+	    queries = 1;
+	}
+	if (queries > 500) {
+	    queries = 500;
+	}
+
+	final World[] worlds = new World[queries];
+
+	for (int i = 0; i < queries; i++) {
+	    worlds[i] = getRandomWorld();
+	}
+
+	return Results.json().render(worlds);
+    }
+
+    private World getRandomWorld() {
+	return worldDao.get(random.nextInt(DB_ROWS) + 1);
+    }
+
+}

+ 28 - 0
ninja/src/main/java/hello/controllers/HelloFortuneController.java

@@ -0,0 +1,28 @@
+package hello.controllers;
+
+import hello.dao.FortuneDao;
+import hello.model.Fortune;
+
+import java.util.Collections;
+import java.util.List;
+
+import ninja.Result;
+import ninja.Results;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+@Singleton
+public class HelloFortuneController {
+
+    @Inject
+    FortuneDao fortuneDao;
+
+    public Result index() {
+	List<Fortune> fortunes = fortuneDao.getAll();
+	fortunes.add(new Fortune(0, "Additional fortune added at request time."));
+	Collections.sort(fortunes);
+
+	return Results.html().render("fortunes", fortunes);
+    }
+}

+ 27 - 0
ninja/src/main/java/hello/controllers/HelloJsonController.java

@@ -0,0 +1,27 @@
+package hello.controllers;
+
+import ninja.Result;
+import ninja.Results;
+
+import com.google.inject.Singleton;
+
+@Singleton
+public class HelloJsonController {
+
+    public Result index() {
+	return Results.json().render(new Message("Hello, world"));
+    }
+
+    public static class Message {
+
+	private final String message;
+
+	public Message(String message) {
+	    this.message = message;
+	}
+
+	public String getMessage() {
+	    return message;
+	}
+    }
+}

+ 13 - 0
ninja/src/main/java/hello/controllers/HelloPlaintextController.java

@@ -0,0 +1,13 @@
+package hello.controllers;
+
+import ninja.Result;
+import ninja.Results;
+
+import com.google.inject.Singleton;
+
+@Singleton
+public class HelloPlaintextController {
+    public Result index() {
+	return Results.html().renderRaw("Hello, world!");
+    }
+}

+ 35 - 0
ninja/src/main/java/hello/dao/FortuneDao.java

@@ -0,0 +1,35 @@
+package hello.dao;
+
+import hello.model.Fortune;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.persist.Transactional;
+
+public class FortuneDao {
+
+    @Inject
+    Provider<EntityManager> entitiyManagerProvider;
+
+    @Transactional
+    public List<Fortune> getAll() {
+	EntityManager entityManager = entitiyManagerProvider.get();
+
+	Query q = entityManager.createQuery("SELECT x FROM Fortune x");
+	List<Fortune> fortunes = q.getResultList();
+
+	return fortunes;
+    }
+
+    @Transactional
+    public void save(Fortune fortune) {
+	EntityManager entityManager = entitiyManagerProvider.get();
+	entityManager.persist(fortune);
+    }
+
+}

+ 28 - 0
ninja/src/main/java/hello/dao/WorldDao.java

@@ -0,0 +1,28 @@
+package hello.dao;
+
+import hello.model.World;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.persist.Transactional;
+
+public class WorldDao {
+
+    @Inject
+    Provider<EntityManager> entitiyManagerProvider;
+
+    @Transactional
+    public World get(int id) {
+
+	EntityManager entityManager = entitiyManagerProvider.get();
+
+	Query q = entityManager
+		.createQuery("SELECT x FROM World x WHERE x.id = :idParam");
+	World world = (World) q.setParameter("idParam", id).getSingleResult();
+
+	return world;
+    }
+}

+ 36 - 0
ninja/src/main/java/hello/model/Fortune.java

@@ -0,0 +1,36 @@
+package hello.model;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class Fortune implements Comparable<Fortune> {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    public int id;
+    public String message;
+
+    public Fortune() {
+
+    }
+
+    public Fortune(int id, String message) {
+	this.id = id;
+	this.message = message;
+    }
+
+    public int getId() {
+	return this.id;
+    }
+
+    public String getMessage() {
+	return this.message;
+    }
+
+    @Override
+    public int compareTo(Fortune other) {
+	return message.compareTo(other.message);
+    }
+}

+ 14 - 0
ninja/src/main/java/hello/model/World.java

@@ -0,0 +1,14 @@
+package hello.model;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class World {
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    public int id;
+    public int randomNumber;
+}

+ 20 - 0
ninja/src/main/java/hello/views/HelloFortuneController/index.ftl.html

@@ -0,0 +1,20 @@
+<!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>

+ 58 - 0
ninja/src/main/resources/META-INF/persistence.xml

@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+	version="2.0">
+
+	<!-- The following config is an example config for mysql -->
+	<persistence-unit name="mysql-test" transaction-type="RESOURCE_LOCAL">
+		<provider>org.hibernate.ejb.HibernatePersistence</provider>
+
+		<properties>
+			<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
+			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
+
+			<property name="hibernate.show_sql" value="false" />
+			<property name="hibernate.format_sql" value="false" />
+
+			<!-- Connection Pooling settings -->
+			<property name="hibernate.connection.provider_class"
+				value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider" />
+
+			<property name="hibernate.c3p0.max_size" value="100" />
+			<property name="hibernate.c3p0.min_size" value="0" />
+			<property name="hibernate.c3p0.acquire_increment" value="1" />
+			<property name="hibernate.c3p0.idle_test_period" value="300" />
+			<property name="hibernate.c3p0.max_statements" value="0" />
+			<property name="hibernate.c3p0.timeout" value="100" />
+		</properties>
+	</persistence-unit>
+
+	<!-- The following config is an example config for mysql -->
+	<persistence-unit name="mysql" transaction-type="RESOURCE_LOCAL">
+		<provider>org.hibernate.ejb.HibernatePersistence</provider>
+		<jta-data-source>java:comp/env/jdbc/hello_world</jta-data-source>
+
+		<properties>
+			<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
+			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
+
+			<property name="hibernate.show_sql" value="false" />
+			<property name="hibernate.format_sql" value="false" />
+
+			<!-- Connection Pooling settings -->
+<!-- 			<property name="hibernate.connection.provider_class" -->
+<!-- 				value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider" /> -->
+			<property name="hibernate.connection.provider_class"
+				value="org.hibernate.connection.C3P0ConnectionProvider" />
+
+			<property name="hibernate.c3p0.max_size" value="100" />
+			<property name="hibernate.c3p0.min_size" value="0" />
+			<property name="hibernate.c3p0.acquire_increment" value="1" />
+			<property name="hibernate.c3p0.idle_test_period" value="300" />
+			<property name="hibernate.c3p0.max_statements" value="0" />
+			<property name="hibernate.c3p0.timeout" value="100" />
+		</properties>
+	</persistence-unit>
+</persistence>

+ 40 - 0
ninja/src/main/resources/conf/application.conf

@@ -0,0 +1,40 @@
+##############################################################################
+# The main properties file to configure your application
+#
+# Properties can be prefixed by "%".
+# "%"" matches a mode you can set as system property. For instance when you
+# are using maven you can do: mvn -Dmode=test jetty:run
+#
+# Using that the following property:
+# %test.myproperty=test property
+# would overwrite the property
+# myproperty=my property
+#
+# You can define as many environments as you want. Simply set them in the mode.
+##############################################################################
+application.name=ninja test application
+
+application.cookie.prefix=NINJA
+
+#ISO Language Code, optionally followed by a valid ISO Country Code. 
+application.languages=en,de
+
+application.session.expire_time_in_seconds=3600
+application.session.send_only_if_changed=true
+application.session.transferred_over_https_only=false
+
+
+##############################################################################
+# Configure JPA
+# simply tell Ninja which persistence unit to use.
+# The persistence units are defined at META-INF/persistence.xml
+##############################################################################
+ninja.migration.run=false
+ninja.jpa.persistence_unit_name = mysql
+%test.ninja.jpa.persistence_unit_name = mysql-test
+
+# db.connection.url=jdbc:mysql://localhost/hello_world
+%test.db.connection.url=jdbc:mysql://localhost/hello_world
+db.connection.username=benchmarkdbuser
+db.connection.password=benchmarkdbpass
+application.secret = b9z4AQO0huDRrJXFVjNiNXmSVqPSbcqjEiNjdPVBApb8n9GnxVjWBr9jp8tRfe73

+ 17 - 0
ninja/src/main/resources/conf/messages.properties

@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2012 the original author or authors.
+#
+# 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.
+#
+
+# This file is utf-8

+ 15 - 0
ninja/src/main/resources/ehcache.xml

@@ -0,0 +1,15 @@
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../config/ehcache.xsd" updateCheck="false">
+
+    <defaultCache
+            maxElementsInMemory="10000"
+            eternal="false"
+            timeToIdleSeconds="120"
+            timeToLiveSeconds="120"
+            overflowToDisk="false"
+            maxElementsOnDisk="10000000"
+            diskPersistent="false"
+            diskExpiryThreadIntervalSeconds="120"
+            memoryStoreEvictionPolicy="LRU"
+    /> 
+    
+</ehcache>

+ 14 - 0
ninja/src/main/resources/logback.xml

@@ -0,0 +1,14 @@
+<configuration>
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- encoders are assigned the type
+         ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+    <encoder>
+      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="error">
+    <appender-ref ref="STDOUT" />
+  </root>
+</configuration>

+ 13 - 0
ninja/src/main/webapp/WEB-INF/resin-web.xml

@@ -0,0 +1,13 @@
+<web-app xmlns="http://caucho.com/ns/resin">
+
+<database jndi-name='jdbc/hello_world'>
+  <driver>
+    <type>com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource</type>
+    <url>jdbc:mysql://localhost:3306/hello_world?jdbcCompliantTruncation=false&amp;elideSetAutoCommits=true&amp;useLocalSessionState=true&amp;cachePrepStmts=true&amp;cacheCallableStmts=true&amp;alwaysSendSetIsolation=false&amp;prepStmtCacheSize=4096&amp;cacheServerConfiguration=true&amp;prepStmtCacheSqlLimit=2048&amp;zeroDateTimeBehavior=convertToNull&amp;traceProtocol=false&amp;useUnbufferedInput=false&amp;useReadAheadInput=false&amp;maintainTimeStats=false&amp;useServerPrepStmts&amp;cacheRSMetadata=true</url>
+    <user>benchmarkdbuser</user>
+    <password>benchmarkdbpass</password>
+    <useUnicode/>
+  </driver>
+</database>
+
+</web-app>

+ 32 - 0
ninja/src/main/webapp/WEB-INF/web.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (C) 2013 the original author or authors.
+
+    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.
+
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" metadata-complete="true" version="3.0">
+  <display-name>ninja</display-name>
+  <listener>
+    <listener-class>ninja.servlet.NinjaServletListener</listener-class>
+  </listener>
+  <filter>
+    <filter-name>guiceFilter</filter-name>
+    <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
+  </filter>
+  <filter-mapping>
+    <filter-name>guiceFilter</filter-name>
+    <url-pattern>/*</url-pattern>
+  </filter-mapping>
+</web-app>