Uploaded image for project: 'Spring Tool Suite'
  1. Spring Tool Suite
  2. STS-4182

Cannot create JUnit 4 test case

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Invalid
    • Affects Version/s: 3.7.0.RELEASE
    • Fix Version/s: 3.7.1.RELEASE
    • Component/s: INTEGRATION
    • Labels:
    • Environment:

      Description

      Creation of new JUnit 4 Test Case (right-click on a project --> New --> JUnit Test Case wizard with "New JUnit 4 test" option selected) fails with the following message in modal error dialog:

      Creation of element failed.

      Index: 5, Size: 5

      Only empty Java file is created instead of an expected skeleton of JUnit 4 Test Case. The file is just plain empty, there is no class declaration, no package, ...

      Error log contains this exception related to org.eclipse.jdt.junit plugin:

      java.lang.reflect.InvocationTargetException
      	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:476)
      	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:371)
      	at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:1002)
      	at org.eclipse.ui.internal.progress.ProgressManager$RunnableWithStatus.run(ProgressManager.java:1394)
      	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
      	at org.eclipse.ui.internal.progress.ProgressManager$5.run(ProgressManager.java:1228)
      	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:186)
      	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:145)
      	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4633)
      	at org.eclipse.ui.internal.progress.ProgressManager.runInUI(ProgressManager.java:1225)
      	at org.eclipse.jdt.internal.junit.wizards.JUnitWizard.finishPage(JUnitWizard.java:66)
      	at org.eclipse.jdt.internal.junit.wizards.NewTestCaseCreationWizard.performFinish(NewTestCaseCreationWizard.java:121)
      	at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:799)
      	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:429)
      	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:619)
      	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
      	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
      	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4481)
      	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1327)
      	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3819)
      	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3430)
      	at org.eclipse.jface.window.Window.runEventLoop(Window.java:827)
      	at org.eclipse.jface.window.Window.open(Window.java:803)
      	at org.eclipse.ui.internal.actions.NewWizardShortcutAction.run(NewWizardShortcutAction.java:136)
      	at org.eclipse.jface.action.Action.runWithEvent(Action.java:473)
      	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
      	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
      	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
      	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
      	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4481)
      	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1327)
      	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3819)
      	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3430)
      	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
      	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
      	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
      	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
      	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
      	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
      	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
      	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
      	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
      	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
      	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
      	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
      	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
      	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
      	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
      	at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
      	at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
      Caused by: java.lang.IndexOutOfBoundsException: Index: 5, Size: 5
      	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
      	at java.util.ArrayList.get(ArrayList.java:429)
      	at org.eclipse.jdt.internal.formatter.TokenManager.get(TokenManager.java:68)
      	at org.eclipse.jdt.internal.formatter.TokenManager.findIndex(TokenManager.java:161)
      	at org.eclipse.jdt.internal.formatter.TokenManager.firstIndexIn(TokenManager.java:188)
      	at org.eclipse.jdt.internal.formatter.TokenManager.firstTokenIn(TokenManager.java:194)
      	at org.eclipse.jdt.internal.formatter.SpacePreparator.visit(SpacePreparator.java:196)
      	at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:611)
      	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
      	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782)
      	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:470)
      	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
      	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.prepareSpaces(DefaultCodeFormatter.java:350)
      	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.prepareFormattedCode(DefaultCodeFormatter.java:193)
      	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:155)
      	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:139)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.formatString(ASTRewriteFormatter.java:246)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.formatNode(ASTRewriteFormatter.java:376)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.getFormattedResult(ASTRewriteFormatter.java:187)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doTextInsert(ASTRewriteAnalyzer.java:1357)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer$ListRewriter.rewriteList(ASTRewriteAnalyzer.java:647)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer$ListRewriter.rewriteList(ASTRewriteAnalyzer.java:802)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.rewriteParagraphList(ASTRewriteAnalyzer.java:1175)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:1811)
      	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:453)
      	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
      	at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.internalRewriteAST(ASTRewrite.java:302)
      	at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.rewriteAST(ASTRewrite.java:291)
      	at org.eclipse.jdt.internal.core.CreateElementInCUOperation.generateNewCompilationUnitAST(CreateElementInCUOperation.java:174)
      	at org.eclipse.jdt.internal.core.CreateElementInCUOperation.executeOperation(CreateElementInCUOperation.java:127)
      	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:729)
      	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2241)
      	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:794)
      	at org.eclipse.jdt.internal.core.SourceType.createMethod(SourceType.java:168)
      	at org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne.createTestMethod(NewTestCaseWizardPageOne.java:976)
      	at org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne.createTestMethodStubs(NewTestCaseWizardPageOne.java:897)
      	at org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne.createTypeMembers(NewTestCaseWizardPageOne.java:753)
      	at org.eclipse.jdt.ui.wizards.NewTypeWizardPage.createType(NewTypeWizardPage.java:2207)
      	at org.eclipse.jdt.ui.wizards.NewTypeWizardPage$7.run(NewTypeWizardPage.java:2699)
      	at org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute(WorkspaceModifyDelegatingOperation.java:70)
      	at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:108)
      	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2241)
      	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:130)
      	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:463)
      	... 54 more
      Root exception:
      java.lang.IndexOutOfBoundsException: Index: 5, Size: 5
      	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
      	at java.util.ArrayList.get(ArrayList.java:429)
      	at org.eclipse.jdt.internal.formatter.TokenManager.get(TokenManager.java:68)
      	at org.eclipse.jdt.internal.formatter.TokenManager.findIndex(TokenManager.java:161)
      	at org.eclipse.jdt.internal.formatter.TokenManager.firstIndexIn(TokenManager.java:188)
      	at org.eclipse.jdt.internal.formatter.TokenManager.firstTokenIn(TokenManager.java:194)
      	at org.eclipse.jdt.internal.formatter.SpacePreparator.visit(SpacePreparator.java:196)
      	at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:611)
      	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
      	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782)
      	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:470)
      	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
      	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.prepareSpaces(DefaultCodeFormatter.java:350)
      	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.prepareFormattedCode(DefaultCodeFormatter.java:193)
      	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:155)
      	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:139)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.formatString(ASTRewriteFormatter.java:246)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.formatNode(ASTRewriteFormatter.java:376)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.getFormattedResult(ASTRewriteFormatter.java:187)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doTextInsert(ASTRewriteAnalyzer.java:1357)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer$ListRewriter.rewriteList(ASTRewriteAnalyzer.java:647)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer$ListRewriter.rewriteList(ASTRewriteAnalyzer.java:802)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.rewriteParagraphList(ASTRewriteAnalyzer.java:1175)
      	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:1811)
      	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:453)
      	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
      	at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.internalRewriteAST(ASTRewrite.java:302)
      	at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.rewriteAST(ASTRewrite.java:291)
      	at org.eclipse.jdt.internal.core.CreateElementInCUOperation.generateNewCompilationUnitAST(CreateElementInCUOperation.java:174)
      	at org.eclipse.jdt.internal.core.CreateElementInCUOperation.executeOperation(CreateElementInCUOperation.java:127)
      	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:729)
      	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2241)
      	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:794)
      	at org.eclipse.jdt.internal.core.SourceType.createMethod(SourceType.java:168)
      	at org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne.createTestMethod(NewTestCaseWizardPageOne.java:976)
      	at org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne.createTestMethodStubs(NewTestCaseWizardPageOne.java:897)
      	at org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne.createTypeMembers(NewTestCaseWizardPageOne.java:753)
      	at org.eclipse.jdt.ui.wizards.NewTypeWizardPage.createType(NewTypeWizardPage.java:2207)
      	at org.eclipse.jdt.ui.wizards.NewTypeWizardPage$7.run(NewTypeWizardPage.java:2699)
      	at org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute(WorkspaceModifyDelegatingOperation.java:70)
      	at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:108)
      	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2241)
      	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:130)
      	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:463)
      	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:371)
      	at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:1002)
      	at org.eclipse.ui.internal.progress.ProgressManager$RunnableWithStatus.run(ProgressManager.java:1394)
      	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
      	at org.eclipse.ui.internal.progress.ProgressManager$5.run(ProgressManager.java:1228)
      	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:186)
      	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:145)
      	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4633)
      	at org.eclipse.ui.internal.progress.ProgressManager.runInUI(ProgressManager.java:1225)
      	at org.eclipse.jdt.internal.junit.wizards.JUnitWizard.finishPage(JUnitWizard.java:66)
      	at org.eclipse.jdt.internal.junit.wizards.NewTestCaseCreationWizard.performFinish(NewTestCaseCreationWizard.java:121)
      	at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:799)
      	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:429)
      	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:619)
      	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
      	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
      	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4481)
      	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1327)
      	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3819)
      	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3430)
      	at org.eclipse.jface.window.Window.runEventLoop(Window.java:827)
      	at org.eclipse.jface.window.Window.open(Window.java:803)
      	at org.eclipse.ui.internal.actions.NewWizardShortcutAction.run(NewWizardShortcutAction.java:136)
      	at org.eclipse.jface.action.Action.runWithEvent(Action.java:473)
      	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
      	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
      	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
      	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
      	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4481)
      	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1327)
      	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3819)
      	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3430)
      	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
      	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
      	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
      	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
      	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
      	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
      	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
      	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
      	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
      	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
      	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
      	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
      	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
      	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
      	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
      	at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
      	at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
      

        Attachments

          Activity

            People

            Assignee:
            mlippert Martin Lippert
            Reporter:
            ZiziTheFirst Tomáš Zilvar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: