-
-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support loading PactSource from annotations on the test class (…
…JUnit 4) #1237
- Loading branch information
Ronald Holshausen
committed
Nov 3, 2020
1 parent
f05d904
commit 94275ae
Showing
16 changed files
with
242 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...der/junit/src/test/java/au/com/dius/pact/provider/junit/CustomAnnotationContractTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package au.com.dius.pact.provider.junit; | ||
|
||
import au.com.dius.pact.provider.junit.target.HttpTarget; | ||
import au.com.dius.pact.provider.junitsupport.Provider; | ||
import au.com.dius.pact.provider.junitsupport.State; | ||
import au.com.dius.pact.provider.junitsupport.TargetRequestFilter; | ||
import au.com.dius.pact.provider.junitsupport.VerificationReports; | ||
import au.com.dius.pact.provider.junitsupport.loader.PactFolder; | ||
import au.com.dius.pact.provider.junitsupport.target.Target; | ||
import au.com.dius.pact.provider.junitsupport.target.TestTarget; | ||
import com.github.restdriver.clientdriver.ClientDriverRule; | ||
import org.apache.http.HttpRequest; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.runner.RunWith; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.Map; | ||
|
||
import static com.github.restdriver.clientdriver.RestClientDriver.giveEmptyResponse; | ||
import static com.github.restdriver.clientdriver.RestClientDriver.onRequestTo; | ||
|
||
@RunWith(PactRunner.class) | ||
@IsContractTest | ||
public class CustomAnnotationContractTest { | ||
@ClassRule | ||
public static final ClientDriverRule embeddedService = new ClientDriverRule(8339); | ||
private static final Logger LOGGER = LoggerFactory.getLogger(CustomAnnotationContractTest.class); | ||
|
||
@TestTarget | ||
public final Target target = new HttpTarget(8339); | ||
|
||
@Before | ||
public void before() { | ||
embeddedService.addExpectation( | ||
onRequestTo("/data").withAnyParams(), giveEmptyResponse() | ||
); | ||
} | ||
|
||
@State("default") | ||
public void toDefaultState() { | ||
} | ||
|
||
@State("state 2") | ||
public void toSecondState(Map params) { | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
provider/junit/src/test/java/au/com/dius/pact/provider/junit/IsContractTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package au.com.dius.pact.provider.junit; | ||
|
||
import au.com.dius.pact.provider.junitsupport.Provider; | ||
import au.com.dius.pact.provider.junitsupport.loader.PactFolder; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(value = ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Provider("myAwesomeService") | ||
@PactFolder("pacts") | ||
public @interface IsContractTest { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
provider/src/main/java/au/com/dius/pact/provider/junitsupport/loader/PactFolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.