Browse Source

Fix failing tests

pull/770/head
Rossen Stoyanchev 10 years ago
parent
commit
eb8c253499
  1. 15
      spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java
  2. 8
      spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java

15
spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java

@ -17,11 +17,11 @@ @@ -17,11 +17,11 @@
package org.springframework.web.cors;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.mock.web.test.MockHttpServletRequest;
import org.springframework.mock.web.test.MockHttpServletResponse;
/**
* Test case for {@link CorsUtils}.
@ -66,17 +66,4 @@ public class CorsUtilsTests { @@ -66,17 +66,4 @@ public class CorsUtilsTests {
assertFalse(CorsUtils.isPreFlightRequest(request));
}
@Test
public void isCorsResponse() {
MockHttpServletResponse response = new MockHttpServletResponse();
response.addHeader(CorsUtils.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
assertTrue(CorsUtils.isCorsResponse(response));
}
@Test
public void isNotCorsResponse() {
MockHttpServletResponse response = new MockHttpServletResponse();
assertFalse(CorsUtils.isCorsResponse(response));
}
}

8
spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java

@ -51,12 +51,10 @@ public class DefaultCorsProcessorTests { @@ -51,12 +51,10 @@ public class DefaultCorsProcessorTests {
this.processor = new DefaultCorsProcessor();
}
@Test
@Test(expected = IllegalArgumentException.class)
public void actualRequestWithoutOriginHeader() throws Exception {
this.request.setMethod(HttpMethod.GET.name());
this.processor.processActualRequest(this.conf, request, response);
assertFalse(response.containsHeader(CorsUtils.ACCESS_CONTROL_ALLOW_ORIGIN));
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
}
@Test
@ -168,13 +166,11 @@ public class DefaultCorsProcessorTests { @@ -168,13 +166,11 @@ public class DefaultCorsProcessorTests {
assertEquals("GET", response.getHeader(CorsUtils.ACCESS_CONTROL_ALLOW_METHODS));
}
@Test
@Test(expected = IllegalArgumentException.class)
public void preflightRequestWithoutOriginHeader() throws Exception {
this.request.setMethod(HttpMethod.OPTIONS.name());
this.request.addHeader(CorsUtils.ACCESS_CONTROL_REQUEST_METHOD, "GET");
this.processor.processPreFlightRequest(this.conf, request, response);
assertFalse(response.containsHeader(CorsUtils.ACCESS_CONTROL_ALLOW_ORIGIN));
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
}
@Test

Loading…
Cancel
Save