本文整理汇总了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();
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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());
}
}
);
}
示例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();
}
示例11: getSupport
import io.dropwizard.testing.DropwizardTestSupport; //导入依赖的package包/类
public final DropwizardTestSupport<DashboardTestConfiguration> getSupport() {
return SUPPORT;
}
示例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();
}