0

在测试我的 Eclipse 4 RCP 应用程序的退出处理程序时,我面临以下异常。

!ENTRY org.eclipse.e4.ui.workbench 2 0 2014-06-10 14:09:22.607
!MESSAGE Could not run processor
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:243)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:220)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:107)
    at org.eclipse.e4.ui.internal.workbench.ModelAssembler.runProcessor(ModelAssembler.java:231)
    at org.eclipse.e4.ui.internal.workbench.ModelAssembler.processModel(ModelAssembler.java:88)
    at org.eclipse.e4.ui.internal.workbench.ResourceHandler.loadMostRecentModel(ResourceHandler.java:220)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.loadApplicationModel(E4Application.java:395)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:238)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:144)
    at org.eclipse.swtbot.eclipse.core.UITestApplication.start(UITestApplication.java:54)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.lang.NullPointerException
    at org.eclipse.e4.tools.emf.liveeditor.ModelProcessor.process(ModelProcessor.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
    ... 23 more

我的测试用例如下所示

    @RunWith(SWTBotJunit4ClassRunner.class)
public class ExitHandlerTest {

    private static SWTBot bot;

    @BeforeClass
    public static void beforeClass() throws Exception {
        bot = new SWTBot();
    }

    @Test
    public void testExitHandler() {
        SWTBotMenu fileMenu = bot.menu("File");
        Assert.assertNotNull(fileMenu);
        SWTBotMenu exitMenu = fileMenu.menu("Exit");
        Assert.assertNotNull(exitMenu);
        exitMenu.click();
    }

    @AfterClass
    public static void sleep() {
    }

}

我存在的处理程序的代码是

public class ExitHandler {
    @Execute
    public void execute(IWorkbench workbench, EPartService partService, ISaveHandler saveHandler) {
        workbench.close();
    }

}

尽管测试运行良好,但我不确定为什么会出现此异常。

4

1 回答 1

0

看起来您的测试中包含了 e4 实时模型编辑器,并且您遇到了 Eclipse 错误426373

我认为这实际上不会影响您的测试,因此您可以忽略它。

于 2014-06-10T18:44:08.243 回答