本文整理了Java中com.squareup.okhttp.mockwebserver.MockWebServer.getHostName()
方法的一些代码示例,展示了MockWebServer.getHostName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MockWebServer.getHostName()
方法的具体详情如下:
包路径:com.squareup.okhttp.mockwebserver.MockWebServer
类名称:MockWebServer
方法名:getHostName
暂无
代码示例来源:origin: com.squareup.okhttp/mockwebserver
/**
* Returns a cookie domain for this server. This returns the server's
* non-loopback host name if it is known. Otherwise this returns ".local" for
* this server's loopback name.
*/
public String getCookieDomain() {
String hostName = getHostName();
return hostName.contains(".") ? hostName : ".local";
}
代码示例来源:origin: apache/jclouds
@Override public String region(String host) {
for (Map.Entry<String, MockWebServer> regionToServer : regionToServers.entrySet()) {
MockWebServer server = regionToServer.getValue();
if (host.equals(server.getHostName() + ":" + regionToServer.getValue().getPort())) {
return regionToServer.getKey();
}
}
throw new IllegalStateException(host + " not found");
}
};
代码示例来源:origin: com.squareup.okhttp/mockwebserver
/**
* Returns a URL for connecting to this server.
*
* @param path the request path, such as "/".
*/
public HttpUrl url(String path) {
return new HttpUrl.Builder()
.scheme(sslSocketFactory != null ? "https" : "http")
.host(getHostName())
.port(getPort())
.build()
.resolve(path);
}
代码示例来源:origin: apache/jclouds
private void test(Properties overrides, String identityHeaderName, String identityHeaderPass) throws Exception{
tempAuthServer.enqueue(new MockResponse().setResponseCode(204)
.addHeader("X-Auth-Token", "token")
.addHeader("X-Storage-Url", swiftServer.getUrl("").toString()));
swiftServer.enqueue(new MockResponse().setBody("[{\"name\":\"test_container_1\",\"count\":2,\"bytes\":78}]"));
SwiftApi api = api(tempAuthServer.getUrl("").toString(), overrides);
// Region name is derived from the swift server host.
assertEquals(api.getConfiguredRegions(), ImmutableSet.of(tempAuthServer.getHostName()));
assertTrue(api.getContainerApi(tempAuthServer.getHostName()).list().iterator().hasNext());
RecordedRequest auth = tempAuthServer.takeRequest();
assertEquals(auth.getMethod(), "GET");
assertEquals(auth.getHeader(identityHeaderName), "user");
assertEquals(auth.getHeader(identityHeaderPass), "password");
// list request went to the destination specified in X-Storage-Url.
RecordedRequest listContainers = swiftServer.takeRequest();
assertEquals(listContainers.getMethod(), "GET");
assertThat(listContainers.getPath().contains("?format=json"));
assertEquals(listContainers.getHeader("Accept"), APPLICATION_JSON);
assertEquals(listContainers.getHeader("X-Auth-Token"), "token");
}
代码示例来源:origin: cfg4j/cfg4j
@Test
void getConfigurationThrowsBeforeInitCalled() {
source = new ConsulConfigurationSourceBuilder()
.withHost(server.getHostName())
.withPort(server.getPort())
.build();
assertThatThrownBy(() -> source.getConfiguration(new ImmutableEnvironment("")))
.isExactlyInstanceOf(IllegalStateException.class);
}
代码示例来源:origin: cfg4j/cfg4j
@Test
void initThrowsOnConnectionFailure() throws Exception {
server.shutdown();
source = new ConsulConfigurationSourceBuilder()
.withHost(server.getHostName())
.withPort(server.getPort())
.build();
assertThatThrownBy(() -> source.init())
.isExactlyInstanceOf(SourceCommunicationException.class);
}
代码示例来源:origin: cfg4j/cfg4j
@Test
void readsConfigsFromConsulConfigurationSource() {
ConfigurationSource source = new ConsulConfigurationSourceBuilder()
.withHost(server.getHostName())
.withPort(server.getPort())
.build();
ConfigurationProvider provider = new ConfigurationProviderBuilder()
.withConfigurationSource(source)
.withEnvironment(new ImmutableEnvironment("us-west-1"))
.build();
assertThat(provider.getProperty("featureA.toggle", String.class)).isEqualTo("disabled");
}
代码示例来源:origin: cfg4j/cfg4j
@BeforeEach
void setUp() throws Exception {
dispatcher = new ModifiableDispatcher();
runMockServer();
source = new ConsulConfigurationSourceBuilder()
.withHost(server.getHostName())
.withPort(server.getPort())
.build();
source.init();
}
内容来源于网络,如有侵权,请联系作者删除!