@@ -33,89 +33,90 @@ protected String getTestSubDir() {
33
33
}
34
34
35
35
private final String expectedJavaSource =
36
- "package com.example.jee.app;\n " +
37
- "\n " +
38
- "import org.springframework.http.MediaType;\n " +
39
- "import org.springframework.web.bind.annotation.PathVariable;\n " +
40
- "import org.springframework.web.bind.annotation.RequestMapping;\n " +
41
- "import org.springframework.web.bind.annotation.RequestMethod;\n " +
42
- "import org.springframework.web.bind.annotation.RestController;\n " +
43
- "\n " +
44
- "@RestController\n " +
45
- "@RequestMapping(value = \" /\" )\n " +
46
- "public class PersonController {\n " +
47
- "\n " +
48
- " @RequestMapping(value = \" /json/{name}\" , produces = \" application/json\" , consumes = \" application/json\" , method = RequestMethod.POST)\n " +
49
- " public String getHelloWorldJSON(@PathVariable(\" name\" ) String name) throws Exception {\n " +
50
- " System.out.println(\" name: \" + name);\n " +
51
- " return \" {\\ \" Hello\\ \" :\\ \" \" + name + \" \\ \" \" ;\n " +
52
- " }\n " +
53
- "\n " +
54
- " @RequestMapping(value = \" /json\" , produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)\n " +
55
- " public String getAllPersons() throws Exception {\n " +
56
- " return \" {\\ \" message\\ \" :\\ \" No person here...\\ \" \" ;\n " +
57
- " }\n " +
58
- "\n " +
59
- "\n " +
60
- " @RequestMapping(value = \" /xml/{name}\" , produces = MediaType.APPLICATION_XML_VALUE, consumes = MediaType.APPLICATION_XML_VALUE, method = RequestMethod.POST)\n " +
61
- " public String getHelloWorldXML(@PathVariable(\" name\" ) String name) throws Exception {\n " +
62
- " System.out.println(\" name: \" + name);\n " +
63
- " return \" <xml>Hello \" +name+\" </xml>\" ;\n " +
64
- " }\n " +
65
- "\n " +
66
- "}\n " ;
36
+ """
37
+ package com.example.jee.app;
38
+
39
+ import org.springframework.http.MediaType;
40
+ import org.springframework.web.bind.annotation.*;
41
+
42
+ @RestController
43
+ @RequestMapping(value = "/")
44
+ public class PersonController {
45
+
46
+ @RequestMapping(value = "/json/{name}", produces = "application/json", consumes = "application/json", method = RequestMethod.POST)
47
+ public String getHelloWorldJSON(@PathVariable("name") String name) throws Exception {
48
+ System.out.println("name: " + name);
49
+ return "{\\ "Hello\\ ":\\ "" + name + "\\ "";
50
+ }
51
+
52
+ @RequestMapping(value = "/json", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
53
+ public String getAllPersons(@RequestParam(required = false, value = "q") String searchBy) throws Exception {
54
+ return "{\\ "message\\ ":\\ "No person here...\\ "";
55
+ }
56
+
57
+
58
+ @RequestMapping(value = "/xml/{name}", produces = MediaType.APPLICATION_XML_VALUE, consumes = MediaType.APPLICATION_XML_VALUE, method = RequestMethod.POST)
59
+ public String getHelloWorldXML(@PathVariable("name") String name) throws Exception {
60
+ System.out.println("name: " + name);
61
+ return "<xml>Hello "+name+"</xml>";
62
+ }
63
+
64
+ }
65
+ """ ;
67
66
68
67
private final String expectedPomSource =
69
- "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " +
70
- "<project xmlns=\" http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" \n " +
71
- " xsi:schemaLocation=\" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\" >\n " +
72
- " <modelVersion>4.0.0</modelVersion>\n " +
73
- " <groupId>org.springframework.sbm.examples</groupId>\n " +
74
- " <artifactId>migrate-jax-rs</artifactId>\n " +
75
- " <packaging>jar</packaging>\n " +
76
- " <version>0.0.1-SNAPSHOT</version>\n " +
77
- " <properties>\n " +
78
- " <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n " +
79
- " </properties>\n " +
80
- " <build>\n " +
81
- " <plugins>\n " +
82
- " <plugin>\n " +
83
- " <groupId>org.apache.maven.plugins</groupId>\n " +
84
- " <artifactId>maven-compiler-plugin</artifactId>\n " +
85
- " <version>3.5.1</version>\n " +
86
- " <configuration>\n " +
87
- " <source>1.8</source>\n " +
88
- " <target>1.8</target>\n " +
89
- " </configuration>\n " +
90
- " </plugin>\n " +
91
- " </plugins>\n " +
92
- " </build>\n " +
93
- " <dependencies>\n " +
94
- " <dependency>\n " +
95
- " <groupId>org.springframework.boot</groupId>\n " +
96
- " <artifactId>spring-boot-starter-web</artifactId>\n " +
97
- " <version>2.3.4.RELEASE</version>\n " +
98
- " </dependency>\n " +
99
- " <dependency>\n " +
100
- " <groupId>org.jboss.spec.javax.ws.rs</groupId>\n " +
101
- " <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>\n " +
102
- " <version>1.0.1.Final</version>\n " +
103
- " <scope>runtime</scope>\n " +
104
- " </dependency>\n " +
105
- " </dependencies>\n " +
106
- " <repositories>\n " +
107
- " <repository>\n " +
108
- " <id>jcenter</id>\n " +
109
- " <name>jcenter</name>\n " +
110
- " <url>https://jcenter.bintray.com</url>\n " +
111
- " </repository>\n " +
112
- " <repository>\n " +
113
- " <id>mavencentral</id>\n " +
114
- " <name>mavencentral</name>\n " +
115
- " <url>https://repo.maven.apache.org/maven2</url>\n " +
116
- " </repository>\n " +
117
- " </repositories>\n " +
118
- "</project>\n " ;
68
+ """
69
+ <?xml version="1.0" encoding="UTF-8"?>
70
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
71
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
72
+ <modelVersion>4.0.0</modelVersion>
73
+ <groupId>org.springframework.sbm.examples</groupId>
74
+ <artifactId>migrate-jax-rs</artifactId>
75
+ <packaging>jar</packaging>
76
+ <version>0.0.1-SNAPSHOT</version>
77
+ <properties>
78
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
79
+ </properties>
80
+ <build>
81
+ <plugins>
82
+ <plugin>
83
+ <groupId>org.apache.maven.plugins</groupId>
84
+ <artifactId>maven-compiler-plugin</artifactId>
85
+ <version>3.5.1</version>
86
+ <configuration>
87
+ <source>1.8</source>
88
+ <target>1.8</target>
89
+ </configuration>
90
+ </plugin>
91
+ </plugins>
92
+ </build>
93
+ <dependencies>
94
+ <dependency>
95
+ <groupId>org.springframework.boot</groupId>
96
+ <artifactId>spring-boot-starter-web</artifactId>
97
+ <version>2.3.4.RELEASE</version>
98
+ </dependency>
99
+ <dependency>
100
+ <groupId>org.jboss.spec.javax.ws.rs</groupId>
101
+ <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
102
+ <version>1.0.1.Final</version>
103
+ <scope>runtime</scope>
104
+ </dependency>
105
+ </dependencies>
106
+ <repositories>
107
+ <repository>
108
+ <id>jcenter</id>
109
+ <name>jcenter</name>
110
+ <url>https://jcenter.bintray.com</url>
111
+ </repository>
112
+ <repository>
113
+ <id>mavencentral</id>
114
+ <name>mavencentral</name>
115
+ <url>https://repo.maven.apache.org/maven2</url>
116
+ </repository>
117
+ </repositories>
118
+ </project>
119
+ """ ;
119
120
120
121
121
122
@ Test
0 commit comments