formatting work
This commit is contained in:
@@ -72,5 +72,5 @@ public abstract class AbstractService {
|
||||
public String getAddress5(final Customer customer) {
|
||||
return customer.getAddress();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,21 +11,21 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
|
||||
public class StudentControllerConfig implements WebApplicationInitializer {
|
||||
|
||||
@Override
|
||||
public void onStartup(ServletContext sc) throws ServletException {
|
||||
AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
|
||||
root.register(WebConfig.class);
|
||||
|
||||
root.setServletContext(sc);
|
||||
@Override
|
||||
public void onStartup(ServletContext sc) throws ServletException {
|
||||
AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
|
||||
root.register(WebConfig.class);
|
||||
|
||||
// Manages the lifecycle of the root application context
|
||||
sc.addListener(new ContextLoaderListener(root));
|
||||
root.setServletContext(sc);
|
||||
|
||||
DispatcherServlet dv = new DispatcherServlet(new GenericWebApplicationContext());
|
||||
// Manages the lifecycle of the root application context
|
||||
sc.addListener(new ContextLoaderListener(root));
|
||||
|
||||
ServletRegistration.Dynamic appServlet = sc.addServlet("test-mvc", dv);
|
||||
appServlet.setLoadOnStartup(1);
|
||||
appServlet.addMapping("/test/*");
|
||||
}
|
||||
DispatcherServlet dv = new DispatcherServlet(new GenericWebApplicationContext());
|
||||
|
||||
ServletRegistration.Dynamic appServlet = sc.addServlet("test-mvc", dv);
|
||||
appServlet.setLoadOnStartup(1);
|
||||
appServlet.addMapping("/test/*");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
@ComponentScan(basePackages= {"org.baeldung.controller.controller","org.baeldung.controller.config" })
|
||||
@ComponentScan(basePackages = { "org.baeldung.controller.controller", "org.baeldung.controller.config" })
|
||||
public class WebConfig extends WebMvcConfigurerAdapter {
|
||||
@Override
|
||||
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
|
||||
configurer.enable();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public ViewResolver viewResolver() {
|
||||
InternalResourceViewResolver bean = new InternalResourceViewResolver();
|
||||
|
||||
@@ -7,15 +7,15 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
public class RestController{
|
||||
public class RestController {
|
||||
|
||||
@GetMapping(value="/student/{studentId}")
|
||||
public @ResponseBody Student getTestData(@PathVariable Integer studentId) {
|
||||
Student student = new Student();
|
||||
student.setName("Peter");
|
||||
student.setId(studentId);
|
||||
@GetMapping(value = "/student/{studentId}")
|
||||
public @ResponseBody Student getTestData(@PathVariable Integer studentId) {
|
||||
Student student = new Student();
|
||||
student.setName("Peter");
|
||||
student.setId(studentId);
|
||||
|
||||
return student;
|
||||
return student;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
package org.baeldung.controller.student;
|
||||
|
||||
public class Student {
|
||||
private String name;
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
private int id;
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode(){
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
return this.name.equals(((Student)obj).getName());
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return this.name.equals(((Student) obj).getName());
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ public class PropertiesWithPlaceHolderConfigurer {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public PropertyPlaceholderConfigurer propertyConfigurer() {
|
||||
final PropertyPlaceholderConfigurer props = new PropertyPlaceholderConfigurer();
|
||||
|
||||
@@ -2,14 +2,14 @@ package org.baeldung.scopes;
|
||||
|
||||
public class HelloMessageGenerator {
|
||||
|
||||
private String message;
|
||||
private String message;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(final String message) {
|
||||
this.message = message;
|
||||
}
|
||||
public void setMessage(final String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
package org.baeldung.scopes;
|
||||
|
||||
public class Person {
|
||||
private String name;
|
||||
private int age;
|
||||
private String name;
|
||||
private int age;
|
||||
|
||||
public Person() {
|
||||
}
|
||||
public Person() {
|
||||
}
|
||||
|
||||
public Person(final String name, final int age) {
|
||||
this.name = name;
|
||||
}
|
||||
public Person(final String name, final int age) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Person [name=" + name + "]";
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Person [name=" + name + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,23 +9,23 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@Controller
|
||||
public class ScopesController {
|
||||
public static final Logger LOG = Logger.getLogger(ScopesController.class);
|
||||
public static final Logger LOG = Logger.getLogger(ScopesController.class);
|
||||
|
||||
@Resource(name = "requestMessage")
|
||||
HelloMessageGenerator requestMessage;
|
||||
@Resource(name = "requestMessage")
|
||||
HelloMessageGenerator requestMessage;
|
||||
|
||||
@Resource(name = "sessionMessage")
|
||||
HelloMessageGenerator sessionMessage;
|
||||
@Resource(name = "sessionMessage")
|
||||
HelloMessageGenerator sessionMessage;
|
||||
|
||||
@RequestMapping("/scopes")
|
||||
public String getScopes(final Model model) {
|
||||
LOG.info("Request Message:" + requestMessage.getMessage());
|
||||
LOG.info("Session Message" + sessionMessage.getMessage());
|
||||
requestMessage.setMessage("Good morning!");
|
||||
sessionMessage.setMessage("Good afternoon!");
|
||||
model.addAttribute("requestMessage", requestMessage.getMessage());
|
||||
model.addAttribute("sessionMessage", sessionMessage.getMessage());
|
||||
return "scopesExample";
|
||||
}
|
||||
@RequestMapping("/scopes")
|
||||
public String getScopes(final Model model) {
|
||||
LOG.info("Request Message:" + requestMessage.getMessage());
|
||||
LOG.info("Session Message" + sessionMessage.getMessage());
|
||||
requestMessage.setMessage("Good morning!");
|
||||
sessionMessage.setMessage("Good afternoon!");
|
||||
model.addAttribute("requestMessage", requestMessage.getMessage());
|
||||
model.addAttribute("sessionMessage", sessionMessage.getMessage());
|
||||
return "scopesExample";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,42 +16,42 @@ import org.springframework.web.servlet.view.UrlBasedViewResolver;
|
||||
@ComponentScan("org.baeldung.scopes")
|
||||
@EnableWebMvc
|
||||
public class ScopesConfig {
|
||||
@Bean
|
||||
public UrlBasedViewResolver setupViewResolver() {
|
||||
final UrlBasedViewResolver resolver = new UrlBasedViewResolver();
|
||||
resolver.setPrefix("/WEB-INF/view/");
|
||||
resolver.setSuffix(".jsp");
|
||||
resolver.setViewClass(JstlView.class);
|
||||
return resolver;
|
||||
}
|
||||
@Bean
|
||||
public UrlBasedViewResolver setupViewResolver() {
|
||||
final UrlBasedViewResolver resolver = new UrlBasedViewResolver();
|
||||
resolver.setPrefix("/WEB-INF/view/");
|
||||
resolver.setSuffix(".jsp");
|
||||
resolver.setViewClass(JstlView.class);
|
||||
return resolver;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public HelloMessageGenerator requestMessage() {
|
||||
return new HelloMessageGenerator();
|
||||
}
|
||||
@Bean
|
||||
@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public HelloMessageGenerator requestMessage() {
|
||||
return new HelloMessageGenerator();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public HelloMessageGenerator sessionMessage() {
|
||||
return new HelloMessageGenerator();
|
||||
}
|
||||
@Bean
|
||||
@Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public HelloMessageGenerator sessionMessage() {
|
||||
return new HelloMessageGenerator();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(value = WebApplicationContext.SCOPE_GLOBAL_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public HelloMessageGenerator globalSessionMessage() {
|
||||
return new HelloMessageGenerator();
|
||||
}
|
||||
@Bean
|
||||
@Scope(value = WebApplicationContext.SCOPE_GLOBAL_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public HelloMessageGenerator globalSessionMessage() {
|
||||
return new HelloMessageGenerator();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope("prototype")
|
||||
public Person personPrototype() {
|
||||
return new Person();
|
||||
}
|
||||
@Bean
|
||||
@Scope("prototype")
|
||||
public Person personPrototype() {
|
||||
return new Person();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope("singleton")
|
||||
public Person personSingleton() {
|
||||
return new Person();
|
||||
}
|
||||
@Bean
|
||||
@Scope("singleton")
|
||||
public Person personSingleton() {
|
||||
return new Person();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ public class Foo {
|
||||
|
||||
private static final AtomicInteger instanceCount = new AtomicInteger(0);
|
||||
|
||||
|
||||
private final int instanceNum;
|
||||
|
||||
public Foo() {
|
||||
|
||||
@@ -18,17 +18,16 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration(classes={WebConfig.class}, loader=AnnotationConfigWebContextLoader.class )
|
||||
@ContextConfiguration(classes = { WebConfig.class }, loader = AnnotationConfigWebContextLoader.class)
|
||||
public class ControllerAnnotationTest {
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext wac;
|
||||
|
||||
|
||||
private Student selectedStudent;
|
||||
|
||||
@Before
|
||||
@@ -43,9 +42,7 @@ public class ControllerAnnotationTest {
|
||||
@Test
|
||||
public void testTestController() throws Exception {
|
||||
|
||||
ModelAndView mv = this.mockMvc.perform(MockMvcRequestBuilders.get("/test/"))
|
||||
.andReturn()
|
||||
.getModelAndView();
|
||||
ModelAndView mv = this.mockMvc.perform(MockMvcRequestBuilders.get("/test/")).andReturn().getModelAndView();
|
||||
|
||||
// validate modal data
|
||||
Assert.assertSame(mv.getModelMap().get("data").toString(), "Welcome home man");
|
||||
@@ -57,9 +54,7 @@ public class ControllerAnnotationTest {
|
||||
@Test
|
||||
public void testRestController() throws Exception {
|
||||
|
||||
String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/student/{studentId}", 1))
|
||||
.andReturn().getResponse()
|
||||
.getContentAsString();
|
||||
String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/student/{studentId}", 1)).andReturn().getResponse().getContentAsString();
|
||||
|
||||
ObjectMapper reader = new ObjectMapper();
|
||||
|
||||
@@ -72,9 +67,7 @@ public class ControllerAnnotationTest {
|
||||
@Test
|
||||
public void testRestAnnotatedController() throws Exception {
|
||||
|
||||
String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/annotated/student/{studentId}", 1))
|
||||
.andReturn().getResponse()
|
||||
.getContentAsString();
|
||||
String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/annotated/student/{studentId}", 1)).andReturn().getResponse().getContentAsString();
|
||||
|
||||
ObjectMapper reader = new ObjectMapper();
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration({"classpath:test-mvc.xml"})
|
||||
@ContextConfiguration({ "classpath:test-mvc.xml" })
|
||||
public class ControllerTest {
|
||||
|
||||
private MockMvc mockMvc;
|
||||
@@ -41,9 +41,7 @@ public class ControllerTest {
|
||||
@Test
|
||||
public void testTestController() throws Exception {
|
||||
|
||||
ModelAndView mv = this.mockMvc.perform(MockMvcRequestBuilders.get("/test/"))
|
||||
.andReturn()
|
||||
.getModelAndView();
|
||||
ModelAndView mv = this.mockMvc.perform(MockMvcRequestBuilders.get("/test/")).andReturn().getModelAndView();
|
||||
|
||||
// validate modal data
|
||||
Assert.assertSame(mv.getModelMap().get("data").toString(), "Welcome home man");
|
||||
@@ -55,9 +53,7 @@ public class ControllerTest {
|
||||
@Test
|
||||
public void testRestController() throws Exception {
|
||||
|
||||
String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/student/{studentId}", 1))
|
||||
.andReturn().getResponse()
|
||||
.getContentAsString();
|
||||
String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/student/{studentId}", 1)).andReturn().getResponse().getContentAsString();
|
||||
|
||||
ObjectMapper reader = new ObjectMapper();
|
||||
|
||||
@@ -70,9 +66,7 @@ public class ControllerTest {
|
||||
@Test
|
||||
public void testRestAnnotatedController() throws Exception {
|
||||
|
||||
String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/annotated/student/{studentId}", 1))
|
||||
.andReturn().getResponse()
|
||||
.getContentAsString();
|
||||
String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/annotated/student/{studentId}", 1)).andReturn().getResponse().getContentAsString();
|
||||
|
||||
ObjectMapper reader = new ObjectMapper();
|
||||
|
||||
|
||||
@@ -8,36 +8,36 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
public class ScopesTest {
|
||||
|
||||
private static final String NAME = "John Smith";
|
||||
private static final String NAME_OTHER = "Anna Jones";
|
||||
private static final String NAME = "John Smith";
|
||||
private static final String NAME_OTHER = "Anna Jones";
|
||||
|
||||
@Test
|
||||
public void testScopeSingleton() {
|
||||
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("scopes.xml");
|
||||
@Test
|
||||
public void testScopeSingleton() {
|
||||
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("scopes.xml");
|
||||
|
||||
final Person personSingletonA = (Person) applicationContext.getBean("personSingleton");
|
||||
final Person personSingletonB = (Person) applicationContext.getBean("personSingleton");
|
||||
final Person personSingletonA = (Person) applicationContext.getBean("personSingleton");
|
||||
final Person personSingletonB = (Person) applicationContext.getBean("personSingleton");
|
||||
|
||||
personSingletonA.setName(NAME);
|
||||
Assert.assertEquals(NAME, personSingletonB.getName());
|
||||
personSingletonA.setName(NAME);
|
||||
Assert.assertEquals(NAME, personSingletonB.getName());
|
||||
|
||||
((AbstractApplicationContext) applicationContext).close();
|
||||
}
|
||||
((AbstractApplicationContext) applicationContext).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScopePrototype() {
|
||||
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("scopes.xml");
|
||||
@Test
|
||||
public void testScopePrototype() {
|
||||
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("scopes.xml");
|
||||
|
||||
final Person personPrototypeA = (Person) applicationContext.getBean("personPrototype");
|
||||
final Person personPrototypeB = (Person) applicationContext.getBean("personPrototype");
|
||||
final Person personPrototypeA = (Person) applicationContext.getBean("personPrototype");
|
||||
final Person personPrototypeB = (Person) applicationContext.getBean("personPrototype");
|
||||
|
||||
personPrototypeA.setName(NAME);
|
||||
personPrototypeB.setName(NAME_OTHER);
|
||||
personPrototypeA.setName(NAME);
|
||||
personPrototypeB.setName(NAME_OTHER);
|
||||
|
||||
Assert.assertEquals(NAME, personPrototypeA.getName());
|
||||
Assert.assertEquals(NAME_OTHER, personPrototypeB.getName());
|
||||
Assert.assertEquals(NAME, personPrototypeA.getName());
|
||||
Assert.assertEquals(NAME_OTHER, personPrototypeB.getName());
|
||||
|
||||
((AbstractApplicationContext) applicationContext).close();
|
||||
}
|
||||
((AbstractApplicationContext) applicationContext).close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,18 +26,12 @@ public class AttributeAnnotationTest extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac)
|
||||
.build();
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInterceptorAddsRequestAndSessionParams_thenParamsInjectedWithAttributesAnnotations() throws Exception {
|
||||
String result = this.mockMvc.perform(get("/test")
|
||||
.accept(MediaType.ALL))
|
||||
.andExpect(status().isOk())
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
String result = this.mockMvc.perform(get("/test").accept(MediaType.ALL)).andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
||||
|
||||
Assert.assertEquals("login = john, query = invoices", result);
|
||||
}
|
||||
|
||||
@@ -29,15 +29,12 @@ public class ComposedMappingTest extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac)
|
||||
.build();
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenRequestingMethodWithGetMapping_thenReceiving200Answer() throws Exception {
|
||||
this.mockMvc.perform(get("/appointments")
|
||||
.accept(MediaType.ALL))
|
||||
.andExpect(status().isOk());
|
||||
this.mockMvc.perform(get("/appointments").accept(MediaType.ALL)).andExpect(status().isOk());
|
||||
verify(appointmentService);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@ContextConfiguration(classes = {FooRepositoryConfiguration.class, FooServiceConfiguration.class})
|
||||
@ContextConfiguration(classes = { FooRepositoryConfiguration.class, FooServiceConfiguration.class })
|
||||
public class ConfigurationConstructorInjectionTest extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.baeldung.spring43.defaultmethods;
|
||||
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@@ -28,27 +28,16 @@ public class ScopeAnnotationsTest extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac)
|
||||
.build();
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenDifferentRequests_thenDifferentInstancesOfRequestScopedBeans() throws Exception {
|
||||
MockHttpSession session = new MockHttpSession();
|
||||
|
||||
String requestScopedServiceInstanceNumber1 = this.mockMvc.perform(get("/appointments/request")
|
||||
.session(session)
|
||||
.accept(MediaType.ALL)).andExpect(status().isOk())
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
String requestScopedServiceInstanceNumber1 = this.mockMvc.perform(get("/appointments/request").session(session).accept(MediaType.ALL)).andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
||||
|
||||
String requestScopedServiceInstanceNumber2 = this.mockMvc.perform(get("/appointments/request")
|
||||
.session(session)
|
||||
.accept(MediaType.ALL)).andExpect(status().isOk())
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
String requestScopedServiceInstanceNumber2 = this.mockMvc.perform(get("/appointments/request").session(session).accept(MediaType.ALL)).andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
||||
|
||||
assertNotEquals(requestScopedServiceInstanceNumber1, requestScopedServiceInstanceNumber2);
|
||||
}
|
||||
@@ -59,24 +48,9 @@ public class ScopeAnnotationsTest extends AbstractJUnit4SpringContextTests {
|
||||
MockHttpSession session1 = new MockHttpSession();
|
||||
MockHttpSession session2 = new MockHttpSession();
|
||||
|
||||
String sessionScopedServiceInstanceNumber1 = this.mockMvc.perform(get("/appointments/session")
|
||||
.session(session1)
|
||||
.accept(MediaType.ALL)).andExpect(status().isOk())
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
String sessionScopedServiceInstanceNumber2 = this.mockMvc.perform(get("/appointments/session")
|
||||
.session(session1)
|
||||
.accept(MediaType.ALL)).andExpect(status().isOk())
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
String sessionScopedServiceInstanceNumber3 = this.mockMvc.perform(get("/appointments/session")
|
||||
.session(session2)
|
||||
.accept(MediaType.ALL)).andExpect(status().isOk())
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
String sessionScopedServiceInstanceNumber1 = this.mockMvc.perform(get("/appointments/session").session(session1).accept(MediaType.ALL)).andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
||||
String sessionScopedServiceInstanceNumber2 = this.mockMvc.perform(get("/appointments/session").session(session1).accept(MediaType.ALL)).andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
||||
String sessionScopedServiceInstanceNumber3 = this.mockMvc.perform(get("/appointments/session").session(session2).accept(MediaType.ALL)).andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
||||
|
||||
assertEquals(sessionScopedServiceInstanceNumber1, sessionScopedServiceInstanceNumber2);
|
||||
|
||||
@@ -90,18 +64,8 @@ public class ScopeAnnotationsTest extends AbstractJUnit4SpringContextTests {
|
||||
MockHttpSession session1 = new MockHttpSession();
|
||||
MockHttpSession session2 = new MockHttpSession();
|
||||
|
||||
String applicationScopedServiceInstanceNumber1 = this.mockMvc.perform(get("/appointments/application")
|
||||
.session(session1)
|
||||
.accept(MediaType.ALL)).andExpect(status().isOk())
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
String applicationScopedServiceInstanceNumber2 = this.mockMvc.perform(get("/appointments/application")
|
||||
.session(session2)
|
||||
.accept(MediaType.ALL)).andExpect(status().isOk())
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
String applicationScopedServiceInstanceNumber1 = this.mockMvc.perform(get("/appointments/application").session(session1).accept(MediaType.ALL)).andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
||||
String applicationScopedServiceInstanceNumber2 = this.mockMvc.perform(get("/appointments/application").session(session2).accept(MediaType.ALL)).andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
||||
|
||||
assertEquals(applicationScopedServiceInstanceNumber1, applicationScopedServiceInstanceNumber2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user