This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@EnableWebMvc | |
public class WebConfig{ | |
// | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Controller | |
final class FooController{ | |
@Autowired | |
IFooService service; | |
@RequestMapping( value = "foo",method = RequestMethod.GET ) | |
@ResponseBody | |
public final List< Foo > getAll(){ | |
return service.getAll(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ResponseStatus( value = HttpStatus.BAD_REQUEST ) | |
public final class BadRequestException extends RuntimeException{ | |
// | |
} | |
@ResponseStatus( value = HttpStatus.NOT_FOUND ) | |
public final class ResourceNotFoundException extends RuntimeException{ | |
// | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith( SpringJUnit4ClassRunner.class ) | |
@ContextConfiguration( classes = { ApplicationConfig.class, PersistenceConfig.class },loader = AnnotationConfigContextLoader.class ) | |
public final class SpringTest{ | |
@Test | |
public final void whenSpringContextIsInstantiated_thenNoExceptions(){ | |
// When | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependencies> | |
<dependency> | |
<groupId>org.codehaus.jackson</groupId> | |
<artifactId>jackson-mapper-asl</artifactId> | |
<version>${jackson-mapper-asl.version}</version> | |
<scope>runtime</scope> | |
</dependency> | |
<dependency> | |
<groupId>javax.xml.bind</groupId> | |
<artifactId>jaxb-api</artifactId> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<filter> | |
<filter-name>springSecurityFilterChain</filter-name> | |
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> | |
</filter> | |
<filter-mapping> | |
<filter-name>springSecurityFilterChain</filter-name> | |
<url-pattern>/*</url-pattern> | |
</filter-mapping> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component( "restAuthenticationEntryPoint" ) | |
public final class RestAuthenticationEntryPoint implements AuthenticationEntryPoint{ | |
@Override | |
public final void commence | |
( HttpServletRequest request, HttpServletResponse response, AuthenticationException authException ) | |
throws IOException{ | |
response.sendError( HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized" ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use the DefaultSavedRequest URL | |
// final String targetUrl = savedRequest.getRedirectUrl(); | |
// this.logger.debug( "Redirecting to DefaultSavedRequest Url: " + targetUrl ); | |
// this.getRedirectStrategy().sendRedirect( request, response, targetUrl ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependencies> | |
<dependency> | |
<groupId>org.springframework.security</groupId> | |
<artifactId>spring-security-web</artifactId> | |
<version>${spring-security.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.security</groupId> | |
<artifactId>spring-security-config</artifactId> | |
<version>${spring-security.version}</version> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void whenResourceIsCreated_thenURIOfTheNewlyCreatedResourceIsDiscoverable(){ | |
// When | |
Foo unpersistedResource = new Foo( randomAlphabetic( 6 ) ); | |
Response createResponse = givenAuthenticated().contentType( MIME_JSON ) | |
.body( unpersistedResource ).post( paths.getFooURL() ); | |
final String uriOfNewlyCreatedResource = createResp | |
.getHeader( HttpHeaders.LOCATION ); | |
// Then |