From eb8c253499af15ed247906d53a8d64f5b91270e8 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 3 Apr 2015 12:26:17 -0400 Subject: [PATCH] Fix failing tests --- .../springframework/web/cors/CorsUtilsTests.java | 15 +-------------- .../web/cors/DefaultCorsProcessorTests.java | 8 ++------ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java b/spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java index ecfc2cd391..6b03d448e7 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java @@ -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 { 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)); - } - } diff --git a/spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java b/spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java index 57c93ce607..6d6fe9ad9c 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java @@ -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 { 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