Skip to content

Commit 8678f58

Browse files
author
shlomisut
committedApr 9, 2014
freemarker-online initial commit
0 parents  commit 8678f58

35 files changed

+1278
-0
lines changed
 

‎.gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
*.class
2+
3+
# Package Files #
4+
*.jar
5+
*.war
6+
*.ear
7+
8+
databaseTest.properties
9+
.settings/
10+
.classpath
11+
.project
12+
workspace/
13+
*.iml
14+
*.ipr
15+
*.iws
16+
build/
17+
out/
18+
.gradle/

‎README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
freemarker-online
2+
====================
3+

‎build.gradle

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
group = 'com.kenshoo.freemarker'
2+
project.projectName = "freemarker-online"
3+
def BUILD_NUMBER = project.hasProperty('BUILD_NUMBER')? "$BUILD_NUMBER":'undef'
4+
project.version = "0.1.$BUILD_NUMBER"
5+
project.yml = "$rootDir/src/main/resources/${projectName}.yml"
6+
project.jarName = "$rootDir/build/libs/${projectName}-${project.version}.jar"
7+
8+
9+
apply from: "intellij.gradle"
10+
apply from: "db.gradle"
11+
apply from: "${rootDir}/dependencies.gradle"
12+
apply plugin: 'maven'
13+
apply plugin: 'java'
14+
apply plugin: 'project-report'
15+
apply plugin: 'fatjar'
16+
apply plugin: 'fpm-packaging'
17+
apply from: "cucumber.gradle"
18+
19+
buildscript {
20+
repositories {
21+
mavenCentral()
22+
}
23+
dependencies {
24+
classpath 'eu.appsatori:gradle-fatjar-plugin:0.2-rc1'
25+
classpath 'com.kenshoo:gradle-fpm:+'
26+
classpath 'com.kenshoo.watership:executor-gradle-plugin:0.2.5'
27+
}
28+
}
29+
30+
31+
32+
dependencies {
33+
compile libraries.dropwizard
34+
compile libraries.springCore
35+
compile libraries.springContext
36+
compile libraries.springContextSupport
37+
compile libraries.springExpression
38+
compile libraries.springSecurityCore
39+
compile libraries.springTransaction
40+
compile libraries.springBeans
41+
compile libraries.fallwizard
42+
compile libraries.dropwizard_migrations
43+
44+
// database context
45+
compile libraries.mysql
46+
compile libraries.tomcatJdbc
47+
compile libraries.springJDBC
48+
compile libraries.springTransaction
49+
compile libraries.jdbi
50+
51+
testCompile libraries.dropwizard_testing
52+
testCompile libraries.springTest
53+
testCompile libraries.junit
54+
testCompile libraries.mockito
55+
56+
// cucumber
57+
testCompile libraries.cucumberJava
58+
testCompile libraries.cucumberJUnit
59+
testCompile libraries.cucumberCore
60+
testCompile libraries.cucumberSpring
61+
testCompile libraries.springJDBC
62+
63+
}
64+
65+
compileJava {
66+
options.compilerArgs << "-Werror"
67+
}
68+
compileTestJava {
69+
options.compilerArgs << "-Werror"
70+
}
71+
72+
task wrapper(type: Wrapper) {
73+
gradleVersion = '1.10'
74+
}
75+
76+
fatJar {
77+
exclude "META-INF/*.SF"
78+
exclude "META-INF/*.DSA"
79+
exclude "META-INF/*.RSA"
80+
manifest { attributes 'Main-Class': 'com.kenshoo.freemarker.dropwizard.ApplicationStartup'
81+
attributes 'Implementation-Version': "$version"}
82+
}
83+
84+
// this merges the spring files into META-INF properly
85+
fatJarPrepareFiles {
86+
include 'META-INF/spring.handlers'
87+
include 'META-INF/spring.schemas'
88+
}
89+
90+
// wrap jar, upstart and yml into deb package:
91+
92+
def stagingDir = new File(project.buildDir, "staging")
93+
94+
task stageArtifacts(type: Copy) {
95+
stagingDir.mkdir()
96+
// place yml file and jar under staging dir
97+
into new File(stagingDir, "/opt/${projectName}")
98+
from "build/resources/main/${projectName}.yml"
99+
from 'build/libs'
100+
}
101+
102+
task stageStartScript << {
103+
new File(stagingDir, "opt/${projectName}/start").withWriter("UTF-8") {
104+
it.println "#!/usr/bin/env sh\nset -e\njava \$* -jar ${project.name}-${project.version}.jar db migrate ${project.name}.yml &\nexec java \$* -jar ${project.name}-${project.version}.jar server ${project.name}.yml"
105+
}
106+
}
107+
108+
task stageFiles(dependsOn: [stageArtifacts, stageStartScript]) << {
109+
println "staging debian files"
110+
}
111+
112+
// configure plugin to package the staging dir we've
113+
// just created, and to declare java-7 dependency
114+
packaging {
115+
dependencies = ['openjdk-7-jre']
116+
baseDir = stagingDir
117+
}
118+
119+
120+
fatJar.dependsOn jar
121+
build.dependsOn fatJar
122+
stageFiles.dependsOn build
123+
debian.dependsOn stageFiles

‎cucumber.gradle

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
configurations {
2+
cucumberRuntime {
3+
extendsFrom testRuntime
4+
}
5+
}
6+
7+
task cucumber(dependsOn: 'cucumberJar') {
8+
def jsonOut = "json:${project.projectDir}/build/cucumber/cucumber.json"
9+
10+
doLast {
11+
javaexec {
12+
main = "cucumber.api.cli.Main"
13+
classpath = configurations.cucumberRuntime
14+
jvmArgs '-Xms256m', '-XX:MaxPermSize=256m'
15+
args = ['--format', 'pretty','-f', jsonOut, '--glue', 'com.kenshoo.cucumber',
16+
'src/test/resources/com/kenshoo/cucumber/'
17+
]
18+
}
19+
}
20+
}
21+
22+
23+
task cucumberJar (type:Jar) {
24+
from sourceSets.test.output
25+
from sourceSets.main.resources
26+
destinationDir = file("${project.projectDir}/build/cucumber")
27+
baseName = "cucumber"
28+
}
29+
30+
31+
32+
dependencies {
33+
/*
34+
In order to work around a really flagrant bug ( http://issues.gradle.org/browse/GRADLE-732 )
35+
You have to create a configuration that includes the jar.archivePath (the jar.archivePath is created by the java plugin)
36+
and give it the same name as the cucumberRuntime configuration, or name it something different and have the cucumberRuntime
37+
configuration extend from it as well.
38+
VERY ANNOYING BUG
39+
*/
40+
cucumberRuntime files("${cucumberJar.archivePath}") + sourceSets.main.output // We add the main source set so that the PathMatchingResourcePatternResolver will find the YML file
41+
// When using classpath*:*.yml pattern - Java will only search for the file in expanded directories
42+
}

‎db.gradle

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
def testConfigLocation = "${project.projectDir}/src/test/resources/databaseTest.properties"
2+
3+
task genDBProps << {
4+
def fileLocation = "${project.projectDir}/src/main/resources/database.properties"
5+
logger.info("preparing database propery file in:" + fileLocation)
6+
createFolder(fileLocation) //creates file
7+
createDatabaseProperties(fileLocation)
8+
}
9+
10+
task genTestDBProps << {
11+
logger.info "preparing *****TEST***** database propery file in:" + testConfigLocation
12+
createFolder(testConfigLocation) //creates file
13+
createDatabaseProperties(testConfigLocation)
14+
}
15+
16+
def createDatabaseProperties(propertyFile) {
17+
java.util.Properties props = new java.util.Properties()
18+
if (project.hasProperty("dbUser")) props.setProperty("database.user", dbUser)
19+
if (project.hasProperty("dbPass")) props.setProperty("database.password", dbPass)
20+
21+
// Not needed for DB config - setting the URL is enough
22+
// props.setProperty("database.dbName", dbName)
23+
// props.setProperty("database.dbHost", dbHost)
24+
props.setProperty("database.url", "jdbc:mysql://${dbHost}:3306/${dbName}?createDatabaseIfNotExist=true")
25+
26+
props.store(new java.io.FileOutputStream(propertyFile), "Kenshoo generated datasource properties DO NOT Commit");
27+
}
28+
29+
def createFolder(path) {
30+
File ds = new File(path)
31+
if (!ds.exists()) {
32+
ds.createNewFile()
33+
}
34+
}
35+
36+
37+
task migrateDB(type: Exec, dependsOn: 'fatJar') {
38+
commandLine = ['java', '-jar', jarName, 'db', 'migrate', yml]
39+
logger.info(commandLine.toString())
40+
}
41+
42+
task clearDB(type: Exec, dependsOn: 'fatJar') {
43+
commandLine = ['java', '-jar', jarName, 'db', 'drop-all','--confirm-delete-everything', yml]
44+
logger.info(commandLine.toString())
45+
}
46+
47+
task migrateTestDB(type: Exec, dependsOn: 'fatJar') {
48+
File testProp = new File(testConfigLocation);
49+
if(!testProp.exists()){
50+
logger.error("----- No Test DB config found---- make sure you run genTestDBProps")
51+
}else{
52+
def params =[]
53+
testProp.text.eachLine{ line ->
54+
if (!line.startsWith("#")){
55+
def unescapedLine = line.replace("\\:",":").replace("\\=","=")
56+
params.add("-Ddw.$unescapedLine")
57+
}
58+
}
59+
commandLine = ['java','-jar', jarName, 'db', 'migrate', yml]
60+
commandLine = commandLine.plus(1,params)
61+
logger.info(commandLine.toString())
62+
}
63+
}
64+

‎dependencies.gradle

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
project.ext.set("libraries", "")
2+
ext.dw_version = "0.6.2";
3+
ext.spring_version = "3.2.2.RELEASE";
4+
ext.cucu_version = "1.1.4";
5+
6+
project.libraries = [
7+
dropwizard: "com.yammer.dropwizard:dropwizard-core:$dw_version",
8+
dropwizard_client: "com.yammer.dropwizard:dropwizard-client:$dw_version",
9+
guava: 'com.google.guava:guava:13.0.1',
10+
jersey_core: 'com.sun.jersey:jersey-core:1.1.4.1',
11+
12+
//Spring
13+
springCore: "org.springframework:spring-core:$spring_version",
14+
springContext: "org.springframework:spring-context:$spring_version",
15+
springContextSupport: "org.springframework:spring-context-support:$spring_version",
16+
springExpression: "org.springframework:spring-expression:$spring_version",
17+
springTransaction: "org.springframework:spring-tx:$spring_version",
18+
springBeans: "org.springframework:spring-beans:$spring_version",
19+
20+
// Security
21+
// Spring and Spring Security support for dropwizard
22+
fallwizard: "com.berico:fallwizard:1.1.1",
23+
// adheres to fallwizard version of spring security
24+
springSecurityCore: "org.springframework.security:spring-security-core:3.1.4.RELEASE",
25+
dropwizardAuth: "com.yammer.dropwizard:dropwizard-auth:$dw_version",
26+
27+
// Spring test
28+
springTest: "org.springframework:spring-test:$spring_version",
29+
30+
// DB
31+
dropwizard_migrations: "com.yammer.dropwizard:dropwizard-migrations:$dw_version",
32+
mysql:'mysql:mysql-connector-java:5.1.6',
33+
tomcatJdbc: "org.apache.tomcat:tomcat-jdbc:7.0.27", // Use tomcat JDBC pool
34+
springJDBC: "org.springframework:spring-jdbc:$spring_version",
35+
spring_orm: "org.springframework:spring-orm:$spring_version",
36+
spring_transaction: "org.springframework:spring-tx:$spring_version",
37+
jdbi:'org.jdbi:jdbi:2.49',
38+
39+
//Test libs
40+
dropwizard_testing: "com.yammer.dropwizard:dropwizard-testing:$dw_version",
41+
junit: 'junit:junit-dep:4.11',
42+
mockito: 'org.mockito:mockito-all:1.9.0',
43+
44+
// cucumber
45+
cucumberJava: "info.cukes:cucumber-java:$cucu_version",
46+
cucumberJUnit: "info.cukes:cucumber-junit:$cucu_version",
47+
cucumberCore: "info.cukes:cucumber-core:$cucu_version",
48+
cucumberSpring: "info.cukes:cucumber-spring:$cucu_version"
49+
]
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Tue Sep 10 11:20:58 IST 2013
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip

‎gradlew

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
#!/usr/bin/env bash
2+
3+
##############################################################################
4+
##
5+
## Gradle start up script for UN*X
6+
##
7+
##############################################################################
8+
9+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10+
DEFAULT_JVM_OPTS=""
11+
12+
APP_NAME="Gradle"
13+
APP_BASE_NAME=`basename "$0"`
14+
15+
# Use the maximum available, or set MAX_FD != -1 to use that value.
16+
MAX_FD="maximum"
17+
18+
warn ( ) {
19+
echo "$*"
20+
}
21+
22+
die ( ) {
23+
echo
24+
echo "$*"
25+
echo
26+
exit 1
27+
}
28+
29+
# OS specific support (must be 'true' or 'false').
30+
cygwin=false
31+
msys=false
32+
darwin=false
33+
case "`uname`" in
34+
CYGWIN* )
35+
cygwin=true
36+
;;
37+
Darwin* )
38+
darwin=true
39+
;;
40+
MINGW* )
41+
msys=true
42+
;;
43+
esac
44+
45+
# For Cygwin, ensure paths are in UNIX format before anything is touched.
46+
if $cygwin ; then
47+
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48+
fi
49+
50+
# Attempt to set APP_HOME
51+
# Resolve links: $0 may be a link
52+
PRG="$0"
53+
# Need this for relative symlinks.
54+
while [ -h "$PRG" ] ; do
55+
ls=`ls -ld "$PRG"`
56+
link=`expr "$ls" : '.*-> \(.*\)$'`
57+
if expr "$link" : '/.*' > /dev/null; then
58+
PRG="$link"
59+
else
60+
PRG=`dirname "$PRG"`"/$link"
61+
fi
62+
done
63+
SAVED="`pwd`"
64+
cd "`dirname \"$PRG\"`/" >&-
65+
APP_HOME="`pwd -P`"
66+
cd "$SAVED" >&-
67+
68+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69+
70+
# Determine the Java command to use to start the JVM.
71+
if [ -n "$JAVA_HOME" ] ; then
72+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73+
# IBM's JDK on AIX uses strange locations for the executables
74+
JAVACMD="$JAVA_HOME/jre/sh/java"
75+
else
76+
JAVACMD="$JAVA_HOME/bin/java"
77+
fi
78+
if [ ! -x "$JAVACMD" ] ; then
79+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80+
81+
Please set the JAVA_HOME variable in your environment to match the
82+
location of your Java installation."
83+
fi
84+
else
85+
JAVACMD="java"
86+
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87+
88+
Please set the JAVA_HOME variable in your environment to match the
89+
location of your Java installation."
90+
fi
91+
92+
# Increase the maximum file descriptors if we can.
93+
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94+
MAX_FD_LIMIT=`ulimit -H -n`
95+
if [ $? -eq 0 ] ; then
96+
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97+
MAX_FD="$MAX_FD_LIMIT"
98+
fi
99+
ulimit -n $MAX_FD
100+
if [ $? -ne 0 ] ; then
101+
warn "Could not set maximum file descriptor limit: $MAX_FD"
102+
fi
103+
else
104+
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105+
fi
106+
fi
107+
108+
# For Darwin, add options to specify how the application appears in the dock
109+
if $darwin; then
110+
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111+
fi
112+
113+
# For Cygwin, switch paths to Windows format before running java
114+
if $cygwin ; then
115+
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116+
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117+
118+
# We build the pattern for arguments to be converted via cygpath
119+
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120+
SEP=""
121+
for dir in $ROOTDIRSRAW ; do
122+
ROOTDIRS="$ROOTDIRS$SEP$dir"
123+
SEP="|"
124+
done
125+
OURCYGPATTERN="(^($ROOTDIRS))"
126+
# Add a user-defined pattern to the cygpath arguments
127+
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128+
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129+
fi
130+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
131+
i=0
132+
for arg in "$@" ; do
133+
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134+
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135+
136+
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137+
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138+
else
139+
eval `echo args$i`="\"$arg\""
140+
fi
141+
i=$((i+1))
142+
done
143+
case $i in
144+
(0) set -- ;;
145+
(1) set -- "$args0" ;;
146+
(2) set -- "$args0" "$args1" ;;
147+
(3) set -- "$args0" "$args1" "$args2" ;;
148+
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149+
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150+
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151+
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152+
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153+
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154+
esac
155+
fi
156+
157+
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158+
function splitJvmOpts() {
159+
JVM_OPTS=("$@")
160+
}
161+
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162+
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163+
164+
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

‎gradlew.bat

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
@if "%DEBUG%" == "" @echo off
2+
@rem ##########################################################################
3+
@rem
4+
@rem Gradle startup script for Windows
5+
@rem
6+
@rem ##########################################################################
7+
8+
@rem Set local scope for the variables with windows NT shell
9+
if "%OS%"=="Windows_NT" setlocal
10+
11+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12+
set DEFAULT_JVM_OPTS=
13+
14+
set DIRNAME=%~dp0
15+
if "%DIRNAME%" == "" set DIRNAME=.
16+
set APP_BASE_NAME=%~n0
17+
set APP_HOME=%DIRNAME%
18+
19+
@rem Find java.exe
20+
if defined JAVA_HOME goto findJavaFromJavaHome
21+
22+
set JAVA_EXE=java.exe
23+
%JAVA_EXE% -version >NUL 2>&1
24+
if "%ERRORLEVEL%" == "0" goto init
25+
26+
echo.
27+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28+
echo.
29+
echo Please set the JAVA_HOME variable in your environment to match the
30+
echo location of your Java installation.
31+
32+
goto fail
33+
34+
:findJavaFromJavaHome
35+
set JAVA_HOME=%JAVA_HOME:"=%
36+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37+
38+
if exist "%JAVA_EXE%" goto init
39+
40+
echo.
41+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42+
echo.
43+
echo Please set the JAVA_HOME variable in your environment to match the
44+
echo location of your Java installation.
45+
46+
goto fail
47+
48+
:init
49+
@rem Get command-line arguments, handling Windowz variants
50+
51+
if not "%OS%" == "Windows_NT" goto win9xME_args
52+
if "%@eval[2+2]" == "4" goto 4NT_args
53+
54+
:win9xME_args
55+
@rem Slurp the command line arguments.
56+
set CMD_LINE_ARGS=
57+
set _SKIP=2
58+
59+
:win9xME_args_slurp
60+
if "x%~1" == "x" goto execute
61+
62+
set CMD_LINE_ARGS=%*
63+
goto execute
64+
65+
:4NT_args
66+
@rem Get arguments from the 4NT Shell from JP Software
67+
set CMD_LINE_ARGS=%$
68+
69+
:execute
70+
@rem Setup the command line
71+
72+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
74+
@rem Execute Gradle
75+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76+
77+
:end
78+
@rem End local scope for the variables with windows NT shell
79+
if "%ERRORLEVEL%"=="0" goto mainEnd
80+
81+
:fail
82+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83+
rem the _cmd.exe /c_ return code!
84+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85+
exit /b 1
86+
87+
:mainEnd
88+
if "%OS%"=="Windows_NT" endlocal
89+
90+
:omega

‎intellij.gradle

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apply plugin: 'idea'
2+
3+
idea {
4+
project {
5+
jdkName = '1.7'
6+
}
7+
}
8+
9+
idea.project.ipr {
10+
withXml { provider ->
11+
provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git'
12+
}
13+
}
14+
15+
idea.workspace.iws.withXml { provider ->
16+
def runManager = provider.node.component.find { it.@name == 'RunManager' }
17+
runManager.attributes().put('selected',"Application.MyProjectStartup")
18+
Node list = runManager.list[0]
19+
list.attributes().put('size','1')
20+
list.appendNode('item',[index:'0' ,class:'java.lang.String' ,itemvalue:'MyProjectStartup'])
21+
def Application = runManager.appendNode('configuration',[default:'false',name:"${projectName}", type:'Application' ,factoryName:'Application'])
22+
Application.appendNode('extension',[name:'coverage',enabled:'false',merge:'false', runner:'idea'])
23+
Application.appendNode('option',[name:'MAIN_CLASS_NAME',value:"com.kenshoo.freemarker.dropwizard.ApplicationStartup" ])
24+
Application.appendNode('option',[name:'VM_PARAMETERS',value:"" ])
25+
Application.appendNode('option',[name:'PROGRAM_PARAMETERS',value:"server src/main/resources/${projectName}.yml" ])
26+
Application.appendNode('option',[name:'WORKING_DIRECTORY',value:"$projectDir" ])
27+
Application.appendNode('option',[name:'ALTERNATIVE_JRE_PATH_ENABLED',value:"false" ])
28+
Application.appendNode('option',[name:'ALTERNATIVE_JRE_PATH',value:"" ])
29+
Application.appendNode('option',[name:'ENABLE_SWING_INSPECTOR',value:"false" ])
30+
Application.appendNode('option',[name:'ENV_VARIABLES'])
31+
Application.appendNode('option',[name:'PASS_PARENT_ENVS',value:"true" ])
32+
Application.appendNode('module',[name:"${projectName}"])
33+
Application.appendNode('envs')
34+
Application.appendNode('RunnerSettings',[RunnerId:'Run' ])
35+
Application.appendNode('ConfigurationWrapper',[RunnerId:'Run' ])
36+
Application.appendNode('method')
37+
}

‎settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'freemarker-online'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2011 Kenshoo.com
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.kenshoo.freemarker.dropwizard;
17+
18+
import com.berico.fallwizard.SpringConfiguration;
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
import com.yammer.dropwizard.db.DatabaseConfiguration;
21+
22+
import javax.validation.Valid;
23+
import javax.validation.constraints.NotNull;
24+
25+
/**
26+
* User: dekely
27+
* Date: 19/03/13
28+
* Time: 12:51
29+
*/
30+
public class ApplicationConfiguration extends SpringConfiguration {
31+
@Valid
32+
@NotNull
33+
@JsonProperty
34+
private DatabaseConfiguration database = new DatabaseConfiguration();
35+
36+
public void setSystemProperties() {
37+
System.setProperty("database.password", database.getPassword());
38+
System.setProperty("database.user", database.getUser());
39+
System.setProperty("database.url", database.getUrl());
40+
System.setProperty("database.driverClass", database.getDriverClass());
41+
}
42+
43+
44+
public DatabaseConfiguration getDatabaseConfiguration() {
45+
return database;
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2011 Kenshoo.com
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.kenshoo.freemarker.dropwizard;
17+
18+
import com.berico.fallwizard.SpringService;
19+
import com.yammer.dropwizard.config.Bootstrap;
20+
import com.yammer.dropwizard.config.Environment;
21+
import com.yammer.dropwizard.db.DatabaseConfiguration;
22+
import com.yammer.dropwizard.migrations.MigrationsBundle;
23+
24+
/**
25+
* User: dekely
26+
* Date: 3/17/13
27+
* Time: 10:39 AM
28+
*/
29+
public class ApplicationStartup extends SpringService<ApplicationConfiguration> {
30+
31+
public static void main(String[] args) throws Exception {
32+
new ApplicationStartup().run(args);
33+
}
34+
35+
@Override
36+
public void initialize(Bootstrap<ApplicationConfiguration> bootstrap) {
37+
bootstrap.setName("freemarker-online");
38+
bootstrap.addBundle(new MigrationsBundle<ApplicationConfiguration>() {
39+
@Override
40+
public DatabaseConfiguration getDatabaseConfiguration(ApplicationConfiguration configuration) {
41+
return configuration.getDatabaseConfiguration();
42+
}
43+
});
44+
45+
}
46+
47+
@Override
48+
public void run(ApplicationConfiguration configuration, Environment environment) throws Exception {
49+
// This is used to allow for overriding/using values from property files
50+
configuration.setSystemProperties();
51+
super.run(configuration, environment);
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.kenshoo.freemarker.healthchecks;
2+
3+
import com.yammer.metrics.core.HealthCheck;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.jdbc.core.JdbcTemplate;
6+
import org.springframework.stereotype.Component;
7+
8+
/**
9+
* Created with IntelliJ IDEA.
10+
* User: shlomis
11+
* Date: 9/2/13
12+
* Time: 10:48 AM
13+
* To change this template use File | Settings | File Templates.
14+
*/
15+
@Component
16+
public class DatabaseHealthCheck extends HealthCheck {
17+
18+
@Autowired
19+
JdbcTemplate template;
20+
21+
protected DatabaseHealthCheck() {
22+
super("Database health check");
23+
}
24+
25+
@Override
26+
protected Result check() throws Exception {
27+
String dbName = template.queryForObject("select DATABASE()",String.class);
28+
return Result.healthy("Connected to database:" + dbName);
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.kenshoo.freemarker.healthchecks;
2+
3+
import com.yammer.metrics.core.HealthCheck;
4+
import org.springframework.stereotype.Component;
5+
6+
/**
7+
* Created by IntelliJ IDEA.
8+
* User: tzachz
9+
* Date: 5/23/13
10+
*/
11+
@Component
12+
public class MyProjectHealthCheck extends HealthCheck {
13+
14+
// note that this is due to the default spring CTR
15+
public MyProjectHealthCheck() {
16+
super("MyProjectHealthCheck");
17+
}
18+
19+
@Override
20+
protected Result check() throws Exception {
21+
return Result.healthy(); // we're always healthy!
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.kenshoo.freemarker.resources;
2+
3+
import org.springframework.stereotype.Component;
4+
5+
import javax.ws.rs.GET;
6+
import javax.ws.rs.Path;
7+
import javax.ws.rs.Produces;
8+
import javax.ws.rs.core.MediaType;
9+
10+
/**
11+
* Created with IntelliJ IDEA.
12+
* User: shlomis
13+
* Date: 9/1/13
14+
* Time: 4:35 PM
15+
* To change this template use File | Settings | File Templates.
16+
*/
17+
@Path("/")
18+
@Component
19+
public class MyProjectResource {
20+
21+
@GET
22+
@Produces(MediaType.TEXT_PLAIN)
23+
public String index() {
24+
return "I'm working!";
25+
}
26+
}

‎src/main/resources/banner.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
______ _ ____ _ _
3+
| ____| | | / __ \ | (_)
4+
| |__ _ __ ___ ___ _ __ ___ __ _ _ __| | _____ _ __ | | | |_ __ | |_ _ __ ___
5+
| __| '__/ _ \/ _ \ '_ ` _ \ / _` | '__| |/ / _ \ '__| | | | | '_ \| | | '_ \ / _ \
6+
| | | | | __/ __/ | | | | | (_| | | | < __/ | | |__| | | | | | | | | | __/
7+
|_| |_| \___|\___|_| |_| |_|\__,_|_| |_|\_\___|_| \____/|_| |_|_|_|_| |_|\___|
8+
9+
10+
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Spring configuration
2+
# Application Contexts to Load.
3+
applicationContext: ['classpath*:/spring/*-context.xml']
4+
5+
# Should Spring Security be used?
6+
useSpringSecurity: false
7+
8+
database:
9+
driverClass: com.mysql.jdbc.Driver
10+
url: jdbc:mysql://localhost:3306/freemarker_online?createDatabaseIfNotExist=true
11+
user: root
12+
password: root
13+
14+
logging:
15+
# Settings for logging to a file.
16+
file:
17+
# If true, write log statements to a file.
18+
enabled: true
19+
threshold: ALL
20+
# The file to which current statements will be logged.
21+
currentLogFilename: /var/log/freemarker-online/${name}.log
22+
23+
# When the log file rotates, the archived log will be renamed to this and gzipped. The
24+
# %d is replaced with the previous day (yyyy-MM-dd). Custom rolling windows can be created
25+
# by passing a SimpleDateFormat-compatible format as an argument: "%d{yyyy-MM-dd-hh}".
26+
archivedLogFilenamePattern: /var/log/freemarker-online/${name}-%d.log.gz
27+
# The number of archived files to keep.
28+
archivedFileCount: 5
29+
30+
# The timezone used to format dates. HINT: USE THE DEFAULT, UTC.
31+
timeZone: UTC

‎src/main/resources/migrations.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
6+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
7+
8+
<includeAll path="migrations"/>
9+
</databaseChangeLog>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<databaseChangeLog
4+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
7+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
8+
9+
10+
<changeSet id="create test table" author="shlomis">
11+
<createTable tableName="dropwizard_bootstrap">
12+
<column name="id" type="bigint" autoIncrement="true">
13+
<constraints primaryKey="true" nullable="false"/>
14+
</column>
15+
<column name="name" type="varchar(120)">
16+
</column>
17+
18+
</createTable>
19+
</changeSet>
20+
21+
</databaseChangeLog>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:context="http://www.springframework.org/schema/context"
5+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
6+
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd ">
7+
8+
<context:component-scan base-package="com.kenshoo"/>
9+
10+
<context:annotation-config/>
11+
12+
<!-- Use the system properties (initalized by DW) to configure spring context files -->
13+
<bean id="propertyPlaceholderConfigurer"
14+
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
15+
<property name="ignoreUnresolvablePlaceholders" value="true" />
16+
<property name="ignoreResourceNotFound" value="true" />
17+
</bean>
18+
19+
</beans>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
5+
6+
<!-- Defining the main DB datasource -->
7+
<bean id="mainDataSource" destroy-method="close" class="org.apache.tomcat.jdbc.pool.DataSource">
8+
<property name="driverClassName" value="${database.driverClass}"/>
9+
<property name="url" value="${database.url}"/>
10+
<property name="username" value="${database.user}"/>
11+
<property name="password" value="${database.password}"/>
12+
<property name="validationQuery" value="SELECT 1 FROM DUAL"/>
13+
<property name="testOnBorrow" value="true"/>
14+
<property name="maxActive" value="30"/>
15+
<property name="maxIdle" value="5"/>
16+
<property name="maxWait" value="10000"/>
17+
<property name="removeAbandoned" value="true"/>
18+
<property name="removeAbandonedTimeout" value="60"/>
19+
</bean>
20+
21+
22+
<bean id="dbi" class="org.skife.jdbi.v2.DBI">
23+
<constructor-arg type="javax.sql.DataSource" ref="mainDataSource"/>
24+
</bean>
25+
26+
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
27+
<property name="dataSource" ref="mainDataSource"/>
28+
</bean>
29+
30+
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
31+
<property name="dataSource" ref="mainDataSource" />
32+
</bean>
33+
</beans>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans:beans xmlns="http://www.springframework.org/schema/security"
3+
xmlns:beans="http://www.springframework.org/schema/beans"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.springframework.org/schema/beans
6+
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7+
http://www.springframework.org/schema/security
8+
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
9+
10+
<global-method-security pre-post-annotations="enabled" />
11+
12+
<http auto-config="true" use-expressions="true">
13+
<intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
14+
</http>
15+
16+
<authentication-manager alias="authenticationManager">
17+
<authentication-provider>
18+
<user-service>
19+
<user name="guest" password="guest" authorities="ROLE_GUEST" />
20+
<user name="user" password="user" authorities="ROLE_USER" />
21+
<user name="admin" password="admin" authorities="ROLE_ADMIN" />
22+
</user-service>
23+
</authentication-provider>
24+
</authentication-manager>
25+
26+
</beans:beans>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.kenshoo.cucumber;
2+
3+
import org.springframework.test.context.ContextConfiguration;
4+
5+
/**
6+
* Created with IntelliJ IDEA.
7+
* User: shlomis
8+
* Date: 9/29/13
9+
* Time: 4:44 PM
10+
* To change this template use File | Settings | File Templates.
11+
*/
12+
@ContextConfiguration({"classpath:cucumber.xml"})
13+
public class BaseCucuStep {
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.kenshoo.cucumber;
2+
3+
import cucumber.api.java.After;
4+
import cucumber.api.java.en.Given;
5+
import cucumber.api.java.en.Then;
6+
import cucumber.api.java.en.When;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.jdbc.core.JdbcTemplate;
9+
import org.springframework.test.context.ContextConfiguration;
10+
11+
import static org.junit.Assert.assertEquals;
12+
13+
/**
14+
* Created with IntelliJ IDEA.
15+
* User: shlomis
16+
* Date: 9/11/13
17+
* Time: 4:05 PM
18+
*/
19+
public class DBStep extends BaseCucuStep{
20+
21+
@Autowired
22+
JdbcTemplate template;
23+
24+
25+
@Given("^I have a value$")
26+
public void given() {
27+
template.execute("INSERT INTO dropwizard_bootstrap SET id=1, name='shlomi'"); // this will also fail on "garbage" from other tests
28+
}
29+
30+
@When("^I set a value$")
31+
public void when() {
32+
template.execute("UPDATE dropwizard_bootstrap SET name='shlomi_dropwizard' WHERE id=1");
33+
}
34+
35+
@Then("^I expect a value$")
36+
public void then() {
37+
assertEquals(1, template.queryForInt("SELECT id FROM dropwizard_bootstrap WHERE name='shlomi_dropwizard'"));
38+
}
39+
40+
@After
41+
public void tearDown(){
42+
template.execute("DELETE FROM dropwizard_bootstrap"); // this will also fail on "garbage" from other tests
43+
}
44+
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.kenshoo.cucumber;
2+
3+
import cucumber.api.java.en.Given;
4+
import cucumber.api.java.en.Then;
5+
import cucumber.api.java.en.When;
6+
import org.springframework.test.context.ContextConfiguration;
7+
8+
/**
9+
* Created with IntelliJ IDEA.
10+
* User: shlomis
11+
* Date: 9/11/13
12+
* Time: 3:27 PM
13+
* Cucu step for the hell of it
14+
*/
15+
16+
public class Step extends BaseCucuStep {
17+
18+
@Given("^I am a given step$")
19+
public void given() {
20+
System.out.println("******************* Given was executed ! ****************");
21+
}
22+
23+
@When("^I am a when step$")
24+
public void when() {
25+
System.out.println("******************* When was executed ! ****************");
26+
}
27+
28+
@Then("^I am a then step$")
29+
public void then() {
30+
System.out.println("******************* Then was executed ! ****************");
31+
}
32+
33+
@Then("^I am a failing then step$")
34+
public void failingThen() {
35+
System.out.println("******************* failingThen was executed ! ****************");
36+
// fail("Fail this biaaatch !");
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.kenshoo.freemarker.platform;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.jdbc.core.JdbcTemplate;
7+
import org.springframework.test.context.ContextConfiguration;
8+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
9+
import org.springframework.transaction.annotation.Transactional;
10+
11+
/**
12+
* Created with IntelliJ IDEA.
13+
* User: shlomis
14+
* Date: 9/2/13
15+
* Time: 11:13 AM
16+
* To change this template use File | Settings | File Templates.
17+
*/
18+
@RunWith(SpringJUnit4ClassRunner.class)
19+
@ContextConfiguration(locations = {
20+
"classpath*:spring/*-context.xml"
21+
,"classpath:spring/bootstrap-security.xml"
22+
,"classpath:spring/test-bootstrap-datasource-context.xml"
23+
})
24+
@Transactional
25+
public class DatabaseBaseTest {
26+
27+
@Autowired
28+
JdbcTemplate template;
29+
30+
@Test
31+
public void testName() throws Exception {
32+
System.out.println(template.queryForObject("select DATABASE()", String.class));
33+
}
34+
35+
@Test
36+
public void testContextOrder() throws Exception {
37+
System.out.println(System.getenv("database.dbName"));
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.kenshoo.freemarker.platform;
2+
3+
import com.google.common.io.Resources;
4+
import com.kenshoo.freemarker.dropwizard.ApplicationConfiguration;
5+
import com.kenshoo.freemarker.dropwizard.ApplicationStartup;
6+
import com.yammer.dropwizard.testing.junit.DropwizardServiceRule;
7+
import org.junit.ClassRule;
8+
import org.junit.Test;
9+
import org.junit.rules.TestRule;
10+
11+
/**
12+
* Created with IntelliJ IDEA.
13+
* User: shlomis
14+
* Date: 9/9/13
15+
* Time: 10:43 AM
16+
*/
17+
public class DropWizardServiceTest {
18+
@ClassRule
19+
public static TestRule testRule = new DropwizardServiceRule<ApplicationConfiguration>(ApplicationStartup.class,
20+
Resources.getResource("freemarker-online.yml").getPath());
21+
22+
23+
@Test
24+
public void testServerIsUp() throws Exception {
25+
((DropwizardServiceRule)testRule).getService();
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.kenshoo.freemarker.platform;
2+
3+
import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml;
4+
import org.springframework.util.PropertiesPersister;
5+
import org.springframework.util.StringUtils;
6+
7+
import java.io.*;
8+
import java.util.Map;
9+
import java.util.Properties;
10+
11+
/**
12+
* Created with IntelliJ IDEA.
13+
* User: shlomis
14+
* Date: 9/8/13
15+
* Time: 10:50 PM
16+
*/
17+
public class YamlPropertiesPersister implements PropertiesPersister {
18+
@Override
19+
public void load(Properties props, InputStream is) throws IOException {
20+
load(props, new InputStreamReader(is));
21+
}
22+
23+
/**
24+
* We want to traverse map representing Yaml object and each time we find String=String pair we want to
25+
* save it as Property. As we are going deeper into map we generate compound key as path-like String
26+
*
27+
* @param props
28+
* @param reader
29+
* @throws IOException
30+
* @see org.springframework.util.PropertiesPersister#load(java.util.Properties, java.io.Reader)
31+
*/
32+
@Override
33+
public void load(Properties props, Reader reader) throws IOException {
34+
Yaml yaml = new Yaml();
35+
Map<String, Object> map = (Map<String, Object>) yaml.load(reader);
36+
// now we can populate supplied props
37+
assignProperties(props, map, null);
38+
}
39+
40+
/**
41+
* @param props
42+
* @param map
43+
*/
44+
public void assignProperties(Properties props, Map<String, Object> map, String path) {
45+
for (Map.Entry<String, Object> entry : map.entrySet()) {
46+
String key = entry.getKey();
47+
if (!StringUtils.isEmpty(path))
48+
key = path + "." + key;
49+
Object val = entry.getValue();
50+
if (val instanceof String) {
51+
// see if we need to create a compound key
52+
props.put(key, val);
53+
} else if (val instanceof Map) {
54+
assignProperties(props, (Map<String, Object>) val, key);
55+
}
56+
}
57+
}
58+
59+
@Override
60+
public void store(Properties props, OutputStream os, String header) throws IOException {
61+
throw new IllegalStateException("Current implementation is a read-only");
62+
}
63+
64+
@Override
65+
public void store(Properties props, Writer writer, String header) throws IOException {
66+
throw new IllegalStateException("Current implementation is a read-only");
67+
}
68+
69+
@Override
70+
public void loadFromXml(Properties props, InputStream is) throws IOException {
71+
throw new IllegalStateException("Use DefaultPropertiesPersister if you want to read/write XML");
72+
}
73+
74+
@Override
75+
public void storeToXml(Properties props, OutputStream os, String header) throws IOException {
76+
throw new IllegalStateException("Use DefaultPropertiesPersister if you want to load/store to XML");
77+
}
78+
79+
@Override
80+
public void storeToXml(Properties props, OutputStream os, String header, String encoding) throws IOException {
81+
throw new IllegalStateException("Use DefaultPropertiesPersister if you want to read/write XML");
82+
}
83+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2011 Kenshoo.com
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.kenshoo.myproject.service;
17+
18+
import org.junit.Test;
19+
20+
import static org.junit.Assert.assertTrue;
21+
22+
/**
23+
* User: dekely
24+
* Date: 03/04/13
25+
* Time: 13:53
26+
*/
27+
public class MyProjectServiceTest {
28+
29+
@Test
30+
public void keepAlive() {
31+
assertTrue(true);
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.kenshoo.cucumber;
2+
3+
import cucumber.api.junit.Cucumber;
4+
import org.junit.runner.RunWith;
5+
6+
/**
7+
* Created with IntelliJ IDEA.
8+
* User: shlomis
9+
* Date: 9/11/13
10+
* Time: 3:49 PM
11+
*/
12+
@RunWith(Cucumber.class)
13+
@Cucumber.Options(features = "src/test/resources/com/kenshoo/cucumber/")
14+
public class StepRunner {
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Feature: Test DB feature
2+
3+
Scenario: Test cucu runs
4+
Given I have a value
5+
When I set a value
6+
Then I expect a value
7+
8+
Scenario: Test cucu runs with cleanup
9+
Given I have a value
10+
When I set a value
11+
Then I expect a value
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Feature: Test feature
2+
3+
Scenario: Test cucu runs
4+
Given I am a given step
5+
When I am a when step
6+
Then I am a then step
7+
8+
9+
Scenario: Test cucu fails
10+
Given I am a given step
11+
When I am a when step
12+
Then I am a failing then step
13+
14+

‎src/test/resources/cucumber.xml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:context="http://www.springframework.org/schema/context"
5+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
6+
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
7+
8+
<context:annotation-config/>
9+
10+
<import resource="classpath*:spring/*-context.xml"/>
11+
<!-- Make sure to override with test values -->
12+
<import resource="classpath:spring/test-bootstrap-datasource-context.xml"/>
13+
<context:component-scan base-package="com.kenshoo.cucumber"/> <!-- This is required for using @Scope("cucumber-glue") in cucumber tests (i.e. using scenario scoped varaibles ) -->
14+
</beans>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:context="http://www.springframework.org/schema/context"
5+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
6+
7+
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
8+
<property name="locations">
9+
<list>
10+
<!--suppress SpringIncorrectResourceTypeInspection -->
11+
<value>classpath*:*.yml</value>
12+
</list>
13+
</property>
14+
<property name="propertiesPersister" ref="persister"/>
15+
</bean>
16+
<bean id="persister" class="com.kenshoo.freemarker.platform.YamlPropertiesPersister"/>
17+
18+
<context:property-placeholder ignore-resource-not-found="true" ignore-unresolvable="true" order="1" location="classpath:databaseTest.properties"/>
19+
20+
</beans>

0 commit comments

Comments
 (0)
Please sign in to comment.