11/*******************************************************************************
2- * Copyright (c) 2000, 2015 IBM Corporation and others.
2+ * Copyright (c) 2000, 2023 IBM Corporation and others.
33 *
44 * This program and the accompanying materials
55 * are made available under the terms of the Eclipse Public License 2.0
3636import org .eclipse .jface .viewers .ISelection ;
3737import org .eclipse .jface .viewers .ISelectionProvider ;
3838import org .eclipse .jface .viewers .StructuredSelection ;
39+ import org .eclipse .ui .IPageLayout ;
3940import org .eclipse .ui .IViewPart ;
4041import org .eclipse .ui .IWorkbenchPage ;
4142import org .eclipse .ui .IWorkbenchPartSite ;
4748 */
4849public class StringSubstitutionTests extends AbstractDebugTest implements IValueVariableListener {
4950
51+ private static final String JAVA14_SOURCE_FILE = "src/bug329294.java" ;
5052 // change notification
5153 public IValueVariable [] fAdded ;
5254 public IValueVariable [] fChanged ;
@@ -464,9 +466,7 @@ public void testRemoveNotificaiton() throws CoreException {
464466 manager .removeVariables (new IValueVariable []{one , two });
465467 }
466468 }
467- /* (non-Javadoc)
468- * @see junit.framework.TestCase#setUp()
469- */
469+
470470 @ Override
471471 protected void setUp () throws Exception {
472472 super .setUp ();
@@ -477,9 +477,6 @@ protected void setUp() throws Exception {
477477 manager .addValueVariableListener (this );
478478 }
479479
480- /* (non-Javadoc)
481- * @see junit.framework.TestCase#tearDown()
482- */
483480 @ Override
484481 protected void tearDown () throws Exception {
485482 IStringVariableManager manager = VariablesPlugin .getDefault ().getStringVariableManager ();
@@ -490,25 +487,16 @@ protected void tearDown() throws Exception {
490487 super .tearDown ();
491488 }
492489
493- /* (non-Javadoc)
494- * @see org.eclipse.debug.internal.core.stringsubstitution.IValueVariableListener#variablesAdded(org.eclipse.debug.internal.core.stringsubstitution.IValueVariable[])
495- */
496490 @ Override
497491 public void variablesAdded (IValueVariable [] variables ) {
498492 fAdded = variables ;
499493 }
500494
501- /* (non-Javadoc)
502- * @see org.eclipse.debug.internal.core.stringsubstitution.IValueVariableListener#variablesChanged(org.eclipse.debug.internal.core.stringsubstitution.IValueVariable[])
503- */
504495 @ Override
505496 public void variablesChanged (IValueVariable [] variables ) {
506497 fChanged = variables ;
507498 }
508499
509- /* (non-Javadoc)
510- * @see org.eclipse.debug.internal.core.stringsubstitution.IValueVariableListener#variablesRemoved(org.eclipse.debug.internal.core.stringsubstitution.IValueVariable[])
511- */
512500 @ Override
513501 public void variablesRemoved (IValueVariable [] variables ) {
514502 fRemoved = variables ;
@@ -575,7 +563,7 @@ public void testProjectPathArgProjectName() throws CoreException {
575563 */
576564 public void testProjectPathSelectFile () throws CoreException {
577565 String expression = "${project_path}" ;
578- IResource resource = get14Project ().getProject ().getFile (".classpath" );
566+ IResource resource = get14Project ().getProject ().getFile (JAVA14_SOURCE_FILE );
579567 setSelection (resource );
580568 String result = doSubs (expression );
581569 assertEquals (resource .getProject ().getFullPath ().toOSString (), result );
@@ -719,7 +707,7 @@ public void testResourcePathArgFolderName() throws CoreException {
719707 */
720708 public void testResourcePathSelectFile () throws CoreException {
721709 String expression = "${resource_path}" ;
722- IResource resource = get14Project ().getProject ().getFile (".classpath" );
710+ IResource resource = get14Project ().getProject ().getFile (JAVA14_SOURCE_FILE );
723711 setSelection (resource );
724712 String result = doSubs (expression );
725713 assertEquals (resource .getFullPath ().toOSString (), result );
@@ -739,7 +727,7 @@ public void testResourceNameArgFolderName() throws CoreException {
739727 */
740728 public void testResourceNameSelectFile () throws CoreException {
741729 String expression = "${resource_name}" ;
742- IResource resource = get14Project ().getProject ().getFile (".classpath" );
730+ IResource resource = get14Project ().getProject ().getFile (JAVA14_SOURCE_FILE );
743731 setSelection (resource );
744732 String result = doSubs (expression );
745733 assertEquals (resource .getName (), result );
@@ -750,7 +738,7 @@ public void testResourceNameSelectFile() throws CoreException {
750738 * application configurations.
751739 */
752740 public void testLocalJavaApplicationParameters () throws CoreException {
753- IResource resource = get14Project ().getProject ().getFile (".classpath" );
741+ IResource resource = get14Project ().getProject ().getFile (JAVA14_SOURCE_FILE );
754742 setSelection (resource );
755743
756744 ILaunchConfiguration config = getLaunchConfiguration ("Breakpoints" );
@@ -774,31 +762,27 @@ public void testLocalJavaApplicationParameters() throws CoreException {
774762 * @param resource resource to select or <code>null</code> if empty
775763 */
776764 protected void setSelection (final IResource resource ) {
777- Runnable r = new Runnable () {
778- @ Override
779- public void run () {
780- IWorkbenchPage page = DebugUIPlugin .getActiveWorkbenchWindow ().getActivePage ();
781- assertNotNull ("the active workbench window page should not be null" , page );
782- IViewPart part ;
783- try {
784- part = page .showView ("org.eclipse.ui.views.ResourceNavigator" );
785- assertNotNull ("the part org.eclipse.ui.views.ResourceNavigator should not be null" , part );
786- ISelection selection = null ;
787- if (resource == null ) {
788- selection = new StructuredSelection ();
789- } else {
790- selection = new StructuredSelection (resource );
791- }
792- IWorkbenchPartSite site = part .getSite ();
793- assertNotNull ("The part site for org.eclipse.ui.views.ResourceNavigator should not be null " , site );
794- ISelectionProvider provider = site .getSelectionProvider ();
795- assertNotNull ("the selection provider should not be null for org.eclipse.ui.views.ResourceNavigator" , provider );
796- provider .setSelection (selection );
797- } catch (PartInitException e ) {
798- assertNotNull ("Failed to open navigator view" , null );
765+ Runnable r = () -> {
766+ IWorkbenchPage page = DebugUIPlugin .getActiveWorkbenchWindow ().getActivePage ();
767+ assertNotNull ("the active workbench window page should not be null" , page );
768+ try {
769+ IViewPart part = page .showView (IPageLayout .ID_PROJECT_EXPLORER );
770+ assertNotNull ("the part 'Project Explorer' should not be null" , part );
771+ ISelection selection = null ;
772+ if (resource == null ) {
773+ selection = new StructuredSelection ();
774+ } else {
775+ selection = new StructuredSelection (resource );
799776 }
800-
777+ IWorkbenchPartSite site = part .getSite ();
778+ assertNotNull ("The part site for 'Project Explorer' should not be null " , site );
779+ ISelectionProvider provider = site .getSelectionProvider ();
780+ assertNotNull ("the selection provider should not be null for 'Project Explorer'" , provider );
781+ provider .setSelection (selection );
782+ } catch (PartInitException e ) {
783+ assertNotNull ("Failed to open 'Project Explorer' view" , null );
801784 }
785+
802786 };
803787 DebugUIPlugin .getStandardDisplay ().syncExec (r );
804788 }
@@ -808,7 +792,7 @@ public void run() {
808792 */
809793 public void testSelectedResourcePathFile () throws CoreException {
810794 String expression = "${selected_resource_path}" ;
811- IResource resource = get14Project ().getProject ().getFile (".classpath" );
795+ IResource resource = get14Project ().getProject ().getFile (JAVA14_SOURCE_FILE );
812796 setSelection (resource );
813797 String result = doSubs (expression );
814798 assertEquals (resource .getFullPath ().toOSString (), result );
@@ -819,7 +803,7 @@ public void testSelectedResourcePathFile() throws CoreException {
819803 */
820804 public void testSelectedResourceNameFile () throws CoreException {
821805 String expression = "${selected_resource_name}" ;
822- IResource resource = get14Project ().getProject ().getFile (".classpath" );
806+ IResource resource = get14Project ().getProject ().getFile (JAVA14_SOURCE_FILE );
823807 setSelection (resource );
824808 String result = doSubs (expression );
825809 assertEquals (resource .getName (), result );
0 commit comments