Search in sources :

Example 6 with HttpProxy

use of org.apache.nifi.remote.protocol.http.HttpProxy in project nifi by apache.

the class SiteToSiteCliMainTest method testParseProxy.

@Test
public void testParseProxy() throws ParseException {
    String expectedHost = "testHost";
    int expectedPort = 292;
    String expectedUser = "testUser";
    String expectedPassword = "badPassword";
    expectedHttpProxy = new HttpProxy(expectedHost, expectedPort, expectedUser, expectedPassword);
    parseAndCheckExpected(new String[] { "--" + SiteToSiteCliMain.PROXY_HOST_OPTION, expectedHost, "--" + SiteToSiteCliMain.PROXY_PORT_OPTION, Integer.toString(expectedPort), "--" + SiteToSiteCliMain.PROXY_USERNAME_OPTION, expectedUser, "--" + SiteToSiteCliMain.PROXY_PASSWORD_OPTION, expectedPassword });
}
Also used : HttpProxy(org.apache.nifi.remote.protocol.http.HttpProxy) Test(org.junit.Test)

Example 7 with HttpProxy

use of org.apache.nifi.remote.protocol.http.HttpProxy in project nifi by apache.

the class SiteToSiteCliMainTest method parseAndCheckExpected.

private void parseAndCheckExpected(String[] args) throws ParseException {
    SiteToSiteCliMain.CliParse cliParse = SiteToSiteCliMain.parseCli(new Options(), args);
    SiteToSiteClient.Builder builder = cliParse.getBuilder();
    assertEquals(expectedUrl, builder.getUrl());
    assertEquals(expectedSiteToSiteTransportProtocol, builder.getTransportProtocol());
    assertEquals(expectedPortName, builder.getPortName());
    assertEquals(expectedPortIdentifier, builder.getPortIdentifier());
    assertEquals(expectedTimeoutNs, builder.getTimeout(TimeUnit.NANOSECONDS));
    assertEquals(expectedPenalizationNs, builder.getPenalizationPeriod(TimeUnit.NANOSECONDS));
    assertEquals(expectedKeystoreFilename, builder.getKeystoreFilename());
    assertEquals(expectedKeystorePass, builder.getKeystorePass());
    assertEquals(expectedKeystoreType, builder.getKeystoreType());
    assertEquals(expectedTruststoreFilename, builder.getTruststoreFilename());
    assertEquals(expectedTruststorePass, builder.getTruststorePass());
    assertEquals(expectedTruststoreType, builder.getTruststoreType());
    assertEquals(expectedCompression, builder.isUseCompression());
    assertEquals(expectedPeerPersistenceFile, builder.getPeerPersistenceFile());
    if (expectedHttpProxy == null) {
        assertNull(builder.getHttpProxy());
    } else {
        HttpProxy httpProxy = builder.getHttpProxy();
        assertNotNull(httpProxy);
        assertEquals(expectedHttpProxy.getHttpHost(), httpProxy.getHttpHost());
        assertEquals(expectedHttpProxy.getUsername(), httpProxy.getUsername());
        assertEquals(expectedHttpProxy.getPassword(), httpProxy.getPassword());
    }
    SiteToSiteClientConfig siteToSiteClientConfig = builder.buildConfig();
    assertEquals(expectedBatchCount, siteToSiteClientConfig.getPreferredBatchCount());
    assertEquals(expectedBatchDuration, siteToSiteClientConfig.getPreferredBatchDuration(TimeUnit.NANOSECONDS));
    assertEquals(expectedBatchSize, siteToSiteClientConfig.getPreferredBatchSize());
    assertEquals(expectedTransferDirection, cliParse.getTransferDirection());
}
Also used : SiteToSiteClient(org.apache.nifi.remote.client.SiteToSiteClient) HttpProxy(org.apache.nifi.remote.protocol.http.HttpProxy) Options(org.apache.commons.cli.Options) SiteToSiteClientConfig(org.apache.nifi.remote.client.SiteToSiteClientConfig)

Aggregations

HttpProxy (org.apache.nifi.remote.protocol.http.HttpProxy)7 SiteToSiteClient (org.apache.nifi.remote.client.SiteToSiteClient)3 Test (org.junit.Test)3 SSLContext (javax.net.ssl.SSLContext)2 SiteToSiteRestApiClient (org.apache.nifi.remote.util.SiteToSiteRestApiClient)2 File (java.io.File)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 DefaultParser (org.apache.commons.cli.DefaultParser)1 Options (org.apache.commons.cli.Options)1 ParseException (org.apache.commons.cli.ParseException)1 OnScheduled (org.apache.nifi.annotation.lifecycle.OnScheduled)1 EventReporter (org.apache.nifi.events.EventReporter)1 ComponentLog (org.apache.nifi.logging.ComponentLog)1 Transaction (org.apache.nifi.remote.Transaction)1 TransferDirection (org.apache.nifi.remote.TransferDirection)1 SiteToSiteClientConfig (org.apache.nifi.remote.client.SiteToSiteClientConfig)1 SiteToSiteTransportProtocol (org.apache.nifi.remote.protocol.SiteToSiteTransportProtocol)1