当前位置: 首页>>代码示例>>Java>>正文


Java LocalTestServer类代码示例

本文整理汇总了Java中org.apache.http.localserver.LocalTestServer的典型用法代码示例。如果您正苦于以下问题:Java LocalTestServer类的具体用法?Java LocalTestServer怎么用?Java LocalTestServer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LocalTestServer类属于org.apache.http.localserver包,在下文中一共展示了LocalTestServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    BasicConfigurator.configure();
    
    server = new LocalTestServer(null, null);

    server.register("/hitme/*", new HttpRequestHandler() {
        @Override
        public void handle(HttpRequest req, HttpResponse resp, HttpContext ctx)
                throws HttpException, IOException 
        {
            resp.setStatusCode(200);
            resp.setEntity(new StringEntity("Hello World"));
        }
    });
    
    server.start();
    
    client = new HttpClient();
}
 
开发者ID:memphis-iis,项目名称:gluten,代码行数:21,代码来源:HttpClientTest.java

示例2: setUp

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    OAuthTokenService.INSTANCE.clearToken();

    HttpRequestHandler tokenHandler = new TokenHandler();
    HttpRequestHandler resourceHandler = new ResourceHandler();

    testServer = new LocalTestServer(null, null);
    testServer.register("/v3/rest/*", resourceHandler);
    testServer.register("/v3/token", tokenHandler);
    testServer.start();

    port = testServer.getServicePort();
    host = testServer.getServiceHostName();

    // System.out.println("LocalTestServer available via http://" + host + ":" + port);

    params = new HashMap<String, String>();
    params.put("username", userName);
    params.put("password", password);
    params.put("scope", scope);
    params.put("grant_type", grantType);

    client = MasheryClientBuilder.masheryClient().withHost(host).withProtocol("http").withPort(port).withApiKey(apiKey).withApiSecret(apiSecret).withTokenRequestParams(params).build();
}
 
开发者ID:afklm,项目名称:mashery-sdk,代码行数:27,代码来源:MasheryClientTest.java

示例3: setUp

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    handler = mock(HttpRequestHandler.class);

    server = new LocalTestServer(null, null);
    server.register("/*", handler);
    server.start();

    // report how to access the server
    System.out.println("LocalTestServer available at " + server.getServiceAddress());
    primaryServiceAddress = server.getServiceAddress().getHostName() + ":" + server.getServiceAddress().getPort();
    secondaryServiceAddress = server.getServiceAddress().getAddress().getHostAddress() + ":" + server.getServiceAddress().getPort();

    impl = new Sosumi("http://" + primaryServiceAddress, "user", "pass");

}
 
开发者ID:tomasca,项目名称:sosumi-java,代码行数:18,代码来源:SosumiTest.java

示例4: setUp

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    // use local test server to intercept http requests sent by the reporter
    server = new LocalTestServer(null, null);
    server.register("*", handler);
    server.start();

    serverUrl = "http://localhost:" + server.getServiceAddress().getPort() + "/";

    Properties properties = new Properties();
    properties.put(BounceProxyControllerPropertyKeys.PROPERTY_BPC_SEND_CREATE_CHANNEL_MAX_RETRY_COUNT, "3");
    properties.put(BounceProxyControllerPropertyKeys.PROPERTY_BPC_SEND_CREATE_CHANNEL_RETRY_INTERVAL_MS, "100");

    Injector injector = Guice.createInjector(new PropertyLoadingModule(properties), new AbstractModule() {

        @Override
        protected void configure() {
            bind(CloseableHttpClient.class).toInstance(HttpClients.createDefault());
        }
    });

    bpFacade = injector.getInstance(RemoteBounceProxyFacade.class);
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:25,代码来源:RemoteBounceProxyFacadeTest.java

示例5: startStorageServers

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
@Before
public void startStorageServers() throws Exception {
    for (int i = 0; i < 3; i++) {
        localServers[i] = new LocalTestServer(null, null);
        localServers[i].register("*", new HttpStorageRequestHandler());

        localServers[i].start();
    }
    cfg = String.format("1 http://localhost:%d\n2 http://localhost:%d\n3 http://localhost:%d\n",
            localServers[0].getServiceAddress().getPort(),
            localServers[1].getServiceAddress().getPort(),
            localServers[2].getServiceAddress().getPort());
}
 
开发者ID:pacheco,项目名称:GlobalFS,代码行数:14,代码来源:HttpStorageTest.java

示例6: killStorageServers

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
@After
public void killStorageServers() {
    for (LocalTestServer s: localServers) {
        try {
            s.stop();
        } catch (Exception e) {
        }
    }
}
 
开发者ID:pacheco,项目名称:GlobalFS,代码行数:10,代码来源:HttpStorageTest.java

示例7: getTestServerAddress

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
public static String getTestServerAddress(LocalTestServer server) {
    return String.format(
            "http://%s:%s",
            server.getServiceAddress().getHostName(),
            server.getServiceAddress().getPort()
    );
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:8,代码来源:TestUtils.java

示例8: FakeConduit

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
public FakeConduit(Map<String, JSONObject> responses) throws Exception {
    server = new LocalTestServer(null, null);
    this.requestBodies = new ArrayList<String>();
    for (Map.Entry<String, JSONObject> entry : responses.entrySet()) {
        register(entry.getKey(), entry.getValue());
    }
    server.start();
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:9,代码来源:FakeConduit.java

示例9: setUp

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  handler = Mockito.mock(HttpRequestHandler.class);
  server = new LocalTestServer(null, null);
  server.register("/jenkinstest/*", handler);
  server.start();

  serverUrl = "http://" + server.getServiceHostName() + ":"
      + server.getServicePort() + "/jenkinstest/123";

  // report how to access the server
  System.out.println("LocalTestServer available at " + serverUrl);
  j.get(PluginDescriptorImpl.class).setUrl(serverUrl);

}
 
开发者ID:SumoLogic,项目名称:sumologic-jenkins-plugin,代码行数:16,代码来源:SumoBuildNotifierTest.java

示例10: setUp

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
public void setUp(HttpRequestHandler handler) throws Exception {
  server = new LocalTestServer(null, null);
  server.register("/*", handler);
  server.start();

  // report how to access the server
  address = "http://" + server.getServiceAddress().getHostName() + ":"
      + server.getServiceAddress().getPort();
  System.out.println("LocalTestServer available at " + address);

}
 
开发者ID:headissue,项目名称:shariff-backend-java,代码行数:12,代码来源:TestServer.java

示例11: setUp

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    // use local test server to intercept http requests sent by the reporter
    server = new LocalTestServer(null, null);
    server.register("*", handler);
    server.start();

    final String serverUrl = "http://localhost:" + server.getServiceAddress().getPort();

    // set test properties manually for a better overview of
    // what is tested
    Properties properties = new Properties();

    // have to set the BPC base url manually as this is the
    // mock server which gets port settings dynamically
    properties.put(BounceProxyPropertyKeys.PROPERTY_BOUNCE_PROXY_CONTROLLER_BASE_URL, serverUrl);
    properties.put(BounceProxyPropertyKeys.PROPERTY_BOUNCE_PROXY_ID, "X.Y");
    properties.put(BounceProxyPropertyKeys.PROPERTY_BOUNCEPROXY_URL_FOR_BPC, "http://joyn-bpX.muc/bp");
    properties.put(BounceProxyPropertyKeys.PROPERTY_BOUNCEPROXY_URL_FOR_CC, "http://joyn-bpX.de/bp");
    properties.put(BounceProxyPropertyKeys.PROPERTY_BOUNCE_PROXY_MONITORING_FREQUENCY_MS, "100");

    properties.put(BounceProxyPropertyKeys.PROPERTY_BOUNCE_PROXY_SEND_LIFECYCLE_REPORT_RETRY_INTERVAL_MS, "100");
    properties.put(BounceProxyPropertyKeys.PROPERTY_BOUNCE_PROXY_MAX_SEND_SHUTDOWN_TIME_SECS, "1");

    Injector injector = Guice.createInjector(new PropertyLoadingModule(properties),
                                             new ControlledBounceProxyModule() {
                                                 @Override
                                                 protected void configure() {
                                                     bind(ChannelService.class).to(DefaultBounceProxyChannelServiceImpl.class);
                                                     bind(BounceProxyLifecycleMonitor.class).to(MonitoringServiceClient.class);
                                                     bind(TimestampProvider.class).toInstance(mockTimestampProvider);
                                                     bind(BounceProxyInformation.class).toProvider(BounceProxyInformationProvider.class);
                                                 }
                                             });

    reporter = injector.getInstance(MonitoringServiceClient.class);
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:39,代码来源:MonitoringServiceClientTest.java

示例12: setUp

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    server = new LocalTestServer(null, null);
    server.register(CHANNELPATH, new HttpRequestHandler() {

        @Override
        public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException,
                                                                                           IOException {
            response.setStatusCode(createChannelResponseCode);
            response.setHeader("Location", bounceProxyUrl + "channels/" + channelId);
        }
    });
    server.start();
    serviceAddress = "http://" + server.getServiceAddress().getHostName() + ":"
            + server.getServiceAddress().getPort();
    bounceProxyUrl = serviceAddress + BOUNCEPROXYPATH;

    Properties properties = new Properties();
    properties.put(MessagingPropertyKeys.CHANNELID, channelId);
    properties.put(MessagingPropertyKeys.BOUNCE_PROXY_URL, bounceProxyUrl);

    Injector injector = Guice.createInjector(new AbstractModule() {
        @Override
        public void configure() {
            bind(HttpRequestFactory.class).to(ApacheHttpRequestFactory.class);
            bind(CloseableHttpClient.class).toProvider(HttpClientProvider.class).in(Singleton.class);
            bind(RequestConfig.class).toProvider(HttpDefaultRequestConfigProvider.class).in(Singleton.class);
            bind(MessagingSettings.class).to(ConfigurableMessagingSettings.class);
        }
    }, new JoynrPropertiesModule(properties), new JsonMessageSerializerModule(), new DummyDiscoveryModule());
    longpollingChannelLifecycle = injector.getInstance(LongPollingChannelLifecycle.class);
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:33,代码来源:LongPollingChannelLifecycleTest.java

示例13: setUp

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    server = new LocalTestServer(null, null);
    server.start();
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:6,代码来源:ConduitAPIClientTest.java

示例14: getServer

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
public LocalTestServer getServer() {
    return server;
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:4,代码来源:FakeConduit.java

示例15: setUp

import org.apache.http.localserver.LocalTestServer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    server = new LocalTestServer(null, null);
    server.start();
    client = getDefaultClient();
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:7,代码来源:UberallsClientTest.java


注:本文中的org.apache.http.localserver.LocalTestServer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。