Skip to content

Commit ff5c275

Browse files
integration testing work
1 parent 3ecc7b8 commit ff5c275

4 files changed

Lines changed: 4 additions & 28 deletions

File tree

‎src/main/java/org/rest/web/event/SingleResourceRetrievedDiscoverabilityListener.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ final class SingleResourceRetrievedDiscoverabilityListener implements Applicatio
1919
public final void onApplicationEvent( final SingleResourceRetrievedEvent ev ){
2020
Preconditions.checkNotNull( ev );
2121

22-
addLinkHeaderOnSingleResourceRetrieval( ev.getUriBuilder(), ev.getResponse(), ev.getClazz() );
22+
discoverGetAllURI( ev.getUriBuilder(), ev.getResponse(), ev.getClazz() );
2323
}
2424

25-
final void addLinkHeaderOnSingleResourceRetrieval( final UriComponentsBuilder uriBuilder, final HttpServletResponse response, final Class clazz ){
25+
final void discoverGetAllURI( final UriComponentsBuilder uriBuilder, final HttpServletResponse response, final Class clazz ){
2626
final String resourceName = clazz.getSimpleName().toString().toLowerCase();
2727
final String uriForResourceCreation = uriBuilder.path( "/" + resourceName ).build().encode().toUriString();
2828

‎src/test/java/org/rest/security/AuthenticationRESTIntegrationTest.java‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
import static org.rest.sec.util.SecurityConstants.ADMIN_PASSWORD;
77
import static org.rest.sec.util.SecurityConstants.ADMIN_USERNAME;
88

9-
import org.junit.Ignore;
109
import org.junit.Test;
1110
import org.junit.runner.RunWith;
1211
import org.rest.spring.application.ApplicationTestConfig;
1312
import org.rest.spring.persistence.jpa.PersistenceJPAConfig;
1413
import org.rest.testing.ExamplePaths;
1514
import org.springframework.beans.factory.annotation.Autowired;
16-
import org.springframework.http.MediaType;
1715
import org.springframework.test.context.ContextConfiguration;
1816
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
1917
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@@ -30,11 +28,10 @@ public class AuthenticationRESTIntegrationTest{
3028
// tests
3129

3230
@Test
33-
@Ignore( "TODO: investigate" )
3431
public final void givenCorrectAuthenticationCredentialsSent_whenAuthenticationResourceIsCreated_then201IsReceived(){
3532
// Given
3633
// When
37-
final Response response = given().auth().digest( ADMIN_USERNAME, ADMIN_PASSWORD ).contentType( MediaType.APPLICATION_XML.toString() ).get( paths.getAuthenticationUri() );
34+
final Response response = given().auth().digest( ADMIN_USERNAME, ADMIN_PASSWORD ).post( paths.getAuthenticationUri() );
3835

3936
// Then
4037
assertThat( response.getStatusCode(), is( 201 ) );

‎src/test/java/org/rest/security/UserSandboxRESTIntegrationTest.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.apache.http.impl.auth.BasicScheme;
1313
import org.apache.http.impl.client.BasicAuthCache;
1414
import org.apache.http.impl.client.DefaultHttpClient;
15-
import org.junit.Ignore;
1615
import org.junit.Test;
1716
import org.junit.runner.RunWith;
1817
import org.rest.sec.dto.User;
@@ -58,12 +57,11 @@ public final void whenGetWithAuthentication_then200IsReceived(){
5857
}
5958

6059
@Test
61-
@Ignore( "TODO: review" )
6260
public final void whenAuthenticating_then201IsReceived(){
6361
final RestTemplate restTemplate = setUpRestTemplate();
6462

6563
// When
66-
final ResponseEntity< User > response = restTemplate.exchange( paths.getAuthenticationUri(), HttpMethod.GET, new HttpEntity< String >( createHeaders() ), User.class );
64+
final ResponseEntity< User > response = restTemplate.exchange( paths.getAuthenticationUri(), HttpMethod.POST, new HttpEntity< String >( createHeaders() ), User.class );
6765

6866
// Then
6967
assertThat( response.getStatusCode().value(), is( 201 ) );

‎src/test/java/org/rest/web/common/AbstractDiscoverabilityRESTIntegrationTest.java‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import static org.junit.matchers.JUnitMatchers.containsString;
1010

1111
import org.hamcrest.core.AnyOf;
12-
import org.junit.Ignore;
1312
import org.junit.Test;
1413
import org.rest.common.IEntity;
1514
import org.rest.common.util.RESTURIUtil;
@@ -42,24 +41,6 @@ public AbstractDiscoverabilityRESTIntegrationTest( final Class< T > clazzToSet )
4241

4342
// GET (single)
4443

45-
/**
46-
* - note: this needs to be done manually and not through the template
47-
*/
48-
@Test
49-
@Ignore( "this isn't doing the right thing; actually the Link header doen't contain the URI of the create-POST, but that of the getAll-GET" )
50-
// TODO: extract the URI by rel first
51-
// TODO: then, this isn't actually implemented anyways
52-
public final void whenResourceIsRetrieved_thenURIToCreateANewResourceIsDiscoverable(){
53-
// When
54-
final Response response = this.getTemplate().createResourceAndGetAsResponse();
55-
56-
// Then
57-
final String linkHeader = response.getHeader( HttpHeaders.LINK );
58-
final String uriForResourceCreation = HTTPLinkHeaderUtils.extractSingleURI( linkHeader );
59-
final Response secondCreationResponse = this.givenAuthenticated().contentType( marshaller.getMime() ).body( this.createNewEntity() ).post( uriForResourceCreation );
60-
assertThat( secondCreationResponse.getStatusCode(), is( 201 ) );
61-
}
62-
6344
@Test
6445
public final void whenResourceIsRetrieved_thenURIToGetAllResourcesIsDiscoverable(){
6546
// Given

0 commit comments

Comments
 (0)