Skip to content

Commit

Permalink
Added missing coverage for the Jvm (stuff exposed by failing sonar te…
Browse files Browse the repository at this point in the history
…st).
  • Loading branch information
mockitoguy committed Feb 1, 2012
1 parent 9e4cdd0 commit 4fe0a9a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions subprojects/core/src/test/groovy/org/gradle/util/JvmTest.groovy
Expand Up @@ -81,6 +81,41 @@ class JvmTest extends Specification {
jvm.toolsJar == toolsJar
}

def "provides information when typical jdk installed"() {
given:
TestFile software = tmpDir.createDir('software')
software.create {
jdk {
jre { lib { file 'rt.jar' }}
lib { file 'tools.jar'}
}
}

when:
System.properties['java.home'] = software.file('jdk/jre').absolutePath

then:
jvm.javaHome.absolutePath == software.file('jdk').absolutePath
jvm.runtimeJar == software.file('jdk/jre/lib/rt.jar')
jvm.toolsJar == software.file('jdk/lib/tools.jar')
}

def "provides information when typical jre installed"() {
given:
TestFile software = tmpDir.createDir('software')
software.create {
jre { lib { file 'rt.jar' }}
}

when:
System.properties['java.home'] = software.file('jre').absolutePath

then:
jvm.javaHome.absolutePath == software.file('jre').absolutePath
jvm.runtimeJar == software.file('jre/lib/rt.jar')
jvm.toolsJar == null
}

def "looks for tools Jar in parent of JRE's Java home directory"() {
TestFile javaHomeDir = tmpDir.createDir('jdk')
TestFile toolsJar = javaHomeDir.file('lib/tools.jar').createFile()
Expand Down

0 comments on commit 4fe0a9a

Please sign in to comment.