Prapurna Manda
08/08/2022, 8:46 AMjava.lang.NoSuchFieldError: TRANSPORT
any help please?Prapurna Manda
08/08/2022, 10:43 AMimport au.com.dius.pact.consumer.MockServer;
import au.com.dius.pact.consumer.dsl.PactBuilder;
import au.com.dius.pact.consumer.junit.MockServerConfig;
import au.com.dius.pact.consumer.junit5.PactConsumerTestExt;
import au.com.dius.pact.consumer.junit5.PactTestFor;
import au.com.dius.pact.consumer.junit5.ProviderType;
import au.com.dius.pact.consumer.model.MockServerImplementation;
import au.com.dius.pact.core.model.PactSpecVersion;
import au.com.dius.pact.core.model.V4Interaction;
import au.com.dius.pact.core.model.V4Pact;
import au.com.dius.pact.core.model.annotations.Pact;
import com.atoss.template.servicetemplate.adapter.handler.grpc.employee.v1.EmployeeServiceGrpc;
import com.atoss.template.servicetemplate.adapter.handler.grpc.employee.v1.Message;
import com.atoss.template.servicetemplate.adapter.handler.grpc.employee.v1.MessageRequest;
import com.google.protobuf.InvalidProtocolBufferException;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import java.util.List;
import java.util.Map;
import static org.hamcrest.MatcherAssert.assertThat;
import static <http://org.hamcrest.Matchers.is|org.hamcrest.Matchers.is>;
@ExtendWith(PactConsumerTestExt.class)
@PactTestFor(providerName = "adapter-handler-grpc", providerType = ProviderType.SYNCH_MESSAGE, pactVersion = PactSpecVersion.V4)
public class PactConsumerTest {
@Pact(consumer = "adapter-client-grpc")
V4Pact testMsg(PactBuilder builder) {
return builder
// Tell Pact we need the Protobuf plugin
.usingPlugin("protobuf", "0.1.8")
// We will use a V4 synchronous message interaction for the test
.expectsToReceive("message", "core/interaction/synchronous-message")
// We need to pass all the details for the interaction over to the plugin
.with(Map.of(
// Configure the proto file, the content type and the service we expect to invoke
"pact:proto", builder.filePath("../adapter-handler-grpc-proto/src/main/resources/proto/EmployeeService.proto"),
"pact:content-type", "application/grpc",
"pact:proto-service", "EmployeeService/getEmployee",
// Details on the request message (ShapeMessage) we will send
"request", Map.of("id", 1),
// Details on the response message we expect to get back (AreaResponse)
"response", List.of(
Map.of(
"msg", "Hello Grpc"
)
)
))
.toPact();
}
@Test
@PactTestFor(pactMethod = "testMsg")
@MockServerConfig(implementation = MockServerImplementation.Plugin, registryEntry = "protobuf/transport/grpc")
void readMessage(MockServer mockServer, V4Interaction.SynchronousMessages interaction) throws InvalidProtocolBufferException {
ManagedChannel channel = ManagedChannelBuilder.forTarget("[::1]:" + mockServer.getPort())
.usePlaintext()
.build();
EmployeeServiceGrpc.EmployeeServiceBlockingStub clientStub = EmployeeServiceGrpc
.newBlockingStub(channel);
Message response = clientStub.getMessage(MessageRequest.newBuilder().setId(1).build());
System.out.println("after response");
assertThat(response.getMsg(), is("{\"msg\":\"Hello Grpc\"}"));
}
}
Prapurna Manda
08/08/2022, 10:44 AMuglyog
Prapurna Manda
08/09/2022, 7:18 AM[INFO] Running com.atoss.template.servicetemplate.adapter.client.grpc.employee.pact.PactConsumerTest
091546.174 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Found @PactTestFor annotation on test method void com.atoss.template.servicetemplate.adapter.client.grpc.employee.pact.PactConsumerTest.readMessage() throws com.google.protobuf.InvalidProtocolBufferException
091546.175 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Found @PactTestFor annotation on test class com.atoss.template.servicetemplate.adapter.client.grpc.employee.pact.PactConsumerTest
091546.324 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - providerInfo = ProviderInfo(providerName=adapter-handler-grpc, hostInterface=, port=, pactVersion=V4, providerType=SYNCH_MESSAGE, https=false, mockServerImplementation=Default, keyStorePath=, keyStoreAlias=, keyStorePassword=, privateKeyPassword=)
091546.333 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Looking for @Pact method named 'testMsg' for provider 'adapter-handler-grpc'
091546.345 [main] DEBUG au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Invoking method 'testMsg' to get Pact for the test 'readMessage'
091546.911 [Thread-1] WARN au.com.dius.pact.core.support.Metrics -
Please note: we are tracking events anonymously to gather important usage statistics like JVM version
and operating system. To disable tracking, set the 'pact_do_not_track' system property or environment
variable to 'true'.
091546.949 [main] INFO au.com.dius.pact.consumer.junit5.PactConsumerTestExt - Writing pacts out to default directory
[ERROR] Tests run: 2, Failures: 1, Errors: 1, Skipped: 0, Time elapsed: 0.801 s <<< FAILURE! - in com.atoss.template.servicetemplate.adapter.client.grpc.employee.pact.PactConsumerTest
[ERROR] readMessage Time elapsed: 0.772 s <<< ERROR!
java.lang.NoSuchFieldError: TRANSPORT
[ERROR] com.atoss.template.servicetemplate.adapter.client.grpc.employee.pact.PactConsumerTest Time elapsed: 0.799 s <<< FAILURE!
java.lang.AssertionError:
The following methods annotated with @Pact were not executed during the test: PactConsumerTest.testMsg
If these are currently a work in progress, add a @Disabled annotation to the method
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] PactConsumerTest The following methods annotated with @Pact were not executed during the test: PactConsumerTest.testMsg
If these are currently a work in progress, add a @Disabled annotation to the method
[ERROR] Errors:
[ERROR] PactConsumerTest.readMessage » NoSuchField TRANSPORT
[INFO]
[ERROR] Tests run: 16, Failures: 1, Errors: 1, Skipped: 0
[INFO]uglyog
Prapurna Manda
08/10/2022, 7:33 AMPrapurna Manda
08/10/2022, 7:33 AM<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>3.21.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.pact.plugin.driver</groupId>
<artifactId>core</artifactId>
<version>0.0.7</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>au.com.dius.pact.consumer</groupId>
<artifactId>junit5</artifactId>
<version>4.4.0-beta.3</version>
</dependency>
uglyog
Prapurna Manda
08/10/2022, 7:34 AMPrapurna Manda
08/10/2022, 7:36 AMPrapurna Manda
08/10/2022, 7:36 AM[main] INFO <http://au.com|au.com>.dius.pact.consumer.junit5.PactConsumerTestExt - Writing pacts out to default directory
[ERROR] Tests run: 2, Failures: 1, Errors: 1, Skipped: 0, Time elapsed: 0.564 s <<< FAILURE! - in com.atoss.template.servicetemplate.adapter.client.grpc.employee.pact.PactConsumerTest
[ERROR] readMessage{MockServer, SynchronousMessages} Time elapsed: 0.541 s <<< ERROR!
java.lang.NoSuchMethodError: au.com.dius.pact.core.support.Utils.lookupEnvironmentValue$default(Lau/com/dius/pact/core/support/Utils;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
at com.atoss.template.servicetemplate.adapter.client.grpc.employee.pact.PactConsumerTest.MessageTest(PactConsumerTest.java:36)
[ERROR] com.atoss.template.servicetemplate.adapter.client.grpc.employee.pact.PactConsumerTest Time elapsed: 0.562 s <<< FAILURE!
java.lang.AssertionError:
The following methods annotated with @Pact were not executed during the test: PactConsumerTest.MessageTest
If these are currently a work in progress, add a @Disabled annotation to the method
093524.510 [Thread-1] DEBUG io.pact.plugins.jvm.core.DefaultPluginManager - SHUTDOWN - shutting down all plugins
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] PactConsumerTest The following methods annotated with @Pact were not executed during the test: PactConsumerTest.MessageTest
If these are currently a work in progress, add a @Disabled annotation to the method
[ERROR] Errors:
[ERROR] PactConsumerTest.MessageTest:36 » NoSuchMethod au.com.dius.pact.core.support.U...
[INFO]
[ERROR] Tests run: 16, Failures: 1, Errors: 1, Skipped: 0
[INFO]uglyog
uglyog
Prapurna Manda
08/10/2022, 7:41 AM<dependency>
<groupId>au.com.dius.pact.consumer</groupId>
<artifactId>junit5</artifactId>
<version>4.4.0-beta.3</version>
</dependency>
Prapurna Manda
08/10/2022, 7:41 AMuglyog
io.pact.plugin.driver
Prapurna Manda
08/10/2022, 7:45 AMPrapurna Manda
08/10/2022, 8:15 AM