Browse Source

testing the standalone version with the fat-jar

Kpacha 12 years ago
parent
commit
647fad0a34

+ 20 - 0
ninja-standalone/.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-standalone/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-standalone/__init__.py


+ 27 - 0
ninja-standalone/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": "Jetty",
+      "webserver": "Jetty",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "ninja-standalone",
+      "notes": "",
+      "versus": ""
+    }
+  }]
+}

+ 163 - 0
ninja-standalone/pom.xml

@@ -0,0 +1,163 @@
+<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-standalone</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>org.ninjaframework</groupId>
+        		<artifactId>ninja-standalone</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>

+ 23 - 0
ninja-standalone/setup.py

@@ -0,0 +1,23 @@
+import subprocess
+import sys
+import setup_util
+import os
+
+def start(args):
+  setup_util.replace_text("ninja/src/main/resource/conf/application.conf", "mysql:\/\/.*:3306", "mysql://" + args.database_host + ":3306")
+  
+  try:
+    subprocess.check_call("mvn clean compile assembly:single", shell=True, cwd="ninja")
+    subprocess.check_call("java -Dninja.port=8080 -Dninja.mode=prod -Dninja.context=/ninja -jar ninja/target/hello-ninja-standalone-0.0.1-SNAPSHOT-jar-with-dependencies.jar", shell=True)
+    return 0
+  except subprocess.CalledProcessError:
+    return 1
+
+def stop():
+  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+  out, err = p.communicate()
+  for line in out.splitlines():
+    if 'hello-ninja' in line:
+      pid = int(line.split(None, 2)[1])
+      os.kill(pid, 9)
+  return 0

+ 35 - 0
ninja-standalone/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
+

+ 1 - 0
ninja-standalone/src/main/java

@@ -0,0 +1 @@
+../../../ninja/src/main/java

+ 1 - 0
ninja-standalone/src/main/resources/META-INF

@@ -0,0 +1 @@
+../../../../ninja/src/main/resources/META-INF

+ 38 - 0
ninja-standalone/src/main/resources/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: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
+db.connection.username=benchmarkdbuser
+db.connection.password=benchmarkdbpass
+
+application.secret = b9z4AQO0huDRrJXFVjNiNXmSVqPSbcqjEiNjdPVBApb8n9GnxVjWBr9jp8tRfe73

+ 17 - 0
ninja-standalone/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-standalone/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-standalone/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>

+ 1 - 0
ninja-standalone/src/main/webapp

@@ -0,0 +1 @@
+../../../ninja/src/main/webapp

+ 1 - 0
ninja-standalone/src/test

@@ -0,0 +1 @@
+../../ninja/src/test