formatting work
This commit is contained in:
parent
6c6cc61caf
commit
5dcca02c96
@ -3,7 +3,6 @@ package org.baeldung.jackson.annotation;
|
|||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
|
||||||
public class BeanWithCreator {
|
public class BeanWithCreator {
|
||||||
public int id;
|
public int id;
|
||||||
public String name;
|
public String name;
|
||||||
|
@ -16,12 +16,8 @@ public class Zoo {
|
|||||||
this.animal = animal;
|
this.animal = animal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = As.PROPERTY, property = "type")
|
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = As.PROPERTY, property = "type")
|
||||||
@JsonSubTypes({
|
@JsonSubTypes({ @JsonSubTypes.Type(value = Dog.class, name = "dog"), @JsonSubTypes.Type(value = Cat.class, name = "cat") })
|
||||||
@JsonSubTypes.Type(value = Dog.class, name = "dog"),
|
|
||||||
@JsonSubTypes.Type(value = Cat.class, name = "cat")
|
|
||||||
})
|
|
||||||
public static class Animal {
|
public static class Animal {
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ import com.fasterxml.jackson.databind.ser.FilterProvider;
|
|||||||
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
|
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
|
||||||
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
|
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
|
||||||
|
|
||||||
|
|
||||||
public class JacksonAnnotationTest {
|
public class JacksonAnnotationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -66,7 +66,7 @@ public class JacksonDeserializationUnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void givenJsonHasUnknownValuesButJacksonIsIgnoringUnknownFields_whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException {
|
public final void givenJsonHasUnknownValuesButJacksonIsIgnoringUnknownFields_whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException {
|
||||||
final String jsonAsString =// @formatter:off
|
final String jsonAsString = // @formatter:off
|
||||||
"{\"stringValue\":\"a\"," +
|
"{\"stringValue\":\"a\"," +
|
||||||
"\"intValue\":1," +
|
"\"intValue\":1," +
|
||||||
"\"booleanValue\":true," +
|
"\"booleanValue\":true," +
|
||||||
@ -84,7 +84,7 @@ public class JacksonDeserializationUnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void givenJsonHasUnknownValuesButUnknownFieldsAreIgnoredOnClass_whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException {
|
public final void givenJsonHasUnknownValuesButUnknownFieldsAreIgnoredOnClass_whenDeserializing_thenCorrect() throws JsonParseException, JsonMappingException, IOException {
|
||||||
final String jsonAsString =// @formatter:off
|
final String jsonAsString = // @formatter:off
|
||||||
"{\"stringValue\":\"a\"," +
|
"{\"stringValue\":\"a\"," +
|
||||||
"\"intValue\":1," +
|
"\"intValue\":1," +
|
||||||
"\"booleanValue\":true," +
|
"\"booleanValue\":true," +
|
||||||
|
@ -6,7 +6,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
|
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@Suite.SuiteClasses({// @formatter:off
|
@Suite.SuiteClasses({ // @formatter:off
|
||||||
JacksonCollectionDeserializationUnitTest.class
|
JacksonCollectionDeserializationUnitTest.class
|
||||||
,JacksonSerializationEnumsUnitTest.class
|
,JacksonSerializationEnumsUnitTest.class
|
||||||
,JacksonDeserializationUnitTest.class
|
,JacksonDeserializationUnitTest.class
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="owner.project.facets" value="java"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
<artifactId>hsqldb</artifactId>
|
<artifactId>hsqldb</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- validation -->
|
<!-- validation -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -11,7 +11,6 @@ public class ChildValueHolder {
|
|||||||
@Value("${child.name:-}")
|
@Value("${child.name:-}")
|
||||||
private String childName;
|
private String childName;
|
||||||
|
|
||||||
|
|
||||||
public String getParentName() {
|
public String getParentName() {
|
||||||
return parentName;
|
return parentName;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ public class ParentValueHolder {
|
|||||||
@Value("${child.name:-}")
|
@Value("${child.name:-}")
|
||||||
private String childName;
|
private String childName;
|
||||||
|
|
||||||
|
|
||||||
public String getParentName() {
|
public String getParentName() {
|
||||||
return parentName;
|
return parentName;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import org.junit.runners.Suite;
|
|||||||
import org.junit.runners.Suite.SuiteClasses;
|
import org.junit.runners.Suite.SuiteClasses;
|
||||||
|
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@SuiteClasses({//@formatter:off
|
@SuiteClasses({ //@formatter:off
|
||||||
PropertiesWithXmlIntegrationTest.class,
|
PropertiesWithXmlIntegrationTest.class,
|
||||||
ExternalPropertiesWithJavaIntegrationTest.class,
|
ExternalPropertiesWithJavaIntegrationTest.class,
|
||||||
ExternalPropertiesWithMultipleXmlsIntegrationTest.class,
|
ExternalPropertiesWithMultipleXmlsIntegrationTest.class,
|
||||||
|
@ -4,14 +4,14 @@ import org.springframework.boot.autoconfigure.web.ErrorController;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
public class MyCustomErrorController implements ErrorController {
|
public class MyCustomErrorController implements ErrorController {
|
||||||
|
|
||||||
private static final String PATH = "/error";
|
private static final String PATH = "/error";
|
||||||
|
|
||||||
public MyCustomErrorController() {
|
public MyCustomErrorController() {
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value=PATH)
|
@RequestMapping(value = PATH)
|
||||||
public String error() {
|
public String error() {
|
||||||
return "Error heaven";
|
return "Error heaven";
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@ public class ErrorController {
|
|||||||
|
|
||||||
public ErrorController() {
|
public ErrorController() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/400")
|
@RequestMapping("/400")
|
||||||
String error400() {
|
String error400() {
|
||||||
return "Error Code: 400 occured.";
|
return "Error Code: 400 occured.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/errorHeaven")
|
@RequestMapping("/errorHeaven")
|
||||||
String errorHeaven() {
|
String errorHeaven() {
|
||||||
return "You have reached the heaven of errors!!!";
|
return "You have reached the heaven of errors!!!";
|
||||||
|
@ -17,7 +17,7 @@ public class MyServletContainerCustomizationBean implements EmbeddedServletConta
|
|||||||
public void customize(ConfigurableEmbeddedServletContainer container) {
|
public void customize(ConfigurableEmbeddedServletContainer container) {
|
||||||
container.setPort(8084);
|
container.setPort(8084);
|
||||||
container.setContextPath("/springbootapp");
|
container.setContextPath("/springbootapp");
|
||||||
|
|
||||||
container.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/400"));
|
container.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/400"));
|
||||||
container.addErrorPages(new ErrorPage("/errorHeaven"));
|
container.addErrorPages(new ErrorPage("/errorHeaven"));
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ import java.util.concurrent.ExecutorService;
|
|||||||
import org.springframework.boot.ExitCodeGenerator;
|
import org.springframework.boot.ExitCodeGenerator;
|
||||||
|
|
||||||
public class ExecutorServiceExitCodeGenerator implements ExitCodeGenerator {
|
public class ExecutorServiceExitCodeGenerator implements ExitCodeGenerator {
|
||||||
|
|
||||||
private ExecutorService executorService;
|
private ExecutorService executorService;
|
||||||
|
|
||||||
public ExecutorServiceExitCodeGenerator(ExecutorService executorService) {
|
public ExecutorServiceExitCodeGenerator(ExecutorService executorService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,8 +20,7 @@ public class ExecutorServiceExitCodeGenerator implements ExitCodeGenerator {
|
|||||||
executorService.shutdownNow();
|
executorService.shutdownNow();
|
||||||
returnCode = 1;
|
returnCode = 1;
|
||||||
}
|
}
|
||||||
}
|
} catch (SecurityException ex) {
|
||||||
catch (SecurityException ex) {
|
|
||||||
returnCode = 0;
|
returnCode = 0;
|
||||||
}
|
}
|
||||||
return returnCode;
|
return returnCode;
|
||||||
|
@ -10,34 +10,32 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
public class HelloWorldServlet extends HttpServlet {
|
public class HelloWorldServlet extends HttpServlet {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public HelloWorldServlet() {
|
public HelloWorldServlet() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
PrintWriter out = null;
|
PrintWriter out = null;
|
||||||
try {
|
try {
|
||||||
out = response.getWriter();
|
out = response.getWriter();
|
||||||
out.println("HelloWorldServlet: GET METHOD");
|
out.println("HelloWorldServlet: GET METHOD");
|
||||||
out.flush();
|
out.flush();
|
||||||
}
|
} finally {
|
||||||
finally {
|
if (!Objects.isNull(out))
|
||||||
if (!Objects.isNull(out))
|
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
PrintWriter out = null;
|
PrintWriter out = null;
|
||||||
try {
|
try {
|
||||||
out = response.getWriter();
|
out = response.getWriter();
|
||||||
out.println("HelloWorldServlet: POST METHOD");
|
out.println("HelloWorldServlet: POST METHOD");
|
||||||
out.flush();
|
out.flush();
|
||||||
}
|
} finally {
|
||||||
finally {
|
if (!Objects.isNull(out))
|
||||||
if (!Objects.isNull(out))
|
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
public class SpringHelloWorldServlet extends HttpServlet {
|
public class SpringHelloWorldServlet extends HttpServlet {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public SpringHelloWorldServlet() {
|
public SpringHelloWorldServlet() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@ -22,9 +22,8 @@ public class SpringHelloWorldServlet extends HttpServlet {
|
|||||||
out = response.getWriter();
|
out = response.getWriter();
|
||||||
out.println("SpringHelloWorldServlet: GET METHOD");
|
out.println("SpringHelloWorldServlet: GET METHOD");
|
||||||
out.flush();
|
out.flush();
|
||||||
}
|
} finally {
|
||||||
finally {
|
if (!Objects.isNull(out))
|
||||||
if (!Objects.isNull(out))
|
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,9 +34,8 @@ public class SpringHelloWorldServlet extends HttpServlet {
|
|||||||
out = response.getWriter();
|
out = response.getWriter();
|
||||||
out.println("SpringHelloWorldServlet: POST METHOD");
|
out.println("SpringHelloWorldServlet: POST METHOD");
|
||||||
out.flush();
|
out.flush();
|
||||||
}
|
} finally {
|
||||||
finally {
|
if (!Objects.isNull(out))
|
||||||
if (!Objects.isNull(out))
|
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,11 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan({ "org.baeldung.common.error", "org.baeldung.common.error.controller",
|
@ComponentScan({ "org.baeldung.common.error", "org.baeldung.common.error.controller", "org.baeldung.common.properties", "org.baeldung.common.resources", "org.baeldung.endpoints", "org.baeldung.service", "org.baeldung.monitor.jmx", "org.baeldung.service" })
|
||||||
"org.baeldung.common.properties", "org.baeldung.common.resources", "org.baeldung.endpoints",
|
|
||||||
"org.baeldung.service", "org.baeldung.monitor.jmx", "org.baeldung.service"})
|
|
||||||
public class SpringBootApplication {
|
public class SpringBootApplication {
|
||||||
|
|
||||||
private static ApplicationContext applicationContext;
|
private static ApplicationContext applicationContext;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LoginService service;
|
private LoginService service;
|
||||||
|
|
||||||
@ -34,21 +32,21 @@ public class SpringBootApplication {
|
|||||||
service.login("admin", "admin".toCharArray());
|
service.login("admin", "admin".toCharArray());
|
||||||
return "TADA!!! You are in Spring Boot Actuator test application.";
|
return "TADA!!! You are in Spring Boot Actuator test application.";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
applicationContext = SpringApplication.run(SpringBootApplication.class, args);
|
applicationContext = SpringApplication.run(SpringBootApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ExecutorService executorService() {
|
public ExecutorService executorService() {
|
||||||
return Executors.newFixedThreadPool(10);
|
return Executors.newFixedThreadPool(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public HelloWorldServlet helloWorldServlet() {
|
public HelloWorldServlet helloWorldServlet() {
|
||||||
return new HelloWorldServlet();
|
return new HelloWorldServlet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SpringHelloServletRegistrationBean servletRegistrationBean() {
|
public SpringHelloServletRegistrationBean servletRegistrationBean() {
|
||||||
SpringHelloServletRegistrationBean bean = new SpringHelloServletRegistrationBean(new SpringHelloWorldServlet(), "/springHelloWorld/*");
|
SpringHelloServletRegistrationBean bean = new SpringHelloServletRegistrationBean(new SpringHelloWorldServlet(), "/springHelloWorld/*");
|
||||||
@ -56,35 +54,35 @@ public class SpringBootApplication {
|
|||||||
bean.addInitParameter("message", "SpringHelloWorldServlet special message");
|
bean.addInitParameter("message", "SpringHelloWorldServlet special message");
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @Bean
|
/* @Bean
|
||||||
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory() {
|
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory() {
|
||||||
JettyEmbeddedServletContainerFactory jettyContainer = new JettyEmbeddedServletContainerFactory();
|
JettyEmbeddedServletContainerFactory jettyContainer = new JettyEmbeddedServletContainerFactory();
|
||||||
jettyContainer.setPort(9000);
|
jettyContainer.setPort(9000);
|
||||||
jettyContainer.setContextPath("/springbootapp");
|
jettyContainer.setContextPath("/springbootapp");
|
||||||
return jettyContainer;
|
return jettyContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
|
public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
|
||||||
UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
|
UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
|
||||||
factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
|
factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(io.undertow.Undertow.Builde builder) {
|
public void customize(io.undertow.Undertow.Builde builder) {
|
||||||
builder.addHttpListener(8080, "0.0.0.0");
|
builder.addHttpListener(8080, "0.0.0.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
return factory;
|
return factory;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Autowired
|
@Autowired
|
||||||
public ExecutorServiceExitCodeGenerator executorServiceExitCodeGenerator(ExecutorService executorService) {
|
public ExecutorServiceExitCodeGenerator executorServiceExitCodeGenerator(ExecutorService executorService) {
|
||||||
return new ExecutorServiceExitCodeGenerator(executorService);
|
return new ExecutorServiceExitCodeGenerator(executorService);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutDown(ExecutorServiceExitCodeGenerator executorServiceExitCodeGenerator) {
|
public void shutDown(ExecutorServiceExitCodeGenerator executorServiceExitCodeGenerator) {
|
||||||
SpringApplication.exit(applicationContext, executorServiceExitCodeGenerator);
|
SpringApplication.exit(applicationContext, executorServiceExitCodeGenerator);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class ChildDao extends AbstractHibernateDao<Child> implements IChildDao {
|
public class ChildDao extends AbstractHibernateDao<Child>implements IChildDao {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SessionFactory sessionFactory;
|
private SessionFactory sessionFactory;
|
||||||
|
@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class FooDao extends AbstractHibernateDao<Foo> implements IFooDao {
|
public class FooDao extends AbstractHibernateDao<Foo>implements IFooDao {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SessionFactory sessionFactory;
|
private SessionFactory sessionFactory;
|
||||||
|
@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class ParentDao extends AbstractHibernateDao<Parent> implements IParentDao {
|
public class ParentDao extends AbstractHibernateDao<Parent>implements IParentDao {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SessionFactory sessionFactory;
|
private SessionFactory sessionFactory;
|
||||||
|
@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ChildService extends AbstractService<Child> implements IChildService {
|
public class ChildService extends AbstractService<Child>implements IChildService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IChildDao dao;
|
private IChildDao dao;
|
||||||
|
@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class FooService extends AbstractService<Foo> implements IFooService {
|
public class FooService extends AbstractService<Foo>implements IFooService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IFooDao dao;
|
private IFooDao dao;
|
||||||
|
@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ParentService extends AbstractService<Parent> implements IParentService {
|
public class ParentService extends AbstractService<Parent>implements IParentService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IParentDao dao;
|
private IParentDao dao;
|
||||||
|
@ -4,7 +4,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
|
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@Suite.SuiteClasses({// @formatter:off
|
@Suite.SuiteClasses({ // @formatter:off
|
||||||
Cause1BeanCreationExceptionIntegrationTest.class
|
Cause1BeanCreationExceptionIntegrationTest.class
|
||||||
,Cause2BeanCreationExceptionIntegrationTest.class
|
,Cause2BeanCreationExceptionIntegrationTest.class
|
||||||
,Cause3BeanCreationExceptionIntegrationTest.class
|
,Cause3BeanCreationExceptionIntegrationTest.class
|
||||||
|
@ -4,7 +4,7 @@ import org.baeldung.persistence.model.Foo;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class FooDao extends AbstractHibernateDao<Foo> implements IFooDao {
|
public class FooDao extends AbstractHibernateDao<Foo>implements IFooDao {
|
||||||
|
|
||||||
public FooDao() {
|
public FooDao() {
|
||||||
super();
|
super();
|
||||||
|
@ -8,6 +8,6 @@ import org.springframework.stereotype.Repository;
|
|||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||||
public class GenericHibernateDao<T extends Serializable> extends AbstractHibernateDao<T> implements IGenericDao<T> {
|
public class GenericHibernateDao<T extends Serializable> extends AbstractHibernateDao<T>implements IGenericDao<T> {
|
||||||
//
|
//
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ import org.baeldung.persistence.model.Child;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class ChildDao extends AbstractHibernateDao<Child> implements IChildDao {
|
public class ChildDao extends AbstractHibernateDao<Child>implements IChildDao {
|
||||||
|
|
||||||
public ChildDao() {
|
public ChildDao() {
|
||||||
super();
|
super();
|
||||||
|
@ -6,7 +6,7 @@ import org.baeldung.persistence.model.Foo;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class FooDao extends AbstractHibernateDao<Foo> implements IFooDao {
|
public class FooDao extends AbstractHibernateDao<Foo>implements IFooDao {
|
||||||
|
|
||||||
public FooDao() {
|
public FooDao() {
|
||||||
super();
|
super();
|
||||||
|
@ -6,7 +6,7 @@ import org.baeldung.persistence.model.Parent;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class ParentDao extends AbstractHibernateDao<Parent> implements IParentDao {
|
public class ParentDao extends AbstractHibernateDao<Parent>implements IParentDao {
|
||||||
|
|
||||||
public ParentDao() {
|
public ParentDao() {
|
||||||
super();
|
super();
|
||||||
|
@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ChildService extends AbstractService<Child> implements IChildService {
|
public class ChildService extends AbstractService<Child>implements IChildService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IChildDao dao;
|
private IChildDao dao;
|
||||||
|
@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class FooService extends AbstractService<Foo> implements IFooService {
|
public class FooService extends AbstractService<Foo>implements IFooService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IFooDao dao;
|
private IFooDao dao;
|
||||||
|
@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ParentService extends AbstractService<Parent> implements IParentService {
|
public class ParentService extends AbstractService<Parent>implements IParentService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IParentDao dao;
|
private IParentDao dao;
|
||||||
|
@ -9,7 +9,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
|
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@Suite.SuiteClasses({// @formatter:off
|
@Suite.SuiteClasses({ // @formatter:off
|
||||||
FooServiceBasicPersistenceIntegrationTest.class
|
FooServiceBasicPersistenceIntegrationTest.class
|
||||||
,FooPaginationPersistenceIntegrationTest.class
|
,FooPaginationPersistenceIntegrationTest.class
|
||||||
,FooServicePersistenceIntegrationTest.class
|
,FooServicePersistenceIntegrationTest.class
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="owner.project.facets" value="java"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
@ -4,7 +4,7 @@ import org.baeldung.persistence.model.Foo;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class FooDao extends AbstractJpaDAO<Foo> implements IFooDao {
|
public class FooDao extends AbstractJpaDAO<Foo>implements IFooDao {
|
||||||
|
|
||||||
public FooDao() {
|
public FooDao() {
|
||||||
super();
|
super();
|
||||||
|
@ -4,7 +4,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
|
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@Suite.SuiteClasses({// @formatter:off
|
@Suite.SuiteClasses({ // @formatter:off
|
||||||
FooPaginationPersistenceIntegrationTest.class
|
FooPaginationPersistenceIntegrationTest.class
|
||||||
,FooServicePersistenceIntegrationTest.class
|
,FooServicePersistenceIntegrationTest.class
|
||||||
,FooServiceSortingTests.class
|
,FooServiceSortingTests.class
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
package org.baeldung.servlet;
|
package org.baeldung.servlet;
|
||||||
|
|
||||||
//public class WebApp implements WebApplicationInitializer {
|
// public class WebApp implements WebApplicationInitializer {
|
||||||
//
|
//
|
||||||
// public WebApp() {
|
// public WebApp() {
|
||||||
// super();
|
// super();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// // API
|
// // API
|
||||||
//
|
//
|
||||||
// @Override
|
// @Override
|
||||||
// public void onStartup(final ServletContext servletContext) throws ServletException {
|
// public void onStartup(final ServletContext servletContext) throws ServletException {
|
||||||
// final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
|
// final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
|
||||||
// root.setServletContext(servletContext);
|
// root.setServletContext(servletContext);
|
||||||
// root.scan("org.baeldung.spring");
|
// root.scan("org.baeldung.spring");
|
||||||
// root.refresh();
|
// root.refresh();
|
||||||
//
|
//
|
||||||
// final Dynamic servlet = servletContext.addServlet("mvc", new DispatcherServlet(root));
|
// final Dynamic servlet = servletContext.addServlet("mvc", new DispatcherServlet(root));
|
||||||
// servlet.setLoadOnStartup(1);
|
// servlet.setLoadOnStartup(1);
|
||||||
// servlet.addMapping("/");
|
// servlet.addMapping("/");
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
@ -39,19 +39,19 @@ public class RedirectControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void whenRedirectOnUrlWithUsingXMLConfig_thenStatusRedirectionAndRedirectedOnUrl() throws Exception {
|
public void whenRedirectOnUrlWithUsingXMLConfig_thenStatusRedirectionAndRedirectedOnUrl() throws Exception {
|
||||||
mockMvc.perform(get("/redirectWithXMLConfig")).andExpect(status().is3xxRedirection()).andExpect(view().name("RedirectedUrl")).andExpect(model().attribute("attribute", is("redirectWithXMLConfig")))
|
mockMvc.perform(get("/redirectWithXMLConfig")).andExpect(status().is3xxRedirection()).andExpect(view().name("RedirectedUrl")).andExpect(model().attribute("attribute", is("redirectWithXMLConfig")))
|
||||||
.andExpect(redirectedUrl("redirectedUrl?attribute=redirectWithXMLConfig"));
|
.andExpect(redirectedUrl("redirectedUrl?attribute=redirectWithXMLConfig"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenRedirectOnUrlWithUsingRedirectPrefix_thenStatusRedirectionAndRedirectedOnUrl() throws Exception {
|
public void whenRedirectOnUrlWithUsingRedirectPrefix_thenStatusRedirectionAndRedirectedOnUrl() throws Exception {
|
||||||
mockMvc.perform(get("/redirectWithRedirectPrefix")).andExpect(status().is3xxRedirection()).andExpect(view().name("redirect:/redirectedUrl")).andExpect(model().attribute("attribute", is("redirectWithRedirectPrefix")))
|
mockMvc.perform(get("/redirectWithRedirectPrefix")).andExpect(status().is3xxRedirection()).andExpect(view().name("redirect:/redirectedUrl")).andExpect(model().attribute("attribute", is("redirectWithRedirectPrefix")))
|
||||||
.andExpect(redirectedUrl("/redirectedUrl?attribute=redirectWithRedirectPrefix"));
|
.andExpect(redirectedUrl("/redirectedUrl?attribute=redirectWithRedirectPrefix"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenRedirectOnUrlWithUsingRedirectAttributes_thenStatusRedirectionAndRedirectedOnUrlAndAddedAttributeToFlashScope() throws Exception {
|
public void whenRedirectOnUrlWithUsingRedirectAttributes_thenStatusRedirectionAndRedirectedOnUrlAndAddedAttributeToFlashScope() throws Exception {
|
||||||
mockMvc.perform(get("/redirectWithRedirectAttributes")).andExpect(status().is3xxRedirection()).andExpect(flash().attribute("flashAttribute", is("redirectWithRedirectAttributes")))
|
mockMvc.perform(get("/redirectWithRedirectAttributes")).andExpect(status().is3xxRedirection()).andExpect(flash().attribute("flashAttribute", is("redirectWithRedirectAttributes")))
|
||||||
.andExpect(model().attribute("attribute", is("redirectWithRedirectAttributes"))).andExpect(model().attribute("flashAttribute", is(nullValue()))).andExpect(redirectedUrl("redirectedUrl?attribute=redirectWithRedirectAttributes"));
|
.andExpect(model().attribute("attribute", is("redirectWithRedirectAttributes"))).andExpect(model().attribute("flashAttribute", is(nullValue()))).andExpect(redirectedUrl("redirectedUrl?attribute=redirectWithRedirectAttributes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -21,7 +21,7 @@ public class Role {
|
|||||||
private Collection<User> users;
|
private Collection<User> users;
|
||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(name = "roles_privileges", joinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "privilege_id", referencedColumnName = "id"))
|
@JoinTable(name = "roles_privileges", joinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id") , inverseJoinColumns = @JoinColumn(name = "privilege_id", referencedColumnName = "id") )
|
||||||
private Collection<Privilege> privileges;
|
private Collection<Privilege> privileges;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -32,7 +32,7 @@ public class User {
|
|||||||
private boolean tokenExpired;
|
private boolean tokenExpired;
|
||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"))
|
@JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id") , inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id") )
|
||||||
private Collection<Role> roles;
|
private Collection<Role> roles;
|
||||||
|
|
||||||
public User() {
|
public User() {
|
||||||
|
@ -18,7 +18,7 @@ public @interface PasswordMatches {
|
|||||||
|
|
||||||
String message() default "Passwords don't match";
|
String message() default "Passwords don't match";
|
||||||
|
|
||||||
Class<?>[] groups() default {};
|
Class<?>[]groups() default {};
|
||||||
|
|
||||||
Class<? extends Payload>[] payload() default {};
|
Class<? extends Payload>[]payload() default {};
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public @interface ValidEmail {
|
|||||||
|
|
||||||
String message() default "Invalid Email";
|
String message() default "Invalid Email";
|
||||||
|
|
||||||
Class<?>[] groups() default {};
|
Class<?>[]groups() default {};
|
||||||
|
|
||||||
Class<? extends Payload>[] payload() default {};
|
Class<? extends Payload>[]payload() default {};
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ public @interface ValidPassword {
|
|||||||
|
|
||||||
String message() default "Invalid Password";
|
String message() default "Invalid Password";
|
||||||
|
|
||||||
Class<?>[] groups() default {};
|
Class<?>[]groups() default {};
|
||||||
|
|
||||||
Class<? extends Payload>[] payload() default {};
|
Class<? extends Payload>[]payload() default {};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ import cz.jirutka.rsql.parser.ast.ComparisonOperator;
|
|||||||
import cz.jirutka.rsql.parser.ast.RSQLOperators;
|
import cz.jirutka.rsql.parser.ast.RSQLOperators;
|
||||||
|
|
||||||
public enum RsqlSearchOperation {
|
public enum RsqlSearchOperation {
|
||||||
EQUAL(RSQLOperators.EQUAL), NOT_EQUAL(RSQLOperators.NOT_EQUAL), GREATER_THAN(RSQLOperators.GREATER_THAN), GREATER_THAN_OR_EQUAL(RSQLOperators.GREATER_THAN_OR_EQUAL), LESS_THAN(RSQLOperators.LESS_THAN), LESS_THAN_OR_EQUAL(RSQLOperators.LESS_THAN_OR_EQUAL), IN(
|
EQUAL(RSQLOperators.EQUAL), NOT_EQUAL(RSQLOperators.NOT_EQUAL), GREATER_THAN(RSQLOperators.GREATER_THAN), GREATER_THAN_OR_EQUAL(RSQLOperators.GREATER_THAN_OR_EQUAL), LESS_THAN(RSQLOperators.LESS_THAN), LESS_THAN_OR_EQUAL(
|
||||||
RSQLOperators.IN), NOT_IN(RSQLOperators.NOT_IN);
|
RSQLOperators.LESS_THAN_OR_EQUAL), IN(RSQLOperators.IN), NOT_IN(RSQLOperators.NOT_IN);
|
||||||
|
|
||||||
private ComparisonOperator operator;
|
private ComparisonOperator operator;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import com.google.common.collect.Lists;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
public class FooService extends AbstractService<Foo> implements IFooService {
|
public class FooService extends AbstractService<Foo>implements IFooService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IFooDao dao;
|
private IFooDao dao;
|
||||||
|
@ -55,12 +55,12 @@ public class SecurityJavaConfig extends WebSecurityConfigurerAdapter {
|
|||||||
} // @formatter:on
|
} // @formatter:on
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MySavedRequestAwareAuthenticationSuccessHandler mySuccessHandler(){
|
public MySavedRequestAwareAuthenticationSuccessHandler mySuccessHandler() {
|
||||||
return new MySavedRequestAwareAuthenticationSuccessHandler();
|
return new MySavedRequestAwareAuthenticationSuccessHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SimpleUrlAuthenticationFailureHandler myFailureHandler(){
|
public SimpleUrlAuthenticationFailureHandler myFailureHandler() {
|
||||||
return new SimpleUrlAuthenticationFailureHandler();
|
return new SimpleUrlAuthenticationFailureHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user