|
|
|
@ -16,16 +16,8 @@
@@ -16,16 +16,8 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.web.servlet.resource; |
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.*; |
|
|
|
|
import static org.mockito.BDDMockito.*; |
|
|
|
|
import static org.mockito.Mockito.mock; |
|
|
|
|
import static org.mockito.Mockito.never; |
|
|
|
|
import static org.mockito.Mockito.times; |
|
|
|
|
import static org.mockito.Mockito.verify; |
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
|
|
import org.junit.Before; |
|
|
|
@ -35,6 +27,13 @@ import org.springframework.core.io.ClassPathResource;
@@ -35,6 +27,13 @@ import org.springframework.core.io.ClassPathResource;
|
|
|
|
|
import org.springframework.core.io.Resource; |
|
|
|
|
import org.springframework.mock.web.test.MockHttpServletRequest; |
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.*; |
|
|
|
|
import static org.mockito.BDDMockito.*; |
|
|
|
|
import static org.mockito.Mockito.mock; |
|
|
|
|
import static org.mockito.Mockito.never; |
|
|
|
|
import static org.mockito.Mockito.times; |
|
|
|
|
import static org.mockito.Mockito.verify; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Unit tests for |
|
|
|
|
* {@link org.springframework.web.servlet.resource.WebJarsResourceResolver}. |
|
|
|
@ -51,6 +50,7 @@ public class WebJarsResourceResolverTests {
@@ -51,6 +50,7 @@ public class WebJarsResourceResolverTests {
|
|
|
|
|
|
|
|
|
|
private HttpServletRequest request = new MockHttpServletRequest(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
|
public void setup() { |
|
|
|
|
// for this to work, an actual WebJar must be on the test classpath
|
|
|
|
@ -59,6 +59,7 @@ public class WebJarsResourceResolverTests {
@@ -59,6 +59,7 @@ public class WebJarsResourceResolverTests {
|
|
|
|
|
this.chain = mock(ResourceResolverChain.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void resolveUrlExisting() { |
|
|
|
|
this.locations = Collections.singletonList(new ClassPathResource("/META-INF/resources/webjars/", getClass())); |
|
|
|
@ -87,7 +88,7 @@ public class WebJarsResourceResolverTests {
@@ -87,7 +88,7 @@ public class WebJarsResourceResolverTests {
|
|
|
|
|
@Test |
|
|
|
|
public void resolveUrlWebJarResource() { |
|
|
|
|
String file = "/underscorejs/underscore.js"; |
|
|
|
|
String expected = "/underscorejs/1.8.2/underscore.js"; |
|
|
|
|
String expected = "/underscorejs/1.8.3/underscore.js"; |
|
|
|
|
given(this.chain.resolveUrlPath(file, this.locations)).willReturn(null); |
|
|
|
|
given(this.chain.resolveUrlPath(expected, this.locations)).willReturn(expected); |
|
|
|
|
|
|
|
|
@ -139,7 +140,7 @@ public class WebJarsResourceResolverTests {
@@ -139,7 +140,7 @@ public class WebJarsResourceResolverTests {
|
|
|
|
|
public void resolveResourceWebJar() { |
|
|
|
|
Resource expected = mock(Resource.class); |
|
|
|
|
String file = "/underscorejs/underscore.js"; |
|
|
|
|
String expectedPath = "/underscorejs/1.8.2/underscore.js"; |
|
|
|
|
String expectedPath = "/underscorejs/1.8.3/underscore.js"; |
|
|
|
|
this.locations = Collections.singletonList(new ClassPathResource("/META-INF/resources/webjars/", getClass())); |
|
|
|
|
given(this.chain.resolveResource(this.request, expectedPath, this.locations)).willReturn(expected); |
|
|
|
|
|
|
|
|
|