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


Java LocalTestServer.start方法代码示例

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


在下文中一共展示了LocalTestServer.start方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: setUp

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

		@Override
		public void handle ( HttpRequest request, HttpResponse response, HttpContext content )
				throws HttpException, IOException
		{
			final String uri = request.getRequestLine().getUri();

			if (uri.contains("list"))
			{
				response.setEntity(new StringEntity("OK - Listed applications for virtual host localhost\n"
						+ "/:running:0:ROOT\n"
						+ "/host-manager:running:0:/usr/share/tomcat7-admin/host-manager\n"
						+ "/manager:running:3:/usr/share/tomcat7-admin/manager\n"
						+ "/good-app:running:4:/var/lib/tomcat7/webapps/good-app\n"
						+ "/bad-app:stopped:0:/var/lib/tomcat7/webapps/bad-app\n"));
				response.setStatusCode(200);
			}
			else if (uri.contains("start") || uri.contains("stop") || uri.contains("undeploy"))
			{
				response.setEntity(new StringEntity("OK - Operation executed"));
				response.setStatusCode(200);
			}
			else
			{
				response.setStatusCode(400);
			}
		}
	});
	server.start();
	hostName = server.getServiceAddress().getHostName();
	port = server.getServiceAddress().getPort();

	tomcatManagerService = new TomcatManagerServiceImpl("http://" + hostName + ":" + port + "/manager/text", null,
			null);
}
 
开发者ID:ClouDesire,项目名称:catwatcher,代码行数:42,代码来源:TomcatManagerServiceTest.java

示例13: 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("*", mockHandler);
    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, "500");
    properties.put(BounceProxyPropertyKeys.PROPERTY_BOUNCE_PROXY_MAX_SEND_SHUTDOWN_TIME_SECS, "2");

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

        @Override
        protected void configure() {

            bind(ScheduledExecutorService.class).toInstance(mockExecutorService);
            bind(BounceProxyPerformanceMonitor.class).toInstance(mockPerformanceMonitor);
            bind(BounceProxyLifecycleMonitor.class).toInstance(mockLifecycleMonitor);
            bind(CloseableHttpClient.class).toInstance(HttpClients.createDefault());
        }

    });

    reporter = injector.getInstance(BounceProxyPerformanceReporter.class);

    // fake the clock for a more robust testing
    clock = new Clock();

    Answer<Void> mockScheduledExecutor = new Answer<Void>() {

        @Override
        public Void answer(final InvocationOnMock invocation) throws Throwable {

            long frequencyMs = (Long) invocation.getArguments()[2];
            Runnable runnable = (Runnable) invocation.getArguments()[0];

            clock.setFrequencyMs(frequencyMs);
            clock.setRunnable(runnable);

            return null;
        }
    };
    Mockito.doAnswer(mockScheduledExecutor)
           .when(mockExecutorService)
           .scheduleWithFixedDelay(Mockito.any(Runnable.class),
                                   Mockito.anyLong(),
                                   Mockito.anyLong(),
                                   Mockito.any(TimeUnit.class));
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:64,代码来源:PerformanceReporterTest.java


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