Java 类org.springframework.web.util.DefaultUriBuilderFactory 实例源码

项目:spring-webflux-client    文件:DefaultRequestTest.java   
@Test
public void headers_withReadOnlyHttpHeaders() {
    HttpHeaders httpHeaders = HttpHeaders.readOnlyHttpHeaders(new HttpHeaders());
    DefaultRequest defaultRequest = new DefaultRequest(new DefaultUriBuilderFactory().builder(),
            HttpMethod.GET, httpHeaders, new HashMap<>(), BodyInserters.empty());
    defaultRequest.headers().add(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE);

    assertThat(defaultRequest.headers().getFirst(HttpHeaders.ACCEPT)).isEqualTo(MediaType.APPLICATION_JSON_VALUE);
}
项目:spring-webflux-client    文件:MethodMetadata.java   
public Builder(String scheme, String authority) {
    this();
    if (scheme != null && authority != null) {
        uriBuilder = new DefaultUriBuilderFactory(scheme + "://" + authority).builder();
    }
    else {
        uriBuilder = new DefaultUriBuilderFactory().builder();
    }
}
项目:spring-webflux-client    文件:MethodMetadata.java   
public Builder(MethodMetadata other) {
    this();
    uriBuilder = new DefaultUriBuilderFactory(other.getRequestTemplate().getUriBuilder().build().toString()).builder();
    variableIndexToName.putAll(other.getRequestTemplate().getVariableIndexToName());
    headers.putAll(other.getRequestTemplate().getRequestHeaders().getHeaders());
    headerIndexToName.putAll(other.getRequestTemplate().getRequestHeaders().getIndexToName());
    httpMethod = other.getRequestTemplate().getHttpMethod();
    targetMethod = other.getTargetMethod();
}
项目:spring-webflux-client    文件:DefaultRequestTest.java   
public DefaultRequest buildRequest(String headerName, String headerValue) {
    HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.add(headerName, headerValue);

    return new DefaultRequest(new DefaultUriBuilderFactory().builder(),
            HttpMethod.GET, httpHeaders, new HashMap<>(), BodyInserters.empty());
}
项目:spring-webflux-client    文件:MethodMetadata.java   
public Builder(String scheme, String authority) {
    this();
    if (scheme != null && authority != null) {
        uriBuilder = new DefaultUriBuilderFactory(scheme + "://" + authority).builder();
    }
    else {
        uriBuilder = new DefaultUriBuilderFactory().builder();
    }
}
项目:spring-webflux-client    文件:MethodMetadata.java   
public Builder(MethodMetadata other) {
    this();
    uriBuilder = new DefaultUriBuilderFactory(other.getRequestTemplate().getUriBuilder().build().toString()).builder();
    variableIndexToName.putAll(other.getRequestTemplate().getVariableIndexToName());
    headers.putAll(other.getRequestTemplate().getRequestHeaders().getHeaders());
    headerIndexToName.putAll(other.getRequestTemplate().getRequestHeaders().getIndexToName());
    httpMethod = other.getRequestTemplate().getHttpMethod();
    targetMethod = other.getTargetMethod();
}
项目:spring-webflux-client    文件:DefaultRequestTest.java   
@Test
public void headers_withReadOnlyHttpHeaders() {
    HttpHeaders httpHeaders = HttpHeaders.readOnlyHttpHeaders(new HttpHeaders());
    DefaultRequest defaultRequest = new DefaultRequest(new DefaultUriBuilderFactory().builder(),
            HttpMethod.GET, httpHeaders, new HashMap<>(), BodyInserters.empty());
    defaultRequest.headers().add(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE);

    assertThat(defaultRequest.headers().getFirst(HttpHeaders.ACCEPT)).isEqualTo(MediaType.APPLICATION_JSON_VALUE);
}
项目:spring-webflux-client    文件:DefaultRequestTest.java   
public DefaultRequest buildRequest(String headerName, String headerValue) {
    HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.add(headerName, headerValue);

    return new DefaultRequest(new DefaultUriBuilderFactory().builder(),
            HttpMethod.GET, httpHeaders, new HashMap<>(), BodyInserters.empty());
}
项目:spring-cloud-netflix    文件:RibbonLoadBalancerClientTests.java   
private void testReconstructUriWithPath(String scheme, String path) {
    RibbonServer server = getRibbonServer();
    IClientConfig config = mock(IClientConfig.class);
    when(config.get(CommonClientConfigKey.IsSecure)).thenReturn(true);
    when(clientFactory.getClientConfig(server.getServiceId())).thenReturn(config);

    RibbonLoadBalancerClient client = getRibbonLoadBalancerClient(server);
    ServiceInstance serviceInstance = client.choose(server.getServiceId());

    URI expanded = new DefaultUriBuilderFactory()
            .expand(scheme + "://" + server.getServiceId() + path);
    URI reconstructed = client.reconstructURI(serviceInstance, expanded);
    assertThat(reconstructed).hasPath(path);
}
项目:spring-webflux-client    文件:DefaultRequestTest.java   
public DefaultRequest buildRequest(String uri, Map<String, Object> variables) {
    UriBuilder uriBuilder = new DefaultUriBuilderFactory(uri).builder();
    return new DefaultRequest(uriBuilder, HttpMethod.GET, new HttpHeaders(), variables, BodyInserters.empty());
}
项目:spring-webflux-client    文件:DefaultRequestTest.java   
public DefaultRequest buildRequest(String uri, Map<String, Object> variables) {
    UriBuilder uriBuilder = new DefaultUriBuilderFactory(uri).builder();
    return new DefaultRequest(uriBuilder, HttpMethod.GET, new HttpHeaders(), variables, BodyInserters.empty());
}