From 9852e36630106a128b846d084a8a4cb925e7cb19 Mon Sep 17 00:00:00 2001 From: Mercy Date: Fri, 10 Jan 2025 18:01:58 +0800 Subject: [PATCH] Polish #57 --- .../EnableWebMvcExtensionDefaultTest.java | 61 +++++++++++++++++++ .../annotation/EnableWebMvcExtensionTest.java | 17 ++++++ 2 files changed, 78 insertions(+) create mode 100644 microsphere-spring-webmvc/src/test/java/io/microsphere/spring/webmvc/annotation/EnableWebMvcExtensionDefaultTest.java diff --git a/microsphere-spring-webmvc/src/test/java/io/microsphere/spring/webmvc/annotation/EnableWebMvcExtensionDefaultTest.java b/microsphere-spring-webmvc/src/test/java/io/microsphere/spring/webmvc/annotation/EnableWebMvcExtensionDefaultTest.java new file mode 100644 index 00000000..003c2a74 --- /dev/null +++ b/microsphere-spring-webmvc/src/test/java/io/microsphere/spring/webmvc/annotation/EnableWebMvcExtensionDefaultTest.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.microsphere.spring.webmvc.annotation; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; + +/** + * {@link EnableWebMvcExtension} Test with defaults + * + * @author Mercy + * @see EnableWebMvcExtension + * @since 1.0.0 + */ +@RunWith(SpringRunner.class) +@WebAppConfiguration +@ContextConfiguration(classes = { + EnableWebMvcExtensionDefaultTest.class +}) +@EnableWebMvc +@EnableWebMvcExtension +public class EnableWebMvcExtensionDefaultTest { + + @Autowired + private WebApplicationContext wac; + + private MockMvc mockMvc; + + @Before + public void setup() { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); + } + + @Test + public void test() { + + } +} diff --git a/microsphere-spring-webmvc/src/test/java/io/microsphere/spring/webmvc/annotation/EnableWebMvcExtensionTest.java b/microsphere-spring-webmvc/src/test/java/io/microsphere/spring/webmvc/annotation/EnableWebMvcExtensionTest.java index d339742a..993eabfe 100644 --- a/microsphere-spring-webmvc/src/test/java/io/microsphere/spring/webmvc/annotation/EnableWebMvcExtensionTest.java +++ b/microsphere-spring-webmvc/src/test/java/io/microsphere/spring/webmvc/annotation/EnableWebMvcExtensionTest.java @@ -16,11 +16,17 @@ */ package io.microsphere.spring.webmvc.annotation; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; /** * {@link EnableWebMvcExtension} Test @@ -34,6 +40,7 @@ @ContextConfiguration(classes = { EnableWebMvcExtensionTest.class }) +@EnableWebMvc @EnableWebMvcExtension( registerHandlerInterceptors = true, storeRequestBodyArgument = true, @@ -41,6 +48,16 @@ ) public class EnableWebMvcExtensionTest { + @Autowired + private WebApplicationContext wac; + + private MockMvc mockMvc; + + @Before + public void setup() { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); + } + @Test public void test() {