@SuppressWarnings("deprecation") @Before public void setupDependencies() throws Exception { if (null != _service_context) { return; } final String temp_dir = System.getProperty("java.io.tmpdir") + File.separator; // OK we're going to use guice, it was too painful doing this by hand... Config config = ConfigFactory.parseReader( new InputStreamReader( this.getClass().getResourceAsStream("test_data_bucket_change.properties"))) .withValue("globals.local_root_dir", ConfigValueFactory.fromAnyRef(temp_dir)) .withValue("globals.local_cached_jar_dir", ConfigValueFactory.fromAnyRef(temp_dir)) .withValue("globals.distributed_root_dir", ConfigValueFactory.fromAnyRef(temp_dir)) .withValue("globals.local_yarn_config_dir", ConfigValueFactory.fromAnyRef(temp_dir)); Injector app_injector = ModuleUtils.createTestInjector(Arrays.asList(), Optional.of(config)); app_injector.injectMembers(this); _db_actor_context = new ManagementDbActorContext(_service_context, true); _actor_context = new DataImportActorContext(_service_context, new GeneralInformationService(), null); // TODO app_injector.injectMembers(_actor_context); // Have to do this in order for the underlying management db to live... _service_context.getCoreManagementDbService(); }
@Before public void setUp() throws Exception { Injector injector = Guice.createInjector(getModule()); injector.injectMembers(this); typeProviderFactory.findOrCreateTypeProvider(resourceSet); syntheticResource = new XMLResourceImpl(URI.createURI("http://synthetic.resource")); resourceSet.getResources().add(syntheticResource); final TypeConformanceComputer delegate = computer; computer = new TypeConformanceComputer() { @Override public boolean isConformant( JvmTypeReference left, JvmTypeReference right, boolean ignoreGenerics) { assertTrue(delegate.isConformant(left, left, true)); assertTrue(delegate.isConformant(left, left, false)); assertTrue(delegate.isConformant(right, right, true)); assertTrue(delegate.isConformant(right, right, false)); assertTrue(delegate.isConformant(left, EcoreUtil2.clone(left), true)); assertTrue(delegate.isConformant(left, EcoreUtil2.clone(left), false)); assertTrue(delegate.isConformant(right, EcoreUtil2.clone(right), true)); assertTrue(delegate.isConformant(right, EcoreUtil2.clone(right), false)); return delegate.isConformant(left, right, ignoreGenerics); } @Override public JvmTypeReference getCommonSuperType(List<JvmTypeReference> types) { return delegate.getCommonSuperType(types); } }; }
@Override protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); ExpressionDirectEditPolicy expressionDirectEditPolicy = new ExpressionDirectEditPolicy(); injector.injectMembers(expressionDirectEditPolicy); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, expressionDirectEditPolicy); }
@Override public SshClient create(IPSocket socket, LoginCredentials credentials) { SshClient client = new SshjSshClient(backoffLimitedRetryHandler, socket, credentials, timeout); injector.injectMembers(client); // add logger return client; }
@BeforeClass(groups = "slow") protected void beforeClass() throws Exception { final Injector injector = Guice.createInjector( Stage.PRODUCTION, new TestEntitlementModuleWithEmbeddedDB(configSource)); injector.injectMembers(this); }
@Before public void setUp() { XtendActivator _instance = XtendActivator.getInstance(); final Injector injector = _instance.getInjector("org.eclipse.xtend.core.Xtend"); injector.injectMembers(this); this.queuedBuildData.reset(); }
private void initialize(Context context) { Context applicationContext = context.getApplicationContext(); Injector injector = AirCastingApplication.class.cast(applicationContext).getInjector(); injector.injectMembers(this); gestureDetector.setOnDoubleTapListener(this); }
/** * Initializes the application; in particular, bootstrapping the Isis backend, and initializing * the {@link ComponentFactoryRegistry} to be used for rendering. */ @Override protected void init() { super.init(); // 6.0.0 rather than overriding getRequestCycleSettings // TODO: reinstate REDIRECT_TO_RENDER once WICKET-4773 implemented (Wicket 6.1.0) getRequestCycleSettings().setRenderStrategy(RenderStrategy.REDIRECT_TO_BUFFER); // 6.0.0 instead of subclassing newRequestCycle getRequestCycleListeners().add(new WebRequestCycleForIsis()); getResourceSettings().setParentFolderPlaceholder("$up$"); final DeploymentType deploymentType = determineDeploymentType(); final IsisConfigurationBuilder isisConfigurationBuilder = createConfigBuilder(getServletContext()); final IsisInjectModule isisModule = new IsisInjectModule(deploymentType, isisConfigurationBuilder); final Injector injector = Guice.createInjector(isisModule, newIsisWicketModule()); injector.injectMembers(this); this.bookmarkedPagesModel = new BookmarkedPagesModel(); initWicketComponentInjection(injector); }
@BeforeClass(groups = "slow") protected void beforeClass() throws Exception { loadSystemPropertiesFromClasspath("/resource.properties"); final Injector injector = Guice.createInjector(new TestPaymentModuleWithEmbeddedDB(configSource, getClock())); injector.injectMembers(this); }
public List<AdminCommand> listCommands() { final ServiceLoader<AdminCommand> loader = ServiceLoader.load(AdminCommand.class); final List<AdminCommand> list = new ArrayList<>(); for (final AdminCommand command : loader) { injector.injectMembers(command); list.add(command); } return list; }
@Before public void setUp() throws Exception { ResourceSet resourceSet = new ResourceSetImpl(); Injector injector = Guice.createInjector(getModule()); injector.injectMembers(this); typeProvider = injector.getInstance(IJvmTypeProvider.Factory.class).findOrCreateTypeProvider(resourceSet); typeRefs = new JvmTypeReferences(injector.getInstance(TypesFactory.class), typeProvider); }
/** * Implementation does injection of actor handler from class. * * <p>{@inheritDoc} */ @Override public void onInit(SparrowEngine engine) { if (actorHandler == null) { actorHandler = injector.getInstance(actorHandlerClass); } else { injector.injectMembers(actorHandler); } super.onInit(engine); }
private void initValidationJob() { final IFile file = ((IFileEditorInput) getEditorInput()).getFile(); validationJob = new SCTValidationJob(getDiagram()); IExpressionLanguageProvider registeredProvider = ExpressionLanguageProviderExtensions.getRegisteredProvider( SemanticTarget.StatechartSpecification, file.getFileExtension()); Injector injector = registeredProvider.getInjector(); injector.injectMembers(validationJob); validationJob.setRule(file); }
/* (non-Javadoc) * @see org.eclipse.riena.navigation.ui.swt.views.SubModuleView#createController(org.eclipse.riena.navigation.ISubModuleNode) */ @Override protected SubModuleController createController(ISubModuleNode node) { SubModuleController controller = super.createController(node); if (controller != null) { BundleContext context = Platform.getBundle("com.agritrace.edairy.desktop").getBundleContext(); ServiceReference service = context.getServiceReference(Injector.class.getName()); Injector injector = (Injector) context.getService(service); injector.injectMembers(controller); } return controller; }
@Before public void initialize() { Config conf = MidoTestConfigurator.forAgents(fillConfig()); injector = Guice.createInjector( new SerializationModule(), new MidolmanConfigModule(conf), new MockZookeeperConnectionModule(), new MidonetBackendTestModule(conf), new LegacyClusterModule()); injector.injectMembers(this); }
/** * Creates an {@link IHandlePart} for the specified vertex of the {@link IGeometry} provided by * the given <i>handleGeometryProvider</i>. * * @param target {@link IVisualPart} for which a selection handle is created. * @param segmentsProvider Provides the {@link BezierCurve}s from which the handle can retrieve * its location. * @param segmentCount Number of segments. * @param segmentIndex Index of the segment where the handle is located. * @param contextMap Stores context information as an {@link IBehavior} is stateless. * @return {@link IHandlePart} for the specified vertex of the {@link IGeometry} provided by the * <i>handleGeometryProvider</i> */ protected IHandlePart<Node, ? extends Node> createSelectionSegmentHandlePart( final IVisualPart<Node, ? extends Node> target, Provider<BezierCurve[]> segmentsProvider, int segmentCount, int segmentIndex, Map<Object, Object> contextMap) { FXCircleSegmentHandlePart part = injector.getInstance(FXCircleSegmentHandlePart.class); part.setSegmentsProvider(segmentsProvider); part.setSegmentIndex(segmentIndex); part.setSegmentParameter(0); injector.injectMembers(part); return part; }
private Object createTest(Class<?> testClass, Map<Field, Binding> fieldValues) throws Exception { FieldModule fields = new FieldModule(fieldValues); Injector injector; Object test = super.createTest(); if (Module.class.isAssignableFrom(testClass)) { injector = Guice.createInjector(fields, (Module) testClass.newInstance()); } else { injector = Guice.createInjector(fields); } injector.injectMembers(test); return test; }
@BeforeGroups(groups = {"integration", "live"}) public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException { if (tag == null) tag = checkNotNull(service, "service"); setupCredentials(); setupKeyPair(); initializeContextAndClient(); Injector injector = createSshClientInjector(); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); socketTester = new RetryablePredicate<IPSocket>(socketOpen, 60, 1, TimeUnit.SECONDS); injector.injectMembers(socketOpen); // add logger }
@Override public void injectMembers(@Nonnull Object instance) throws MembersInjectionException { requireNonNull(instance, ERROR_INSTANCE_NULL); if (isClosed()) { throw new MembersInjectionException(instance, new ClosedInjectorException(this)); } try { delegate.injectMembers(instance); } catch (RuntimeException e) { throw new MembersInjectionException(instance, e); } }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { try { IFile file = (IFile) HandlerUtil.getActiveEditorInput(event).getAdapter(IFile.class); if (file != null) { RuntimeMatcherRegistrator registrator = new RuntimeMatcherRegistrator(file, null); injector.injectMembers(registrator); Display.getDefault().asyncExec(registrator); } } catch (Exception e) { throw new ExecutionException("Cannot load pattern file", e); } return null; }
public boolean visit(IResourceDelta delta) { IResource res = delta.getResource(); if (res != null && res instanceof IFile && delta.getKind() == IResourceDelta.CHANGED) { IFile file = (IFile) res; if (PatternRegistry.getInstance().getFiles().contains(file)) { RuntimeMatcherRegistrator registrator = new RuntimeMatcherRegistrator((IFile) file); injector.injectMembers(registrator); Display.getDefault().syncExec(registrator); } return false; } return true; }
@Override public void setUp() throws Exception { super.setUp(); IJavaProject project = JavaProjectSetupUtil.createJavaProject(TEST_PROJECT); addNature(project.getProject(), XtextProjectHelper.NATURE_ID); Injector injector = Activator.getInstance().getInjector(getEditorId()); injector.injectMembers(this); IFile fooFile = IResourcesSetupUtil.createFile(TEST_PROJECT + "/foo.refactoringtestlanguage", "foo"); IFile barFile = IResourcesSetupUtil.createFile( TEST_PROJECT + "/bar.refactoringtestlanguage", "bar { ref foo }"); waitForAutoBuild(); fooEditor = openEditor(fooFile); barEditor = openEditor(barFile); assertTrue(refactoringPreferences.useInlineRefactoring()); }
@Override @Before public void setUp() { Injector injector = Guice.createInjector( // configure the provider to return always the same in memory implementation of the // strategy catalog new SearchApiCuseBindingModule(InMemoryRepository.class) { @Override EntityLoader getEntityLoader(Injector injector) { return inMemoryRepository; } }); injector.injectMembers(this); super.setUp(); }
@Before public void setUpInjector() throws Exception { lifecycle = new LifecycleManager(); Injector injector = createInjector(); lifecycle.add(injector); injector.injectMembers(this); lifecycle.start(); db = schemaFactory.open(); schemaCreator.create(db); userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId(); Account userAccount = db.accounts().get(userId); userAccount.setPreferredEmail("*****@*****.**"); db.accounts().update(ImmutableList.of(userAccount)); user = userFactory.create(Providers.of(db), userId); requestContext.setContext(newRequestContext(userAccount.getId())); }
/** Guice test initialization method. */ @Before public void beforeGwtGuiceTest() { final Injector injector = getInjector(); // add a new RemoteServiceHandler which will call Guice Injector addGwtCreateHandler( new RemoteServiceCreateHandler() { @Override protected Object findService( Class<?> remoteServiceClass, String remoteServiceRelativePath) { return getRpcServiceFromInjector( injector, remoteServiceClass, remoteServiceRelativePath); } }); injector.injectMembers(this); }
public NewMechanoidOpsFileWizard() { Injector injector = OpServiceModelActivator.getInstance() .getInjector(OpServiceModelActivator.COM_ROBOTOWORKS_MECHANOID_OPS_OPSERVICEMODEL); injector.injectMembers(this); mNewFilePage = new NewMechanoidElementPage("new_file_page") { // $NON-NLS-1$ @Override protected String getNameFieldInfoMessage() { return Messages.NewMechanoidOpsFileWizard_Widget_Label_Message_Name; } }; mNewFilePage.setTitle(Messages.NewMechanoidOpsFileWizard_Title); mNewFilePage.setDescription(Messages.NewMechanoidOpsFileWizard_Message); }
@BeforeGroups(groups = {"live"}) public void setupClient() { String identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity"); Injector injector = new RestContextFactory() .createContextBuilder( "slicehost", identity, null, ImmutableSet.<Module>of(new Log4JLoggingModule(), new JschSshClientModule()), new Properties()) .buildInjector(); client = injector.getInstance(SlicehostClient.class); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); socketTester = new RetryablePredicate<IPSocket>(socketOpen, 120, 1, TimeUnit.SECONDS); injector.injectMembers(socketOpen); // add logger }
@Test public void testDecodeURI() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypack"); _builder.newLine(); _builder.newLine(); _builder.append("class Foo {"); _builder.newLine(); _builder.append("\t"); _builder.append("public def void foo() {"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final IFile file = this.helper.createFile("mypack/MyClass Foo.xtend", _builder.toString()); IResourcesSetupUtil.waitForAutoBuild(); final ResourceStorageTest.TestableStorageAwareTrace storageAwareTrace = new ResourceStorageTest.TestableStorageAwareTrace(); Injector _injector = this.getInjector(); _injector.injectMembers(storageAwareTrace); storageAwareTrace.setLocalStorage(file); URI _createURI = URI.createURI("mypack/MyClass%20Foo.xtend"); URI result = storageAwareTrace.resolvePath(_createURI); String _string = result.toString(); Assert.assertEquals( "platform:/resource/test.project/src/mypack/MyClass%20Foo.xtend", _string); IProject _project = this.helper.getProject(); URI _createURI_1 = URI.createURI("src/mypack/MyClass%20Foo.xtend"); URI _resolvePath = storageAwareTrace.resolvePath(_project, _createURI_1); result = _resolvePath; String _string_1 = result.toString(); Assert.assertEquals( "platform:/resource/test.project/src/mypack/MyClass%20Foo.xtend", _string_1); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@BeforeGroups(groups = {"live"}) public void setupClient() { setupCredentials(); Properties overrides = setupProperties(); Injector injector = new RestContextFactory() .createContextBuilder( provider, ImmutableSet.<Module>of(new Log4JLoggingModule()), overrides) .buildInjector(); client = injector.getInstance(EC2Client.class); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); socketTester = new RetryablePredicate<IPSocket>(socketOpen, 120, 1, TimeUnit.SECONDS); VolumeAvailable volumeAvailable = injector.getInstance(VolumeAvailable.class); volumeTester = new RetryablePredicate<Volume>(volumeAvailable, 60, 1, TimeUnit.SECONDS); SnapshotCompleted snapshotCompleted = injector.getInstance(SnapshotCompleted.class); snapshotTester = new RetryablePredicate<Snapshot>(snapshotCompleted, 120, 3, TimeUnit.SECONDS); VolumeAttached volumeAttached = injector.getInstance(VolumeAttached.class); attachTester = new RetryablePredicate<Attachment>(volumeAttached, 60, 1, TimeUnit.SECONDS); runningTester = new RetryablePredicate<RunningInstance>( new InstanceStateRunning(client), 180, 5, TimeUnit.SECONDS); InstanceStateStopped instanceStateStopped = injector.getInstance(InstanceStateStopped.class); stoppedTester = new RetryablePredicate<RunningInstance>(instanceStateStopped, 60, 1, TimeUnit.SECONDS); InstanceStateTerminated instanceStateTerminated = injector.getInstance(InstanceStateTerminated.class); terminatedTester = new RetryablePredicate<RunningInstance>(instanceStateTerminated, 60, 1, TimeUnit.SECONDS); injector.injectMembers(socketOpen); // add logger }
@Override public void start(BundleContext context) throws Exception { injector = GuiceContext.createChildInjector( Peaberry.osgiModule(context), new AbstractMyBatisExportModule() { @Override protected void initialize() { this.addSimpleAlias(AsCompoModel.class); this.addSimpleAlias(BusinessType.class); this.addSimpleAlias(Company.class); this.addSimpleAlias(Org.class); this.addSimpleAlias(Point.class); this.addSimpleAlias(Position.class); this.addSimpleAlias(Staff.class); this.addMapperClass(BusinessMapper.class); this.exportService(BusinessService.class, BusinessServiceImpl.class); } }); injector.injectMembers(this); }