Skip to content

Commit

Permalink
OverlappingFileLockException only thrown since Java 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
marchof committed Jun 9, 2020
1 parent 3802f22 commit d82a4cf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions org.jacoco.agent.rt.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<groupId>${project.groupId}</groupId>
<artifactId>org.jacoco.agent.rt</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>org.jacoco.core.test</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import org.jacoco.core.runtime.AgentOptions;
import org.jacoco.core.runtime.RuntimeData;
import org.jacoco.core.test.validation.JavaVersion;
import org.junit.AssumptionViolatedException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
Expand Down Expand Up @@ -79,6 +81,11 @@ public void startup_should_throw_IOException_when_execfile_cannot_be_created()
@Test(expected = OverlappingFileLockException.class)
public void startup_should_throws_OverlappingFileLockException_when_execfile_is_permanently_locked()
throws Exception {
if (JavaVersion.current().isBefore("1.6")) {
throw new AssumptionViolatedException(
"OverlappingFileLockException only thrown since Java 1.6");
}

File destFile = folder.newFile("jacoco.exec");
AgentOptions options = new AgentOptions();
options.setDestfile(destFile.getAbsolutePath());
Expand All @@ -96,6 +103,11 @@ public void startup_should_throws_OverlappingFileLockException_when_execfile_is_
@Test(expected = InterruptedIOException.class)
public void startup_should_throws_InterruptedIOException_when_execfile_is_locked_and_thread_is_interrupted()
throws Exception {
if (JavaVersion.current().isBefore("1.6")) {
throw new AssumptionViolatedException(
"OverlappingFileLockException only thrown since Java 1.6");
}

File destFile = folder.newFile("jacoco.exec");
AgentOptions options = new AgentOptions();
options.setDestfile(destFile.getAbsolutePath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,11 @@ public boolean isBefore(final String version) {
&& this.update < other.update);
}

/**
* @return Version of the current JVM
*/
public static JavaVersion current() {
return new JavaVersion(System.getProperty("java.version"));
}

}

0 comments on commit d82a4cf

Please sign in to comment.