Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 164389 Details for
Bug 308650
[DI] Requestors pick up extra dependencies during updates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
JUnit test
patch DI outside 4.txt (text/plain), 5.05 KB, created by
Oleg Besedin
on 2010-04-09 11:18:25 EDT
(
hide
)
Description:
JUnit test
Filename:
MIME Type:
Creator:
Oleg Besedin
Created:
2010-04-09 11:18:25 EDT
Size:
5.05 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.e4.core.tests.services.annotations >Index: src/org/eclipse/e4/core/tests/services/internal/annotations/ExtraDependenciesTest.java >=================================================================== >RCS file: src/org/eclipse/e4/core/tests/services/internal/annotations/ExtraDependenciesTest.java >diff -N src/org/eclipse/e4/core/tests/services/internal/annotations/ExtraDependenciesTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/core/tests/services/internal/annotations/ExtraDependenciesTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,105 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.e4.core.tests.services.internal.annotations; >+ >+import java.lang.reflect.InvocationTargetException; >+ >+import javax.inject.Inject; >+import javax.inject.Named; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.e4.core.contexts.ContextInjectionFactory; >+import org.eclipse.e4.core.contexts.EclipseContextFactory; >+import org.eclipse.e4.core.contexts.IEclipseContext; >+import org.eclipse.e4.core.di.IDisposable; >+import org.eclipse.e4.core.di.annotations.PreDestroy; >+ >+public class ExtraDependenciesTest extends TestCase { >+ >+ static public class TestObject { >+ >+ public String string; >+ public Integer integer; >+ public String other; >+ >+ public boolean disposed = false; >+ >+ @Inject >+ public void injectedMethod(@Named("arg1") String strValue, @Named("arg2") Integer intValue, IEclipseContext context) { >+ string = strValue; >+ integer = intValue; >+ if (context == null) { >+ other = null; >+ return; >+ } >+ IEclipseContext otherContext = (IEclipseContext) context.get("otherContext"); >+ if (otherContext == null) >+ other = null; >+ else >+ other = (String) otherContext.get("arg3"); >+ } >+ >+ @PreDestroy >+ public void finita() { >+ disposed = true; >+ } >+ } >+ >+ public void testExtraDependencies() throws InvocationTargetException, InstantiationException { >+ IEclipseContext context = EclipseContextFactory.create(); >+ context.set("arg1", "abc"); >+ context.set("arg2", new Integer (123)); >+ >+ IEclipseContext otherContext = EclipseContextFactory.create(); >+ otherContext.set("arg3", "other"); >+ >+ context.set("otherContext", otherContext); >+ >+ TestObject object = (TestObject) ContextInjectionFactory.make(TestObject.class, context); >+ >+ // check that initial values are properly injected >+ assertEquals("abc", object.string); >+ assertEquals(new Integer(123), object.integer); >+ assertEquals("other", object.other); >+ >+ // modify argument value to cause update - bug 308650 >+ context.set("arg2", new Integer (789)); >+ >+ // change the "other" value; should not be propagated >+ otherContext.set("arg3", "wrong"); >+ assertEquals("other", object.other); >+ >+ // dispose the other context; should not cause disposal of the test object >+ ((IDisposable)otherContext).dispose(); >+ assertEquals("other", object.other); >+ assertFalse(object.disposed); >+ >+ // remove "other" context, should not be propagated >+ context.remove("otherContext"); >+ assertEquals("other", object.other); >+ >+ // check that changes in the method arguments are propagated >+ context.set("arg1", "xyz"); >+ context.set("arg2", new Integer (456)); >+ assertEquals("xyz", object.string); >+ assertEquals(new Integer(456), object.integer); >+ assertNull(object.other); >+ >+ // check that disposal of the injected context causes disposal of the injected object >+ ((IDisposable)context).dispose(); >+ assertTrue(object.disposed); >+ assertNull(object.string); >+ assertNull(object.integer); >+ assertNull(object.other); >+ } >+ >+} >Index: src/org/eclipse/e4/core/tests/services/internal/annotations/ServicesTestSuiteAnnotations.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.core.tests.services.annotations/src/org/eclipse/e4/core/tests/services/internal/annotations/ServicesTestSuiteAnnotations.java,v >retrieving revision 1.7 >diff -u -r1.7 ServicesTestSuiteAnnotations.java >--- src/org/eclipse/e4/core/tests/services/internal/annotations/ServicesTestSuiteAnnotations.java 24 Mar 2010 19:09:32 -0000 1.7 >+++ src/org/eclipse/e4/core/tests/services/internal/annotations/ServicesTestSuiteAnnotations.java 9 Apr 2010 15:17:18 -0000 >@@ -29,5 +29,6 @@ > addTestSuite(InjectionOrderTest.class); > addTestSuite(GroupedUpdatesTest.class); > addTestSuite(Bug304585Test.class); >+ addTestSuite(ExtraDependenciesTest.class); > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 308650
:
164389
|
164433