Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
Expand Down Expand Up @@ -95,7 +99,7 @@ public Response cseResponse(InvocationContext c1) {
return response;
}

@RequestMapping(path = "/testUserMap", method = RequestMethod.POST)
@PostMapping(path = "/testUserMap")
public Map<String, User> testUserMap(@RequestBody Map<String, User> userMap) {
return userMap;
}
Expand Down Expand Up @@ -126,7 +130,7 @@ public int add(@RequestAttribute("a") int a, @RequestAttribute("b") int b) {
return a + b;
}

@RequestMapping(path = "/reduce", method = RequestMethod.GET)
@GetMapping(path = "/reduce")
@ApiImplicitParams({@ApiImplicitParam(name = "a", dataType = "integer", format = "int32", paramType = "query")})
public int reduce(HttpServletRequest request, @CookieValue(name = "b") int b) {
int a = Integer.parseInt(request.getParameter("a"));
Expand Down Expand Up @@ -157,7 +161,7 @@ public String saySomething(@RequestHeader(name = "prefix") String prefix, @Reque
return prefix + " " + user.getName();
}

@RequestMapping(path = "/sayhi/{name}", method = RequestMethod.PUT)
@PutMapping(path = "/sayhi/{name}")
public String sayHi(@PathVariable(name = "name") String name) {
ContextUtils.getInvocationContext().setStatus(202);
return name + " sayhi";
Expand All @@ -173,7 +177,7 @@ public boolean isTrue() {
return true;
}

@RequestMapping(path = "/addstring", method = RequestMethod.DELETE, produces = MediaType.TEXT_PLAIN_VALUE)
@DeleteMapping(path = "/addstring", produces = MediaType.TEXT_PLAIN_VALUE)
public String addString(@RequestParam(name = "s") List<String> s) {
String result = "";
for (String x : s) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MediaType;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -34,12 +36,12 @@
@RestSchema(schemaId = "controller")
@RequestMapping(path = "/controller", produces = MediaType.APPLICATION_JSON)
public class ControllerImpl {
@RequestMapping(path = "/add", method = RequestMethod.GET)
@GetMapping(path = "/add")
public int add(@RequestParam("a") int a, @RequestParam("b") int b) {
return a + b;
}

@RequestMapping(path = "/sayhello/{name}", method = RequestMethod.POST)
@PostMapping(path = "/sayhello/{name}")
public String sayHello(@PathVariable("name") String name) {
return "hello " + name;
}
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,24 @@

package io.servicecomb.demo.springmvc.tests;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringMvcSpringMain.class)
public class SpringMvcSpringIntegrationTest extends SpringMvcIntegrationTestBase {
private static ConfigurableApplicationContext context;

@BeforeClass
public static void init() throws Exception {
context = SpringApplication.run(SpringMvcSpringMain.class);
}

@AfterClass
public static void shutdown() throws Exception {
context.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@

package io.servicecomb.demo.springmvc.tests;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import io.servicecomb.springboot.starter.provider.EnableServiceComb;

@SpringBootApplication
@EnableServiceComb
public class SpringMvcSpringMain {

public static void main(final String[] args) throws Exception {
SpringApplication.run(SpringMvcSpringMain.class, args);
}
class SpringMvcSpringMain {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2017 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.servicecomb.demo.springmvc.tests;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
public class SpringMvcSpringSimplifiedMappingAnnotationIntegrationTest extends SpringMvcIntegrationTestBase {
private static ConfigurableApplicationContext context;

@BeforeClass
public static void init() throws Exception {
System.setProperty("spring.profiles.active", "SimplifiedMapping");
context = SpringApplication.run(SpringMvcSpringMain.class);
}

@AfterClass
public static void shutdown() throws Exception {
context.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,24 @@

package io.servicecomb.demo.springmvc.tests;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.springframework.context.event.ContextClosedEvent;

import io.servicecomb.core.CseApplicationListener;
import io.servicecomb.foundation.common.utils.BeanUtils;

public class RawSpringMvcIntegrationTest extends SpringMvcIntegrationTestBase {

@BeforeClass
public static void setUp() throws Exception {
public static void init() throws Exception {
SpringMvcTestMain.main(new String[0]);
}

@AfterClass
public static void shutdown() throws Exception {
CseApplicationListener cal = BeanUtils.getBean("io.servicecomb.core.CseApplicationListener");
ContextClosedEvent event = new ContextClosedEvent(BeanUtils.getContext());
cal.onApplicationEvent(event);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2017 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.servicecomb.demo.springmvc.tests;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.springframework.context.event.ContextClosedEvent;

import io.servicecomb.core.CseApplicationListener;
import io.servicecomb.foundation.common.utils.BeanUtils;

public class RawSpringMvcSimplifiedMappingAnnotationIntegrationTest extends SpringMvcIntegrationTestBase {

@BeforeClass
public static void init() throws Exception {
System.setProperty("spring.profiles.active", "SimplifiedMapping");
SpringMvcTestMain.main(new String[0]);
}

@AfterClass
public static void shutdown() throws Exception {
CseApplicationListener cal = BeanUtils.getBean("io.servicecomb.core.CseApplicationListener");
ContextClosedEvent event = new ContextClosedEvent(BeanUtils.getContext());
cal.onApplicationEvent(event);
}
}
Loading