Class BaseProviderRule

java.lang.Object
org.junit.rules.ExternalResource
au.com.dius.pact.consumer.junit.BaseProviderRule
All Implemented Interfaces:
org.junit.rules.TestRule
Direct Known Subclasses:
PactHttpsProviderRule, PactProviderRule

public class BaseProviderRule extends org.junit.rules.ExternalResource
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected au.com.dius.pact.consumer.model.MockProviderConfig
     
    protected final String
     
    protected final Object
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseProviderRule(Object target, String provider, String hostInterface, Integer port, au.com.dius.pact.core.model.PactSpecVersion pactVersion)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.junit.runners.model.Statement
    apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
     
    au.com.dius.pact.consumer.model.MockProviderConfig
     
    au.com.dius.pact.consumer.MockServer
     
    protected Map<String,au.com.dius.pact.core.model.BasePact>
    getPacts(String fragment)
    scan all methods for @Pact annotation and execute them, if not already initialized
    Returns the port number for the mock server.
    Returns the URL for the mock server.
    protected void
    validateResult(au.com.dius.pact.consumer.PactVerificationResult result, PactVerification pactVerification)
     

    Methods inherited from class org.junit.rules.ExternalResource

    after, before

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • provider

      protected final String provider
    • target

      protected final Object target
    • config

      protected au.com.dius.pact.consumer.model.MockProviderConfig config
  • Constructor Details

    • BaseProviderRule

      public BaseProviderRule(Object target, String provider, String hostInterface, Integer port, au.com.dius.pact.core.model.PactSpecVersion pactVersion)
  • Method Details

    • getConfig

      public au.com.dius.pact.consumer.model.MockProviderConfig getConfig()
    • getMockServer

      public au.com.dius.pact.consumer.MockServer getMockServer()
    • apply

      public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
      Specified by:
      apply in interface org.junit.rules.TestRule
      Overrides:
      apply in class org.junit.rules.ExternalResource
    • validateResult

      protected void validateResult(au.com.dius.pact.consumer.PactVerificationResult result, PactVerification pactVerification) throws Throwable
      Throws:
      Throwable
    • getPacts

      protected Map<String,au.com.dius.pact.core.model.BasePact> getPacts(String fragment)
      scan all methods for @Pact annotation and execute them, if not already initialized
      Parameters:
      fragment -
    • getUrl

      public String getUrl()
      Returns the URL for the mock server. Returns null if the mock server is not running.
      Returns:
      String URL or null if mock server not running
    • getPort

      public Integer getPort()
      Returns the port number for the mock server. Returns null if the mock server is not running.
      Returns:
      port number or null if mock server not running