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


Java DropwizardTestSupport类代码示例

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


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

示例1: setUp

import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
@Before
public void setUp() {
    KeyStoreResource verifyHubKeystoreResource = aKeyStoreResource()
        .withCertificate("VERIFY-FEDERATION", aCertificate().withCertificate(METADATA_SIGNING_A_PUBLIC_CERT).build().getCertificate())
        .build();
    verifyHubKeystoreResource.create();
    applicationTestSupport = new DropwizardTestSupport<>(
        VerifyServiceProviderApplication.class,
        "verify-service-provider.yml",
        config("verifyHubConfiguration.environment", "COMPLIANCE_TOOL"),
        config("verifyHubConfiguration.metadata.uri", () -> String.format("http://localhost:%s/SAML2/metadata", wireMockServer.port())),
        config("msaMetadata.uri", msaServer::getUri),
        config("msaMetadata.expectedEntityId", MockMsaServer.MSA_ENTITY_ID),
        config("verifyHubConfiguration.metadata.expectedEntityId", HUB_ENTITY_ID),
        config("verifyHubConfiguration.metadata.trustStore.path", verifyHubKeystoreResource.getAbsolutePath()),
        config("verifyHubConfiguration.metadata.trustStore.password", verifyHubKeystoreResource.getPassword()),
        config("serviceEntityIds", "[\"http://some-service-entity-id\"]"),
        config("samlSigningKey", TEST_RP_PRIVATE_SIGNING_KEY),
        config("samlPrimaryEncryptionKey", TEST_RP_PRIVATE_ENCRYPTION_KEY)
    );

    IdaSamlBootstrap.bootstrap();
    wireMockServer.start();
    msaServer.serveDefaultMetadata();
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:26,代码来源:HubMetadataFeatureTest.java

示例2: createsPlainTextServer

import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
@Test
public void createsPlainTextServer() throws Exception {
    final DropwizardTestSupport<TestConfiguration> testSupport =
            new DropwizardTestSupport<>(TestApplication.class, resourceFilePath("grpc-test-config.yaml"));

    ManagedChannel channel = null;
    try {
        testSupport.before();
        channel = createPlaintextChannel(testSupport);
        final PersonServiceGrpc.PersonServiceBlockingStub client = PersonServiceGrpc.newBlockingStub(channel);

        final GetPersonResponse resp =
                client.getPerson(GetPersonRequest.newBuilder().setName(TEST_PERSON_NAME).build());
        assertEquals(TEST_PERSON_NAME, resp.getPerson().getName());
    } finally {
        testSupport.after();
        shutdownChannel(channel);
    }
}
 
开发者ID:msteinhoff,项目名称:dropwizard-grpc,代码行数:20,代码来源:GrpcServerTests.java

示例3: createsServerWithTls

import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
@Test
public void createsServerWithTls() throws Exception {
    final DropwizardTestSupport<TestConfiguration> testSupport = new DropwizardTestSupport<>(TestApplication.class,
        resourceFilePath("grpc-test-config.yaml"), Optional.empty(),
        ConfigOverride.config("grpcServer.certChainFile", getURIForResource("cert/server.crt")),
        ConfigOverride.config("grpcServer.privateKeyFile", getURIForResource("cert/server.key")));

    ManagedChannel channel = null;
    try {
        testSupport.before();
        channel = createClientChannelForEncryptedServer(testSupport);
        final PersonServiceGrpc.PersonServiceBlockingStub client = PersonServiceGrpc.newBlockingStub(channel);

        final GetPersonResponse resp =
                client.getPerson(GetPersonRequest.newBuilder().setName(TEST_PERSON_NAME).build());
        assertEquals(TEST_PERSON_NAME, resp.getPerson().getName());
    } finally {
        testSupport.after();
        shutdownChannel(channel);
    }
}
 
开发者ID:msteinhoff,项目名称:dropwizard-grpc,代码行数:22,代码来源:GrpcServerTests.java

示例4: grpcServerGetsStopped

import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
@Test
public void grpcServerGetsStopped() {
    final DropwizardTestSupport<TestConfiguration> testSupport =
            new DropwizardTestSupport<>(TestApplication.class, resourceFilePath("grpc-test-config.yaml"));

    ManagedChannel channel = null;
    try {
        testSupport.before();
        channel = createPlaintextChannel(testSupport);
        final PersonServiceGrpc.PersonServiceBlockingStub client = PersonServiceGrpc.newBlockingStub(channel);

        testSupport.after();

        try {
            // this should fail as the server is now stopped
            client.getPerson(GetPersonRequest.newBuilder().setName("blah").build());
            fail("Request should have failed.");
        } catch (final Exception e) {
            assertEquals(StatusRuntimeException.class, e.getClass());
            assertEquals(Code.UNAVAILABLE, ((StatusRuntimeException) e).getStatus().getCode());
        }
    } finally {
        testSupport.after();
        shutdownChannel(channel);
    }
}
 
开发者ID:msteinhoff,项目名称:dropwizard-grpc,代码行数:27,代码来源:GrpcServerTests.java

示例5: startApplicationWith

import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
public static DropwizardTestSupport<ApplicationConfiguration> startApplicationWith(
        int initialDelayInMillis, Class testClass, int periodInMillis) {

    ConfigOverride[] configOverrides = {
        ConfigOverride.config("testClasses", testClass.getName()),
        ConfigOverride.config("initialDelayInMillis", String.valueOf(initialDelayInMillis)),
        ConfigOverride.config("periodInMillis", String.valueOf(periodInMillis))
    };

    DropwizardTestSupport<ApplicationConfiguration> applicationConfigurationDropwizardTestSupport =
            new DropwizardTestSupport<>(Atam4jTestApplication.class,
                    ResourceHelpers.resourceFilePath("atam4j-config.yml"),
                    configOverrides);

    applicationConfigurationDropwizardTestSupport.before();
    return applicationConfigurationDropwizardTestSupport;
}
 
开发者ID:atam4j,项目名称:atam4j,代码行数:18,代码来源:Atam4jApplicationStarter.java

示例6: setUp

import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
@Before
public void setUp() {
    KeyStoreResource verifyHubKeystoreResource = aKeyStoreResource()
        .withCertificate("VERIFY-FEDERATION", aCertificate().withCertificate(METADATA_SIGNING_A_PUBLIC_CERT).build().getCertificate())
        .build();
    verifyHubKeystoreResource.create();
    this.applicationTestSupport = new DropwizardTestSupport<>(
        VerifyServiceProviderApplication.class,
        "verify-service-provider.yml",
        config("verifyHubConfiguration.metadata.uri", () -> String.format("http://localhost:%s/SAML2/metadata", hubServer.port())),
        config("msaMetadata.uri", () -> String.format("http://localhost:%s/matching-service/metadata", wireMockServer.port())),
        config("verifyHubConfiguration.metadata.expectedEntityId", HUB_ENTITY_ID),
        config("msaMetadata.expectedEntityId", MockMsaServer.MSA_ENTITY_ID),
        config("verifyHubConfiguration.metadata.trustStore.path", verifyHubKeystoreResource.getAbsolutePath()),
        config("verifyHubConfiguration.metadata.trustStore.password", verifyHubKeystoreResource.getPassword())
    );

    environmentHelper.setEnv(new HashMap<String, String>() {{
        put("VERIFY_ENVIRONMENT", "COMPLIANCE_TOOL");
        put("MSA_METADATA_URL", "some-msa-metadata-url");
        put("MSA_ENTITY_ID", "some-msa-entity-id");
        put("SERVICE_ENTITY_IDS", "[\"http://some-service-entity-id\"]");
        put("SAML_SIGNING_KEY", TEST_RP_PRIVATE_SIGNING_KEY);
        put("SAML_PRIMARY_ENCRYPTION_KEY", TEST_RP_PRIVATE_ENCRYPTION_KEY);
    }});

    IdaSamlBootstrap.bootstrap();
    wireMockServer.start();
    hubServer.serveDefaultMetadata();
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:31,代码来源:MsaMetadataFeatureTest.java

示例7: setup

import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
public void setup(
        Class<? extends Application<TestConfiguration>> applicationClass,
        String configPath, ConfigOverride... configOverrides) {
    dropwizardTestSupport = new DropwizardTestSupport<>(applicationClass,
            ResourceHelpers.resourceFilePath(configPath), configOverrides);
    dropwizardTestSupport.before();
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:8,代码来源:AbstractApplicationTest.java

示例8: createClientChannelForEncryptedServer

import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
/**
 * Creates a <code>ManagedChannel</code> connecting to an <b>encrypted</b> gRPC server in
 * <code>TestApplication</code> in <code>testSupport</code>. The certificate is taken from the
 * <code>GrpcServerFactory</code> in the configuration.
 *
 * @param testSupport the already initialised (started) <code>DropwizardTestSupport</code> instance
 * @return the channel connecting to the server (to be used in a client)
 */
public static ManagedChannel createClientChannelForEncryptedServer(
        final DropwizardTestSupport<TestConfiguration> testSupport) throws SSLException {
    final SslContext sslContext = GrpcSslContexts.forClient()
        .trustManager(testSupport.getConfiguration().getGrpcServerFactory().getCertChainFile().toFile()).build();
    final TestApplication application = testSupport.getApplication();
    return NettyChannelBuilder.forAddress("localhost", application.getServer().getPort()).sslContext(sslContext)
        .overrideAuthority("grpc-dropwizard.example.com").build();
}
 
开发者ID:msteinhoff,项目名称:dropwizard-grpc,代码行数:17,代码来源:Utils.java

示例9: buildApp

import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
public static DropwizardAppRule<TestConfiguration> buildApp(
    String configFile, final Before before
) {
    return new DropwizardAppRule<>(
        new DropwizardTestSupport<TestConfiguration>(
            TestApp.class, ResourceHelpers.resourceFilePath(configFile)
        ) {
            @Override
            public void before() {
                super.before();
                before.before(getEnvironment());
            }
        }
    );
}
 
开发者ID:timmolter,项目名称:dropwizard-sundial,代码行数:16,代码来源:SundialBundleITBase.java

示例10: setup

import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
protected void setup(Class<? extends Application<TestConfiguration>> applicationClass) {
    dropwizardTestSupport = new DropwizardTestSupport<>(applicationClass, ResourceHelpers.resourceFilePath("integration-test.yaml"),
            ConfigOverride.config("dataSource.url", "jdbc:hsqldb:mem:DbTest" + System.nanoTime() + "?hsqldb.translate_dti_types=false"));
    dropwizardTestSupport.before();
}
 
开发者ID:scottescue,项目名称:dropwizard-entitymanager,代码行数:6,代码来源:AbstractIntegrationTest.java

示例11: getSupport

import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
public final DropwizardTestSupport<DashboardTestConfiguration> getSupport() {
    return SUPPORT;
}
 
开发者ID:SeaCloudsEU,项目名称:SeaCloudsPlatform,代码行数:4,代码来源:AbstractProxyTest.java

示例12: createPlaintextChannel

import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
/**
 * Creates a <code>ManagedChannel</code> connecting to the <b>plaintext</b> gRPC server in
 * <code>TestApplication</code> in <code>testSupport</code>.
 *
 * @param testSupport the already initialised (started) <code>DropwizardTestSupport</code> instance
 * @return the channel connecting to the server (to be used in a client)
 */
public static ManagedChannel createPlaintextChannel(final DropwizardTestSupport<TestConfiguration> testSupport) {
    final TestApplication application = testSupport.getApplication();
    return ManagedChannelBuilder.forAddress("localhost", application.getServer().getPort()).usePlaintext(true)
        .build();
}
 
开发者ID:msteinhoff,项目名称:dropwizard-grpc,代码行数:13,代码来源:Utils.java


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