io.dropwizard.Application Java Examples
The following examples show how to use
io.dropwizard.Application.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BootstrapProxyFactory.java From dropwizard-guicey with MIT License | 6 votes |
/** * @param bootstrap dropwizard bootstrap object * @param context guicey configuration context * @return dropwizard bootstrap proxy object */ @SuppressWarnings("unchecked") public static Bootstrap create(final Bootstrap bootstrap, final ConfigurationContext context) { try { final ProxyFactory factory = new ProxyFactory(); factory.setSuperclass(Bootstrap.class); final Class proxy = factory.createClass(); final Bootstrap res = (Bootstrap) proxy.getConstructor(Application.class).newInstance(new Object[]{null}); ((Proxy) res).setHandler((self, thisMethod, proceed, args) -> { // intercept only bundle addition if (thisMethod.getName().equals("addBundle")) { context.registerDropwizardBundles((ConfiguredBundle) args[0]); return null; } // other methods called as is return thisMethod.invoke(bootstrap, args); }); return res; } catch (Exception e) { throw new IllegalStateException("Failed to create Bootstrap proxy", e); } }
Example #2
Source File: ParametersInjectionDwTest.java From dropwizard-guicey with MIT License | 6 votes |
@Test void checkAllPossibleParams(Application app, AutoScanApplication app2, Configuration conf, TestConfiguration conf2, Environment env, ObjectMapper mapper, Injector injector, ClientSupport client, DummyService service, @Jit JitService jit) { assertNotNull(app); assertNotNull(app2); assertNotNull(conf); assertNotNull(conf2); assertNotNull(env); assertNotNull(mapper); assertNotNull(injector); assertNotNull(client); assertNotNull(service); assertNotNull(jit); assertEquals(client.getPort(), 8080); assertEquals(client.getAdminPort(), 8081); }
Example #3
Source File: TestGuiceyAppExtension.java From dropwizard-guicey with MIT License | 6 votes |
@SuppressWarnings({"unchecked", "checkstyle:Indentation"}) private <C extends Configuration> DropwizardTestSupport<C> create( final ExtensionContext context, final Class<? extends Application> app, final String configPath, final String configPrefix, final String... overrides) { // NOTE: DropwizardTestSupport.ServiceListener listeners would be called ONLY on start! return new DropwizardTestSupport<>((Class<? extends Application<C>>) app, configPath, configPrefix, application -> { final TestCommand<C> cmd = new TestCommand<>(application); // need to hold command itself in order to properly shutdown it later getExtensionStore(context).put(TestCommand.class, cmd); return cmd; }, ConfigOverrideUtils.convert(configPrefix, overrides)); }
Example #4
Source File: TestParametersSupport.java From dropwizard-guicey with MIT License | 6 votes |
@Override @SuppressWarnings("checkstyle:ReturnCount") public Object resolveParameter(final ParameterContext parameterContext, final ExtensionContext extensionContext) throws ParameterResolutionException { final Parameter parameter = parameterContext.getParameter(); final Class<?> type = parameter.getType(); if (ClientSupport.class.equals(type)) { return getClient(extensionContext); } final DropwizardTestSupport<?> support = Preconditions.checkNotNull(getSupport(extensionContext)); if (Application.class.isAssignableFrom(type)) { return support.getApplication(); } if (ObjectMapper.class.equals(type)) { return support.getObjectMapper(); } return InjectorLookup.getInjector(support.getApplication()) .map(it -> it.getInstance(getKey(parameter))) .get(); }
Example #5
Source File: ParametersInjectionGuiceyTest.java From dropwizard-guicey with MIT License | 6 votes |
@Test void checkAllPossibleParams(Application app, AutoScanApplication app2, Configuration conf, TestConfiguration conf2, Environment env, ObjectMapper mapper, Injector injector, ClientSupport clientSupport, DummyService service, @Jit JitService jit) { assertNotNull(app); assertNotNull(app2); assertNotNull(conf); assertNotNull(conf2); assertNotNull(env); assertNotNull(mapper); assertNotNull(injector); assertNotNull(clientSupport); assertNotNull(service); assertNotNull(jit); }
Example #6
Source File: TestParametersSupport.java From dropwizard-guicey with MIT License | 5 votes |
@Override @SuppressWarnings("checkstyle:ReturnCount") public boolean supportsParameter(final ParameterContext parameterContext, final ExtensionContext extensionContext) throws ParameterResolutionException { final Parameter parameter = parameterContext.getParameter(); if (parameter.getAnnotations().length > 0) { if (AnnotationSupport.isAnnotated(parameter, Jit.class)) { return true; } else if (!isQualifierAnnotation(parameter.getAnnotations())) { // if any other annotation declared on the parameter - skip it (possibly other extension's parameter) return false; } } final Class<?> type = parameter.getType(); if (Application.class.isAssignableFrom(type) || Configuration.class.isAssignableFrom(type)) { // special case when exact app or configuration class used return true; } else { for (Class<?> cls : supportedClasses) { if (type.equals(cls)) { return true; } } } // declared guice binding (by class only) return getInjector(extensionContext) .map(it -> it.getExistingBinding(getKey(parameter)) != null) .orElse(false); }
Example #7
Source File: InjectorLookup.java From dropwizard-guicey with MIT License | 5 votes |
/** * Used internally to register application specific injector. * * @param application application instance * @param injector injector instance */ public static void registerInjector(final Application application, final Injector injector) { // This method is actually not required anymore as guicey can register state directly // Preserving for backwards compatibility (possible usages in test integrations) SharedConfigurationState.getOrFail(application, "No shared state assigned to application") .put(Injector.class, injector); }
Example #8
Source File: GuiceyAppExtension.java From dropwizard-guicey with MIT License | 5 votes |
@SuppressWarnings({"unchecked", "checkstyle:Indentation"}) private <C extends Configuration> DropwizardTestSupport<C> create( final Class<? extends Application> app, final String configPath, final ConfigOverride... overrides) { return new DropwizardTestSupport<C>((Class<? extends Application<C>>) app, configPath, (String) null, application -> { command = new TestCommand<>(application); return command; }, overrides); }
Example #9
Source File: SharedConfigurationState.java From dropwizard-guicey with MIT License | 5 votes |
/** * Called on initialization phase to assign registry instance to application (to be able to statically * reference registry). * * @param application application instance */ protected void assignTo(final Application application) { this.application = application; Preconditions.checkState(!STATE.containsKey(application), "Shared state already associated with application %s", application.getClass().getName()); STATE.put(application, this); }
Example #10
Source File: GuiceyAppRule.java From dropwizard-guicey with MIT License | 5 votes |
public GuiceyAppRule(final Class<? extends Application<C>> applicationClass, @Nullable final String configPath, final ConfigOverride... configOverrides) { this.applicationClass = applicationClass; this.configPath = configPath; for (ConfigOverride configOverride : configOverrides) { configOverride.addToSystemProperties(); } }
Example #11
Source File: GuiceyAppRule.java From dropwizard-guicey with MIT License | 5 votes |
protected Application<C> newApplication() { try { return applicationClass.newInstance(); } catch (Exception e) { throw new IllegalStateException("Failed to instantiate application", e); } }
Example #12
Source File: AbstractAppTest.java From monasca-common with Apache License 2.0 | 5 votes |
public AbstractAppTest(Class<? extends Application<C>> applicationClass, String configPath, ConfigOverride... configOverrides) { this.applicationClass = applicationClass; this.configPath = configPath; for (ConfigOverride configOverride : configOverrides) { configOverride.addToSystemProperties(); } }
Example #13
Source File: TLSTruststoreTestCommand.java From dcos-commons with Apache License 2.0 | 5 votes |
public TLSTruststoreTestCommand(Application<T> application) { this( application, "truststoretest", "Runs GET request against HTTPS secured URL with provided truststore" ); }
Example #14
Source File: AbstractApplicationTest.java From dropwizard-pac4j with Apache License 2.0 | 5 votes |
public void setup( Class<? extends Application<TestConfiguration>> applicationClass, String configPath, ConfigOverride... configOverrides) { dropwizardTestSupport = new DropwizardTestSupport<>(applicationClass, ResourceHelpers.resourceFilePath(configPath), configOverrides); dropwizardTestSupport.before(); }
Example #15
Source File: AbstractAppTest.java From monasca-common with Apache License 2.0 | 5 votes |
public Application<C> newApplication() { try { return applicationClass.newInstance(); } catch (Exception e) { throw new RuntimeException(e); } }
Example #16
Source File: TestGuiceyAppExtension.java From dropwizard-guicey with MIT License | 4 votes |
public Builder(final Class<? extends Application> app) { this.cfg.app = Preconditions.checkNotNull(app, "Application class must be provided"); }
Example #17
Source File: TestDropwizardAppExtension.java From dropwizard-guicey with MIT License | 4 votes |
public Builder(final Class<? extends Application> app) { this.cfg.app = Preconditions.checkNotNull(app, "Application class must be provided"); }
Example #18
Source File: MetaAnnotationDwTest.java From dropwizard-guicey with MIT License | 4 votes |
@Test void checkAnnotationRecognized(Application app) { Assertions.assertNotNull(app); }
Example #19
Source File: ParametersInjectionDwTest.java From dropwizard-guicey with MIT License | 4 votes |
@BeforeAll static void before(Application app, DummyService service) { Preconditions.checkNotNull(app); Preconditions.checkNotNull(service); }
Example #20
Source File: ParametersInjectionDwTest.java From dropwizard-guicey with MIT License | 4 votes |
@BeforeEach void setUp(Application app, DummyService service) { Preconditions.checkNotNull(app); Preconditions.checkNotNull(service); }
Example #21
Source File: ParametersInjectionDwTest.java From dropwizard-guicey with MIT License | 4 votes |
@AfterEach void tearDown(Application app, DummyService service) { Preconditions.checkNotNull(app); Preconditions.checkNotNull(service); }
Example #22
Source File: ParametersInjectionDwTest.java From dropwizard-guicey with MIT License | 4 votes |
@AfterAll static void after(Application app, DummyService service) { Preconditions.checkNotNull(app); Preconditions.checkNotNull(service); }
Example #23
Source File: AbstractApplicationTests.java From trellis with Apache License 2.0 | 4 votes |
@Test void testGetName() { final Application<AppConfiguration> app = new TrellisApplication(); assertEquals("Trellis LDP", app.getName(), "Incorrect application name!"); }
Example #24
Source File: AnnotatedBaseDwTest.java From dropwizard-guicey with MIT License | 4 votes |
@Test void checkExtensionApplied(Application app) { Assertions.assertNotNull(app); }
Example #25
Source File: ParametersInjectionGuiceyTest.java From dropwizard-guicey with MIT License | 4 votes |
@BeforeAll static void before(Application app, DummyService service) { Preconditions.checkNotNull(app); Preconditions.checkNotNull(service); }
Example #26
Source File: ParametersInjectionGuiceyTest.java From dropwizard-guicey with MIT License | 4 votes |
@BeforeEach void setUp(Application app, DummyService service) { Preconditions.checkNotNull(app); Preconditions.checkNotNull(service); }
Example #27
Source File: ParametersInjectionGuiceyTest.java From dropwizard-guicey with MIT License | 4 votes |
@AfterEach void tearDown(Application app, DummyService service) { Preconditions.checkNotNull(app); Preconditions.checkNotNull(service); }
Example #28
Source File: ParametersInjectionGuiceyTest.java From dropwizard-guicey with MIT License | 4 votes |
@AfterAll static void after(Application app, DummyService service) { Preconditions.checkNotNull(app); Preconditions.checkNotNull(service); }
Example #29
Source File: MetaAnnotationGuiceyTest.java From dropwizard-guicey with MIT License | 4 votes |
@Test void checkAnnotationRecognized(Application app) { Assertions.assertNotNull(app); }
Example #30
Source File: AnnotatedBaseGuiceyTest.java From dropwizard-guicey with MIT License | 4 votes |
@Test void checkExtensionApplied(Application app) { Assertions.assertNotNull(app); }