當前位置: 首頁>>代碼示例>>Java>>正文


Java DropwizardAppRule類代碼示例

本文整理匯總了Java中io.dropwizard.testing.junit.DropwizardAppRule的典型用法代碼示例。如果您正苦於以下問題:Java DropwizardAppRule類的具體用法?Java DropwizardAppRule怎麽用?Java DropwizardAppRule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DropwizardAppRule類屬於io.dropwizard.testing.junit包,在下文中一共展示了DropwizardAppRule類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: DropwizardAppWithPostgresRule

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
public DropwizardAppWithPostgresRule(String configPath, ConfigOverride... configOverrides) {
    configFilePath = resourceFilePath(configPath);
    postgres = new PostgresDockerRule();
    List<ConfigOverride> cfgOverrideList = newArrayList(configOverrides);
    cfgOverrideList.add(config("database.url", postgres.getConnectionUrl()));
    cfgOverrideList.add(config("database.user", postgres.getUsername()));
    cfgOverrideList.add(config("database.password", postgres.getPassword()));

    app = new DropwizardAppRule<>(
            AdminUsersApp.class,
            configFilePath,
            cfgOverrideList.toArray(new ConfigOverride[cfgOverrideList.size()])
    );
    createJpaModule(postgres);
    rules = RuleChain.outerRule(postgres).around(app);
    registerShutdownHook();
}
 
開發者ID:alphagov,項目名稱:pay-adminusers,代碼行數:18,代碼來源:DropwizardAppWithPostgresRule.java

示例2: readTimerCount

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
public static int readTimerCount(DropwizardAppRule<TestConfiguration> app, Client client, String timerName) {
    Response response = client.target(
        String.format(
            "http://localhost:%d/%s/metrics",
            app.getAdminPort(), app.getEnvironment().getAdminContext().getContextPath()
        ))
        .request()
        .get();

    assertThat(response.getStatus()).isEqualTo(200);

    JsonNode body = response.readEntity(JsonNode.class);

    if (!body.get("timers").has(timerName)) {
        return 0;
    }
    return body.get("timers").get(timerName).get("count").intValue();
}
 
開發者ID:timmolter,項目名稱:dropwizard-sundial,代碼行數:19,代碼來源:SundialBundleITBase.java

示例3: AbstractIT

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
protected AbstractIT(final Class<APP_CLASS> appClass,
                     final Class<DOC_REF_ENTITY> docRefEntityClass,
                     final String docRefType) {
    this.appClass = appClass;
    this.appRule =
            new DropwizardAppRule<>(this.appClass, resourceFilePath("config.yml"));

    this.docRefType = docRefType;
    this.docRefEntityClass = docRefEntityClass;
}
 
開發者ID:gchq,項目名稱:stroom-query,代碼行數:11,代碼來源:AbstractIT.java

示例4: RegisterRule

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
public RegisterRule() {
    this.appRule = new DropwizardAppRule<>(RegisterApplication.class,
            ResourceHelpers.resourceFilePath("test-app-config.yaml"));
    wipeRule = new WipeDatabaseRule(TestRegister.values());
    wholeRule = RuleChain
            .outerRule(appRule)
            .around(wipeRule);
}
 
開發者ID:openregister,項目名稱:openregister-java,代碼行數:9,代碼來源:RegisterRule.java

示例5: buildClient

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
public static Client buildClient(DropwizardAppRule<ConerCoreConfiguration> appRule,
                                 String clientNamePrefix) {
    Joiner joiner = Joiner.on("-").skipNulls();
    return new JerseyClientBuilder(appRule.getEnvironment())
            .using(appRule.getConfiguration().getJerseyClientConfiguration())
            .build(joiner.join(clientNamePrefix, TEST_CLIENT_NAME));
}
 
開發者ID:caeos,項目名稱:coner-core,代碼行數:8,代碼來源:IntegrationTestUtils.java

示例6: IntegrationTestStandardRequestDelegate

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
public IntegrationTestStandardRequestDelegate(
        DropwizardAppRule<ConerCoreConfiguration> rule,
        Client client
) {
    this.rule = rule;
    this.client = client;
}
 
開發者ID:caeos,項目名稱:coner-core,代碼行數:8,代碼來源:IntegrationTestStandardRequestDelegate.java

示例7: buildApp

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的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

示例8: startJob

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
public static void startJob(DropwizardAppRule<TestConfiguration> app, Client client, String jobName) {
    Response response = client.target(
        String.format(
            "http://localhost:%d/%s/tasks/startjob?JOB_NAME=%s",
            app.getAdminPort(), app.getEnvironment().getAdminContext().getContextPath(), jobName
        ))
        .request()
        .post(Entity.text(""));

    assertThat(response.getStatus()).isEqualTo(200);
}
 
開發者ID:timmolter,項目名稱:dropwizard-sundial,代碼行數:12,代碼來源:SundialBundleITBase.java

示例9: stopJob

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
public static boolean stopJob(DropwizardAppRule<TestConfiguration> app, Client client, String jobName) {
    Response response = client.target(
        String.format(
            "http://localhost:%d/%s/tasks/stopjob?JOB_NAME=%s",
            app.getAdminPort(), app.getEnvironment().getAdminContext().getContextPath(), jobName
        ))
        .request()
        .post(Entity.text(""));

    return response.getStatus() == 200;
}
 
開發者ID:timmolter,項目名稱:dropwizard-sundial,代碼行數:12,代碼來源:SundialBundleITBase.java

示例10: validateAppIsRunning

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
private static void validateAppIsRunning(DropwizardAppRule<Configuration> app) {
    final Client client = new JerseyClientBuilder(app.getEnvironment()).build("appOne");
    final Response response = client
            .target(String.format("http://localhost:%d", app.getLocalPort()))
            .request()
            .get();
    assertThat(response.getStatus()).isEqualTo(Response.Status.NO_CONTENT.getStatusCode());

    response.close();
}
 
開發者ID:yammer,項目名稱:tenacity,代碼行數:11,代碼來源:TenacityConfiguredBundleTest.java

示例11: getAppRule

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
public static DropwizardAppRule<Config> getAppRule() {
    return RULE;
}
 
開發者ID:gchq,項目名稱:stroom-stats,代碼行數:4,代碼來源:AbstractAppIT.java

示例12: createStandardRule

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
public static DropwizardAppRule<ApplicationConfig> createStandardRule() {
    return createStandardRuleWithTemplate("fixtures/systemtests/application-config-template.yml");
}
 
開發者ID:adamkewley,項目名稱:jobson,代碼行數:4,代碼來源:SystemTestHelpers.java

示例13: createStandardRuleWithTemplate

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
public static DropwizardAppRule<ApplicationConfig> createStandardRuleWithTemplate(String fixture) {
    try {
        final Path usersFilePath = Files.createTempFile(SystemTestHelpers.class.getSimpleName(), "user-file");
        final String users = fixture("fixtures/systemtests/users");
        Files.write(usersFilePath, users.getBytes());

        final Path sessionsFilePath = Files.createTempFile(SystemTestHelpers.class.getSimpleName(), "sessions-file");

        final Path jobSpecsDir = Files.createTempDirectory(TestJobSpecsAPI.class.getSimpleName());
        final List<JobSpec> specs =
                Arrays.asList(
                        TestHelpers.YAML_MAPPER.readValue(
                                fixture("fixtures/systemtests/jobspecs.yml"),
                                JobSpec[].class));
        for (JobSpec spec : specs) {
            Files.createDirectory(jobSpecsDir.resolve(spec.getId().toString()));

            final String specYAML = TestHelpers.YAML_MAPPER.writeValueAsString(spec);

            Files.write(jobSpecsDir.resolve(spec.getId().toString()).resolve(Constants.SPEC_DIR_SPEC_FILENAME), specYAML.getBytes());
        }

        // This is used by the second spec
        final String secondSpecScript = fixture("fixtures/systemtests/script.sh");
        Files.write(jobSpecsDir.resolve("second-spec").resolve("script.sh"), secondSpecScript.getBytes());

        final Path jobDataDir = Files.createTempDirectory(SystemTestHelpers.class.getSimpleName());
        final Path workingDirsDir = Files.createTempDirectory(SystemTestHelpers.class.getSimpleName());

        final String resolvedAppConfigText =
                fixture(fixture)
                        .replaceAll("\\$userFile", usersFilePath.toAbsolutePath().toString())
                        .replaceAll("\\$sessionsFile", sessionsFilePath.toAbsolutePath().toString())
                        .replaceAll("\\$jobSpecDir", jobSpecsDir.toAbsolutePath().toString())
                        .replaceAll("\\$jobDataDir", jobDataDir.toAbsolutePath().toString())
                        .replaceAll("\\$workingDirsDir", workingDirsDir.toAbsolutePath().toString());


        final Path resolvedAppConfigPath = Files.createTempFile(TestJobSpecsAPI.class.getSimpleName(), "config");

        Files.write(resolvedAppConfigPath, resolvedAppConfigText.getBytes());

        return new DropwizardAppRule<>(App.class, resolvedAppConfigPath.toString());
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
 
開發者ID:adamkewley,項目名稱:jobson,代碼行數:48,代碼來源:SystemTestHelpers.java

示例14: generateRequest

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
public static Invocation.Builder generateRequest(DropwizardAppRule<ApplicationConfig> rule, String absPath) {
    final String path = String.format("http://localhost:%d" + absPath, rule.getLocalPort());
    return rule.client().target(path).request();
}
 
開發者ID:adamkewley,項目名稱:jobson,代碼行數:5,代碼來源:SystemTestHelpers.java

示例15: generateAuthenticatedRequest

import io.dropwizard.testing.junit.DropwizardAppRule; //導入依賴的package包/類
public static Invocation.Builder generateAuthenticatedRequest(DropwizardAppRule<ApplicationConfig> rule, String absPath) {
    final Invocation.Builder ret = generateRequest(rule, absPath);
    authenticate(ret);
    return ret;
}
 
開發者ID:adamkewley,項目名稱:jobson,代碼行數:6,代碼來源:SystemTestHelpers.java


注:本文中的io.dropwizard.testing.junit.DropwizardAppRule類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。