Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple methods with pactMethods throwing "java.lang.IllegalStateException: server in wrong state" error #1457

Open
prashanth-sams opened this issue Sep 30, 2021 · 9 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@prashanth-sams
Copy link

prashanth-sams commented Sep 30, 2021

My consumer test

@Test
@PactTestFor(pactMethods = {"countryDetails", "countryDetails2"})
@DisplayName("validate country details")
public void getCountryDetails(MockServer mockServer) throws Exception {
    CountriesConsumer cc = new CountriesConsumer(mockServer.getUrl());

    CountryDetailsDTO resp = cc.getCountryDetails("1");
    assertEquals(resp.getCountry(), "United States");
}

Pact-JVM version: 4.2.12

Error Log

[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< contract-testing:consumer >----------------------
[INFO] Building consumer 2.0.8
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ consumer ---
[INFO] Deleting /Users/.../consumer/target
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ consumer ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ consumer ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /Users/.../consumer/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ consumer ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ consumer ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/..../consumer/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ consumer ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/prashanthsams/.m2/repository/ch/qos/logback/logback-classic/1.2.4/logback-classic-1.2.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/prashanthsams/.m2/repository/org/slf4j/slf4j-log4j12/1.7.32/slf4j-log4j12-1.7.32.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/prashanthsams/.m2/repository/org/slf4j/slf4j-simple/1.7.32/slf4j-simple-1.7.32.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
[INFO] Running global.country.contract.consumer.CountriesConsumerTest
22:39:57.873 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Found @PactTestFor annotation on test method public void global.country.contract.consumer.CountriesConsumerTest.getCountryName(au.com.dius.pact.consumer.MockServer) throws java.lang.Exception
22:39:57.875 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Found @PactTestFor annotation on test class global.country.contract.consumer.CountriesConsumerTest
22:39:57.899 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - providerInfo = ProviderInfo(providerName=providerA, hostInterface=, port=8880, pactVersion=null, providerType=null, https=false, mockServerImplementation=Default, keyStorePath=, keyStoreAlias=, keyStorePassword=, privateKeyPassword=)
22:39:57.904 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Looking for @Pact method named 'countryName' for provider 'providerA'
22:39:57.905 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Invoking method 'countryName' to get Pact for the test 'getCountryName'
22:39:58.222 [main] DEBUG au.com.dius.pact.consumer.BaseJdkMockServer - Starting mock server
22:39:58.223 [main] DEBUG au.com.dius.pact.consumer.BaseJdkMockServer - Mock server started: /127.0.0.1:8880
22:39:58.414 [main] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default
22:39:58.420 [main] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context
22:39:58.420 [main] DEBUG org.apache.http.impl.conn.BasicHttpClientConnectionManager - Get connection for route {}->http://127.0.0.1:8880
22:39:58.428 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 0
22:39:58.441 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {}->http://127.0.0.1:8880
22:39:58.445 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to /127.0.0.1:8880
22:39:58.448 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 127.0.0.1:53902<->127.0.0.1:8880
22:39:58.449 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Executing request OPTIONS / HTTP/1.1
22:39:58.449 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
22:39:58.450 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
22:39:58.452 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> OPTIONS / HTTP/1.1
22:39:58.452 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> X-PACT-BOOTCHECK: true
22:39:58.452 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: 127.0.0.1:8880
22:39:58.452 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
22:39:58.452 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.13 (Java/13.0.2)
22:39:58.452 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
22:39:58.452 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "OPTIONS / HTTP/1.1[\r][\n]"
22:39:58.453 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-PACT-BOOTCHECK: true[\r][\n]"
22:39:58.453 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: 127.0.0.1:8880[\r][\n]"
22:39:58.453 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
22:39:58.453 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.13 (Java/13.0.2)[\r][\n]"
22:39:58.453 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
22:39:58.453 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
22:39:58.483 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
22:39:58.483 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Thu, 30 Sep 2021 18:39:58 GMT[\r][\n]"
22:39:58.483 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Transfer-encoding: chunked[\r][\n]"
22:39:58.483 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "X-pact-bootcheck: true[\r][\n]"
22:39:58.483 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
22:39:58.487 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 OK
22:39:58.487 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Thu, 30 Sep 2021 18:39:58 GMT
22:39:58.487 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Transfer-encoding: chunked
22:39:58.487 [main] DEBUG org.apache.http.headers - http-outgoing-0 << X-pact-bootcheck: true
22:39:58.492 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection can be kept alive indefinitely
22:39:58.498 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-0: Close connection
22:39:58.501 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection discarded
22:39:58.501 [main] DEBUG org.apache.http.impl.conn.BasicHttpClientConnectionManager - Releasing connection [Not bound]
22:39:58.537 [main] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default
22:39:58.537 [main] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context
22:39:58.538 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://127.0.0.1:8880][total available: 0; route allocated: 0 of 100; total allocated: 0 of 200]
22:39:58.540 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://127.0.0.1:8880][total available: 0; route allocated: 1 of 100; total allocated: 1 of 200]
22:39:58.541 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {}->http://127.0.0.1:8880
22:39:58.541 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to /127.0.0.1:8880
22:39:58.542 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 127.0.0.1:53903<->127.0.0.1:8880
22:39:58.542 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Executing request GET /code/USA HTTP/1.1
22:39:58.543 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
22:39:58.543 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
22:39:58.543 [main] DEBUG org.apache.http.headers - http-outgoing-1 >> GET /code/USA HTTP/1.1
22:39:58.544 [main] DEBUG org.apache.http.headers - http-outgoing-1 >> Host: 127.0.0.1:8880
22:39:58.544 [main] DEBUG org.apache.http.headers - http-outgoing-1 >> Connection: Keep-Alive
22:39:58.544 [main] DEBUG org.apache.http.headers - http-outgoing-1 >> User-Agent: Apache-HttpClient/4.5.13 (Java/13.0.2)
22:39:58.544 [main] DEBUG org.apache.http.headers - http-outgoing-1 >> Accept-Encoding: gzip,deflate
22:39:58.545 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "GET /code/USA HTTP/1.1[\r][\n]"
22:39:58.545 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "Host: 127.0.0.1:8880[\r][\n]"
22:39:58.545 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "Connection: Keep-Alive[\r][\n]"
22:39:58.545 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "User-Agent: Apache-HttpClient/4.5.13 (Java/13.0.2)[\r][\n]"
22:39:58.545 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "Accept-Encoding: gzip,deflate[\r][\n]"
22:39:58.545 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "[\r][\n]"
22:39:58.559 [HTTP-Dispatcher] DEBUG au.com.dius.pact.consumer.BaseJdkMockServer - Received request:    method: GET
        path: /code/USA
        query: {}
        headers: {Accept-encoding=[gzip,deflate], Connection=[Keep-Alive], Host=[127.0.0.1:8880], User-agent=[Apache-HttpClient/4.5.13 (Java/13.0.2)]}
        matchers: MatchingRules(rules={})
        generators: Generators(categories={})
        body: EMPTY
22:39:58.562 [HTTP-Dispatcher] DEBUG au.com.dius.pact.core.matchers.RequestMatching - comparing to expected request: 
        method: GET
        path: /code/USA
        query: {}
        headers: {}
        matchers: MatchingRules(rules={})
        generators: Generators(categories={})
        body: MISSING
22:39:58.572 [HTTP-Dispatcher] DEBUG au.com.dius.pact.core.matchers.Matching - No matcher for null, using equality
22:39:58.573 [HTTP-Dispatcher] DEBUG au.com.dius.pact.core.matchers.RequestMatching - Request mismatch: RequestMatchResult(method=null, path=null, query=[], cookie=null, headers=[], body=BodyMatchResult(typeMismatch=null, bodyResults=[]))
22:39:58.578 [HTTP-Dispatcher] DEBUG au.com.dius.pact.consumer.BaseJdkMockServer - Generating response:         status: 200
        headers: {Cache-Control=[no-cache], Expires=[0], Content-Type=[text/plain;charset=UTF-8]}
        matchers: MatchingRules(rules={header=MatchingRuleCategory(name=header, matchingRules={Content-Type=MatchingRuleGroup(rules=[RegexMatcher(regex=text/plain;charset=UTF-8, example=null)], ruleLogic=AND, cascaded=false), Expires=MatchingRuleGroup(rules=[RegexMatcher(regex=0, example=null)], ruleLogic=AND, cascaded=false), Cache-Control=MatchingRuleGroup(rules=[RegexMatcher(regex=no-cache, example=null)], ruleLogic=AND, cascaded=false)}), status=MatchingRuleCategory(name=status, matchingRules={}), body=MatchingRuleCategory(name=body, matchingRules={})})
        generators: Generators(categories={})
        body: PRESENT(United States)
22:39:58.580 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "HTTP/1.1 200 OK[\r][\n]"
22:39:58.580 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Date: Thu, 30 Sep 2021 18:39:58 GMT[\r][\n]"
22:39:58.580 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Cache-Control: no-cache[\r][\n]"
22:39:58.580 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Expires: 0[\r][\n]"
22:39:58.580 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Content-length: 13[\r][\n]"
22:39:58.580 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Content-Type: text/plain;charset=UTF-8[\r][\n]"
22:39:58.580 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "[\r][\n]"
22:39:58.581 [main] DEBUG org.apache.http.headers - http-outgoing-1 << HTTP/1.1 200 OK
22:39:58.581 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Date: Thu, 30 Sep 2021 18:39:58 GMT
22:39:58.581 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Cache-Control: no-cache
22:39:58.581 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Expires: 0
22:39:58.581 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Content-length: 13
22:39:58.581 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Content-Type: text/plain;charset=UTF-8
22:39:58.582 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection can be kept alive indefinitely
22:39:58.586 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "United States"
22:39:58.586 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection [id: 0][route: {}->http://127.0.0.1:8880] can be kept alive indefinitely
22:39:58.586 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-1: set socket timeout to 0
22:39:58.586 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {}->http://127.0.0.1:8880][total available: 1; route allocated: 1 of 100; total allocated: 1 of 200]
22:39:58.703 [main] DEBUG au.com.dius.pact.consumer.BaseJdkMockServer - Mock server shutdown
22:39:58.716 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Found @PactTestFor annotation on test method public void global.country.contract.consumer.CountriesConsumerTest.getCountryDetails(au.com.dius.pact.consumer.MockServer) throws java.lang.Exception
22:39:58.716 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Found @PactTestFor annotation on test class global.country.contract.consumer.CountriesConsumerTest
22:39:58.717 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Looking for @Pact method named 'countryDetails' for provider 'null'
22:39:58.717 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Looking for @Pact method named 'countryDetails2' for provider 'null'
22:39:58.717 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - providerInfo = ProviderInfo(providerName=, hostInterface=, port=8880, pactVersion=null, providerType=null, https=false, mockServerImplementation=Default, keyStorePath=, keyStoreAlias=, keyStorePassword=, privateKeyPassword=)
22:39:58.718 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Looking for @Pact method named 'countryDetails' for provider 'default'
22:39:58.718 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Invoking method 'countryDetails' to get Pact for the test 'getCountryDetails'
22:39:58.726 [main] DEBUG au.com.dius.pact.consumer.BaseJdkMockServer - Starting mock server
22:39:58.727 [main] DEBUG au.com.dius.pact.consumer.BaseJdkMockServer - Mock server started: /127.0.0.1:8880
22:39:58.728 [main] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default
22:39:58.728 [main] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context
22:39:58.728 [main] DEBUG org.apache.http.impl.conn.BasicHttpClientConnectionManager - Get connection for route {}->http://127.0.0.1:8880
22:39:58.728 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-2: set socket timeout to 0
22:39:58.728 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {}->http://127.0.0.1:8880
22:39:58.729 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to /127.0.0.1:8880
22:39:58.729 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 127.0.0.1:53904<->127.0.0.1:8880
22:39:58.729 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Executing request OPTIONS / HTTP/1.1
22:39:58.729 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
22:39:58.729 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
22:39:58.729 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> OPTIONS / HTTP/1.1
22:39:58.729 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> X-PACT-BOOTCHECK: true
22:39:58.729 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> Host: 127.0.0.1:8880
22:39:58.729 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> Connection: Keep-Alive
22:39:58.730 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> User-Agent: Apache-HttpClient/4.5.13 (Java/13.0.2)
22:39:58.730 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> Accept-Encoding: gzip,deflate
22:39:58.730 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "OPTIONS / HTTP/1.1[\r][\n]"
22:39:58.730 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "X-PACT-BOOTCHECK: true[\r][\n]"
22:39:58.730 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "Host: 127.0.0.1:8880[\r][\n]"
22:39:58.730 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "Connection: Keep-Alive[\r][\n]"
22:39:58.730 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "User-Agent: Apache-HttpClient/4.5.13 (Java/13.0.2)[\r][\n]"
22:39:58.730 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "Accept-Encoding: gzip,deflate[\r][\n]"
22:39:58.730 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "[\r][\n]"
22:39:58.733 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "HTTP/1.1 200 OK[\r][\n]"
22:39:58.733 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "Date: Thu, 30 Sep 2021 18:39:58 GMT[\r][\n]"
22:39:58.734 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "Transfer-encoding: chunked[\r][\n]"
22:39:58.734 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "X-pact-bootcheck: true[\r][\n]"
22:39:58.734 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "[\r][\n]"
22:39:58.734 [main] DEBUG org.apache.http.headers - http-outgoing-2 << HTTP/1.1 200 OK
22:39:58.735 [main] DEBUG org.apache.http.headers - http-outgoing-2 << Date: Thu, 30 Sep 2021 18:39:58 GMT
22:39:58.735 [main] DEBUG org.apache.http.headers - http-outgoing-2 << Transfer-encoding: chunked
22:39:58.735 [main] DEBUG org.apache.http.headers - http-outgoing-2 << X-pact-bootcheck: true
22:39:58.735 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection can be kept alive indefinitely
22:39:58.735 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-2: Close connection
22:39:58.735 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection discarded
22:39:58.735 [main] DEBUG org.apache.http.impl.conn.BasicHttpClientConnectionManager - Releasing connection [Not bound]
22:39:58.736 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - providerInfo = ProviderInfo(providerName=, hostInterface=, port=8880, pactVersion=null, providerType=null, https=false, mockServerImplementation=Default, keyStorePath=, keyStoreAlias=, keyStorePassword=, privateKeyPassword=)
22:39:58.736 [main] DEBUG au.com.dius.pact.consumer.BaseJdkMockServer - Starting mock server
22:39:58.737 [main] DEBUG au.com.dius.pact.consumer.BaseJdkMockServer - Mock server shutdown
22:39:58.753 [main] INFO au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Writing pacts out to default directory
22:39:58.754 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Writing pact consumerA -> providerA to file target/pacts/consumerA-providerA.json
[ERROR] Tests run: 3, Failures: 1, Errors: 1, Skipped: 0, Time elapsed: 1.176 s <<< FAILURE! - in global.country.contract.consumer.CountriesConsumerTest
[ERROR] getCountryDetails{MockServer}  Time elapsed: 0.027 s  <<< ERROR!
java.lang.IllegalStateException: server in wrong state

[ERROR] global.country.contract.consumer.CountriesConsumerTest  Time elapsed: 0.298 s  <<< FAILURE!
java.lang.AssertionError: 
The following methods annotated with @Pact were not executed during the test: CountriesConsumerTest.countryDetails2
If these are currently a work in progress, add a @Disabled annotation to the method


[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   CountriesConsumerTest The following methods annotated with @Pact were not executed during the test: CountriesConsumerTest.countryDetails2
If these are currently a work in progress, add a @Disabled annotation to the method

[ERROR] Errors: 
[ERROR]   CountriesConsumerTest.getCountryDetails » IllegalState server in wrong state
[INFO] 
[ERROR] Tests run: 3, Failures: 1, Errors: 1, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.097 s
[INFO] Finished at: 2021-09-30T22:39:59+04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project consumer: There are test failures.
[ERROR] 
[ERROR] Please refer to /Users/.../consumer/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
@SergeyPirogov
Copy link

Have the same problem

@SergeyPirogov
Copy link

@mefellows any ideas?

@DNAlchemist
Copy link

This is reproduced when two pacts are specified with the same provider. Any chance to fix this?

@DNAlchemist
Copy link

DNAlchemist commented Feb 26, 2022

@SergeyPirogov @prashanth-sams
I figured out, you should combine all provider methods in single pact

builder
            .uponReceiving("User request by phone")
...
            .uponReceiving("User request by email")
...       
            .toPact()

@Yrlish
Copy link

Yrlish commented Apr 3, 2023

@DNAlchemist Does this mean I need to write all my consumer contracts in one super-long class? We have a api gateway design for our microservices, where the gateway could make requests to three different microservices/providers with a total of five requests.

@PactTestFor(pactMethods = {"countryDetails", "countryDetails2"}) refers only to methods in the same class, no?

This class will be ridiculously big in the end if that's the case.

@rholshausen rholshausen added bug Indicates an unexpected problem or unintended behavior smartbear-supported labels Apr 11, 2023
@github-actions
Copy link

👋 Hi! The 'smartbear-supported' label has just been added to this issue, which will create an internal tracking ticket in PactFlow's Jira (PACT-927). We will use this to prioritise and assign a team member to this task. All activity will be public on this ticket. For now, sit tight and we'll update this ticket once we have more information on the next steps.

See our documentation for more information.

@rholshausen
Copy link
Contributor

@Yrlish what @DNAlchemist is saying is that you can combine the two methods into one which sets up both interactions and you won't be affected by this issue, because the issue here as reported is where the provider is the same for both methods. It does not make sense to have two different methods for the same provider.

If you have different providers, then you have to have different Pact methods, but then the provider names will be different so you won't be affected by this issue.

@Yrlish
Copy link

Yrlish commented Apr 11, 2023

@rholshausen Hi Ronald! So you're saying that the pattern of having one method for each endpoint is bad? If I have one method containing 20+ interactions of each different endpoint paths, how would I test this with the @PactTestFor annotation?

@rholshausen
Copy link
Contributor

No, we are saying there is a work around while this issue is being fixed. The original example did not need multiple Pact methods (the ones annotated with @Pact) because the provider was the same.

rholshausen added a commit that referenced this issue Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

6 participants