Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hamcrest Matcher signer information does not match signer information of other classes in the same package

I'm trying to write some integration tests in my Spring Boot application using REST-Assured and JUnit5 but when I run the following:

@SpringBootTest(classes = ProductsApplication.class)
class ProductsApiTest {

  @Before
  public void setup() {
    RestAssured.baseURI = "http://localhost:8080/test/api/products";
  }

  @Test
  public void test1() {
    ValidatableResponse statusCode = given().when().get().then().statusCode(200);
  }
}

A nasty error comes up:

java.lang.SecurityException: class "org.hamcrest.Matchers"'s signer information does not match signer information of other classes in the same package

Please take a look at my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    ...
    <dependencies>
        ...
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        ...
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>   
        <dependency>
                    <groupId>org.junit.jupiter</groupId>
                    <artifactId>junit-jupiter-engine</artifactId>
                    <scope>test</scope>
        </dependency>
        <dependency>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-runner</artifactId>
                    <scope>test</scope>
        </dependency>

            ...
        <!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
        </dependency>
    </dependencies>

    <build>
        ...
    </build>
</project>

Here are the Order and Export + the Libraries the Eclipse project uses: enter image description here

enter image description here

How do I set up the Eclipse environment to work with REST-Assured and Hamcrest? Why would this exception be thrown?

like image 805
Stoyan Lupov Avatar asked Jan 29 '20 09:01

Stoyan Lupov


1 Answers

I deleted the org.hamcrest.core_1.3.0.v201303031735.jar from my .p2 plugins folder and it worked for me.

  1. I searched for "hamcrest" in "C:\Users\Dell.p2\pool\plugins" folder and found "org.hamcrest.core_1.3.0.v201303031735.jar" there.
  2. I deleted it for this path.
  3. Tried to run the test cases and it got passed with no failure in statusCode() method line.

Please suggest if anyone has a better solution.

like image 126
Rahul Sharma Avatar answered Oct 23 '22 09:10

Rahul Sharma