|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2011 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
| 10 |
******************************************************************************/ |
| 11 |
|
| 12 |
package org.eclipse.e4.core.internal.tests.contexts.inject; |
| 13 |
|
| 14 |
import javax.annotation.PostConstruct; |
| 15 |
import javax.annotation.PreDestroy; |
| 16 |
|
| 17 |
import junit.framework.TestCase; |
| 18 |
|
| 19 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
| 20 |
import org.eclipse.e4.core.contexts.EclipseContextFactory; |
| 21 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
| 22 |
|
| 23 |
public class Bug354427Test extends TestCase { |
| 24 |
|
| 25 |
public static class SuperInject { |
| 26 |
|
| 27 |
boolean pcCalled = false; |
| 28 |
boolean pdCalled = false; |
| 29 |
|
| 30 |
@PostConstruct |
| 31 |
void pc() { |
| 32 |
pcCalled = true; |
| 33 |
} |
| 34 |
|
| 35 |
@PreDestroy |
| 36 |
void pd() { |
| 37 |
pdCalled = true; |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
public static class SubInject extends SuperInject { |
| 42 |
|
| 43 |
@Override |
| 44 |
void pc() { |
| 45 |
super.pc(); |
| 46 |
} |
| 47 |
|
| 48 |
@Override |
| 49 |
void pd() { |
| 50 |
super.pd(); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
public void testUnannotatedOverrides() throws Exception { |
| 55 |
IEclipseContext context = EclipseContextFactory.create(); |
| 56 |
|
| 57 |
SubInject subInject = ContextInjectionFactory.make(SubInject.class, context); |
| 58 |
|
| 59 |
assertTrue(subInject.pcCalled); |
| 60 |
assertFalse(subInject.pdCalled); |
| 61 |
|
| 62 |
context.dispose(); |
| 63 |
|
| 64 |
assertTrue(subInject.pcCalled); |
| 65 |
assertFalse(subInject.pdCalled); |
| 66 |
} |
| 67 |
|
| 68 |
} |