100+ results for 'google guice createinjector lang:java'
Not the results you expected?
FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeatTest.java (git://github.com/jclouds/jclouds.git) Java · 176 lines
31 import com.google.inject.AbstractModule;
32 import com.google.inject.Guice;
33 import com.google.inject.TypeLiteral;
105 public void testPropertyChangesDelimiter() {
106 GroupNamingConvention fn = Guice.createInjector(new AbstractModule() {
108 @Override
120 public void testPropertyChangesPrefix() {
121 GroupNamingConvention fn = Guice.createInjector(new AbstractModule() {
123 @Override
136 public void testCanChangeSuffixSupplier() {
137 GroupNamingConvention fn = Guice.createInjector(new AbstractModule() {
139 @Override
OrphanedGroupsFromDeadNodesTest.java (git://github.com/jclouds/jclouds.git) Java · 172 lines
15 * limitations under the License.
16 */
17 package org.jclouds.googlecomputeengine.compute.functions;
19 import static org.easymock.EasyMock.createMock;
30 import org.jclouds.compute.domain.NodeMetadata;
31 import org.jclouds.compute.domain.internal.NodeMetadataImpl;
32 import org.jclouds.googlecomputeengine.compute.predicates.GroupIsEmpty;
33 import org.testng.annotations.Test;
39 import com.google.inject.AbstractModule;
40 import com.google.inject.Guice;
42 public class OrphanedGroupsFromDeadNodesTest {
165 private Predicate<String> allNodesInGroupTerminated(final ComputeService mock) {
166 return Guice.createInjector(new AbstractModule() {
167 @Override protected void configure() {
168 bind(ComputeService.class).toInstance(mock);
ApplicationLoader.java (https://github.com/jeremychone/deprecated-snow-1.x.git) Java · 199 lines
17 import org.snowfk.web.db.hibernate.DefaultHibernateModule;
19 import com.google.inject.Guice;
20 import com.google.inject.Injector;
21 import com.google.inject.Module;
22 import com.google.inject.util.Modules;
152 rootModules.add(combineAppModule);
154 appInjector = Guice.createInjector(rootModules);
155 /*--------- /Load WebApplication ---------*/
JpaDynamicFindersTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 239 lines
19 import com.google.inject.AbstractModule;
20 import com.google.inject.Guice;
21 import com.google.inject.Inject;
22 import com.google.inject.Injector;
23 import com.wideplay.warp.persist.PersistenceService;
24 import com.wideplay.warp.persist.Transactional;
54 @BeforeClass
55 public void pre() {
56 injector = Guice.createInjector(PersistenceService.usingJpa()
57 .across(UnitOfWork.TRANSACTION)
58 .addAccessor(JpaTestAccessor.class)
ParseMetadataListTest.java (git://github.com/jclouds/jclouds.git) Java · 59 lines
EntityManagerPerRequestProvisionTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 148 lines
19 import com.google.inject.AbstractModule;
20 import com.google.inject.Guice;
21 import com.google.inject.Inject;
22 import com.google.inject.Injector;
23 import com.google.inject.matcher.Matchers;
47 @BeforeClass
48 public void pre() {
49 injector = Guice.createInjector(PersistenceService.usingJpa()
50 .across(UnitOfWork.REQUEST)
TestNavigator.java (http://heavylead.googlecode.com/svn/trunk/) Java · 429 lines
ExceptionMeteredTest.java (git://github.com/codahale/metrics.git) Java · 385 lines
1 package com.yammer.metrics.guice.tests;
3 import com.google.inject.Guice;
4 import com.google.inject.Injector;
22 @Before
23 public void setup() {
24 final Injector injector = Guice.createInjector(new InstrumentationModule());
25 instance = injector.getInstance(InstrumentedWithExceptionMetered.class);
26 registry = injector.getInstance(MetricsRegistry.class);
248 "timedAndExceptionExceptions"));
250 assertThat("Guice creates a metric",
251 timedMetric,
252 is(notNullValue()));
254 assertThat("Guice creates a timer",
255 timedMetric,
256 is(instanceOf(Timer.class)));
JnarioActivator.java (git://github.com/bmwcarit/Jnario.git) Java · 66 lines
15 import org.osgi.framework.BundleContext;
17 import com.google.inject.Guice;
18 import com.google.inject.Injector;
19 import com.google.inject.Module;
21 public class JnarioActivator extends AbstractUIPlugin {
44 public synchronized Injector getInjector() {
45 if (injector == null) {
46 injector = createInjector();
47 }
48 return injector;
53 Module sharedStateModule = getSharedStateModule();
54 Module jnarioModule = new JnarioUiModule(this);
55 return Guice.createInjector(Modules2.mixin(jnarioModule, sharedStateModule));
56 } catch (Exception e) {
57 logger.error("Failed to create injector for jnario");
ConfigModuleTest.java
(http://testability-explorer.googlecode.com/svn/trunk/)
Java · 139 lines
✨ Summary
This Java code is a test class for a Guice module that parses command-line arguments and configures a testing framework. It tests various scenarios, including parsing single and multiple classes, packages, and flags, as well as handling errors and edge cases. The tests verify the correctness of the parsed values and error messages.
This Java code is a test class for a Guice module that parses command-line arguments and configures a testing framework. It tests various scenarios, including parsing single and multiple classes, packages, and flags, as well as handling errors and edge cases. The tests verify the correctness of the parsed values and error messages.
16 package com.google.test.metric;
18 import com.google.inject.Guice;
19 import com.google.inject.Injector;
80 Injector injector = Guice.createInjector(new ConfigModule(new String[]{
81 "-cp", "not/default/path",
82 "com.google.FirstClass com.google.second.package com.google.third.package"},
83 outStream, errStream));
84 CommandLineConfig commandLineConfig = injector.getInstance(CommandLineConfig.class);
117 public void testJarFileNoClasspath() throws Exception {
118 Guice.createInjector(new ConfigModule(new String[] {"junit.runner", "-cp"},
119 outStream, errStream)).getInstance(CommandLineConfig.class);
120 /**
130 String fileUrl = "http://code.google.com/p/testability-explorer/source/browse/trunk/src/{path}";
131 Injector injector = Guice.createInjector(new ConfigModule(new String[]{
132 "-srcFileLineUrl", lineUrl, "-srcFileUrl", fileUrl},
133 outStream, errStream));
VarargsServletDispatchIntegrationTest.java (https://code.google.com/p/google-guice/) Java · 235 lines
22 import static org.easymock.EasyMock.verify;
24 import com.google.inject.Guice;
25 import com.google.inject.Injector;
62 public final void testDispatchRequestToManagedPipelineServlets()
63 throws ServletException, IOException {
64 final Injector injector = Guice.createInjector(new ServletModule() {
66 @Override
102 public final void testVarargsSkipDispatchRequestToManagedPipelineServlets()
103 throws ServletException, IOException {
104 final Injector injector = Guice.createInjector(new ServletModule() {
106 @Override
142 public final void testDispatchRequestToManagedPipelineWithFilter()
143 throws ServletException, IOException {
144 final Injector injector = Guice.createInjector(new ServletModule() {
146 @Override
WMLActivator.java (git://pkgs.fedoraproject.org/wesnoth) Java · 83 lines
6 import static com.google.inject.util.Modules.override;
7 import static com.google.inject.Guice.createInjector;
9 import org.apache.log4j.Logger;
12 import org.osgi.framework.BundleContext;
14 import com.google.inject.Injector;
15 import com.google.inject.Module;
46 protected void registerInjectorFor(String language) throws Exception {
47 injectors.put(language, createInjector(
48 override(override(getRuntimeModule(language)).with(getSharedStateModule())).with(getUiModule(language))));
49 }
DwrGuiceServletContextListener.java (git://github.com/burris/dwr.git) Java · 118 lines
14 * limitations under the License.
15 */
16 package org.directwebremoting.guice;
18 import java.util.prefs.Preferences;
20 import com.google.inject.Guice;
21 import com.google.inject.Injector;
31 * @author Tim Peierls [tim at peierls dot net]
32 */
33 public abstract class DwrGuiceServletContextListener extends AbstractDwrGuiceServletContextListener
34 {
35 /**
39 protected final Injector createInjector()
40 {
41 return Guice.createInjector(getStage(), new DwrScopeBinder(this));
42 }
BindProviderMetadataContextAndCredentialsTest.java (git://github.com/jclouds/jclouds.git) Java · 146 lines
46 import com.google.common.reflect.TypeToken;
47 import com.google.inject.Guice;
48 import com.google.inject.Key;
99 .password("password").build());
101 ExpectedBindings bindings = Guice.createInjector(new BindProviderMetadataContextAndCredentials(md, creds))
102 .getInstance(ExpectedBindings.class);
103 assertEquals(bindings.creds.identity, "user");
111 Supplier<Credentials> creds = Suppliers.<Credentials> ofInstance(LoginCredentials.builder().user("user").build());
113 ExpectedBindings bindings = Guice.createInjector(new BindProviderMetadataContextAndCredentials(md, creds))
114 .getInstance(ExpectedBindings.class);
115 assertEquals(bindings.creds.identity, "user");
125 Supplier<Credentials> creds = Suppliers.<Credentials> ofInstance(LoginCredentials.builder().user("user").build());
127 ExpectedBindings bindings = Guice.createInjector(new BindProviderMetadataContextAndCredentials(md, creds))
128 .getInstance(ExpectedBindings.class);
129 assertEquals(bindings.buildVersion, null);
VarargsFilterDispatchIntegrationTest.java (https://code.google.com/p/google-guice/) Java · 183 lines
6 import static org.easymock.EasyMock.verify;
8 import com.google.inject.Guice;
9 import com.google.inject.Injector;
47 public final void testDispatchRequestToManagedPipeline() throws ServletException, IOException {
48 final Injector injector = Guice.createInjector(new ServletModule() {
50 @Override
87 public final void testDispatchThatNoFiltersFire() throws ServletException, IOException {
88 final Injector injector = Guice.createInjector(new ServletModule() {
90 @Override
127 IOException {
129 final Injector injector = Guice.createInjector(new ServletModule() {
131 @Override
ListDomainsResponseTest.java (git://github.com/jclouds/jclouds.git) Java · 60 lines
CreateUniqueKeyTest.java (git://github.com/jclouds/jclouds.git) Java · 102 lines
41 import org.testng.annotations.Test;
43 import com.google.common.base.Supplier;
44 import com.google.common.base.Suppliers;
45 import com.google.common.collect.ImmutableMap;
46 import com.google.inject.AbstractModule;
47 import com.google.inject.Guice;
48 import com.google.inject.TypeLiteral;
60 @BeforeClass
61 public void setup() throws InvalidKeySpecException, NoSuchAlgorithmException, IOException {
62 namingConvention = Guice.createInjector(new AbstractModule() {
64 @Override
CustomizingTheSpecCreationSpec.java (git://github.com/bmwcarit/Jnario.git) Java · 94 lines
25 * framework should be used for creating specs. To do so, create a custom `SpecCreator` and
26 * annotate your spec with `CreateWith` and pass as a value the type of the custom `SpecCreator`.
27 * Here is an example for a custom `SpecCreator` that uses Google Guice to create the specification:
28 *
29 * <pre class="prettyprint">
30 * package org.jnario.lib;
31 *
32 * import com.google.inject.Guice;
33 * import com.google.inject.util.Modules;
35 * public class GuiceSpecCreator extends AbstractSpecCreator {
36 * public Object create(Class<?> klass) throws Exception {
37 * return Guice.createInjector(Modules.EMPTY_MODULE).getInstance(klass);
38 * }
39 * }
55 /**
56 * This example uses the Google Guice to instantiate the specification.
57 * @filter('''|.executesSuccessfully)
58 */
Guice1TestPlugin.java
(http://mycila.googlecode.com/svn/)
Java · 129 lines
✨ Summary
This Java code is a Guice plugin for testing, allowing developers to easily create test instances with dependencies injected using Guice. It generates modules and bindings based on annotations on test classes and methods, enabling easy setup of test environments. The plugin uses reflection to inspect annotations and generate the necessary configuration for Guice.
This Java code is a Guice plugin for testing, allowing developers to easily create test instances with dependencies injected using Guice. It generates modules and bindings based on annotations on test classes and methods, enabling easy setup of test environments. The plugin uses reflection to inspect annotations and generate the necessary configuration for Guice.
15 */
17 package com.mycila.testing.plugin.guice;
19 import com.google.inject.*;
20 import com.google.inject.binder.AnnotatedBindingBuilder;
21 import com.google.inject.binder.LinkedBindingBuilder;
22 import com.google.inject.binder.ScopedBindingBuilder;
39 public void prepareTestInstance(Context context) {
40 GuiceContext ctx = context.getTest().getTargetClass().getAnnotation(GuiceContext.class);
41 List<Module> modules = new ArrayList<Module>();
42 modules.addAll(contextualModules(ctx));
47 modules.add((Module) context.getTest().getTarget());
48 }
49 Injector injector = Guice.createInjector(findStage(ctx), modules);
50 context.setAttribute("com.google.inject.Injector", injector);
InteractiveExample.java (https://bitbucket.org/sgla/aiml-core.git) Java · 80 lines
9 import javax.inject.Inject;
11 import com.google.inject.Guice;
12 import com.google.inject.Injector;
72 public static void main(String[] args)
73 {
74 Injector injector = Guice.createInjector(new AIMLModule());
75 InteractiveExample example = new InteractiveExample();
76 injector.injectMembers(example);
SessionFactoryProvisionTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 85 lines
19 import com.google.inject.AbstractModule;
20 import com.google.inject.Guice;
21 import com.google.inject.Injector;
22 import com.google.inject.matcher.Matchers;
23 import com.wideplay.codemonkey.web.startup.Initializer;
24 import com.wideplay.warp.persist.PersistenceService;
48 @BeforeTest
49 public void pre() {
50 injector = Guice.createInjector(PersistenceService.usingHibernate()
51 .across(UnitOfWork.TRANSACTION)
52 .forAll(Matchers.any())
RefDslActivator.java (http://grooveclipse.googlecode.com/svn/trunk/) Java · 96 lines
6 import static com.google.inject.util.Modules.override;
7 import static com.google.inject.Guice.createInjector;
9 import org.apache.log4j.Logger;
12 import org.osgi.framework.BundleContext;
14 import com.google.inject.Injector;
15 import com.google.inject.Module;
16 import com.google.common.cache.Cache;
17 import com.google.common.cache.CacheBuilder;
18 import com.google.common.cache.CacheLoader;
20 import java.util.concurrent.ExecutionException;
Main.java (git://github.com/restlet/restlet-framework-java.git) Java · 184 lines
38 import org.restlet.ext.guice.FinderFactory;
39 import org.restlet.ext.guice.RestletGuice;
40 import org.restlet.resource.Get;
41 import org.restlet.resource.ServerResource;
45 import com.google.inject.Injector;
46 import com.google.inject.Module;
48 /**
51 * instances obtained from a FinderFactory. A command line argument controls
52 * whether the Injector behind the FinderFactory is created explicitly with
53 * RestletGuice or implicitly from the first use of RestletGuice.Module as a
54 * FinderFactory.
55 */
158 switch (mode) {
159 case EXPLICIT_INJECTOR:
160 Injector injector = RestletGuice.createInjector(bindings);
161 ff = injector.getInstance(FinderFactory.class);
162 break;
GuiceSelfInjectingServerResourceModuleTestCase.java (git://github.com/restlet/restlet-framework-java.git) Java · 145 lines
23 */
25 package org.restlet.test.ext.guice;
27 import javax.inject.Inject;
35 import org.restlet.data.MediaType;
36 import org.restlet.data.Protocol;
37 import org.restlet.ext.guice.SelfInjectingServerResource;
38 import org.restlet.ext.guice.SelfInjectingServerResourceModule;
44 import com.google.inject.AbstractModule;
45 import com.google.inject.Guice;
46 import com.google.inject.Provides;
109 super.setUp();
111 Guice.createInjector(new TestModule(),
112 new SelfInjectingServerResourceModule());
RestfuWebServiceWithSubpaths2AcceptanceTest.java
(git://github.com/dhanji/sitebricks.git)
Java · 167 lines
✨ Summary
This Java code is a test class for a RESTful web service using SiteBricks, a Java framework for building web applications. It tests various HTTP methods (GET, POST, PUT, DELETE) on different URL paths to ensure they return expected responses. The tests verify the correct handling of dynamic and static paths, as well as mixed path scenarios with multiple HTTP methods.
This Java code is a test class for a RESTful web service using SiteBricks, a Java framework for building web applications. It tests various HTTP methods (GET, POST, PUT, DELETE) on different URL paths to ensure they return expected responses. The tests verify the correct handling of dynamic and static paths, as well as mixed path scenarios with multiple HTTP methods.
4 import com.google.inject.AbstractModule;
5 import com.google.inject.Guice;
6 import com.google.inject.Injector;
7 import com.google.sitebricks.acceptance.util.AcceptanceTest;
8 import com.google.sitebricks.client.Web;
25 public void shouldServiceTopLevelDynamicPath() {
26 WebResponse response = createInjector()
27 .getInstance(Web.class)
28 .clientOf(AcceptanceTest.baseUrl() + "/superpath2/" + TOPLEVEL)
137 private Injector createInjector() {
138 return Guice.createInjector(new AbstractModule() {
139 protected void configure() {
140 bind(ConverterRegistry.class).toInstance(new StandardTypeConverter(
EdslTest.java (git://pkgs.fedoraproject.org/google-guice) Java · 107 lines
1 /**
2 * Copyright (C) 2008 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
18 import com.google.inject.AbstractModule;
19 import com.google.inject.Guice;
20 import com.google.inject.Injector;
35 public final void testExplicitBindingsWorksWithGuiceServlet() {
36 Injector injector = Guice.createInjector(
37 new AbstractModule() {
38 @Override
103 //verify that it doesn't blow up!
104 Guice.createInjector(Stage.TOOL, webModule);
105 }
106 }
ManagedLocalTransactionsTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 145 lines
9 import org.hibernate.SessionFactory;
10 import org.hibernate.criterion.Expression;
11 import com.google.inject.Guice;
12 import com.google.inject.Injector;
13 import com.google.inject.Inject;
14 import com.google.inject.AbstractModule;
15 import com.google.inject.matcher.Matchers;
16 import com.wideplay.codemonkey.web.startup.Initializer;
17 import com.wideplay.warp.persist.*;
34 @BeforeClass
35 public void pre() {
36 injector = Guice.createInjector(PersistenceService.usingHibernate()
37 .across(UnitOfWork.TRANSACTION)
38 .transactedWith(TransactionStrategy.LOCAL)
GuiceXamp.java (https://github.com/dburger/archive.git) Java · 160 lines
1 package com.dburger.guice.xamp;
3 import com.google.inject.AbstractModule;
4 import com.google.inject.Guice;
5 import com.google.inject.Inject;
6 import com.google.inject.Injector;
7 import com.google.inject.Provider;
8 import com.google.inject.Provides;
10 import com.google.inject.name.Named;
152 System.out.println("hello world, going to inject...");
153 System.out.println("=================================================");
154 Injector injector = Guice.createInjector(new WorldDominationModule());
155 WorldDominator wd = injector.getInstance(WorldDominator.class);
156 wd.dominate();
ParseCreatedMachineTest.java (git://github.com/jclouds/jclouds.git) Java · 81 lines
30 import org.testng.annotations.Test;
32 import com.google.common.collect.ImmutableMap;
33 import com.google.common.collect.ImmutableSet;
34 import com.google.inject.Guice;
35 import com.google.inject.Injector;
69 protected Injector injector() {
70 return Guice.createInjector(new GsonModule() {
72 @Override
ParseMachineTest.java (git://github.com/jclouds/jclouds.git) Java · 80 lines
30 import org.testng.annotations.Test;
32 import com.google.common.collect.ImmutableMap;
33 import com.google.common.collect.ImmutableSet;
34 import com.google.inject.Guice;
35 import com.google.inject.Injector;
68 protected Injector injector() {
69 return Guice.createInjector(new GsonModule() {
71 @Override
ParseVmSpecificationTest.java (git://github.com/jclouds/jclouds.git) Java · 74 lines
GuiceServletConfig.java (git://github.com/jersey/jersey-1.x.git) Java · 69 lines
41 package com.sun.jersey.test.functional.guice;
43 import com.google.inject.Guice;
44 import com.google.inject.Injector;
45 import com.google.inject.servlet.GuiceServletContextListener;
46 import com.google.inject.servlet.ServletModule;
47 import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
48 import com.sun.jersey.test.functional.guice.resources.PerRequestResource;
52 * @author paulsandoz
53 */
54 public class GuiceServletConfig extends GuiceServletContextListener {
56 @Override
AbstractDwrGuiceServletContextListener.java (git://github.com/burris/dwr.git) Java · 134 lines
16 package org.directwebremoting.guice;
18 import static org.directwebremoting.guice.DwrGuiceUtil.INJECTOR;
20 import java.util.ArrayList;
28 import org.apache.commons.logging.LogFactory;
30 import static org.directwebremoting.guice.util.ContextCloseHandlers.newExceptionLoggingCloseableHandler;
32 import com.google.inject.Injector;
47 {
48 final ServletContext servletContext = servletContextEvent.getServletContext();
49 DwrGuiceUtil.withServletContext(servletContext, new Runnable()
50 {
51 public void run()
AssignCorrectHostnameForBucketTest.java (git://github.com/jclouds/jclouds.git) Java · 71 lines
27 import org.testng.annotations.Test;
29 import com.google.common.base.Functions;
30 import com.google.common.base.Optional;
31 import com.google.common.base.Supplier;
32 import com.google.common.base.Suppliers;
34 import com.google.inject.Binder;
35 import com.google.inject.Guice;
36 import com.google.inject.Module;
39 @Test
40 public class AssignCorrectHostnameForBucketTest {
41 static final RegionToEndpointOrProviderIfNull REGION_TO_ENDPOINT = Guice.createInjector(new Module() {
42 @Override public void configure(Binder binder) {
43 binder.bindConstant().annotatedWith(Provider.class).to("s3");
OrphanedGroupsByRegionIdTest.java (git://github.com/jclouds/jclouds.git) Java · 91 lines
35 import org.testng.annotations.Test;
37 import com.google.common.base.Predicates;
38 import com.google.common.base.Supplier;
39 import com.google.common.base.Suppliers;
40 import com.google.common.collect.ImmutableMap;
42 import com.google.common.collect.ImmutableSet;
43 import com.google.inject.Guice;
45 @Test(testName = "OrphanedGroupsByRegionIdTest")
53 .<String, Location> of("az-1.region-a.geo-1", region));
55 GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);
57 @Test
CreateDriveRequestToMapTest.java (git://github.com/jclouds/jclouds.git) Java · 62 lines
25 import org.testng.annotations.Test;
27 import com.google.common.collect.ImmutableMap;
28 import com.google.common.collect.ImmutableSet;
29 import com.google.inject.Guice;
31 @Test(groups = { "unit" })
32 public class CreateDriveRequestToMapTest {
34 private static final CreateDriveRequestToMap BASEDRIVE_TO_MAP = Guice.createInjector().getInstance(
35 CreateDriveRequestToMap.class);
CreateSharedIpGroupOptionsTest.java (git://github.com/jclouds/jclouds.git) Java · 74 lines
TestEditSettingsPresenter.java (http://heavylead.googlecode.com/svn/trunk/) Java · 263 lines
OhaiModuleTest.java (git://github.com/jclouds/jclouds-chef.git) Java · 140 lines
36 import org.testng.annotations.Test;
38 import com.google.common.base.Supplier;
39 import com.google.common.base.Suppliers;
40 import com.google.inject.AbstractModule;
41 import com.google.inject.Guice;
42 import com.google.inject.Injector;
61 sysProperties.setProperty("user.name", "user");
63 Injector injector = Guice.createInjector(new ChefParserModule(), new GsonModule(), new OhaiModule() {
64 @Override
65 protected Long millis() {
90 sysProperties.setProperty("user.name", "user");
92 Injector injector = Guice.createInjector(new ChefParserModule(), new GsonModule(), new OhaiModule() {
93 @Override
94 protected Long millis() {
ParseOsFamilyVersion64BitFromImageNameTest.java (git://github.com/jclouds/jclouds.git) Java · 74 lines
17 package org.jclouds.glesys.compute.functions;
19 import static com.google.common.collect.Iterables.transform;
20 import static com.google.common.collect.Lists.newArrayList;
36 import org.testng.annotations.Test;
38 import com.google.common.base.Function;
39 import com.google.gson.Gson;
40 import com.google.inject.Guice;
41 import com.google.inject.TypeLiteral;
66 ParseOsFamilyVersion64BitFromImageName parser = new ParseOsFamilyVersion64BitFromImageName(new BaseComputeServiceContextModule() {
67 }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule())
68 .getInstance(Json.class)));
DataHandler.java (https://code.google.com/p/rabbit-eclipse/) Java · 117 lines
ParseCookbookDefinitionFromJsonTest.java (git://github.com/jclouds/jclouds.git) Java · 75 lines
JacobRunner.java (http://mu-labs.googlecode.com/svn/trunk/) Java · 112 lines
33 import com.google.inject.Binder;
34 import com.google.inject.Guice;
35 import com.google.inject.Injector;
36 import com.google.inject.Module;
37 import com.mu.jacob.core.ant.ConfigModule;
38 import com.mu.jacob.core.builder.IBuilder;
48 private ElementModule elementModule = new ElementModule();
50 /* Custom module for Guice DI */
51 private Module module = null;
79 ConfigModule configModule = new ConfigModule();
80 Module customModule = (module != null)? module : emptyModule;
81 Injector injector = Guice.createInjector(configModule, decoratorModule, elementModule, customModule);
83 // Create configuration
GuiceAwareValidationTestCase.java (git://pkgs.fedoraproject.org/bval) Java · 96 lines
15 * limitations under the License.
16 */
17 package org.apache.bval.guice;
19 import java.util.Set;
26 import junit.framework.TestCase;
28 import com.google.inject.Guice;
30 /**
51 @Override
52 protected void setUp() throws Exception {
53 Guice.createInjector(new ValidationModule()).injectMembers(this);
54 }
NamesTest.java (https://code.google.com/p/google-guice/) Java · 113 lines
24 import com.google.inject.AbstractModule;
25 import com.google.inject.Guice;
26 import com.google.inject.Injector;
61 teams.setProperty("Edmonton", "Oilers");
63 Injector injector = Guice.createInjector(new AbstractModule() {
64 protected void configure() {
65 Names.bindProperties(binder(), teams);
75 "SanJose", "Sharks", "Edmonton", "Oilers");
77 Injector injector = Guice.createInjector(new AbstractModule() {
78 protected void configure() {
79 Names.bindProperties(binder(), properties);
94 teams.setProperty("Edmonton", "Oilers");
96 Injector injector = Guice.createInjector(new AbstractModule() {
97 protected void configure() {
98 Names.bindProperties(binder(), teams);
SfVsMk2.java (http://java-fighting-game-engine.googlecode.com/svn/trunk/) Java · 150 lines
40 import android.view.Window;
42 import com.google.inject.Guice;
43 import com.google.inject.Injector;
44 import com.google.inject.Key;
45 import com.google.inject.TypeLiteral;
46 import com.google.inject.name.Names;
65 */
66 public SfVsMk2() {
67 injector = Guice.createInjector(
68 new EngineModule(),
69 new AndroidGraphicsModule(this),
InterceptingBindingsBuilderTest.java (http://guiceberry.googlecode.com/svn/trunk/) Java · 237 lines
79 };
81 Injector injector = Guice.createInjector(new InterceptingBindingsBuilder()
82 .intercept(String.class)
83 .install(module)
117 };
119 Injector injector = Guice.createInjector(new InterceptingBindingsBuilder()
120 .intercept(Integer.class)
121 .install(module)
223 };
225 Injector injector = Guice.createInjector(new InterceptingBindingsBuilder()
226 .intercept(List.class)
227 .intercept(Collection.class)
VCloudDirectorErrorHandlerTest.java (git://github.com/jclouds/jclouds.git) Java · 103 lines
35 import org.testng.annotations.Test;
37 import com.google.inject.Guice;
39 /**
64 String content, Class<? extends Exception> expected) {
66 VCloudDirectorErrorHandler function = Guice.createInjector().getInstance(VCloudDirectorErrorHandler.class);
68 HttpCommand command = createMock(HttpCommand.class);
GuiceFactoryTest.java (git://github.com/cucumber/cucumber-jvm.git) Java · 199 lines
40 @Test
41 public void factoryCanBeIntantiatedWithArgConstructor() {
42 factory = new GuiceFactory(Guice.createInjector());
43 assertThat(factory, notNullValue());
44 }
46 @Test
47 public void factoryStartFailsIfScenarioScopeIsNotBound() {
48 factory = new GuiceFactory(Guice.createInjector());
49 try {
50 factory.start();
162 private Injector injector(Module... module) {
163 return Guice.createInjector(Stage.PRODUCTION, module);
164 }
XadesProfileCore.java (http://xades4j.googlecode.com/svn/trunk/) Java · 227 lines
19 import com.google.inject.Binder;
20 import com.google.inject.Guice;
21 import com.google.inject.Key;
22 import com.google.inject.Module;
23 import com.google.inject.TypeLiteral;
24 import com.google.inject.multibindings.MapBinder;
25 import com.google.inject.multibindings.Multibinder;
26 import com.google.inject.util.Modules;
27 import com.google.inject.util.Types;
217 try
218 {
219 return Guice.createInjector(finalModules).getInstance(clazz);
220 }
221 catch (RuntimeException ex)
BindHexEncodedMD5sToJsonPayloadTest.java (git://github.com/jclouds/jclouds.git) Java · 70 lines
17 package org.jclouds.chef.binders;
19 import static com.google.common.io.BaseEncoding.base16;
20 import static com.google.common.primitives.Bytes.asList;
32 import org.testng.annotations.Test;
34 import com.google.common.collect.ImmutableSet;
35 import com.google.inject.AbstractModule;
36 import com.google.inject.Guice;
37 import com.google.inject.Injector;
40 public class BindHexEncodedMD5sToJsonPayloadTest {
42 Injector injector = Guice.createInjector(new AbstractModule() {
43 @Override
44 protected void configure() {
ListenerSingleInjectionTestCase.java (https://bitbucket.org/noctarius/guiceidentityinjection) Java · 218 lines
39 final Listener listener = new Listener();
41 final Injector injector = Guice.createInjector(new IdentityModule() {
42 @Override
43 protected void configure() {
96 final Listener listener = new Listener();
98 final Injector injector = Guice.createInjector(new IdentityModule() {
99 @Override
100 protected void configure() {
127 final Listener listener = new Listener();
129 final Injector injector = Guice.createInjector(new IdentityModule() {
130 @Override
131 protected void configure() {
GwtRpcServiceImplTest.java
(https://code.google.com/p/gwtrpccommlayer/)
Java · 122 lines
✨ Summary
This Java code tests a GWT RPC service implementation, specifically GwtRpcServiceImpl
. It sets up a server with Guice and creates instances of TestService
and TestServiceAsync
, which are proxy-based services generated by the RPC framework. The test verifies that these services can be created and used successfully, including synchronous and asynchronous calls.
This Java code tests a GWT RPC service implementation, specifically GwtRpcServiceImpl
. It sets up a server with Guice and creates instances of TestService
and TestServiceAsync
, which are proxy-based services generated by the RPC framework. The test verifies that these services can be created and used successfully, including synchronous and asynchronous calls.
3 import com.google.gwt.user.client.rpc.AsyncCallback;
4 import com.google.inject.Guice;
5 import com.google.inject.Injector;
6 import com.google.inject.internal.Preconditions;
7 import com.google.inject.servlet.GuiceFilter;
8 import com.google.inject.servlet.GuiceServletContextListener;
38 @Before
39 public void setUp() throws Exception {
40 injector = Guice.createInjector(new Module());
42 }
55 @Override
56 protected Injector getInjector() {
57 return Guice.createInjector(new ServletModule() {
58 @Override
59 protected void configureServlets() {
ParseImageTest.java (git://github.com/jclouds/jclouds.git) Java · 95 lines
34 import org.testng.annotations.Test;
36 import com.google.common.collect.ImmutableMap;
37 import com.google.common.collect.ImmutableSet;
38 import com.google.inject.Guice;
39 import com.google.inject.Injector;
92 protected Injector injector() {
93 return Guice.createInjector(new NovaParserModule(), new GsonModule());
94 }
95 }
NinjaDaoTestBase.java (https://gitlab.com/kidaa/ninja.git) Java · 97 lines
28 import com.google.common.base.Optional;
29 import com.google.inject.Guice;
30 import com.google.inject.Injector;
46 private JpaInitializer jpaInitializer;
47 /**
48 * Guice Injector to get DAOs
49 */
50 private Injector injector;
75 public final void initialize() {
76 NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(ninjaMode);
77 injector = Guice.createInjector(new JpaModule(ninjaProperties));
78 jpaInitializer = injector.getInstance(JpaInitializer.class);
79 jpaInitializer.start();
ScenarioSharedState.java (https://gitlab.com/libpgrid/github_mirror.git) Java · 137 lines
OptionalBindingTest.java (https://code.google.com/p/google-guice/) Java · 296 lines
84 public void testEverythingInjectorGetInstance() {
85 Guice.createInjector(everythingModule)
86 .getInstance(HasOptionalInjections.class)
87 .assertEverythingInjected();
120 public void testEverythingInjectorToInstance() {
121 Guice.createInjector(everythingModule, toInstanceModule)
122 .getInstance(HasOptionalInjections.class)
123 .assertEverythingInjected();
277 */
278 public void testIndirectOptionalInjection() {
279 Indirect indirect = Guice.createInjector().getInstance(Indirect.class);
280 assertNotNull(indirect.hasOptionalInjections);
281 indirect.hasOptionalInjections.assertNothingInjected();
GuiceFactoryTest.java (git://github.com/cucumber/cucumber-jvm.git) Java · 220 lines
61 @Test
62 void factoryCanBeIntantiatedWithArgConstructor() {
63 factory = new GuiceFactory(Guice.createInjector());
64 assertThat(factory, notNullValue());
65 }
67 @Test
68 void factoryStartFailsIfScenarioScopeIsNotBound() {
69 factory = new GuiceFactory(Guice.createInjector());
71 Executable testMethod = () -> factory.start();
86 private Injector injector(Module... module) {
87 return Guice.createInjector(Stage.PRODUCTION, module);
88 }
ParseCookbookNamesFromJsonTest.java (git://github.com/jclouds/jclouds.git) Java · 72 lines
29 import org.testng.annotations.Test;
31 import com.google.common.collect.ImmutableSet;
32 import com.google.inject.AbstractModule;
33 import com.google.inject.Guice;
34 import com.google.inject.Injector;
44 @BeforeTest
45 protected void setUpInjector() throws IOException {
46 Injector injector = Guice.createInjector(new AbstractModule() {
47 @Override
48 protected void configure() {
NameUsageComponentTestIT.java (http://gbif-ecat.googlecode.com/svn/trunk/) Java · 132 lines
32 import org.gbif.checklistbank.api.service.TypeSpecimenService;
33 import org.gbif.checklistbank.api.service.VernacularNameService;
34 import org.gbif.checklistbank.ws.client.guice.ChecklistBankWsClientModule;
35 import org.gbif.checklistbank.ws.guice.ChecklistBankWsModule;
37 import com.google.inject.Guice;
38 import com.google.inject.Injector;
53 public void init() {
54 clientInjector =
55 Guice
56 .createInjector(new UrlBindingModule(this.getBaseURI(), "clb"), new ChecklistBankWsClientModule(false, true));
ScalaModuleTest.java (http://scala-eclipse-plugin.googlecode.com/svn/trunk/) Java · 80 lines
1 package code.lucamarrocco.scala.eclipse;
3 import static com.google.inject.Guice.*;
4 import static org.hamcrest.Matchers.*;
5 import static org.junit.Assert.*;
12 import org.junit.*;
14 import com.google.inject.*;
16 public class ScalaModuleTest {
38 workspace = mock(IWorkspace.class);
39 module = new ScalaModule(plugin, log, editorRegistry, contentTypeManager, workspace);
40 injector = createInjector(module);
41 }
JschSshClientModuleTest.java (git://github.com/jclouds/jclouds.git) Java · 45 lines
27 import com.google.common.net.HostAndPort;
28 import com.google.inject.Guice;
29 import com.google.inject.Injector;
37 public void testConfigureBindsClient() throws UnknownHostException {
39 Injector i = Guice.createInjector(new JschSshClientModule(), new SLF4JLoggingModule());
40 SshClient.Factory factory = i.getInstance(SshClient.Factory.class);
41 SshClient connection = factory.create(HostAndPort.fromParts("localhost", 22), LoginCredentials.builder().user("username")
BasicProjectGuiceServletContextListener.java (http://gwt-cx.googlecode.com/svn/trunk/) Java · 28 lines
15 package com.kiahu.sample.server.guice;
17 import com.google.inject.Guice;
18 import com.google.inject.Injector;
19 import com.google.inject.servlet.GuiceServletContextListener;
21 public class BasicProjectGuiceServletContextListener extends GuiceServletContextListener {
23 @Override
24 protected Injector getInjector() {
25 return Guice.createInjector(new BasicProjectServerModule(), new BasicProjectServletModule());
26 }
27 }
TestRMWebServicesFairScheduler.java (git://github.com/apache/hadoop-common.git) Java · 120 lines
36 import org.junit.Test;
38 import com.google.inject.Guice;
39 import com.google.inject.Injector;
40 import com.google.inject.servlet.GuiceServletContextListener;
41 import com.google.inject.servlet.ServletModule;
42 import com.sun.jersey.api.client.ClientResponse;
43 import com.sun.jersey.api.client.WebResource;
44 import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
45 import com.sun.jersey.test.framework.JerseyTest;
46 import com.sun.jersey.test.framework.WebAppDescriptor;
50 private YarnConfiguration conf;
52 private Injector injector = Guice.createInjector(new ServletModule() {
53 @Override
54 protected void configureServlets() {
ListTagsResponseTest.java (git://github.com/jclouds/jclouds.git) Java · 66 lines
BindUserMetadataToHeadersTest.java (git://github.com/jclouds/jclouds.git) Java · 85 lines
25 import org.testng.annotations.Test;
27 import com.google.inject.Guice;
28 import com.google.inject.Injector;
33 @Test(groups = "unit")
34 public class BindUserMetadataToHeadersTest {
35 Injector injector = Guice.createInjector();
36 BindUserMetadataToHeaders binder = injector.getInstance(BindUserMetadataToHeaders.class);
GuiceProvider.java (git://github.com/caelum/vraptor.git) Java · 151 lines
34 import com.google.inject.ConfigurationException;
35 import com.google.inject.Guice;
36 import com.google.inject.Injector;
39 import com.google.inject.Stage;
40 import com.google.inject.TypeLiteral;
41 import com.google.inject.multibindings.Multibinder;
44 /**
45 *
46 * A Container Provider that uses Google Guice as DI container.
47 *
48 * @author Lucas Cavalcanti
96 container = new GuiceContainer();
97 injector = Guice.createInjector(Stage.PRODUCTION, Modules.override(new VRaptorAbstractModule(context, container)).with(customModule()));
98 executeStereotypeHandlers();
99 injector.injectMembers(REQUEST);
ManualLocalTransactionsWithCustomMatchersTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 128 lines
19 import com.google.inject.AbstractModule;
20 import com.google.inject.Guice;
21 import com.google.inject.Inject;
22 import com.google.inject.Injector;
23 import com.google.inject.matcher.Matchers;
55 @BeforeClass
56 public void pre() {
57 injector = Guice.createInjector(PersistenceService.usingHibernate()
58 .across(UnitOfWork.REQUEST)
59 .forAll(Matchers.subclassesOf(TransactionalObject.class), Matchers.any())
ProviderInjectionTest.java (https://gitlab.com/jbwhips883/roboguice.git) Java · 190 lines
33 public void testProviderInjection() throws CreationException {
34 Injector injector = Guice.createInjector(new AbstractModule() {
35 @Override
36 protected void configure() {
70 try {
71 Guice.createInjector(m);
72 fail("Should have thrown a CreationException");
73 }
82 */
83 public void testProvidersAreInjectedBeforeTheyAreUsed() {
84 Injector injector = Guice.createInjector(new AbstractModule() {
85 @Override
86 public void configure() {
OrphanedGroupsByZoneIdTest.java (git://github.com/jclouds/jclouds.git) Java · 97 lines
35 import org.testng.annotations.Test;
37 import com.google.common.base.Predicates;
38 import com.google.common.base.Supplier;
39 import com.google.common.base.Suppliers;
40 import com.google.common.collect.ImmutableMap;
42 import com.google.common.collect.ImmutableSet;
43 import com.google.inject.Guice;
45 /**
58 .<String, Location> of("az-1.region-a.geo-1", zone));
60 GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);
62 @Test
ParseExtensionListNormalTest.java (git://github.com/jclouds/jclouds.git) Java · 76 lines
InjectedTest.java (git://pkgs.fedoraproject.org/sisu) Java · 173 lines
10 * You may elect to redistribute this code under either of these licenses.
11 *******************************************************************************/
12 package org.sonatype.guice.bean.containers;
14 import java.io.File;
25 import org.sonatype.guice.bean.binders.SpaceModule;
26 import org.sonatype.guice.bean.binders.WireModule;
27 import org.sonatype.guice.bean.locators.MutableBeanLocator;
35 import com.google.inject.Binder;
36 import com.google.inject.Guice;
37 import com.google.inject.Key;
62 public void setUp()
63 {
64 Guice.createInjector( new WireModule( new SetUpModule(), new SpaceModule( space(), scanning() ) ) );
65 }
ParseNOVNCConsoleTest.java (git://github.com/jclouds/jclouds.git) Java · 69 lines
PlexusBeanLocatorTest.java (git://pkgs.fedoraproject.org/sisu) Java · 542 lines
24 import com.google.inject.Binder;
25 import com.google.inject.Guice;
26 import com.google.inject.ImplementedBy;
365 } ), 3 );
367 locator.add( Guice.createInjector( new Module()
368 {
369 public void configure( final Binder binder )
425 } ), 7 );
427 locator.add( Guice.createInjector( new Module()
428 {
429 public void configure( final Binder binder )
446 world.getRealm( "B2" ).importFrom( "B3", "B3" );
448 locator.add( Guice.createInjector( new AbstractModule()
449 {
450 @Override
GuiceWrappedFinderTestCase.java (git://github.com/restlet/restlet-framework-java.git) Java · 185 lines
23 */
25 package org.restlet.test.ext.guice;
27 import javax.inject.Inject;
33 import org.restlet.data.MediaType;
34 import org.restlet.data.Protocol;
35 import org.restlet.ext.guice.ResourceInjectingApplication;
36 import org.restlet.ext.guice.SelfInjectingServerResource;
44 import com.google.inject.AbstractModule;
45 import com.google.inject.Guice;
46 import com.google.inject.Injector;
144 protected void setUp() throws Exception {
145 super.setUp();
146 Injector injector = Guice.createInjector(new TestModule(),
147 new SelfInjectingServerResourceModule());
CheckedProviderMethodsModuleTest.java (https://code.google.com/p/google-guice/) Java · 195 lines
125 public void testNoAnnotationNoScope() throws BindException, RemoteException {
126 Injector injector = Guice.createInjector(new TestModule());
127 RpcProvider<String> provider = injector
128 .getInstance(Key.get(rpcProviderOfString));
162 public void testWithThrownException() {
163 TestModule testModule = new TestModule();
164 Injector injector = Guice.createInjector(testModule);
165 RpcProvider<Float> provider = injector
166 .getInstance(Key.get(rpcProviderOfFloat));
177 public void testExposedMethod() throws BindException, RemoteException {
178 TestModule testModule = new TestModule();
179 Injector injector = Guice.createInjector(testModule);
180 RpcProvider<String> provider = injector
181 .getInstance(Key.get(rpcProviderOfString, Names.named("fruit")));
GenericInjectionTest.java (https://code.google.com/p/google-guice/) Java · 188 lines
37 final List<String> names = Arrays.asList("foo", "bar", "bob");
39 Injector injector = Guice.createInjector((Module) new AbstractModule() {
40 protected void configure() {
41 bind(new TypeLiteral<List<String>>() {}).toInstance(names);
58 public void testImplicitBindingOfGenericType() {
59 Parameterized<String> parameterized
60 = Guice.createInjector().getInstance(Key.get(new TypeLiteral<Parameterized<String>>() {}));
61 assertNotNull(parameterized);
62 }
64 public void testExplicitBindingOfGenericType() {
65 Injector injector = Guice.createInjector(new AbstractModule() {
66 protected void configure() {
67 bind(Key.get(new TypeLiteral<Parameterized<String>>() {}))
Tests.java (git://github.com/jOOQ/jOOQ.git) Java · 101 lines
38 package org.jooq.example.guice.test;
40 import static com.google.inject.Guice.createInjector;
41 import static org.junit.Assert.assertEquals;
42 import static org.junit.Assert.fail;
44 import org.jooq.example.db.h2.tables.pojos.Author;
45 import org.jooq.example.guice.Module;
46 import org.jooq.example.guice.Service;
54 public class Tests {
56 Service service = createInjector(new Module()).getInstance(Service.class);
58 @Test
ParseFloatingIPPoolListTest.java (git://github.com/jclouds/jclouds.git) Java · 51 lines
VirtualGuestToImageTest.java (git://github.com/jclouds/jclouds.git) Java · 119 lines
SessionProvisionTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 86 lines
3 import com.google.inject.Injector;
4 import com.google.inject.Guice;
5 import com.google.inject.AbstractModule;
6 import com.google.inject.matcher.Matchers;
7 import com.wideplay.codemonkey.web.startup.Initializer;
8 import com.wideplay.warp.hibernate.HibernatePersistenceService;
32 @BeforeClass
33 public void pre() {
34 injector = Guice.createInjector(PersistenceService.usingHibernate()
35 .across(UnitOfWork.TRANSACTION)
36 .transactedWith(TransactionStrategy.LOCAL)
ParseSandboxFromJsonTest.java (git://github.com/jclouds/jclouds.git) Java · 71 lines
34 import com.google.inject.AbstractModule;
35 import com.google.inject.Guice;
36 import com.google.inject.Injector;
37 import com.google.inject.Key;
38 import com.google.inject.TypeLiteral;
49 @BeforeTest
50 protected void setUpInjector() throws IOException {
51 Injector injector = Guice.createInjector(new AbstractModule() {
52 @Override
53 protected void configure() {
ImageAdapterTest.java (git://github.com/jclouds/jclouds.git) Java · 93 lines
17 package org.jclouds.openstack.nova.v2_0.config;
19 import static com.google.common.collect.Iterables.getOnlyElement;
20 import static org.testng.Assert.assertEquals;
21 import static org.testng.Assert.assertNotNull;
28 import org.testng.annotations.Test;
30 import com.google.common.base.Charsets;
31 import com.google.common.io.Resources;
32 import com.google.gson.Gson;
33 import com.google.inject.Guice;
34 import com.google.inject.Injector;
41 @BeforeTest
42 public void setup() {
43 Injector injector = Guice.createInjector(new GsonModule(), new NovaParserModule());
44 gson = injector.getInstance(Gson.class);
45 }
ManyConstructorsTest.java (https://code.google.com/p/google-guice/) Java · 277 lines
48 public void testDifferentOrderParameters() {
49 Injector injector = Guice.createInjector(new AbstractModule() {
50 @Override
51 protected void configure() {
95 assertEquals(null, noIndex.index);
97 injector = Guice.createInjector(new AbstractModule() {
98 @Override
99 protected void configure() {
229 public void testDependenciesAndOtherAnnotations() {
230 Injector injector = Guice.createInjector(new AbstractModule() {
231 @Override
232 protected void configure() {
ModuleProcessor.java (git://pkgs.fedoraproject.org/resteasy) Java · 77 lines
3 import com.google.inject.Binding;
4 import com.google.inject.Guice;
5 import com.google.inject.Injector;
30 public void process(final Module... modules)
31 {
32 final Injector injector = Guice.createInjector(modules);
33 processInjector(injector);
34 }
36 public void process(final Stage stage, final Module... modules)
37 {
38 final Injector injector = Guice.createInjector(stage, modules);
39 processInjector(injector);
40 }
42 public void process(final Iterable<Module> modules)
43 {
44 final Injector injector = Guice.createInjector(modules);
45 processInjector(injector);
46 }
MergerModuleTest.java (https://code.google.com/p/rabbit-eclipse/) Java · 80 lines
25 import rabbit.data.internal.xml.schema.events.TaskFileEventType;
27 import com.google.inject.Guice;
28 import com.google.inject.Injector;
29 import com.google.inject.Key;
30 import com.google.inject.TypeLiteral;
70 this.mergerInterface = mergerInterface;
71 this.mergerImpl = mergerImpl;
72 this.injector = Guice.createInjector(new MergerModule());
73 }
StatsIntegrationTest.java
(git://github.com/dhanji/sitebricks.git)
Java · 234 lines
✨ Summary
This Java code is a test suite for a statistics system, specifically testing how stats are published from parent classes when a child class is published. It tests various scenarios such as publishing stats in different services, using different exposers, and registering standalone stats. The tests verify that the expected stats are published correctly.
This Java code is a test suite for a statistics system, specifically testing how stats are published from parent classes when a child class is published. It tests various scenarios such as publishing stats in different services, using different exposers, and registering standalone stats. The tests verify that the expected stats are published correctly.
1 package com.google.sitebricks.stat;
3 import com.google.common.collect.ImmutableMap;
4 import com.google.inject.AbstractModule;
5 import com.google.inject.Guice;
6 import com.google.inject.Injector;
7 import com.google.sitebricks.stat.testservices.ChildDummyService;
8 import com.google.sitebricks.stat.testservices.DummyService;
9 import com.google.sitebricks.stat.testservices.StatExposerTestingService;
10 import com.google.sitebricks.stat.testservices.StaticDummyService;
26 @BeforeMethod
27 public final void before() {
28 injector = Guice.createInjector(new AbstractModule() {
29 @Override
30 protected void configure() {
GuiceServletConfig.java (git://github.com/jclouds/jclouds-chef.git) Java · 96 lines
41 import com.google.common.collect.ImmutableSet;
42 import com.google.inject.Guice;
43 import com.google.inject.Injector;
44 import com.google.inject.servlet.GuiceServletContextListener;
45 import com.google.inject.servlet.ServletModule;
53 * @author Adrian Cole
54 */
55 public class GuiceServletConfig extends GuiceServletContextListener {
57 private Logger logger = new JDKLogger.JDKLoggerFactory().getLogger(GuiceServletConfig.class.getName());
78 @Override
79 protected Injector getInjector() {
80 return Guice.createInjector(concat(modulesForProviderInProperties("chef", properties), ImmutableSet.of(
81 new GsonModule(), new ServletModule() {
82 @Override
ProxyPoolImpl.java (http://digital-delegation.googlecode.com/svn/proj/dd/trunk/) Java · 210 lines
26 import com.google.inject.AbstractModule;
27 import com.google.inject.Guice;
28 import com.google.inject.Inject;
39 public static ProxyPool newInstance()
40 {
41 return Guice.createInjector(new AbstractModule() {
42 @Override protected void configure() {
54 proxyPool.submitAndWait(Arrays.<Worker>asList(new Worker() {
55 public void work(Session with) throws Throwable {
56 with.load(new URL("http://www.google.com/"));
57 System.out.println("DONE google!!!");
InstantiateVAppTemplateOptionsTest.java (git://github.com/jclouds/jclouds.git) Java · 75 lines
ParseOsFamilyVersion64BitFromImageNameTest.java (git://github.com/jclouds/jclouds.git) Java · 79 lines
17 package org.jclouds.cloudsigma.functions;
19 import static com.google.common.collect.Iterables.transform;
20 import static com.google.common.collect.Lists.newArrayList;
37 import org.testng.annotations.Test;
39 import com.google.common.base.Function;
40 import com.google.gson.Gson;
41 import com.google.inject.Guice;
42 import com.google.inject.TypeLiteral;
70 ParseOsFamilyVersion64BitFromImageName parser = new ParseOsFamilyVersion64BitFromImageName(new BaseComputeServiceContextModule() {
71 }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule())
72 .getInstance(Json.class)));
BootstrapConfigForGroupTest.java (git://github.com/jclouds/jclouds.git) Java · 92 lines
FirewallServiceHandlerTest.java (git://github.com/jclouds/jclouds.git) Java · 65 lines
32 import com.google.common.collect.ImmutableSet;
33 import com.google.inject.Guice;
34 import com.google.inject.Injector;
49 public void test() {
50 InputStream is = getClass().getResourceAsStream("/firewallService.xml");
51 Injector injector = Guice.createInjector(new SaxParserModule());
52 Factory factory = injector.getInstance(ParseSax.Factory.class);
53 FirewallService result = factory.create(injector.getInstance(FirewallServiceHandler.class)).parse(is);
GuiceContainer.java
(http://mycila.googlecode.com/svn/)
Java · 73 lines
✨ Summary
This Java code implements a custom container for AtUnit testing framework using Google Guice dependency injection framework. It creates an injector that binds test class fields with their corresponding values, allowing for dynamic configuration of test classes. The injector is then used to inject dependencies into the test target.
This Java code implements a custom container for AtUnit testing framework using Google Guice dependency injection framework. It creates an injector that binds test class fields with their corresponding values, allowing for dynamic configuration of test classes. The injector is then used to inject dependencies into the test target.
18 import atunit.core.Container;
19 import atunit.lib.com.google.common.collect.Iterables;
20 import atunit.lib.com.google.common.collect.Multimap;
21 import atunit.lib.com.google.common.collect.Multimaps;
22 import com.google.inject.*;
28 import java.util.Map;
30 public class GuiceContainer implements Container {
32 public Object createTest(Class<?> testClass, Map<Field, Object> fieldValues) throws Exception {
34 Injector injector;
35 if (Module.class.isAssignableFrom(testClass)) {
36 injector = Guice.createInjector(fields, (Module) testClass.newInstance());
37 } else {
38 injector = Guice.createInjector(fields);
GuiceBeanLocatorTest.java (http://salve.googlecode.com/svn/trunk/) Java · 91 lines
15 * limitations under the License.
16 */
17 package salve.depend.guice;
19 import junit.framework.Assert;
28 import salve.depend.guice.model.Injected;
29 import salve.depend.guice.model.MockService;
31 import com.google.inject.AbstractModule;
32 import com.google.inject.Guice;
33 import com.google.inject.Injector;
58 };
60 Injector injector = Guice.createInjector(module);
61 locator = new GuiceBeanLocator(injector);
ParseIpAddressFromResponseTest.java (git://github.com/jclouds/jclouds.git) Java · 60 lines
ServletContextInfoSupplierTest.java (git://github.com/jclouds/jclouds-chef.git) Java · 157 lines
35 import org.testng.annotations.Test;
37 import com.google.inject.Guice;
38 import com.google.inject.Injector;
62 replay(converter);
64 Injector injector = Guice.createInjector(new GsonModule(), new ServletOhaiModule() {
65 @SuppressWarnings("unused")
66 @Provides
98 replay(converter);
100 Injector injector = Guice.createInjector(new GsonModule(), new ServletOhaiModule() {
101 @SuppressWarnings("unused")
102 @Provides
134 replay(converter);
136 Injector injector = Guice.createInjector(new GsonModule(), new ServletOhaiModule() {
137 @SuppressWarnings("unused")
138 @Provides
GuiceContainer.java
(http://mycila.googlecode.com/svn/)
Java · 77 lines
✨ Summary
This Java code implements a custom container for AtUnit testing framework using Google Guice dependency injection framework. It creates an injector that binds test class fields with their corresponding values, allowing for dynamic configuration of test classes. The injector is then used to inject dependencies into the test class, enabling flexible and dynamic testing scenarios.
This Java code implements a custom container for AtUnit testing framework using Google Guice dependency injection framework. It creates an injector that binds test class fields with their corresponding values, allowing for dynamic configuration of test classes. The injector is then used to inject dependencies into the test class, enabling flexible and dynamic testing scenarios.
18 import atunit.core.Container;
19 import atunit.lib.com.google.common.collect.Iterables;
20 import atunit.lib.com.google.common.collect.Multimap;
21 import atunit.lib.com.google.common.collect.Multimaps;
22 import com.google.inject.AbstractModule;
23 import com.google.inject.Guice;
24 import com.google.inject.Injector;
38 Injector injector;
39 if (Module.class.isAssignableFrom(testClass)) {
40 injector = Guice.createInjector(fields, (Module) testClass.newInstance());
41 } else {
42 injector = Guice.createInjector(fields);
GuiceAsyncDriver.java (git://github.com/bbejeck/Java-7.git) Java · 24 lines
1 package bbejeck.nio.channels.guice;
3 import com.google.common.base.Stopwatch;
4 import com.google.inject.Guice;
5 import com.google.inject.Injector;
11 * Time: 10:01 PM
12 */
13 public class GuiceAsyncDriver {
15 public static void main(String[] args) throws Exception {
16 Injector injector = Guice.createInjector(new AsynchronousServerModule());
17 AsyncSocketServerGuiceExample socketServer = injector.getInstance(AsyncSocketServerGuiceExample.class);
BindDriveToPlainTextStringTest.java (git://github.com/jclouds/jclouds.git) Java · 88 lines
34 import org.testng.annotations.Test;
36 import com.google.common.base.Function;
37 import com.google.common.collect.ImmutableSet;
38 import com.google.inject.AbstractModule;
39 import com.google.inject.Guice;
40 import com.google.inject.TypeLiteral;
47 public class BindDriveToPlainTextStringTest {
49 private static final BindDriveToPlainTextString FN = Guice.createInjector(new AbstractModule() {
51 @Override
GuiceWebloggerProvider.java (https://github.com/apache/roller.git) Java · 90 lines
19 package org.apache.roller.weblogger.business;
21 import com.google.inject.Guice;
22 import com.google.inject.Injector;
41 /**
42 * Instantiate a new GuiceWebloggerProvider using default guice module
43 * configured in WebloggerConfig via 'guice.backend.module' property.
52 /**
53 * Instantiate a new GuiceWebloggerProvider using the given Guice module.
54 *
55 * @param moduleClassname The full classname of the Guice module to use.
61 try {
62 Module module = (Module) Reflection.newInstance(moduleClassname);
63 injector = Guice.createInjector(module);
64 } catch (ThreadDeath t) {
65 throw t;
TagToBootScriptTest.java (git://github.com/jclouds/jclouds-chef.git) Java · 105 lines
39 import org.testng.annotations.Test;
41 import com.google.common.base.Charsets;
42 import com.google.common.base.Suppliers;
43 import com.google.common.collect.ImmutableList;
44 import com.google.common.collect.ImmutableMap;
46 import com.google.common.io.Resources;
47 import com.google.inject.Guice;
48 import com.google.inject.Injector;
54 public class TagToBootScriptTest {
56 Injector injector = Guice.createInjector(new ChefParserModule(), new GsonModule());
57 Json json = injector.getInstance(Json.class);
58 Statement installChefGems = new InstallChefGems();
MycilaInitDestroyBindingsTest.java (http://mycila.googlecode.com/svn/) Java · 239 lines
15 */
17 import com.google.inject.AbstractModule;
18 import com.google.inject.Provider;
63 @Test
64 public void testUntargettedBinding() {
65 Jsr250Injector injector = Jsr250.createInjector(new AbstractModule() {
66 @Override
67 protected void configure() {
81 @Test
82 public void testLinkedBinding() {
83 Jsr250Injector injector = Jsr250.createInjector(new AbstractModule() {
84 @Override
85 protected void configure() {
96 assertEquals(1, component.destroyed);
98 // Guice creates an internal jit ConstructorBinding therefor this fails as Mycila destroys on both bindings
99 }
ManualLocalTransactionsTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 96 lines
3 import com.google.inject.Injector;
4 import com.google.inject.Guice;
5 import com.google.inject.Inject;
6 import com.google.inject.AbstractModule;
7 import com.google.inject.matcher.Matchers;
34 @BeforeClass
35 public void pre() {
36 injector = Guice.createInjector(PersistenceService.usingHibernate()
37 .across(UnitOfWork.REQUEST)
38 .transactedWith(TransactionStrategy.LOCAL)
ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSetTest.java (git://github.com/jclouds/jclouds.git) Java · 49 lines
25 import com.google.common.collect.ImmutableSet;
26 import com.google.inject.Guice;
28 /**
33 public class ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSetTest {
35 private static final ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet FN = Guice.createInjector().getInstance(
36 ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class);
OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java (git://github.com/jclouds/jclouds.git) Java · 116 lines
32 import com.google.inject.AbstractModule;
33 import com.google.inject.Guice;
34 import com.google.inject.name.Names;
44 @Test(groups = "unit", testName = "OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest")
45 public class OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest {
46 ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull = Guice.createInjector().getInstance(
47 ValueOfConfigurationKeyOrNull.class);
92 assertEquals(
93 new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(Guice.createInjector(
94 new AbstractModule() {
95 protected void configure() {
106 ReferenceType reference2 = new ReferenceTypeImpl("hail mary", null, null);
108 new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(Guice.createInjector(new AbstractModule() {
109 protected void configure() {
110 bindConstant().annotatedWith(Names.named("foo")).to(".*happy.*");
LocalizationTest.java
(git://github.com/dhanji/sitebricks.git)
Java · 289 lines
✨ Summary
This Java code is a unit test for a localization utility, testing various scenarios such as parameterized templates with different locales and bundles. It verifies that the correct message is returned based on the locale and available bundles, simulating different Accept-Language headers and defaulting to English when no external bundle is provided.
This Java code is a unit test for a localization utility, testing various scenarios such as parameterized templates with different locales and bundles. It verifies that the correct message is returned based on the locale and available bundles, simulating different Accept-Language headers and defaulting to English when no external bundle is provided.
47 resourceBundle.put(HELLO, "hello there!");
49 String msg = Guice.createInjector(new AbstractModule() {
50 @Override
51 protected void configure() {
197 = new AtomicReference<HttpServletRequest>(japaneseRequest);
199 Injector injector = Guice.createInjector(new AbstractModule() {
200 @Override
201 protected void configure() {
242 @Test
243 public final void parameterizedWithNoExternalBundle() {
244 String msg = Guice.createInjector(new AbstractModule() {
245 @Override
246 protected void configure() {
GuiceServletConfig.java (git://github.com/jersey/jersey-1.x.git) Java · 74 lines
40 package com.sun.jersey.samples.guice;
42 import com.google.inject.Guice;
43 import com.google.inject.Injector;
44 import com.google.inject.servlet.GuiceServletContextListener;
45 import com.google.inject.servlet.ServletModule;
46 import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
47 import com.sun.jersey.samples.guice.resources.PerRequestResource;
54 * @author Marek Potociar (marek.potociar at oracle.com)
55 */
56 public class GuiceServletConfig extends GuiceServletContextListener {
58 @Override
ParseImageFromJsonResponseTest.java (git://github.com/jclouds/jclouds.git) Java · 90 lines
34 import com.google.inject.AbstractModule;
35 import com.google.inject.Guice;
36 import com.google.inject.Injector;
37 import com.google.inject.Key;
38 import com.google.inject.TypeLiteral;
45 @Test(groups = "unit")
46 public class ParseImageFromJsonResponseTest {
47 Injector i = Guice.createInjector(new AbstractModule() {
49 @Override
71 public static Image parseImage() {
72 Injector i = Guice.createInjector(new AbstractModule() {
74 @Override
MultiModulesTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 152 lines
16 package com.wideplay.warp.persist;
18 import com.google.inject.*;
19 import com.wideplay.codemonkey.web.startup.Initializer;
20 import com.wideplay.warp.persist.dao.Finder;
59 .buildModule();
61 injector = Guice.createInjector(hibernateModule, hibernateModule2,
62 new PersistenceServiceExtrasModule());
HibernateDynamicFinderWithIsolationTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 316 lines
24 import com.google.inject.Injector;
25 import com.google.inject.Guice;
26 import com.google.inject.AbstractModule;
50 @BeforeMethod
51 public void pre() {
52 injector = Guice.createInjector(PersistenceService.usingHibernate()
53 .across(UnitOfWork.TRANSACTION)
54 .addAccessor(HibernateTestAccessorForDFs.class)
BaseGoogleComputeEngineParseTest.java (git://github.com/jclouds/jclouds.git) Java · 41 lines
15 * limitations under the License.
16 */
17 package org.jclouds.googlecomputeengine.internal;
19 import java.util.Date;
21 import org.jclouds.date.internal.SimpleDateFormatDateService;
22 import org.jclouds.googlecomputeengine.config.GoogleComputeEngineParserModule;
23 import org.jclouds.json.BaseItemParserTest;
24 import org.jclouds.json.config.GsonModule;
26 import com.google.inject.Guice;
27 import com.google.inject.Injector;
33 @Override
34 protected Injector injector() {
35 return Guice.createInjector(new GsonModule(), new GoogleComputeEngineParserModule());
36 }
ServletDispatchIntegrationTest.java (https://code.google.com/p/google-guice/) Java · 269 lines
23 import static org.easymock.EasyMock.verify;
25 import com.google.inject.Guice;
26 import com.google.inject.Injector;
64 public final void testDispatchRequestToManagedPipelineServlets()
65 throws ServletException, IOException {
66 final Injector injector = Guice.createInjector(new ServletModule() {
68 @Override
108 public final void testDispatchRequestToManagedPipelineWithFilter()
109 throws ServletException, IOException {
110 final Injector injector = Guice.createInjector(new ServletModule() {
112 @Override
234 public void testForwardUsingRequestDispatcher() throws IOException, ServletException {
235 Guice.createInjector(new ServletModule() {
236 @Override
237 protected void configureServlets() {
ContextLinkingTest.java (git://github.com/jclouds/jclouds.git) Java · 69 lines
34 import com.google.common.reflect.TypeToken;
35 import com.google.inject.Guice;
36 import com.google.inject.Injector;
37 import com.google.inject.Key;
38 import com.google.inject.name.Names;
43 @Test
44 public void testLinkedViewBindsViewAndContextSuppliers() {
45 Injector injector = Guice.createInjector(linkView(new DummyView(contextFor(IntegrationTestClient.class))));
47 assertNotNull(injector.getExistingBinding(Key.get(CONTEXT_SUPPLIER, Names.named("IntegrationTestClient"))));
51 @Test
52 public void testLinkedContextBindsContextSupplier() {
53 Injector injector = Guice.createInjector(linkContext(contextFor(IntegrationTestClient.class)));
55 assertNotNull(injector.getExistingBinding(Key.get(CONTEXT_SUPPLIER, Names.named("IntegrationTestClient"))));
ReadOnlyTransactionsTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 91 lines
18 import com.google.inject.AbstractModule;
19 import com.google.inject.Guice;
20 import com.google.inject.Inject;
21 import com.google.inject.Injector;
22 import com.google.inject.matcher.Matchers;
43 @BeforeClass
44 public void pre() {
45 injector = Guice.createInjector(PersistenceService.usingHibernate()
46 .across(UnitOfWork.TRANSACTION)
47 .forAll(Matchers.any())
NetworkHandlerTest.java (git://github.com/jclouds/jclouds.git) Java · 75 lines
30 import org.testng.annotations.Test;
32 import com.google.inject.Guice;
33 import com.google.inject.Injector;
43 public void test() {
44 InputStream is = getClass().getResourceAsStream("/network.xml");
45 Injector injector = Guice.createInjector(new SaxParserModule());
46 Factory factory = injector.getInstance(ParseSax.Factory.class);
47 Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
54 public void testNat() {
55 InputStream is = getClass().getResourceAsStream("/network-nat.xml");
56 Injector injector = Guice.createInjector(new SaxParserModule());
57 Factory factory = injector.getInstance(ParseSax.Factory.class);
58 Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
65 public void tesWhenNoVAppsInNetworkSetsAllZerosToGatewayAndNetmask() {
66 InputStream is = getClass().getResourceAsStream("/network-unused.xml");
67 Injector injector = Guice.createInjector(new SaxParserModule());
68 Factory factory = injector.getInstance(ParseSax.Factory.class);
69 Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
ParseRackspaceApiMetadataTest.java (git://github.com/jclouds/jclouds.git) Java · 68 lines
LazyGenModelInferenceTest.java (git://pkgs.fedoraproject.org/eclipse-emf) Java · 168 lines
39 import org.junit.runner.RunWith;
41 import com.google.inject.Guice;
42 import com.google.inject.Inject;
43 import com.google.inject.Injector;
44 import com.google.inject.Provider;
70 public Injector createInjector()
71 {
72 return Guice.createInjector(new org.eclipse.emf.ecore.xcore.XcoreRuntimeModule()
73 {
74 @Override
79 });
80 }
81 }.createInjectorAndDoEMFRegistration();
82 stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
83 }
NameUsageSearchTestIT.java (http://gbif-ecat.googlecode.com/svn/trunk/) Java · 92 lines
20 import org.gbif.checklistbank.search.model.NameUsageSolrSearchResult;
22 import com.google.inject.Guice;
23 import com.google.inject.Injector;
24 import com.google.inject.Key;
25 import com.google.inject.TypeLiteral;
40 @BeforeClass
41 public static void init() {
42 injector = Guice.createInjector(new SearchModule());
43 searchService = injector.getInstance(Key.get(new TypeLiteral<NameUsageSearchService<NameUsageSolrSearchResult>>() {
44 }));
Injector.java (https://bitbucket.org/brunofr/nodus.git) Java · 34 lines
ObjectContainerProvisionTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 110 lines
23 import com.google.inject.AbstractModule;
24 import com.google.inject.Guice;
25 import com.google.inject.Inject;
26 import com.google.inject.Injector;
27 import com.google.inject.name.Names;
43 @BeforeClass
44 public void preClass() {
45 injector = Guice.createInjector(PersistenceService.usingDb4o()
46 .across(UnitOfWork.TRANSACTION)
47 .buildModule(),
BaseEC2HandlerTest.java (git://github.com/jclouds/jclouds.git) Java · 82 lines
31 import org.testng.annotations.Test;
33 import com.google.common.base.Supplier;
34 import com.google.common.base.Suppliers;
35 import com.google.common.collect.ImmutableMap;
36 import com.google.common.collect.ImmutableSet;
38 import com.google.inject.AbstractModule;
39 import com.google.inject.Guice;
40 import com.google.inject.Provides;
47 @Override
48 protected void setUpInjector() {
49 injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
51 @Override
Factory.java
(https://code.google.com/p/spinn3r-client/)
Java · 131 lines
✨ Summary
This Java code defines a factory class that sets up a dependency injection framework using Guice. It provides different logging modules, including a rotating log manager, a fresh start module, and a null log manager. The factory allows users to enable logging with a specified save directory and maximum log size, or restart functionality with a counter and URL.
This Java code defines a factory class that sets up a dependency injection framework using Guice. It provides different logging modules, including a rotating log manager, a fresh start module, and a null log manager. The factory allows users to enable logging with a specified save directory and maximum log size, or restart functionality with a counter and URL.
9 import com.google.inject.AbstractModule;
10 import com.google.inject.Guice;
11 import com.google.inject.Injector;
12 import com.google.inject.Module;
13 import com.google.inject.Provider;
14 import com.google.inject.Provides;
15 import com.google.inject.Singleton;
127 return Guice.createInjector(modules);
128 }
MembersInjectorTest.java (https://code.google.com/p/google-guice/) Java · 288 lines
171 public void testCannotBindMembersInjector() {
172 try {
173 Guice.createInjector(new AbstractModule() {
174 protected void configure() {
175 bind(MembersInjector.class).toProvider(Providers.<MembersInjector>of(null));
231 public void testGettingRawMembersInjector() {
232 Injector injector = Guice.createInjector();
233 try {
234 injector.getInstance(MembersInjector.class);
242 public void testGettingAnnotatedMembersInjector() {
243 Injector injector = Guice.createInjector();
244 try {
245 injector.getInstance(new Key<MembersInjector<String>>(Names.named("foo")) {});
OrgListHandlerTest.java (git://github.com/jclouds/jclouds.git) Java · 57 lines
34 import com.google.common.collect.ImmutableSet;
35 import com.google.inject.Guice;
36 import com.google.inject.Injector;
46 public void testSavvis() {
47 InputStream is = getClass().getResourceAsStream("/orglist.xml");
48 Injector injector = Guice.createInjector(new SaxParserModule());
49 Factory factory = injector.getInstance(ParseSax.Factory.class);
50 Set<Resource> result = factory.create(injector.getInstance(OrgListHandler.class)).parse(is);
ParseDatasetTest.java (git://github.com/jclouds/jclouds.git) Java · 72 lines
TestabilityExplorerMojo.java
(http://testability-explorer.googlecode.com/svn/trunk/)
Java · 210 lines
✨ Summary
This Java code defines a Maven plugin, TestabilityExplorerMojo
, which generates a report on testability for a project. It takes various parameters to customize the report, such as output directory and formatting options. The plugin uses Guice and Google’s Testability Runner to analyze the project’s classpath and generate the report.
This Java code defines a Maven plugin, TestabilityExplorerMojo
, which generates a report on testability for a project. It takes various parameters to customize the report, such as output directory and formatting options. The plugin uses Guice and Google’s Testability Runner to analyze the project’s classpath and generate the report.
1 package com.google.maven;
3 import com.google.classpath.ClassPath;
4 import com.google.classpath.ClassPathFactory;
5 import com.google.inject.Guice;
6 import com.google.test.metric.JavaTestabilityRunner;
175 return;
176 }
177 Guice.createInjector(new MavenConfigModule(this)).
178 getInstance(JavaTestabilityRunner.class).
179 run();
ProvisionExceptionsTest.java (https://code.google.com/p/google-guice/) Java · 179 lines
35 public void testConstructorRuntimeException() {
36 Injector injector = Guice.createInjector(new AbstractModule() {
37 @Override
38 protected void configure() {
57 public void testConstructorCheckedException() {
58 Injector injector = Guice.createInjector(new AbstractModule() {
59 @Override
60 protected void configure() {
79 public void testCustomProvidersRuntimeException() {
80 Injector injector = Guice.createInjector(new AbstractModule() {
81 @Override
82 protected void configure() {
ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest.java (git://github.com/jclouds/jclouds.git) Java · 78 lines
31 import org.testng.annotations.Test;
33 import com.google.common.base.Function;
34 import com.google.common.collect.ImmutableSet;
35 import com.google.inject.AbstractModule;
36 import com.google.inject.Guice;
37 import com.google.inject.TypeLiteral;
44 public class ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest {
46 private static final ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet FN = Guice.createInjector(
47 new AbstractModule() {
XtendMavenStandaloneSetup.java (git://github.com/bmwcarit/Jnario.git) Java · 26 lines
7 import org.eclipse.xtext.xbase.annotations.XbaseWithAnnotationsStandaloneSetup;
9 import com.google.inject.Guice;
10 import com.google.inject.Injector;
14 private static Injector injector = null;
16 public Injector createInjectorAndDoEMFRegistration() {
17 if (injector != null)
18 return injector;
19 XbaseWithAnnotationsStandaloneSetup.doSetup();
20 EPackage.Registry.INSTANCE.put(XtendPackage.eINSTANCE.getNsURI(), XtendPackage.eINSTANCE);
21 injector = Guice.createInjector(new XtendMavenModule());
22 new XtendStandaloneSetupGenerated().register(injector);
23 return injector;
NestSlashKeysTest.java (git://github.com/jclouds/jclouds.git) Java · 117 lines
30 import org.testng.annotations.Test;
32 import com.google.common.base.Supplier;
33 import com.google.common.base.Suppliers;
34 import com.google.common.collect.ImmutableListMultimap;
35 import com.google.inject.AbstractModule;
36 import com.google.inject.Guice;
37 import com.google.inject.Injector;
48 @BeforeTest
49 protected void setUpInjector() throws IOException {
50 Injector injector = Guice.createInjector(new AbstractModule() {
51 @Override
52 protected void configure() {
CreateUniqueKeyPairTest.java (git://github.com/jclouds/jclouds.git) Java · 109 lines
31 import org.testng.annotations.Test;
33 import com.google.common.base.Optional;
34 import com.google.common.base.Supplier;
36 import com.google.inject.AbstractModule;
37 import com.google.inject.Guice;
38 import com.google.inject.TypeLiteral;
56 replay(api, keyApi);
58 CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
60 @Override
90 replay(api, keyApi, uniqueIdSupplier);
92 CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
94 @Override
ChecklistBankSearchWsModule.java (http://gbif-ecat.googlecode.com/svn/trunk/) Java · 69 lines
20 import java.util.Map;
22 import com.google.inject.Guice;
23 import com.google.inject.Injector;
24 import com.google.inject.servlet.GuiceServletContextListener;
25 import com.sun.jersey.api.core.PackagesResourceConfig;
26 import com.sun.jersey.api.json.JSONConfiguration;
27 import com.sun.jersey.guice.JerseyServletModule;
28 import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
59 protected Injector getInjector() {
60 try {
61 return Guice.createInjector(new SearchModule(), new ChecklistBankSearchWsJerseyModule());
62 } catch (Exception e) {
63 LOG.error("Startup of checklistbank-search-ws failed", e);
CacheNodeStoreModuleTest.java (git://github.com/jclouds/jclouds.git) Java · 163 lines
37 import com.google.inject.AbstractModule;
38 import com.google.inject.Guice;
39 import com.google.inject.Injector;
57 checkConsistent(map, getStore(createInjectorWithProvidedMap(map)), "test", "instance1", "instancename");
58 checkConsistent(map, getStore(createInjectorWithProvidedMap(map)), "test", "instance1", "instancename");
59 remove(map, getStore(createInjectorWithProvidedMap(map)), "test");
64 Map<String, Node> map = Maps.newConcurrentMap();
66 Injector injector = createInjectorWithProvidedMap(map);
67 assertEquals(injector.getInstance(Key.get(new TypeLiteral<LoadingCache<String, Node>>() {
68 })).asMap(), map);
103 private Injector createInjectorWithProvidedMap(Map<String, Node> map) {
104 return Guice.createInjector(new CacheNodeStoreModule(map), new AbstractModule() {
106 @Override
114 private Injector createInjectorWithProvidedCache(LoadingCache<String, Node> cache) {
115 return Guice.createInjector(new CacheNodeStoreModule(cache), new AbstractModule() {
117 @Override
BoogieActivator.java (https://hg.codeplex.com/boogietools) Java · 96 lines
15 import com.google.common.collect.Maps;
16 import com.google.inject.Guice;
17 import com.google.inject.Injector;
18 import com.google.inject.Module;
20 /**
53 Injector injector = injectors.get(language);
54 if (injector == null) {
55 injectors.put(language, injector = createInjector(language));
56 }
57 return injector;
65 Module uiModule = getUiModule(language);
66 Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
67 return Guice.createInjector(mergedModule);
68 } catch (Exception e) {
69 logger.error("Failed to create injector for " + language);
EntityIntegrationSpec.java (git://github.com/orfjackal/dimdwarf.git) Java · 154 lines
EnsureJpaCanTakeObjectsInPropertiesTest.java (https://bitbucket.org/TinkerBoard_Android/external-guice.git) Java · 110 lines
13 */
15 package com.google.inject.persist.jpa;
17 import com.google.inject.AbstractModule;
18 import com.google.inject.Guice;
19 import com.google.inject.Injector;
20 import com.google.inject.persist.PersistService;
21 import com.google.inject.persist.UnitOfWork;
89 final DataSource dataSource = getDataSource();
91 injector = Guice.createInjector(new DBModule(dataSource, passDataSource));
93 //startup persistence
MoreUnitMockPlugin.java (git://pkgs.fedoraproject.org/eclipse-moreunit) Java · 94 lines
9 import org.osgi.framework.BundleContext;
11 import com.google.inject.Guice;
12 import com.google.inject.Inject;
13 import com.google.inject.Injector;
14 import com.google.inject.Module;
49 {
50 BundleContext bundleContext = getBundle().getBundleContext();
51 Guice.createInjector(osgiModule(bundleContext, eclipseRegistry()), module).injectMembers(this);
53 templateLoader.loadTemplates();
OpSourceServersErrorHandlerTest.java (git://github.com/jclouds/jclouds.git) Java · 103 lines
35 import org.testng.annotations.Test;
37 import com.google.inject.Guice;
39 /**
64 String content, Class<? extends Exception> expected) {
66 OpSourceServersErrorHandler function = Guice.createInjector().getInstance(OpSourceServersErrorHandler.class);
68 HttpCommand command = createMock(HttpCommand.class);
UpmUiTestRunner.java (https://bitbucket.org/atlassian/atlassian-universal-plugin-manager.git) Java · 121 lines
14 import com.atlassian.webdriver.refapp.RefappTestedProduct;
16 import com.google.common.base.Function;
17 import com.google.common.collect.ImmutableList;
18 import com.google.inject.AbstractModule;
19 import com.google.inject.ConfigurationException;
20 import com.google.inject.Guice;
21 import com.google.inject.Injector;
37 public static Composer compose()
38 {
39 Injector injector = Guice.createInjector(new UpmUiModule());
40 return CompositeTestRunner.compose().
41 from(TestGroupRunner.compose()).
TestMonitoringGuiceInterceptor.java (http://javamelody.googlecode.com/svn/trunk/) Java · 118 lines
31 import com.google.inject.AbstractModule;
32 import com.google.inject.Guice;
33 import com.google.inject.Injector;
52 @Test
53 public void testNewInstance() {
54 assertNotNull("new MonitoringGuiceInterceptor", new MonitoringGuiceInterceptor());
55 }
65 public void testGuiceAOP() {
66 final Counter guiceCounter = MonitoringProxy.getGuiceCounter();
67 guiceCounter.clear();
84 }
85 };
86 final Injector injector = Guice.createInjector(testModule);
87 final SpringTestFacade springTestFacade = injector.getInstance(SpringTestFacade.class);
ClientGuiceModule.java (http://google-secure-data-connector.googlecode.com/svn/trunk/) Java · 103 lines
1 /* Copyright 2008 Google Inc.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
17 package com.google.dataconnector.util;
19 import com.google.dataconnector.protocol.ProtocolGuiceModule;
20 import com.google.inject.AbstractModule;
21 import com.google.inject.Guice;
22 import com.google.inject.Injector;
54 public static Injector getInjector() {
55 if (injector == null) {
56 injector = Guice.createInjector(new ClientGuiceModule(), new ProtocolGuiceModule());
57 }
58 return injector;
Db4oWorkManagerTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 131 lines
23 import com.google.inject.AbstractModule;
24 import com.google.inject.Guice;
25 import com.google.inject.Inject;
26 import com.google.inject.Injector;
27 import com.google.inject.name.Names;
41 @BeforeClass
42 public void preClass() {
43 injector = Guice.createInjector(PersistenceService.usingDb4o()
44 .across(UnitOfWork.REQUEST)
InjectorSourceFactoryTest.java (git://github.com/cucumber/cucumber-jvm.git) Java · 113 lines
1 package cucumber.runtime.java.guice.impl;
3 import com.google.inject.Injector;
4 import cucumber.runtime.Env;
5 import cucumber.runtime.java.guice.InjectorSource;
6 import org.junit.Test;
15 public class InjectorSourceFactoryTest {
17 private InjectorSourceFactory createInjectorSourceFactory(Properties properties) {
18 return new InjectorSourceFactory(new Env(properties));
19 }
21 @Test
22 public void createsDefaultInjectorSourceWhenGuiceModulePropertyIsNotSet() throws Exception {
23 InjectorSourceFactory injectorSourceFactory = createInjectorSourceFactory(new Properties());
ParseKeyListTest.java (git://github.com/jclouds/jclouds.git) Java · 71 lines
BasicExample.java (https://bitbucket.org/sgla/aiml-core.git) Java · 94 lines
11 import org.apache.commons.logging.LogFactory;
13 import com.google.inject.Guice;
14 import com.google.inject.Injector;
86 public static void main(String[] args)
87 {
88 Injector injector = Guice.createInjector(new AIMLModule());
89 BasicExample example = new BasicExample();
90 injector.injectMembers(example);
ManualLocalTransactionsConfidenceTest.java (https://code.google.com/p/google-guice/) Java · 96 lines
1 /**
2 * Copyright (C) 2010 Google, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
17 package com.google.inject.persist.jpa;
19 import com.google.inject.Guice;
20 import com.google.inject.Inject;
21 import com.google.inject.Injector;
22 import com.google.inject.persist.PersistService;
42 @Override
43 public void setUp() {
44 injector = Guice.createInjector(new JpaPersistModule("testUnit"));
46 //startup persistence
EntityManagerProvisionTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 136 lines
19 import com.google.inject.AbstractModule;
20 import com.google.inject.Guice;
21 import com.google.inject.Inject;
22 import com.google.inject.Injector;
23 import com.google.inject.matcher.Matchers;
49 @BeforeClass
50 public void pre() {
51 injector = Guice.createInjector(PersistenceService.usingJpa()
52 .across(UnitOfWork.TRANSACTION)
53 .forAll(Matchers.any())
GuiceFactory.java (git://github.com/cucumber/cuke4duke.git) Java · 92 lines
1 package cuke4duke.internal.jvmclass;
3 import com.google.inject.*;
4 import cuke4duke.StepMother;
12 public class GuiceFactory implements ObjectFactory {
14 private static final String CONFIG_GUICE_MODULE = "cuke4duke.guiceModule";
16 private final List<Module> modules = new ArrayList<Module>();
41 public void createObjects() {
42 Injector injector = Guice.createInjector(modules);
43 for (Class<?> clazz : classes) {
44 try {
NestSlashKeysTest.java (git://github.com/jclouds/jclouds-chef.git) Java · 102 lines
30 import org.testng.annotations.Test;
32 import com.google.common.base.Supplier;
33 import com.google.common.base.Suppliers;
34 import com.google.common.collect.ImmutableMultimap;
35 import com.google.inject.Guice;
36 import com.google.inject.Injector;
49 @BeforeTest
50 protected void setUpInjector() throws IOException {
51 Injector injector = Guice.createInjector(new ChefParserModule(), new GsonModule());
52 converter = injector.getInstance(NestSlashKeys.class);
53 json = injector.getInstance(Json.class);
BindBlockDeviceMappingToIndexedFormParamsTest.java (git://github.com/jclouds/jclouds.git) Java · 68 lines
30 import com.google.common.collect.Maps;
31 import com.google.inject.Guice;
32 import com.google.inject.Injector;
37 @Test(groups = "unit")
38 public class BindBlockDeviceMappingToIndexedFormParamsTest {
39 Injector injector = Guice.createInjector();
40 BindBlockDeviceMappingToIndexedFormParams binder = injector
41 .getInstance(BindBlockDeviceMappingToIndexedFormParams.class);
SpecMavenStandaloneSetup.java (git://github.com/bmwcarit/Jnario.git) Java · 24 lines
6 import org.jnario.spec.spec.SpecPackage;
8 import com.google.inject.Guice;
9 import com.google.inject.Injector;
13 private static Injector injector = null;
15 public Injector createInjectorAndDoEMFRegistration() {
16 if (injector != null)
17 return injector;
18 EPackage.Registry.INSTANCE.put(SpecPackage.eINSTANCE.getNsURI(), SpecPackage.eINSTANCE);
19 injector = Guice.createInjector(new SpecMavenModule());
20 new SpecStandaloneSetupGenerated().register(injector);
21 return injector;
SshjSshClientModuleTest.java (git://github.com/jclouds/jclouds.git) Java · 43 lines
25 import com.google.common.net.HostAndPort;
26 import com.google.inject.Guice;
27 import com.google.inject.Injector;
35 public void testConfigureBindsClient() {
37 Injector i = Guice.createInjector(new SshjSshClientModule(), new SLF4JLoggingModule());
38 SshClient.Factory factory = i.getInstance(SshClient.Factory.class);
39 SshClient connection = factory.create(HostAndPort.fromParts("localhost", 22), LoginCredentials.builder().user("username")
NameUsageTestIT.java (http://gbif-ecat.googlecode.com/svn/trunk/) Java · 93 lines
17 import org.gbif.checklistbank.api.model.NameUsage;
18 import org.gbif.checklistbank.api.service.NameUsageService;
19 import org.gbif.checklistbank.ws.client.guice.ChecklistBankWsClientModule;
20 import org.gbif.checklistbank.ws.guice.ChecklistBankWsModule;
24 import java.util.UUID;
26 import com.google.inject.Guice;
27 import com.google.inject.Injector;
44 public void init() {
45 clientInjector =
46 Guice
47 .createInjector(new UrlBindingModule(this.getBaseURI(), "clb"), new ChecklistBankWsClientModule(false, true));
InjectorTest.java (https://bitbucket.org/cvgaviao/google-guice-mavenized) Java · 290 lines
40 public void testToStringDoesNotInfinitelyRecurse() {
41 Injector injector = Guice.createInjector(Stage.TOOL);
42 injector.toString();
43 injector.getBinding(Injector.class).toString();
48 final SampleSingleton other = new SampleSingleton();
50 Injector injector = Guice.createInjector(new AbstractModule() {
51 protected void configure() {
52 bind(SampleSingleton.class).toInstance(singleton);
195 public void testInjectStatics() throws CreationException {
196 Guice.createInjector(new AbstractModule() {
197 protected void configure() {
198 bindConstant().annotatedWith(S.class).to("test");
MutableSingletonScopeTest.java (http://guiceberry.googlecode.com/svn/trunk/) Java · 91 lines
15 */
17 package com.google.inject.testing.guiceberry.util;
19 import com.google.common.testing.junit3.TearDownTestCase;
20 import com.google.inject.AbstractModule;
21 import com.google.inject.Guice;
22 import com.google.inject.Inject;
42 SomethingElse somethingElse = new SomethingElse();
44 Injector injector = Guice.createInjector(new FooModule());
45 assertNull(somethingElse.barService);
46 assertNull(something.barService);
55 SomethingElse somethingElse = new SomethingElse();
57 Injector injector = Guice.createInjector(new FooModule());
58 assertNull(something.barService);
59 assertNull(something.barService);
SisuGuice.java (git://pkgs.fedoraproject.org/sisu) Java · 145 lines
23 import org.sonatype.guice.bean.locators.BeanLocator;
24 import org.sonatype.guice.bean.reflect.Logs;
26 import com.google.inject.AbstractModule;
27 import com.google.inject.Binder;
28 import com.google.inject.Guice;
29 import com.google.inject.Injector;
93 if ( null != locator )
94 {
95 Guice.createInjector( new WireModule()
96 {
97 @Override
127 if ( "injectMembers".equals( methodName ) )
128 {
129 Guice.createInjector( new WireModule( new AbstractModule()
130 {
131 @Override
TransferRequestIntegrationTest.java (https://code.google.com/p/google-guice/) Java · 123 lines
1 /**
2 * Copyright (C) 2012 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
15 */
17 package com.google.inject.servlet;
19 import com.google.common.collect.ImmutableMap;
20 import com.google.inject.AbstractModule;
21 import com.google.inject.Guice;
22 import com.google.inject.Injector;
61 public void testTransferNonHttpRequest() throws Exception {
62 final Injector injector = Guice.createInjector(new AbstractModule() {
63 @Override protected void configure() {
64 bindScope(RequestScoped.class, ServletScopes.REQUEST);
InjectorGrapherDemo.java (https://code.google.com/p/google-guice/) Java · 49 lines
1 /**
2 * Copyright (C) 2008 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
17 package com.google.inject.grapher.demo;
19 import com.google.inject.Guice;
20 import com.google.inject.Injector;
36 public static void main(String[] args) throws Exception {
37 // TODO(phopkins): Switch to Stage.TOOL when issue 297 is fixed.
38 Injector demoInjector = Guice.createInjector(Stage.DEVELOPMENT,
39 new BackToTheFutureModule(), new MultibinderModule(), new PrivateTestModule());
40 PrintWriter out = new PrintWriter(new File(args[0]), "UTF-8");
42 Injector injector = Guice.createInjector(new GraphvizModule());
43 GraphvizGrapher grapher = injector.getInstance(GraphvizGrapher.class);
44 grapher.setOut(out);
TraceDslStandaloneSetupGenerated.java (http://grooveclipse.googlecode.com/svn/trunk/) Java · 53 lines
6 import org.eclipse.emf.ecore.resource.Resource;
8 import com.google.inject.Guice;
9 import com.google.inject.Injector;
15 public class TraceDslStandaloneSetupGenerated implements ISetup {
17 public Injector createInjectorAndDoEMFRegistration() {
18 // register default ePackages
19 if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
26 EPackage.Registry.INSTANCE.put(org.eclipse.xtext.XtextPackage.eNS_URI, org.eclipse.xtext.XtextPackage.eINSTANCE);
28 Injector injector = createInjector();
29 register(injector);
30 return injector;
33 public Injector createInjector() {
34 return Guice.createInjector(new org.grooveclipse.analyze.TraceDslRuntimeModule());
35 }
NetworkConnectionSectionHandlerTest.java (git://github.com/jclouds/jclouds.git) Java · 64 lines
32 import com.google.common.collect.Iterables;
33 import com.google.inject.Guice;
34 import com.google.inject.Injector;
43 public void testVCloud1_0() {
44 InputStream is = getClass().getResourceAsStream("/networkconnectionsection.xml");
45 Injector injector = Guice.createInjector(new SaxParserModule());
46 Factory factory = injector.getInstance(ParseSax.Factory.class);
47 NetworkConnectionSection result = factory.create(injector.getInstance(NetworkConnectionSectionHandler.class))
GuiceTest.java (http://mycila.googlecode.com/svn/) Java · 138 lines
19 import com.google.inject.Binder;
20 import com.google.inject.Guice;
21 import com.google.inject.Inject;
35 import com.mycila.event.api.annotation.Reference;
36 import com.mycila.event.api.annotation.Subscribe;
37 import com.mycila.event.integration.guice.MycilaEventGuiceModule;
38 import com.mycila.event.spi.AnnotationProcessors;
39 import com.mycila.event.spi.Dispatchers;
45 import java.util.Arrays;
47 import static com.mycila.event.integration.guice.MycilaEventGuice.*;
49 /**
89 }
90 };
91 Injector injector = Guice.createInjector(this, m);
92 injector.getInstance(GuiceTest.class).publisher.publish("Hello world !");
RequireAtInjectOnConstructorsTest.java (https://code.google.com/p/google-guice/) Java · 203 lines
29 public void testNoCxtors_explicitBinding() {
30 try {
31 Guice.createInjector(new AbstractModule() {
32 @Override
33 protected void configure() {
48 public void testNoCxtors_jitBinding() {
49 Injector injector = Guice.createInjector(new AbstractModule() {
50 @Override
51 protected void configure() {
66 public void testNoCxtors_implicitBinding() {
67 try {
68 Guice.createInjector(new AbstractModule() {
69 @Override
70 protected void configure() {
SolrMeterMain.java (http://solrmeter.googlecode.com/svn/trunk/) Java · 118 lines
16 package com.plugtree.solrmeter;
18 import com.google.inject.Guice;
19 import com.google.inject.Injector;
20 import com.google.inject.Module;
21 import com.plugtree.solrmeter.controller.StatisticsRepository;
22 import com.plugtree.solrmeter.runMode.SolrMeterRunMode;
45 public static void main(String[] args) throws Exception {
46 addPlugins(new ExpectedParameter(args, "statisticsLocation", "./plugins").getValue());
47 createInjector();
48 runMode = injector.getInstance(SolrMeterRunMode.class);
49 runMode.main(injector);
84 modules.add(createModule("guice.solrMeterRunModeModule"));
85 modules.add(new StressTestScopeModule());
86 injector = Guice.createInjector(modules);
87 }
FuncTestRuleChain.java (https://bitbucket.org/ahmed_bilal_360factors/jira7-core.git) Java · 62 lines
18 import com.atlassian.jira.testkit.client.xmlbackup.XmlBackupCopier;
19 import com.atlassian.jira.webtests.util.JIRAEnvironmentData;
20 import com.google.inject.Guice;
21 import com.google.inject.Injector;
32 final WebTesterRule webTesterRule = new WebTesterRule(environmentDataSupplier, clientListenerSupplier);
34 final Injector injector = Guice.createInjector(
35 webTesterRule,
36 backdoorModule,
GInjectorCreateHandler.java
(http://gwt-test-utils.googlecode.com/svn/src/framework/trunk/)
Java · 113 lines
✨ Summary
This Java class, GInjectorCreateHandler
, handles the creation of a proxy injector for Google Web Toolkit (GWT) applications using the Guice dependency injection framework. It inspects a GWT class annotated with @GinModules
to determine which Guice modules to use and creates a proxy injector that delegates calls to the corresponding Guice injector.
This Java class, GInjectorCreateHandler
, handles the creation of a proxy injector for Google Web Toolkit (GWT) applications using the Guice dependency injection framework. It inspects a GWT class annotated with @GinModules
to determine which Guice modules to use and creates a proxy injector that delegates calls to the corresponding Guice injector.
14 import com.google.gwt.inject.client.GinModules;
15 import com.google.gwt.inject.client.Ginjector;
16 import com.google.gwt.inject.rebind.adapter.GinModuleAdapter;
17 import com.google.inject.Guice;
18 import com.google.inject.Injector;
49 Object guiceInjectorProxy = injectors.get(classLiteral);
51 if (guiceInjectorProxy != null) {
52 LOGGER.debug("Proxy for class '" + ginInjectorClass.getName()
53 + "'has been found in cache. It is returned");
60 Module[] guiceModules = readGuiceModules(ginInjectorClass, ginModules);
61 Injector injector = Guice.createInjector(guiceModules);
63 LOGGER.debug("creating new Proxy for class '" + ginInjectorClass.getName()
HeadlessReplyTest.java
(git://github.com/dhanji/sitebricks.git)
Java · 230 lines
✨ Summary
This Java code is a unit test for a HeadlessRenderer
class, which generates HTML responses from input data. The tests cover three scenarios: generating plain text, JSON, and XML responses with headers. It uses EasyMock to mock dependencies and verifies the output of each scenario against expected results.
This Java code is a unit test for a HeadlessRenderer
class, which generates HTML responses from input data. The tests cover three scenarios: generating plain text, JSON, and XML responses with headers. It uses EasyMock to mock dependencies and verifies the output of each scenario against expected results.
55 @Test
56 public void textReply() throws IOException {
57 Injector injector = Guice.createInjector();
58 HeadlessRenderer renderer = injector.getInstance(HeadlessRenderer.class);
59 HttpServletResponse response = createNiceMock(HttpServletResponse.class);
79 @Test
80 public void jsonReply() throws IOException {
81 Injector injector = Guice.createInjector(new AbstractModule() {
82 @SuppressWarnings("rawtypes")
83 @Override
120 @Test
121 public void xmlReplyWithHeaders() throws IOException {
122 Injector injector = Guice.createInjector();
123 HeadlessRenderer renderer = injector.getInstance(HeadlessRenderer.class);
124 HttpServletResponse response = createNiceMock(HttpServletResponse.class);
SoyFile.java
(https://code.google.com/p/plovr/)
Java · 115 lines
✨ Summary
This Java class represents a Soy file, which is a template language used for generating JavaScript code. It extends LocalFileJsInput
and provides methods to compile the Soy file into JavaScript code using the Google Guice framework and the Soy compiler. The class also handles configuration options and plugin modules.
This Java class represents a Soy file, which is a template language used for generating JavaScript code. It extends LocalFileJsInput
and provides methods to compile the Soy file into JavaScript code using the Google Guice framework and the Soy compiler. The class also handles configuration options and plugin modules.
12 import com.google.common.collect.Maps;
13 import com.google.inject.Guice;
14 import com.google.inject.Injector;
15 import com.google.inject.Module;
16 import com.google.template.soy.SoyFileSet;
17 import com.google.template.soy.SoyModule;
18 import com.google.template.soy.base.SoySyntaxException;
19 import com.google.template.soy.jssrc.SoyJsSrcOptions;
20 import com.google.template.soy.jssrc.SoyJsSrcOptions.CodeStyle;
110 }
112 return Guice.createInjector(guiceModules);
113 }
114 }
JerseyListener.java (http://gbif-ecat.googlecode.com/svn/trunk/) Java · 0 lines
6 import java.util.Map;
8 import com.google.inject.Guice;
9 import com.google.inject.Injector;
11 import com.google.inject.name.Names;
12 import com.google.inject.servlet.GuiceServletContextListener;
13 import com.sun.jersey.api.core.PackagesResourceConfig;
14 import com.sun.jersey.api.json.JSONConfiguration;
15 import com.sun.jersey.guice.JerseyServletModule;
16 import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
18 public class JerseyListener extends GuiceServletContextListener {
20 @Override
21 protected Injector getInjector() {
22 return Guice.createInjector(new JerseyTestModule());
23 }
BindLoggersAnnotatedWithResourceTest.java (git://github.com/jclouds/jclouds.git) Java · 137 lines
17 package org.jclouds.logging.config;
19 import static com.google.inject.matcher.Matchers.any;
20 import static org.easymock.EasyMock.createMock;
21 import static org.testng.Assert.assertEquals;
37 import com.google.inject.AbstractModule;
38 import com.google.inject.Guice;
39 import com.google.inject.Injector;
65 @Test
66 void testHear() {
67 Injector i = Guice.createInjector(new AbstractModule() {
69 @Override
ManualLocalTransactionsTest.java (https://code.google.com/p/google-guice/) Java · 106 lines
1 /**
2 * Copyright (C) 2010 Google, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
17 package com.google.inject.persist.jpa;
19 import com.google.inject.Guice;
20 import com.google.inject.Inject;
21 import com.google.inject.Injector;
22 import com.google.inject.persist.PersistService;
45 public void setUp() {
46 injector = Guice.createInjector(new JpaPersistModule("testUnit"));
48 //startup persistence
CustomLoginPortFromImageTest.java (git://github.com/jclouds/jclouds.git) Java · 106 lines
26 import org.testng.annotations.Test;
28 import com.google.common.base.Optional;
29 import com.google.common.base.Predicate;
30 import com.google.common.collect.ImmutableList;
31 import com.google.common.collect.Iterables;
32 import com.google.inject.AbstractModule;
33 import com.google.inject.Guice;
34 import com.google.inject.Injector;
42 @BeforeClass
43 public void setup() {
44 Injector i = Guice.createInjector(new LoginPortLookupModule(), new AbstractModule() {
45 @Override
46 protected void configure() {
ManualLocalTransactionsWithCustomMatcherTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 117 lines
19 import com.google.inject.AbstractModule;
20 import com.google.inject.Guice;
21 import com.google.inject.Inject;
22 import com.google.inject.Injector;
23 import com.google.inject.matcher.Matchers;
50 @BeforeClass
51 public void pre() {
52 injector = Guice.createInjector(PersistenceService.usingJpa()
53 .across(UnitOfWork.REQUEST)
54 .forAll(Matchers.subclassesOf(TransactionalObject.class), Matchers.any())
SitebricksServiceTest.java (git://github.com/dhanji/sitebricks.git) Java · 141 lines
1 package com.google.sitebricks.acceptance.util;
3 import java.io.File;
14 import com.google.inject.Binder;
15 import com.google.inject.Guice;
16 import com.google.inject.Injector;
17 import com.google.inject.Key;
18 import com.google.inject.Module;
19 import com.google.inject.name.Names;
20 import com.google.sitebricks.SitebricksModule;
54 @BeforeMethod
55 public void setUp() {
56 injector = Guice.createInjector(new SetUpModule(), sitebricksModule());
57 }
ParseKeySetFromJsonTest.java (git://github.com/jclouds/jclouds-chef.git) Java · 63 lines
32 import com.google.common.collect.ImmutableSet;
33 import com.google.inject.Guice;
34 import com.google.inject.Injector;
46 @BeforeTest
47 protected void setUpInjector() throws IOException {
48 Injector injector = Guice.createInjector(new ChefParserModule(), new GsonModule());
49 handler = injector.getInstance(ParseKeySetFromJson.class);
50 }
OhaiModuleTest.java (git://github.com/jclouds/jclouds.git) Java · 147 lines
35 import org.testng.annotations.Test;
37 import com.google.common.base.Supplier;
38 import com.google.common.base.Suppliers;
39 import com.google.inject.AbstractModule;
40 import com.google.inject.Guice;
41 import com.google.inject.Injector;
59 sysProperties.setProperty("user.name", "user");
61 Injector injector = Guice.createInjector(new AbstractModule() {
62 @Override
63 protected void configure() {
93 sysProperties.setProperty("user.name", "user");
95 Injector injector = Guice.createInjector(new AbstractModule() {
96 @Override
97 protected void configure() {
TestScopeTestCase.java (http://solrmeter.googlecode.com/svn/trunk/) Java · 96 lines
ParseOrganizationFromJsonTest.java (git://github.com/jclouds/jclouds-chef.git) Java · 65 lines
32 import org.testng.annotations.Test;
34 import com.google.inject.Guice;
35 import com.google.inject.Injector;
36 import com.google.inject.Key;
37 import com.google.inject.TypeLiteral;
49 @BeforeTest
50 protected void setUpInjector() throws IOException {
51 Injector injector = Guice.createInjector(new ChefParserModule(), new GsonModule());
52 handler = injector.getInstance(Key.get(new TypeLiteral<ParseJson<Organization>>() {
53 }));
AbstractInjectorGrapherTest.java (https://code.google.com/p/google-guice/) Java · 184 lines
23 import com.google.inject.BindingAnnotation;
24 import com.google.inject.Guice;
25 import com.google.inject.Inject;
123 public void testLinkedAndInstanceBindings() throws Exception {
124 grapher.graph(Guice.createInjector(new AbstractModule() {
125 @Override protected void configure() {
126 bind(IA.class).to(A.class);
144 public void testProviderBindings() throws Exception {
145 final Wrapper<Provider<A2>> wrapper = new Wrapper<Provider<A2>>();
146 grapher.graph(Guice.createInjector(new AbstractModule() {
147 @Override protected void configure() {
148 wrapper.value = getProvider(A2.class);
168 public void testGraphWithGivenRoot() throws Exception {
169 grapher.graph(Guice.createInjector(new AbstractModule() {
170 @Override protected void configure() {
171 bind(IA.class).to(A.class);
SerializationTest.java (https://code.google.com/p/google-guice/) Java · 64 lines
1 /**
2 * Copyright (C) 2008 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
18 package com.google.inject;
20 import static com.google.inject.Asserts.assertSimilarWhenReserialized;
29 /**
30 * @author jessewilson@google.com (Jesse Wilson)
31 */
32 public class SerializationTest extends TestCase {
45 private CreationException createCreationException() {
46 try {
47 Guice.createInjector(new AbstractModule() {
48 protected void configure() {
49 bind(List.class);
ParseBackupScheduleFromJsonResponseTest.java (git://github.com/jclouds/jclouds.git) Java · 67 lines
30 import org.testng.annotations.Test;
32 import com.google.inject.Guice;
33 import com.google.inject.Injector;
34 import com.google.inject.Key;
35 import com.google.inject.TypeLiteral;
42 @Test(groups = "unit")
43 public class ParseBackupScheduleFromJsonResponseTest {
44 Injector i = Guice.createInjector(new GsonModule());
46 public void testApplyInputStreamDetails() throws UnknownHostException {
SfVsMk2.java (http://java-fighting-game-engine.googlecode.com/svn/trunk/) Java · 81 lines
31 import org.jfge.j2se.graphics.J2SeGraphicsModule;
33 import com.google.inject.Guice;
34 import com.google.inject.Injector;
35 import com.google.inject.Key;
36 import com.google.inject.TypeLiteral;
38 public class SfVsMk2 {
39 public static void main(String[] args) {
40 Injector injector = Guice.createInjector(
41 new EngineModule(),
42 new J2SeGraphicsModule(),
EntityManagerFactoryProvisionTest.java (http://warp-persist.googlecode.com/svn/trunk/) Java · 87 lines
19 import com.google.inject.AbstractModule;
20 import com.google.inject.Guice;
21 import com.google.inject.Injector;
22 import com.google.inject.matcher.Matchers;
23 import com.wideplay.warp.persist.PersistenceService;
24 import com.wideplay.warp.persist.UnitOfWork;
49 @BeforeTest
50 public void pre() {
51 injector = Guice.createInjector(PersistenceService.usingJpa()
52 .across(UnitOfWork.TRANSACTION)
CatalogItemHandlerTest.java (git://github.com/jclouds/jclouds.git) Java · 87 lines
32 import com.google.common.collect.ImmutableSortedMap;
33 import com.google.inject.Guice;
34 import com.google.inject.Injector;
44 public void testApplyInputStream() {
45 InputStream is = getClass().getResourceAsStream("/catalogItem-hosting.xml");
46 Injector injector = Guice.createInjector(new SaxParserModule());
47 Factory factory = injector.getInstance(ParseSax.Factory.class);
48 CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is);
61 public void testApplyInputStreamWithNamespaceUsingVcloud() {
62 InputStream is = getClass().getResourceAsStream("/catalogItem-carrenza-with-vcloud-namespace.xml");
63 Injector injector = Guice.createInjector(new SaxParserModule());
64 Factory factory = injector.getInstance(ParseSax.Factory.class);
65 CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is);
74 public void testApplyInputStreamWithNamespaceUsingDefault() {
75 InputStream is = getClass().getResourceAsStream("/catalogItem-carrenza-with-default-namespace.xml");
76 Injector injector = Guice.createInjector(new SaxParserModule());
77 Factory factory = injector.getInstance(ParseSax.Factory.class);
78 CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is);
BasicGuiceServletContextListener.java (http://gwt-cx.googlecode.com/svn/trunk/) Java · 28 lines
15 package com.gwtcx.sample.basic.server.guice;
17 import com.google.inject.Guice;
18 import com.google.inject.Injector;
19 import com.google.inject.servlet.GuiceServletContextListener;
21 public class BasicGuiceServletContextListener extends GuiceServletContextListener {
23 @Override
24 protected Injector getInjector() {
25 return Guice.createInjector(new BasicServerModule(), new BasicServletModule());
26 }
27 }
GuiceAdapter.java (http://t-2.googlecode.com/svn/trunk/) Java · 194 lines
31 import org.t2framework.t2.handler.impl.GlobalExceptionHandlerImpl;
33 import com.google.inject.Guice;
34 import com.google.inject.Injector;
37 /**
38 *
39 * {@.en An adapter class for Google Guice.}
40 *
41 * <br />
99 protected void setupInjector() {
100 if (injector == null) {
101 injector = Guice.createInjector(modules);
102 }
103 }
106 public <T> List<T> getComponents(Class<? super T> componentClass) {
107 logger
108 .debug("GuiceAdapter does not support getComponents(), so just return single component.");
109 setupInjector();
110 if (hasComponent(componentClass)) {
OSGiTestActivator.java (https://bitbucket.org/TinkerBoard_Android/external-guice.git) Java · 511 lines
1 /**
2 * Copyright (C) 2009 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
15 */
17 package com.googlecode.guice.bundle;
19 import static com.google.inject.name.Names.named;
21 import com.google.inject.AbstractModule;
22 import com.google.inject.Guice;
23 import com.google.inject.Inject;
485 final Bundle bundle = context.getBundle();
487 Injector injector = Guice.createInjector(new TestModule(bundle));
488 /*if[AOP]*/
489 Injector aopInjector = Guice.createInjector(new TestModule(bundle), new InterceptorModule());
MeteredTest.java (git://github.com/codahale/metrics.git) Java · 103 lines
1 package com.yammer.metrics.guice.tests;
3 import com.google.inject.Guice;
4 import com.google.inject.Injector;
5 import com.yammer.metrics.core.*;
6 import com.yammer.metrics.guice.InstrumentationModule;
8 import org.junit.Before;
23 @Before
24 public void setup() {
25 final Injector injector = Guice.createInjector(new InstrumentationModule());
26 instance = injector.getInstance(InstrumentedWithMetered.class);
27 registry = injector.getInstance(MetricsRegistry.class);
39 assertMetricIsSetup(metric);
41 assertThat("Guice creates a meter which gets marked",
42 ((Meter) metric).count(),
43 is(1L));
GuiceContainerFactory.java (http://webwind.googlecode.com/svn/trunk/) Java · 120 lines
13 import org.expressme.webwind.ConfigException;
14 import org.expressme.webwind.Destroyable;
15 import org.expressme.webwind.guice.ServletContextAware;
17 import com.google.inject.Binding;
18 import com.google.inject.Guice;
19 import com.google.inject.Injector;
20 import com.google.inject.Key;
21 import com.google.inject.Module;
58 if (moduleList.isEmpty())
59 throw new ConfigException("No module found.");
60 this.injector = Guice.createInjector(Stage.PRODUCTION, moduleList);
61 config.getServletContext().setAttribute(Injector.class.getName(), this.injector);
62 }
ControlManagementTest.java (https://github.com/wabu/hank.git) Java · 142 lines
21 import java.util.logging.Logger;
23 import com.google.inject.Guice;
24 import com.google.inject.Injector;
71 // COMMENT(wabu): @Inject does not work for junit tests
72 public void setUp() { // PlayerControlMap keymap, ControlManagement manager) {
73 Injector inj = Guice.createInjector(new ControlModule(), new MainModelModule());
74 this.keymap = inj.getInstance(PlayerControlMap.class);
75 this.manager = inj.getInstance(ControlManagement.class);
GoGridErrorHandlerTest.java (git://github.com/jclouds/jclouds.git) Java · 77 lines
31 import org.testng.annotations.Test;
33 import com.google.inject.Guice;
35 /**
44 InputStream is = getClass().getResourceAsStream("/test_error_handler.json");
46 GoGridErrorHandler handler = Guice.createInjector(new GsonModule()).getInstance(GoGridErrorHandler.class);
48 HttpCommand command = createHttpCommand();
CloudServersImageToImageTest.java (git://github.com/jclouds/jclouds.git) Java · 63 lines
31 import org.testng.annotations.Test;
33 import com.google.inject.Guice;
35 /**
55 CloudServersComputeServiceContextModule.toPortableImageStatus, new CloudServersImageToOperatingSystem(
56 new BaseComputeServiceContextModule() {
57 }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(
58 new GsonModule()).getInstance(Json.class))));
InfrastructureDslStandaloneSetupGenerated.java (http://grooveclipse.googlecode.com/svn/trunk/) Java · 45 lines
6 import org.eclipse.emf.ecore.resource.Resource;
8 import com.google.inject.Guice;
9 import com.google.inject.Injector;
15 public class InfrastructureDslStandaloneSetupGenerated implements ISetup {
17 public Injector createInjectorAndDoEMFRegistration() {
18 org.eclipse.xtext.common.TerminalsStandaloneSetup.doSetup();
20 Injector injector = createInjector();
21 register(injector);
22 return injector;
25 public Injector createInjector() {
26 return Guice.createInjector(new org.grooveclipse.infrastructure.dsl.InfrastructureDslRuntimeModule());
27 }
FGCPRestClientModuleTest.java (git://github.com/jclouds/jclouds.git) Java · 96 lines
33 import org.testng.annotations.Test;
35 import com.google.inject.Guice;
36 import com.google.inject.Injector;
47 @BeforeTest
48 protected void createCrypto() {
49 Injector i = Guice.createInjector();
50 crypto = i.getInstance(Crypto.class);
51 }
53 @BeforeTest
54 protected void createRestClientModule() {
55 Injector i = Guice.createInjector();
56 module = i.getInstance(FGCPRestClientModule.class);
57 }
LifecycleSupportTest.java (https://gitlab.com/kidaa/ninja.git) Java · 203 lines
29 import com.google.inject.AbstractModule;
30 import com.google.inject.Guice;
31 import com.google.inject.Injector;
58 @Test
59 public void serviceShouldBeStartedIfAccessedAfterLifecycleServiceIsStarted() {
60 Injector injector = createInjector();
61 start(injector);
62 injector.getInstance(MockService.class);
90 @Test
91 public void serviceShouldNotBeStartedIfExplicitlyBoundAndNotSingleton() {
92 Injector injector = createInjector(new AbstractModule() {
93 @Override
94 protected void configure() {
163 List<Module> ms = new ArrayList<Module>(Arrays.asList(modules));
164 ms.add(LifecycleSupport.getModule());
165 return Guice.createInjector(ms);
166 }
JMXTest.java (git://github.com/jclouds/jclouds.git) Java · 82 lines
36 import org.testng.annotations.Test;
38 import com.google.common.base.Supplier;
39 import com.google.inject.AbstractModule;
40 import com.google.inject.Guice;
41 import com.google.inject.Injector;
56 replay(runtime);
58 Injector injector = Guice.createInjector(new AbstractModule() {
59 @Override
60 protected void configure() {
FeatureMavenStandaloneSetup.java (git://github.com/bmwcarit/Jnario.git) Java · 24 lines
6 import org.jnario.feature.feature.FeaturePackage;
8 import com.google.inject.Guice;
9 import com.google.inject.Injector;
13 private static Injector injector = null;
15 public Injector createInjectorAndDoEMFRegistration() {
16 if (injector != null)
17 return injector;
18 EPackage.Registry.INSTANCE.put(FeaturePackage.eINSTANCE.getNsURI(), FeaturePackage.eINSTANCE);
19 injector = Guice.createInjector(new FeatureMavenModule());
20 new FeatureStandaloneSetupGenerated().register(injector);
21 return injector;
RestfuWebServiceWithSubpathsAcceptanceTest.java
(git://github.com/dhanji/sitebricks.git)
Java · 112 lines
✨ Summary
This Java code is a test class for a RESTful web service using SiteBricks, a Java framework for building web applications. It tests various scenarios, including accessing top-level and sub-path resources, posting data to different paths, and handling variable-length path segments. The tests verify that the expected responses are received from the web service.
This Java code is a test class for a RESTful web service using SiteBricks, a Java framework for building web applications. It tests various scenarios, including accessing top-level and sub-path resources, posting data to different paths, and handling variable-length path segments. The tests verify that the expected responses are received from the web service.
4 import com.google.inject.AbstractModule;
5 import com.google.inject.Guice;
6 import com.google.inject.Injector;
7 import com.google.sitebricks.acceptance.util.AcceptanceTest;
8 import com.google.sitebricks.client.Web;
9 import com.google.sitebricks.client.WebResponse;
10 import com.google.sitebricks.client.transport.Json;
11 import com.google.sitebricks.conversion.Converter;
12 import com.google.sitebricks.conversion.ConverterRegistry;
13 import com.google.sitebricks.conversion.StandardTypeConverter;
104 private Injector createInjector() {
105 return Guice.createInjector(new AbstractModule() {
106 protected void configure() {
107 bind(ConverterRegistry.class).toInstance(new StandardTypeConverter(
NetworkConnectionSectionHandlerTest.java (git://github.com/jclouds/jclouds.git) Java · 53 lines
29 import org.testng.annotations.Test;
31 import com.google.inject.Guice;
32 import com.google.inject.Injector;
42 public void test() {
43 InputStream is = getClass().getResourceAsStream("/networkconnectionsection.xml");
44 Injector injector = Guice.createInjector(new SaxParserModule());
45 Factory factory = injector.getInstance(ParseSax.Factory.class);
46 NetworkConnectionSection result = factory.create(injector.getInstance(NetworkConnectionSectionHandler.class))
GbuiTestCase.java (http://heavylead.googlecode.com/svn/trunk/) Java · 102 lines
CreateDefaultDb.java (http://gbif-ecat.googlecode.com/svn/trunk/) Java · 133 lines
19 import org.gbif.checklistbank.Constants;
20 import org.gbif.checklistbank.TestConstants;
21 import org.gbif.checklistbank.guice.BasicModule;
22 import org.gbif.checklistbank.guice.ConfigModuleMaven;
29 import java.util.List;
31 import com.google.inject.Guice;
32 import com.google.inject.Injector;
52 public static void main(String[] args) {
53 Injector injector = Guice.createInjector(new ConfigModuleMaven(), new BasicModule(false));
54 CreateDefaultDb db = new CreateDefaultDb(injector.getInstance(ChecklistImportService.class),
55 injector.getInstance(ChecklistService.class));
MvelRequestBinderTest.java (https://github.com/arnihermann/warp-core.git) Java · 208 lines
1 package com.wideplay.warp.widgets.binding;
3 import com.google.inject.Guice;
4 import com.google.inject.Provider;
32 final AnObject o = new AnObject();
34 final Evaluator evaluator = Guice.createInjector()
35 .getInstance(Evaluator.class);
69 final AnObject o = new AnObject();
71 final Evaluator evaluator = Guice.createInjector()
72 .getInstance(Evaluator.class);
102 final AnObject o = new AnObject();
104 final Evaluator evaluator = Guice.createInjector()
105 .getInstance(Evaluator.class);
StorerModuleTest.java (https://code.google.com/p/rabbit-eclipse/) Java · 93 lines
29 import rabbit.data.store.model.TaskFileEvent;
31 import com.google.inject.Guice;
32 import com.google.inject.Injector;
33 import com.google.inject.Key;
34 import com.google.inject.TypeLiteral;
75 this.storerInterface = storerInterface;
76 this.storerImplementation = storerImplementation;
77 this.injector = Guice.createInjector(
78 new StorerModule(), new StoreNamesModule(), new ConverterModule(), new MergerModule());
79 }
NamedDatabaseTest.java (git://github.com/playframework/Play20.git) Java · 113 lines
9 import com.google.common.collect.ImmutableMap;
10 import com.google.inject.Guice;
11 import com.google.inject.Injector;
17 import play.ApplicationLoader.Context;
18 import play.Environment;
19 import play.inject.guice.GuiceApplicationBuilder;
20 import play.inject.guice.GuiceApplicationLoader;
60 "db.other.url", "jdbc:h2:mem:other"
61 );
62 Injector injector = createInjector(config);
63 assertThat(injector.getInstance(NamedOtherComponent.class).db.getUrl(), equalTo("jdbc:h2:mem:other"));
64 exception.expect(com.google.inject.ConfigurationException.class);
94 private Injector createInjector(Map<String, Object> config) {
95 GuiceApplicationBuilder builder = new GuiceApplicationLoader()
96 .builder(new Context(Environment.simple(), config));
97 return Guice.createInjector(builder.applicationModule());
ExtendedSuiteInjectorProvider.java (git://github.com/bmwcarit/Jnario.git) Java · 34 lines
12 import org.jnario.suite.SuiteStandaloneSetup;
14 import com.google.inject.Guice;
15 import com.google.inject.Injector;
17 public class ExtendedSuiteInjectorProvider extends SuiteInjectorProvider {
19 protected Injector internalCreateInjector() {
20 return new SuiteStandaloneSetup(){
21 public Injector createInjector() {
22 return Guice.createInjector(new SuiteRuntimeModule(){
23 public void configure(com.google.inject.Binder binder) {
30 });
31 }
32 }.createInjectorAndDoEMFRegistration();
33 }
34 }
Main6.java (http://t-2.googlecode.com/svn/trunk/) Java · 38 lines
3 import com.google.inject.AbstractModule;
4 import com.google.inject.Guice;
5 import com.google.inject.Injector;
6 import com.google.inject.Module;
8 public class Main6 {
27 };
28 Injector injector = Guice.createInjector(module1, module2);
29 Bar bar = injector.getInstance(Bar.class);
30 System.out.println(bar.getMessage());
BindCloneDriveOptionsToPlainTextStringTest.java (git://github.com/jclouds/jclouds.git) Java · 72 lines
30 import org.testng.annotations.Test;
32 import com.google.common.base.Throwables;
33 import com.google.common.collect.ImmutableList;
34 import com.google.common.collect.ImmutableMap;
35 import com.google.inject.Guice;
36 /**
37 *
41 public class BindCloneDriveOptionsToPlainTextStringTest {
43 private static final BindCloneDriveOptionsToPlainTextString binder = Guice.createInjector().getInstance(
44 BindCloneDriveOptionsToPlainTextString.class);
SupportedVersionsHandlerTest.java (git://github.com/jclouds/jclouds.git) Java · 54 lines
30 import com.google.common.collect.ImmutableSortedMap;
31 import com.google.inject.Guice;
32 import com.google.inject.Injector;
43 InputStream is = getClass().getResourceAsStream("/versions.xml");
45 Injector injector = Guice.createInjector(new SaxParserModule());
46 Factory factory = injector.getInstance(ParseSax.Factory.class);
BinderTest.java (https://bitbucket.org/cvgaviao/google-guice-mavenized) Java · 184 lines
128 final Integer[] integers = new Integer[] { 1 };
130 Injector injector = Guice.createInjector(new AbstractModule() {
131 protected void configure() {
132 bind(String[].class).toInstance(strings);
144 try {
145 Guice.createInjector(new AbstractModule() {
146 protected void configure() {
147 bind(String[].class).toInstance(strings);
176 // public void testBindInterfaceWithoutImplementation() {
177 // Guice.createInjector(new AbstractModule() {
178 // protected void configure() {
179 // bind(Runnable.class);
EasyAntPlugin.java (https://svn.apache.org/repos/asf/incubator/easyant/) Java · 0 lines
31 import org.eclipse.ui.PlatformUI;
33 import com.google.inject.Guice;
34 import com.google.inject.Injector;
35 import com.google.inject.Module;
37 public class EasyAntPlugin {
41 public EasyAntPlugin(Module... modules) {
42 injector = Guice.createInjector(modules);
43 injector.injectMembers(this);
44 }
MvelRequestBinderTest.java
(git://github.com/dhanji/sitebricks.git)
Java · 275 lines
✨ Summary
This Java code tests a class MvelRequestBinder
that binds HTTP request parameters to an object using MVEL (Java Expression Language). It creates mock requests with valid and invalid parameter values, then tests how the binder handles them, asserting whether the bindings are correct or not. The test cases cover different scenarios, including partially and totally invalid bindings.
This Java code tests a class MvelRequestBinder
that binds HTTP request parameters to an object using MVEL (Java Expression Language). It creates mock requests with valid and invalid parameter values, then tests how the binder handles them, asserting whether the bindings are correct or not. The test cases cover different scenarios, including partially and totally invalid bindings.
1 package com.google.sitebricks.binding;
3 import com.google.inject.Guice;
4 import com.google.inject.Provider;
34 final AnObject o = new AnObject();
36 final Evaluator evaluator = Guice.createInjector()
37 .getInstance(Evaluator.class);
71 final AnObject o = new AnObject();
73 final Evaluator evaluator = Guice.createInjector()
74 .getInstance(Evaluator.class);
104 final AnObject o = new AnObject();
106 final Evaluator evaluator = Guice.createInjector()
107 .getInstance(Evaluator.class);
EssentialOCLActivator.java (git://pkgs.fedoraproject.org/eclipse-mdt-ocl) Java · 74 lines
10 import org.osgi.framework.BundleContext;
12 import com.google.inject.Guice;
13 import com.google.inject.Injector;
14 import com.google.inject.Module;
15 import com.google.inject.util.Modules;
36 try {
38 injectors.put("org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCL", Guice.createInjector(
39 Modules.override(Modules.override(getRuntimeModule("org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCL")).with(getUiModule("org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCL"))).with(getSharedStateModule())
40 ));
ParseFloatingIPTest.java (git://github.com/jclouds/jclouds.git) Java · 53 lines
SystemVerilogStandaloneSetupGenerated.java (http://hdl-forge.googlecode.com/svn/trunk/) Java · 45 lines
6 import org.eclipse.emf.ecore.resource.Resource;
8 import com.google.inject.Guice;
9 import com.google.inject.Injector;
15 public class SystemVerilogStandaloneSetupGenerated implements ISetup {
17 public Injector createInjectorAndDoEMFRegistration() {
18 org.eclipse.xtext.common.TerminalsStandaloneSetup.doSetup();
20 Injector injector = createInjector();
21 register(injector);
22 return injector;
25 public Injector createInjector() {
26 return Guice.createInjector(new com.ironglass.hdlforge.SystemVerilogRuntimeModule());
27 }
OCLstdlibActivator.java (git://pkgs.fedoraproject.org/eclipse-mdt-ocl) Java · 74 lines
10 import org.osgi.framework.BundleContext;
12 import com.google.inject.Guice;
13 import com.google.inject.Injector;
14 import com.google.inject.Module;
15 import com.google.inject.util.Modules;
36 try {
38 injectors.put("org.eclipse.ocl.examples.xtext.oclstdlib.OCLstdlib", Guice.createInjector(
39 Modules.override(Modules.override(getRuntimeModule("org.eclipse.ocl.examples.xtext.oclstdlib.OCLstdlib")).with(getUiModule("org.eclipse.ocl.examples.xtext.oclstdlib.OCLstdlib"))).with(getSharedStateModule())
40 ));