use of org.springframework.web.util.UriComponentsBuilder in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method testFromControllerWithCustomBaseUrlViaStaticCall.
@Test
public void testFromControllerWithCustomBaseUrlViaStaticCall() {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("http://example.org:9090/base");
UriComponents uriComponents = fromController(builder, PersonControllerImpl.class).build();
assertEquals("http://example.org:9090/base/people", uriComponents.toString());
assertEquals("http://example.org:9090/base", builder.toUriString());
}
use of org.springframework.web.util.UriComponentsBuilder in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method testFromMethodCallWithCustomBaseUrlViaStaticCall.
@Test
public void testFromMethodCallWithCustomBaseUrlViaStaticCall() {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("http://example.org:9090/base");
UriComponents uriComponents = fromMethodCall(builder, on(ControllerWithMethods.class).myMethod(null)).build();
assertEquals("http://example.org:9090/base/something/else", uriComponents.toString());
assertEquals("http://example.org:9090/base", builder.toUriString());
}
use of org.springframework.web.util.UriComponentsBuilder in project spring-framework by spring-projects.
the class MvcUriComponentsBuilderTests method testFromMethodNameWithCustomBaseUrlViaStaticCall.
@Test
public void testFromMethodNameWithCustomBaseUrlViaStaticCall() throws Exception {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("http://example.org:9090/base");
UriComponents uriComponents = fromMethodName(builder, ControllerWithMethods.class, "methodWithPathVariable", new Object[] { "1" }).build();
assertEquals("http://example.org:9090/base/something/1/foo", uriComponents.toString());
assertEquals("http://example.org:9090/base", builder.toUriString());
}
use of org.springframework.web.util.UriComponentsBuilder in project libresonic by Libresonic.
the class JWTSecurityServiceTest method addJWTToken.
@Test
public void addJWTToken() throws Exception {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(uriString);
String actualUri = service.addJWTToken(builder).build().toUriString();
String jwtToken = UriComponentsBuilder.fromUriString(actualUri).build().getQueryParams().getFirst(JWTSecurityService.JWT_PARAM_NAME);
DecodedJWT verify = verifier.verify(jwtToken);
Claim claim = verify.getClaim(JWTSecurityService.CLAIM_PATH);
assertEquals(expectedClaimString, claim.asString());
}
use of org.springframework.web.util.UriComponentsBuilder in project libresonic by Libresonic.
the class HLSController method generateVariantPlaylist.
private void generateVariantPlaylist(HttpServletRequest request, int id, Player player, List<Pair<Integer, Dimension>> bitRates, PrintWriter writer) {
writer.println("#EXTM3U");
writer.println("#EXT-X-VERSION:1");
// writer.println("#EXT-X-TARGETDURATION:" + SEGMENT_DURATION);
String contextPath = getContextPath(request);
for (Pair<Integer, Dimension> bitRate : bitRates) {
Integer kbps = bitRate.getFirst();
writer.println("#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=" + kbps * 1000L);
UriComponentsBuilder url = (UriComponentsBuilder.fromUriString(contextPath + "ext/hls/hls.m3u8").queryParam("id", id).queryParam("player", player.getId()).queryParam("bitRate", kbps));
jwtSecurityService.addJWTToken(url);
writer.print(url.toUriString());
Dimension dimension = bitRate.getSecond();
if (dimension != null) {
writer.print("@" + dimension.width + "x" + dimension.height);
}
writer.println();
}
// writer.println("#EXT-X-ENDLIST");
}
Aggregations