Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

start db enhanced

  • Loading branch information...
commit 6ab0084e021e7b258fd9ef3e3e59dd56db47ce31 1 parent b4814ae
jbaruch authored

Showing 3 changed files with 23 additions and 12 deletions. Show diff stats Hide diff stats

  1. +1 1  README
  2. +16 10 build.gradle
  3. +6 1 gradle.properties
2  README
@@ -3,5 +3,5 @@ Spring Batch meta-data persistency DAOs implementation over MongoDB. For more de
3 3 Here's how:
4 4 1. Get MongoDB - http://www.mongodb.org/display/DOCS/Downloads
5 5 2. Get Gradle - http://dist.codehaus.org/gradle
6   -3. (Optional, currently windows only) Set mongod home in gradle.properties. If you do so, database will automatically start before tests and shutdown after
  6 +3. (Optional) Set mongoDB home and startMongo flag in gradle.properties. If you do so, database will automatically start before tests and shutdown after. If you're on *nix and installed MongoDB distribution, it will be found without setting MongoDB home.
7 7 4. Run 'gradle test assemble'
26 build.gradle
@@ -75,22 +75,28 @@ task replacePoms(dependsOn: install) << {
75 75 }
76 76
77 77 test.doFirst {
78   - if (project.hasProperty('mongodHome') && !((String) project.mongodHome).isEmpty()) {
  78 + if (project.hasProperty('startMongo') && project.startMongo) {
79 79 def windows = ((String) System.properties['os.name']).toLowerCase().contains("win")
80   - def executable = project.mongodHome + "/" + "mongod" + (windows ? ".exe" : "")
81   - def line = windows ? "/c start " + executable : executable
82   - println "Going to startup Mongo daemon: ${executable}"
83   - ant.exec(outputproperty: "cmdOut",
84   - errorproperty: "cmdErr",
85   - failonerror: "true",
86   - executable: windows ? 'cmd.exe' : 'TODO *nix') {
87   - arg(line: line)
  80 + File executable
  81 + project.mongoExecFound = false
  82 + if (project.hasProperty('mongoHome')) {
  83 + executable = new File(project.mongoHome + "/bin/" + "mongod" + (windows ? ".exe" : ""))
  84 + project.mongoExecFound = executable.isFile();
  85 + }
  86 + if (!project.mongoExecFound && !windows) {
  87 + executable = new File('/bin/mongod');
  88 + project.mongoExecFound = executable.isFile();
  89 + }
  90 + if (project.mongoExecFound) {
  91 + logger.info("Going to startup MongoDB daemon: ${executable} ...")
  92 + ant.exec(spawn: true, executable: executable.getAbsolutePath())
88 93 }
89 94 }
90 95 }
91 96
92 97 test.doLast {
93   - if (project.hasProperty('mongodHome') && !((String) project.mongodHome).isEmpty()) {
  98 + if (project.mongoExecFound) {
  99 + logger.info('taking MongoDB down...')
94 100 //Shutdown the db. Can't just call the class since script's classpath can't use project classes
95 101 ant.java(classname: 'org.springframework.batch.mongo.util.Shutdown',
96 102 fork: true,
7 gradle.properties
... ... @@ -1 +1,6 @@
1   -mongodHome=C:/Users/JBaruch/lib/mongodb-win32-i386-1.4.1/bin
  1 +#MongoDB installation directory.
  2 +#Mandatory for Windows (if you want the test to start MongoDB), on *Nix will search in ... if not set.
  3 +mongoHome=C:/Users/JBaruch/lib/mongodb-win32-i386-1.4.1
  4 +
  5 +#Try to start MongoDB before tests and shut it down after.
  6 +startMongo=true

0 comments on commit 6ab0084

Please sign in to comment.
Something went wrong with that request. Please try again.