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

Getting 404 on Request mapping with Request method.GET #325

Open
ShubhamShekhar1996 opened this issue Jan 29, 2025 · 0 comments
Open

Getting 404 on Request mapping with Request method.GET #325

ShubhamShekhar1996 opened this issue Jan 29, 2025 · 0 comments

Comments

@ShubhamShekhar1996
Copy link

ShubhamShekhar1996 commented Jan 29, 2025

After migrating to latest citrus dependency, all my request mapping are giving 404.
pom.xml:-
[](

4.0.0

org.springframework.boot
spring-boot-starter-parent
3.3.2


com.example
your-artifact-id
1.0.0-SNAPSHOT
demo
Demo project for Spring Boot

<java.version>17</java.version>
<springboot.version>3.3.2</springboot.version>
<citrus.simulator.version>3.0.2</citrus.simulator.version>



org.springframework.boot
spring-boot-starter-web


org.springframework.boot
spring-boot-starter


org.glassfish.jersey.core
jersey-client


org.glassfish.jersey.core
jersey-common


org.glassfish.jersey.inject
jersey-hk2
2.26


org.citrusframework
citrus-simulator
3.0.2
pom


org.citrusframework
citrus-simulator-starter
2.1.1

jakarta.xml.soap jakarta.xml.soap-api 3.0.2 org.springframework.boot spring-boot-starter-actuator org.codehaus.groovy groovy 2.5.23
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

)

Config:-
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.citrusframework.simulator.http.HttpRequestAnnotationScenarioMapper;
import org.citrusframework.simulator.http.HttpRequestPathScenarioMapper;
import org.citrusframework.simulator.http.SimulatorRestAdapter;
import org.citrusframework.simulator.http.SimulatorRestConfigurationProperties;
import org.citrusframework.simulator.scenario.mapper.ContentBasedXPathScenarioMapper;
import org.citrusframework.simulator.scenario.mapper.ScenarioMapper;
import org.citrusframework.simulator.scenario.mapper.ScenarioMappers;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.HttpStatus;
import com.consol.citrus.endpoint.EndpointAdapter;
import com.consol.citrus.endpoint.adapter.StaticEndpointAdapter;
import com.consol.citrus.http.message.HttpMessage;
import com.consol.citrus.message.Message;

import jakarta.xml.soap.MessageFactory;

@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
@componentscan(basePackages = {"com.example.demo.*"})
public class DemoApplication extends SimulatorRestAdapter {

@Override
public String urlMapping(SimulatorRestConfigurationProperties simulatorRestConfiguration) {
    return "**";
}

@Override
public EndpointAdapter fallbackEndpointAdapter() {
    return new StaticEndpointAdapter() {
        @Override
        protected Message handleMessageInternal(Message message) {
            return new HttpMessage().status(HttpStatus.INTERNAL_SERVER_ERROR);
        }
    };
}

// Note these run on all requests in order, so avoid collisions!
@Override
public ScenarioMapper scenarioMapper() {
    return ScenarioMappers.of(new ContentBasedXPathScenarioMapper().addXPathExpression("//:request-id"),
            new HttpRequestPathScenarioMapper(), new HttpRequestAnnotationScenarioMapper());
}

public static void main(String[] args) {
	SpringApplication.run(DemoApplication.class, args);
}

}
Scenario class:-
package com.example.demo.controller;

import org.citrusframework.simulator.scenario.AbstractSimulatorScenario;
import org.citrusframework.simulator.scenario.Scenario;
import org.citrusframework.simulator.scenario.ScenarioDesigner;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Scenario("GetCircuit")
@RequestMapping(value = "/sim/accessMigration/v1/inventory/circuits/BBEC.000099..ATI", method = RequestMethod.GET)
public class TestClass extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {

    scenario.http().receive().get();
    scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json")
            .payload(new ClassPathResource("datamanager/GetCircuit.json"));

}

}

Application.properties:-
spring.application.name=demo
#spring.datasource.url=jdbc:mysql://localhost:3370/catalogdb?useSSL=false
#spring.datasource.username=root
#spring.datasource.password=password
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

Hibernate properties

#spring.jpa.hibernate.ddl-auto=update
#spring.jpa.show-sql=true
#spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect

spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
logging.level.org.springframework.web=DEBUG
logging.level.org.citrusframework=DEBUG

info.simulator.name=REST Simulator
logging.file=debug.log
logging.level.com.consol.citrus=DEBUG
logging.level.com.att.mso=DEBUG
logging.level.org.reflections.Reflections=ERROR

Enable Http REST support

citrus.simulator.rest.enabled=true
citrus.simulator.ws.enabled=true
citrus.simulator.ws.servlet.mapping=/services/ws/*

Default timeout setting

citrus.simulator.default.timeout=120000
citrus.simulator.defaultTimeout=120000

Default message template path

citrus.simulator.templatePath=templates

Default scenario name

citrus.simulator.defaultScenario=Default

Should Citrus validate incoming messages on syntax and semantics

citrus.simulator.templateValidation=true

management.endpoints.web.exposure.include=*

It gives 404 after upgrading to latest citrus framework and java 17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant