@Test public void resolveUrlExisting() { this.locations = Collections.singletonList(new ClassPathResource("/META-INF/resources/webjars/", getClass())); String file = "/foo/2.3/foo.txt"; given(this.chain.resolveUrlPath(file, this.locations)).willReturn(file); String actual = this.resolver.resolveUrlPath(file, this.locations, this.chain); assertEquals(file, actual); verify(this.chain, times(1)).resolveUrlPath(file, this.locations); }
@Test public void resolveUrlExistingNotInJarFile() { this.locations = Collections.singletonList(new ClassPathResource("/META-INF/resources/webjars/", getClass())); String file = "foo/foo.txt"; given(this.chain.resolveUrlPath(file, this.locations)).willReturn(null); String actual = this.resolver.resolveUrlPath(file, this.locations, this.chain); assertNull(actual); verify(this.chain, times(1)).resolveUrlPath(file, this.locations); verify(this.chain, never()).resolveUrlPath("foo/2.3/foo.txt", this.locations); }
@Test public void resolveUrlWebJarResourceNotFound() { String file = "something/something.js"; given(this.chain.resolveUrlPath(file, this.locations)).willReturn(null); String actual = this.resolver.resolveUrlPath(file, this.locations, this.chain); assertNull(actual); verify(this.chain, times(1)).resolveUrlPath(file, this.locations); verify(this.chain, never()).resolveUrlPath(null, this.locations); }
@Test public void resolveUrlWebJarResource() { String file = "underscorejs/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); String actual = this.resolver.resolveUrlPath(file, this.locations, this.chain); assertEquals(expected, actual); verify(this.chain, times(1)).resolveUrlPath(file, this.locations); verify(this.chain, times(1)).resolveUrlPath(expected, this.locations); }