From 8eb0b5956aec8818dc2a1d0c8cd3b6a1f28f80d1 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 5 Apr 2016 14:08:34 +0200 Subject: [PATCH] Fixed(?) stub runner tests (?) --- .../stubrunner/junit/AccurestRuleJUnitTest.java | 9 +++++++++ .../stubrunner/junit/AccurestRuleSpec.groovy | 10 +++++++--- .../junit/AccurestRuleSysPropsSpec.groovy | 13 ++++++++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/stub-runner/stub-runner-junit/src/test/groovy/io/codearte/accurest/stubrunner/junit/AccurestRuleJUnitTest.java b/stub-runner/stub-runner-junit/src/test/groovy/io/codearte/accurest/stubrunner/junit/AccurestRuleJUnitTest.java index 3660014705..8b6b237925 100644 --- a/stub-runner/stub-runner-junit/src/test/groovy/io/codearte/accurest/stubrunner/junit/AccurestRuleJUnitTest.java +++ b/stub-runner/stub-runner-junit/src/test/groovy/io/codearte/accurest/stubrunner/junit/AccurestRuleJUnitTest.java @@ -1,6 +1,8 @@ package io.codearte.accurest.stubrunner.junit; import org.apache.commons.io.IOUtils; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -14,6 +16,13 @@ import static org.assertj.core.api.BDDAssertions.then; */ public class AccurestRuleJUnitTest { + @BeforeClass + @AfterClass + public static void setupProps() { + System.getProperties().setProperty("stubrunner.stubs.repository.root", ""); + System.getProperties().setProperty("stubrunner.stubs.classifier", "stubs"); + } + @ClassRule public static AccurestRule rule = new AccurestRule() .repoRoot(repoRoot()) .downloadStub("io.codearte.accurest.stubs", "loanIssuance") diff --git a/stub-runner/stub-runner-junit/src/test/groovy/io/codearte/accurest/stubrunner/junit/AccurestRuleSpec.groovy b/stub-runner/stub-runner-junit/src/test/groovy/io/codearte/accurest/stubrunner/junit/AccurestRuleSpec.groovy index a5dbf056e1..91f693c113 100644 --- a/stub-runner/stub-runner-junit/src/test/groovy/io/codearte/accurest/stubrunner/junit/AccurestRuleSpec.groovy +++ b/stub-runner/stub-runner-junit/src/test/groovy/io/codearte/accurest/stubrunner/junit/AccurestRuleSpec.groovy @@ -1,5 +1,7 @@ package io.codearte.accurest.stubrunner.junit +import org.junit.AfterClass +import org.junit.BeforeClass import org.junit.ClassRule import spock.lang.Shared import spock.lang.Specification @@ -9,9 +11,11 @@ import spock.lang.Specification */ class AccurestRuleSpec extends Specification { - static { - System.properties.setProperty("stubrunner.stubs.repository.root", "") - System.properties.setProperty("stubrunner.stubs.classifier", 'stubs') + @BeforeClass + @AfterClass + void setupProps() { + System.getProperties().setProperty("stubrunner.stubs.repository.root", ""); + System.getProperties().setProperty("stubrunner.stubs.classifier", "stubs"); } @ClassRule @Shared AccurestRule rule = new AccurestRule() diff --git a/stub-runner/stub-runner-junit/src/test/groovy/io/codearte/accurest/stubrunner/junit/AccurestRuleSysPropsSpec.groovy b/stub-runner/stub-runner-junit/src/test/groovy/io/codearte/accurest/stubrunner/junit/AccurestRuleSysPropsSpec.groovy index 2dc4fe0939..00e4065198 100644 --- a/stub-runner/stub-runner-junit/src/test/groovy/io/codearte/accurest/stubrunner/junit/AccurestRuleSysPropsSpec.groovy +++ b/stub-runner/stub-runner-junit/src/test/groovy/io/codearte/accurest/stubrunner/junit/AccurestRuleSysPropsSpec.groovy @@ -1,21 +1,28 @@ package io.codearte.accurest.stubrunner.junit +import org.junit.AfterClass +import org.junit.BeforeClass import org.junit.ClassRule import spock.lang.Shared import spock.lang.Specification -import spock.util.environment.RestoreSystemProperties /** * @author Marcin Grzejszczak */ -@RestoreSystemProperties class AccurestRuleSysPropsSpec extends Specification { - static { + @BeforeClass + void setProps() { System.properties.setProperty("stubrunner.stubs.repository.root", AccurestRuleSysPropsSpec.getResource("/m2repo").toURI().toString()) System.properties.setProperty("stubrunner.stubs.classifier", 'classifier that will be overridden') } + @AfterClass + void cleanupProps() { + System.getProperties().setProperty("stubrunner.stubs.repository.root", ""); + System.getProperties().setProperty("stubrunner.stubs.classifier", "stubs"); + } + @ClassRule @Shared AccurestRule rule = new AccurestRule() .downloadStub("io.codearte.accurest.stubs", "loanIssuance", "stubs") .downloadStub("io.codearte.accurest.stubs:fraudDetectionServer:stubs")