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


Java HttpProxyServer.stop方法代码示例

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


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

示例1: testSftpSimpleProduceThroughProxy

import org.littleshoot.proxy.HttpProxyServer; //导入方法依赖的package包/类
@Test
public void testSftpSimpleProduceThroughProxy() throws Exception {
    if (!canTest()) {
        return;
    }

    // start http proxy
    HttpProxyServer proxyServer = new DefaultHttpProxyServer(proxyPort);
    proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
        @Override
        public boolean authenticate(String userName, String password) {
            return "user".equals(userName) && "password".equals(password);
        }
    });
    proxyServer.start();

    template.sendBodyAndHeader("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin&proxy=#proxy", "Hello World", Exchange.FILE_NAME, "hello.txt");

    File file = new File(FTP_ROOT_DIR + "/hello.txt");
    assertTrue("File should exist: " + file, file.exists());
    assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
    
    proxyServer.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:SftpSimpleProduceThroughProxyTest.java

示例2: testSftpSimpleSubPathProduceThroughProxy

import org.littleshoot.proxy.HttpProxyServer; //导入方法依赖的package包/类
@Test
public void testSftpSimpleSubPathProduceThroughProxy() throws Exception {
    if (!canTest()) {
        return;
    }

    // start http proxy
    HttpProxyServer proxyServer = new DefaultHttpProxyServer(proxyPort);
    proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
        @Override
        public boolean authenticate(String userName, String password) {
            return "user".equals(userName) && "password".equals(password);
        }
    });
    proxyServer.start();

    template.sendBodyAndHeader("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "/mysub?username=admin&password=admin&proxy=#proxy", "Bye World", Exchange.FILE_NAME, "bye.txt");

    File file = new File(FTP_ROOT_DIR + "/mysub/bye.txt");
    assertTrue("File should exist: " + file, file.exists());
    assertEquals("Bye World", context.getTypeConverter().convertTo(String.class, file));

    proxyServer.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:SftpSimpleProduceThroughProxyTest.java

示例3: testSftpSimpleTwoSubPathProduceThroughProxy

import org.littleshoot.proxy.HttpProxyServer; //导入方法依赖的package包/类
@Test
public void testSftpSimpleTwoSubPathProduceThroughProxy() throws Exception {
    if (!canTest()) {
        return;
    }

    // start http proxy
    HttpProxyServer proxyServer = new DefaultHttpProxyServer(proxyPort);
    proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
        @Override
        public boolean authenticate(String userName, String password) {
            return "user".equals(userName) && "password".equals(password);
        }
    });
    proxyServer.start();

    template.sendBodyAndHeader("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "/mysub/myother?username=admin&password=admin&proxy=#proxy", "Farewell World", Exchange.FILE_NAME,
        "farewell.txt");

    File file = new File(FTP_ROOT_DIR + "/mysub/myother/farewell.txt");
    assertTrue("File should exist: " + file, file.exists());
    assertEquals("Farewell World", context.getTypeConverter().convertTo(String.class, file));

    proxyServer.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:SftpSimpleProduceThroughProxyTest.java

示例4: eSENS_TA10

import org.littleshoot.proxy.HttpProxyServer; //导入方法依赖的package包/类
/**
 * Prerequisite:<br>
 * SMSH and RMSH are configured to exchange AS4 messages according to the
 * e-SENS profile (One-Way/Push MEP). Simulate the RMSH to not send receipts
 * (can be done by intercepting the receipts). SMSH tries to send an AS4 User
 * Message to the RMSH.<br>
 * <br>
 * Predicate: <br>
 * The SMSH retries to send the AS4 User Message (at least once).
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void eSENS_TA10 () throws Exception
{
  final ICommonsMap <String, Object> aOldSettings = m_aSettings.getClone ();
  final int nProxyPort = 8001;
  m_aSettings.putIn (SETTINGS_SERVER_PROXY_ENABLED, true);
  m_aSettings.putIn (SETTINGS_SERVER_PROXY_ADDRESS, "localhost");
  m_aSettings.putIn (SETTINGS_SERVER_PROXY_PORT, nProxyPort);

  final HttpProxyServer aProxyServer = _startProxyServer (nProxyPort);
  try
  {
    // send message
    final MimeMessage aMsg = MimeMessageCreator.generateMimeMessage (m_eSOAPVersion,
                                                                     testSignedUserMessage (m_eSOAPVersion,
                                                                                            m_aPayload,
                                                                                            null,
                                                                                            new AS4ResourceManager ()),
                                                                     null);
    sendMimeMessage (new HttpMimeMessageEntity (aMsg), false, EEbmsError.EBMS_OTHER.getErrorCode ());
  }
  finally
  {
    aProxyServer.stop ();
    // Restore original properties
    m_aSettings.setAll (aOldSettings);
  }
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:42,代码来源:AS4eSENSCEFOneWayFuncTest.java

示例5: testSftpSimpleConsumeThroughProxy

import org.littleshoot.proxy.HttpProxyServer; //导入方法依赖的package包/类
@Test
public void testSftpSimpleConsumeThroughProxy() throws Exception {
    if (!canTest()) {
        return;
    }

    // start http proxy
    HttpProxyServer proxyServer = new DefaultHttpProxyServer(proxyPort);
    proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
        @Override
        public boolean authenticate(String userName, String password) {
            return "user".equals(userName) && "password".equals(password);
        }
    });
    proxyServer.start();

    String expected = "Hello World";

    // create file using regular file
    template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");

    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    mock.expectedHeaderReceived(Exchange.FILE_NAME, "hello.txt");
    mock.expectedBodiesReceived(expected);
    
    context.startRoute("foo");

    assertMockEndpointsSatisfied();
    
    proxyServer.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:SftpSimpleConsumeThroughProxyTest.java

示例6: testFetchWithProxy

import org.littleshoot.proxy.HttpProxyServer; //导入方法依赖的package包/类
@Test
public void testFetchWithProxy() {
    String protocolPrefix = "https.";

    // Remember current settings
    String oldProxyHost = System.getProperty(protocolPrefix + "proxyHost", null);
    String oldProxyPort = System.getProperty(protocolPrefix + "proxyPort", null);

    System.setProperty(protocolPrefix + "proxyHost", PROXY_HOST);
    System.setProperty(protocolPrefix + "proxyPort", PROXY_PORT);

    HttpProxyServer server = DefaultHttpProxyServer.bootstrap()
            .withPort(8887)
            .start();

    try {
        Appcast appcast = manager.fetch(new URL("https://drive.google.com/uc?export=download&id=0BxjtsbG95NcHX1VxaUpVVjFsN2M"));
        assertNotNull(appcast);
        System.out.println("Got latest online version: " + appcast.getLatestVersion());
    } catch (MalformedURLException | AppcastException ex) {
        fail("Fetching failed: " + ex.toString());
    }

    if (oldProxyHost != null && !oldProxyHost.isEmpty()) {
        System.setProperty(protocolPrefix + "proxyHost", oldProxyHost);
    } else {
        System.clearProperty(protocolPrefix + "proxyHost");
    }
    if (oldProxyPort != null && !oldProxyPort.isEmpty()) {
        System.setProperty(protocolPrefix + "proxyPort", oldProxyHost);
    } else {
        System.clearProperty(protocolPrefix + "proxyPort");
    }

    server.stop();
}
 
开发者ID:dimaki,项目名称:refuel,代码行数:37,代码来源:AppcastManagerTest.java

示例7: testUserSecretKeyFileWithProxy

import org.littleshoot.proxy.HttpProxyServer; //导入方法依赖的package包/类
@Test
public void testUserSecretKeyFileWithProxy()
{
    HttpProxyServer proxyServer = null;
    try {
         proxyServer = createProxyServer(PROXY_PORT);

        // setting embulk config
        final String pathPrefix = "/test/testUserPassword";
        String configYaml = "" +
                "type: sftp\n" +
                "host: " + HOST + "\n" +
                "port: " + PORT + "\n" +
                "user: " + USERNAME + "\n" +
                "secret_key_file: " + SECRET_KEY_FILE + "\n" +
                "secret_key_passphrase: " + SECRET_KEY_PASSPHRASE + "\n" +
                "path_prefix: " + testFolder.getRoot().getAbsolutePath() + pathPrefix + "\n" +
                "file_ext: txt\n" +
                "proxy: \n" +
                "  type: http\n" +
                "  host: " + PROXY_HOST + "\n" +
                "  port: " + PROXY_PORT + " \n" +
                "  user: " + USERNAME + "\n" +
                "  password: " + PASSWORD + "\n" +
                "  command: \n" +
                "formatter:\n" +
                "  type: csv\n" +
                "  newline: CRLF\n" +
                "  newline_in_field: LF\n" +
                "  header_line: true\n" +
                "  charset: UTF-8\n" +
                "  quote_policy: NONE\n" +
                "  quote: \"\\\"\"\n" +
                "  escape: \"\\\\\"\n" +
                "  null_string: \"\"\n" +
                "  default_timezone: 'UTC'";

        // runner.transaction -> ...
        run(configYaml);

        List<String> fileList = lsR(Lists.<String>newArrayList(), Paths.get(testFolder.getRoot().getAbsolutePath()));
        assertThat(fileList, hasItem(containsString(pathPrefix + "001.00.txt")));

        assertRecordsInFile(String.format("%s/%s001.00.txt",
                testFolder.getRoot().getAbsolutePath(),
                pathPrefix));
    }
    finally {
        if (proxyServer != null) {
            proxyServer.stop();
        }
    }
}
 
开发者ID:embulk,项目名称:embulk-output-sftp,代码行数:54,代码来源:TestSftpFileOutputPlugin.java

示例8: stop

import org.littleshoot.proxy.HttpProxyServer; //导入方法依赖的package包/类
public static void stop(HttpProxyServer proxyServer) {
	proxyServer.stop();
	System.out.println("*** STOPPED TEST PROXY SERVER ***");
}
 
开发者ID:jirkapinkas,项目名称:sitemonitoring-production,代码行数:5,代码来源:ProxyServerUtil.java


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