-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathAbstractDebugTest.java
More file actions
3268 lines (3026 loc) · 126 KB
/
AbstractDebugTest.java
File metadata and controls
3268 lines (3026 loc) · 126 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* Copyright (c) 2000, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
* Jesper Steen Møller - bug 422029: [1.8] Enable debug evaluation support for default methods
* Jesper Steen Møller - bug 426903: [1.8] Cannot evaluate super call to default method
* Jesper Steen Møller - bug 341232
*******************************************************************************/
package org.eclipse.jdt.debug.tests;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchDelegate;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.ILineBreakpoint;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.internal.core.LaunchDelegate;
import org.eclipse.debug.internal.core.LaunchManager;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointOrganizer;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPresentationManager;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointOrganizerManager;
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
import org.eclipse.jdt.core.IAccessRule;
import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.debug.core.IJavaClassPrepareBreakpoint;
import org.eclipse.jdt.debug.core.IJavaDebugTarget;
import org.eclipse.jdt.debug.core.IJavaExceptionBreakpoint;
import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
import org.eclipse.jdt.debug.core.IJavaMethodBreakpoint;
import org.eclipse.jdt.debug.core.IJavaObject;
import org.eclipse.jdt.debug.core.IJavaPatternBreakpoint;
import org.eclipse.jdt.debug.core.IJavaStackFrame;
import org.eclipse.jdt.debug.core.IJavaStratumLineBreakpoint;
import org.eclipse.jdt.debug.core.IJavaTargetPatternBreakpoint;
import org.eclipse.jdt.debug.core.IJavaThread;
import org.eclipse.jdt.debug.core.IJavaVariable;
import org.eclipse.jdt.debug.core.IJavaWatchpoint;
import org.eclipse.jdt.debug.core.JDIDebugModel;
import org.eclipse.jdt.debug.eval.EvaluationManager;
import org.eclipse.jdt.debug.eval.IAstEvaluationEngine;
import org.eclipse.jdt.debug.eval.IEvaluationListener;
import org.eclipse.jdt.debug.eval.IEvaluationResult;
import org.eclipse.jdt.debug.testplugin.DebugElementEventWaiter;
import org.eclipse.jdt.debug.testplugin.DebugElementKindEventDetailWaiter;
import org.eclipse.jdt.debug.testplugin.DebugElementKindEventWaiter;
import org.eclipse.jdt.debug.testplugin.DebugEventWaiter;
import org.eclipse.jdt.debug.testplugin.JavaProjectHelper;
import org.eclipse.jdt.debug.testplugin.JavaTestPlugin;
import org.eclipse.jdt.debug.tests.core.LiteralTests17;
import org.eclipse.jdt.debug.tests.refactoring.MemberParser;
import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin;
import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget;
import org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine;
import org.eclipse.jdt.internal.debug.ui.BreakpointUtils;
import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstallChangedListener;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.PropertyChangeEvent;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.IHyperlink;
import org.eclipse.ui.console.TextConsole;
import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition;
import org.eclipse.ui.intro.IIntroManager;
import org.eclipse.ui.intro.IIntroPart;
import org.eclipse.ui.progress.UIJob;
import org.osgi.service.prefs.BackingStoreException;
import com.sun.jdi.InternalException;
import com.sun.jdi.InvocationException;
import junit.framework.TestCase;
/**
* Tests for launch configurations
*/
@SuppressWarnings("deprecation")
public abstract class AbstractDebugTest extends TestCase implements IEvaluationListener {
private static boolean setupFirstTest = false;
public static final String MULTI_OUTPUT_PROJECT_NAME = "MultiOutput";
public static final String BOUND_EE_PROJECT_NAME = "BoundEE";
public static final String ONE_FOUR_PROJECT_NAME = "DebugTests";
public static final String ONE_FOUR_PROJECT_CLOSED_NAME = "ClosedDebugTests";
public static final String ONE_FIVE_PROJECT_NAME = "OneFive";
public static final String ONE_SEVEN_PROJECT_NAME = "OneSeven";
public static final String ONE_EIGHT_PROJECT_NAME = "OneEight";
public static final String NINE_PROJECT_NAME = "Nine";
public static final String ONESIX_PROJECT_NAME = "One_Six";
public static final String TWENTYONE_PROJECT_NAME = "Two_One";
public static final String TWENTYTHREE_PROJECT_NAME = "Two_Three";
public static final String TWENTYFOUR_PROJECT_NAME = "Two_Four";
public static final String TWENTYFIVE_PROJECT_NAME = "Two_Five";
public static final String TWENTYSIX_PROJECT_NAME = "Two_Six";
public static final String BOUND_JRE_PROJECT_NAME = "BoundJRE";
public static final String MR_PROJECT_NAME = "MR";
public static final String CLONE_SUFFIX = "Clone";
final String[] LAUNCH_CONFIG_NAMES_1_4 = { "LargeSourceFile", "LotsOfFields",
"Breakpoints",
"InstanceVariablesTests",
"LocalVariablesTests", "LocalVariableTests2", "StaticVariablesTests",
"DropTests", "ThrowsNPE", "ThrowsException", "org.eclipse.debug.tests.targets.Watchpoint",
"org.eclipse.debug.tests.targets.BreakpointsLocationBug344984", "org.eclipse.debug.tests.targets.CallLoop", "A",
"HitCountLooper", "CompileError", "MultiThreadedLoop", "HitCountException", "MultiThreadedException", "MultiThreadedList", "MethodLoop", "StepFilterOne",
"StepFilterFour", "EvalArrayTests", "EvalSimpleTests", "EvalTypeTests", "EvalNestedTypeTests", "EvalTypeHierarchyTests",
"EvalAnonymousClassVariableTests", "WorkingDirectoryTest",
"OneToTen", "OneToTenPrint", "FloodConsole", "ConditionalStepReturn", "VariableChanges", "DefPkgReturnType", "InstanceFilterObject", "org.eclipse.debug.tests.targets.CallStack",
"org.eclipse.debug.tests.targets.ThreadStack", "org.eclipse.debug.tests.targets.HcrClass", "org.eclipse.debug.tests.targets.StepIntoSelectionClass",
"WatchItemTests", "ArrayTests", "ByteArrayTests", "PerfLoop", "Console80Chars", "ConsoleStackTrace", "ConsoleVariableLineLength", "StackTraces",
"ConsoleInput", "PrintConcatenation", "VariableDetails", "org.eclipse.debug.tests.targets.ArrayDetailTests", "ArrayDetailTestsDef", "ForceReturnTests",
"ForceReturnTestsTwo", "LogicalStructures", "BreakpointListenerTest", "LaunchHistoryTest", "LaunchHistoryTest2", "RunnableAppletImpl", "java6.AllInstancesTests",
"bug329294", "bug401270", "org.eclipse.debug.tests.targets.HcrClass2", "org.eclipse.debug.tests.targets.HcrClass3", "org.eclipse.debug.tests.targets.HcrClass4",
"org.eclipse.debug.tests.targets.HcrClass5", "org.eclipse.debug.tests.targets.HcrClass6", "org.eclipse.debug.tests.targets.HcrClass7", "org.eclipse.debug.tests.targets.HcrClass8",
"org.eclipse.debug.tests.targets.HcrClass9", "TestContributedStepFilterClass", "TerminateAll_01", "TerminateAll_02", "StepResult1",
"StepResult2", "StepResult3", "StepUncaught", "TriggerPoint_01", "BulkThreadCreationTest", "MethodExitAndException",
"Bug534319earlyStart", "Bug534319lateStart", "Bug534319singleThread", "Bug534319startBetwen", "MethodCall", "Bug538303", "Bug540243",
"OutSync", "OutSync2", "ConsoleOutputUmlaut", "ErrorRecurrence", "ModelPresentationTests", "Bug565982",
"SuspendVMConditionalBreakpointsTestSnippet", "FileConditionSnippet2", "compare.CompareObjectsStringTest", "compare.CompareListObjects",
"compare.CompareMapObjects", "compare.CompareSetObjects", "compare.CompareNormalObjects", "compare.CompareArrayObjects",
"StatementStep", "StatementStepArgument", "StatementStepNested", "StatementStepWithOperations", "WatchItemContext" };
/**
* the default timeout
*/
public static final int DEFAULT_TIMEOUT = 30000;
//constants
protected static final String JAVA = "java"; //$NON-NLS-1$
protected static final String JAVA_EXTENSION = ".java"; //$NON-NLS-1$
protected static final String LAUNCHCONFIGURATIONS = "launchConfigurations"; //$NON-NLS-1$
protected static final String LAUNCH_EXTENSION = ".launch"; //$NON-NLS-1$
protected static final String LOCAL_JAVA_APPLICATION_TYPE_ID = "org.eclipse.jdt.launching.localJavaApplication"; //$NON-NLS-1$
protected static final String JAVA_LAUNCH_SHORTCUT_ID = "org.eclipse.jdt.debug.ui.localJavaShortcut"; //$NON-NLS-1$
protected static final String TEST_LAUNCH_SHORTCUT = "org.eclipse.jdt.debug.tests.testShortCut";
/**
* an evaluation result
*/
public IEvaluationResult fEvaluationResult;
/**
* The last relevant event set - for example, that caused
* a thread to suspend
*/
protected DebugEvent[] fEventSet;
private static boolean loadedPrefs = false;
private static boolean loaded14 = false;
private static boolean loaded15 = false;
private static boolean loaded17 = false;
private static boolean loaded18 = false;
private static boolean loaded9 = false;
private static boolean loaded16_ = false;
private static boolean loaded21 = false;
private static boolean loaded23 = false;
private static boolean loaded24 = false;
private static boolean loaded25 = false;
private static boolean loaded26 = false;
private static boolean loadedEE = false;
private static boolean loadedJRE = false;
private static boolean loadedMulti = false;
private static boolean loadedMR;
private static boolean welcomeClosed = false;
protected boolean isJRE26plus = false;
/**
* Constructor
*/
public AbstractDebugTest(String name) {
super(name);
// set error dialog to non-blocking to avoid hanging the UI during test
ErrorDialog.AUTOMATED_MODE = true;
SafeRunnable.setIgnoreErrors(true);
String javaVersion = System.getProperty("java.version");
if (javaVersion.startsWith("26")) {
isJRE26plus = true;
}
}
@Override
protected void setUp() throws Exception {
if (!setupFirstTest) {
setupFirstTest = true;
TestUtil.logInfo("SETTING UP TESTS");
JavaRuntime.addVMInstallChangedListener(new LogVMInstallChanges());
}
TestUtil.logInfo("SETUP " + getClass().getSimpleName() + "." + getName());
super.setUp();
setPreferences();
IProject pro = ResourcesPlugin.getWorkspace().getRoot().getProject(ONE_FOUR_PROJECT_NAME);
loaded14 = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(ONE_FIVE_PROJECT_NAME);
loaded15 = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(ONE_SEVEN_PROJECT_NAME);
loaded17 = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(ONE_EIGHT_PROJECT_NAME);
loaded18 = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(NINE_PROJECT_NAME);
loaded9 = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(ONESIX_PROJECT_NAME);
loaded16_ = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(TWENTYONE_PROJECT_NAME);
loaded21 = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(BOUND_JRE_PROJECT_NAME);
loadedJRE = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(BOUND_EE_PROJECT_NAME);
loadedEE = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(MULTI_OUTPUT_PROJECT_NAME);
loadedMulti = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(MR_PROJECT_NAME);
loadedMR = pro.exists();
assertWelcomeScreenClosed();
}
synchronized void setPreferences() throws BackingStoreException {
if(!loadedPrefs) {
IPreferenceStore debugUIPreferences = DebugUIPlugin.getDefault().getPreferenceStore();
// Don't prompt for perspective switching
debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_SWITCH_PERSPECTIVE_ON_SUSPEND, MessageDialogWithToggle.ALWAYS);
debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_SWITCH_TO_PERSPECTIVE, MessageDialogWithToggle.ALWAYS);
debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_RELAUNCH_IN_DEBUG_MODE, MessageDialogWithToggle.NEVER);
debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_WAIT_FOR_BUILD, MessageDialogWithToggle.ALWAYS);
debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR, MessageDialogWithToggle.ALWAYS);
debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH, MessageDialogWithToggle.NEVER);
String property = System.getProperty("debug.workbenchActivation");
boolean activate = property != null && property.equals("on");
debugUIPreferences.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, activate);
debugUIPreferences.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, activate);
debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_ACTIVATE_DEBUG_VIEW, activate);
debugUIPreferences.setValue(IDebugUIConstants.PREF_ACTIVATE_WORKBENCH, activate);
IPreferenceStore jdiUIPreferences = JDIDebugUIPlugin.getDefault().getPreferenceStore();
// Turn off suspend on uncaught exceptions
jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_SUSPEND_ON_UNCAUGHT_EXCEPTIONS, false);
jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_SUSPEND_ON_COMPILATION_ERRORS, false);
// Don't warn about HCR failures
jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_ALERT_HCR_FAILED, false);
jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_ALERT_HCR_NOT_SUPPORTED, false);
jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_ALERT_OBSOLETE_METHODS, false);
// Set the timeout preference to a high value, to avoid timeouts while
// testing
JDIDebugModel.getPreferences().setDefault(JDIDebugModel.PREF_REQUEST_TIMEOUT, 10000);
// turn off monitor information
jdiUIPreferences.setValue(IJavaDebugUIConstants.PREF_SHOW_MONITOR_THREAD_INFO, false);
//make sure we are auto-refreshing external workspace changes
IEclipsePreferences node = InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES);
if(node != null) {
node.putBoolean(ResourcesPlugin.PREF_AUTO_REFRESH, true);
node.putBoolean(ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH, true);
node.flush();
}
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode("org.eclipse.urischeme");
if (prefs != null) {
prefs.putBoolean("skipAutoRegistration", true);
}
loadedPrefs = true;
}
}
/**
* Creates the Java 1.4 compliant project
*/
synchronized void assert14Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded14) {
try {
jp = JavaProjectHelper.createJavaProject(ONE_FOUR_PROJECT_CLOSED_NAME);
jp.getProject().close(null);
}
catch(Exception e) {
handleProjectCreationException(e, ONE_FOUR_PROJECT_CLOSED_NAME, jp);
}
jp = createProject(ONE_FOUR_PROJECT_NAME, JavaProjectHelper.TEST_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_1_8_EE_NAME, false);
if (isJRE26plus) {
// these files cannot be compiled against 26+
jp.getProject().getFile("src/AppletImpl.java").delete(true, null);
jp.getProject().getFile("src/RunnableAppletImpl.java").delete(true, null);
}
IPackageFragmentRoot src = jp.findPackageFragmentRoot(new Path(ONE_FOUR_PROJECT_NAME).append(JavaProjectHelper.SRC_DIR).makeAbsolute());
assertNotNull("The 'src' package fragment root should not be null", src);
File root = JavaTestPlugin.getDefault().getFileInPlugin(new Path("testjars"));
JavaProjectHelper.importFilesFromDirectory(root, src.getPath(), null);
IPath path = src.getPath().append("A.jar");
JavaProjectHelper.addLibrary(jp, path);
//add a closed project optional classpath entry
//see https://bugs.eclipse.org/bugs/show_bug.cgi?id=380918
IClasspathEntry entry = JavaCore.newProjectEntry(
new Path(ONE_FOUR_PROJECT_CLOSED_NAME).makeAbsolute(),
new IAccessRule[0],
false,
new IClasspathAttribute[] {JavaCore.newClasspathAttribute(IClasspathAttribute.OPTIONAL, Boolean.TRUE.toString())},
false);
JavaProjectHelper.addToClasspath(jp, entry);
// create launch configurations
for (int i = 0; i < LAUNCH_CONFIG_NAMES_1_4.length; i++) {
cfgs.add(createLaunchConfiguration(jp, LAUNCH_CONFIG_NAMES_1_4[i]));
}
loaded14 = true;
waitForBuild();
}
}
catch(Exception e) {
try {
if(jp != null) {
jp.getProject().delete(true, true, null);
}
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
catch (CoreException ce) {
//ignore
}
handleProjectCreationException(e, ONE_FOUR_PROJECT_NAME, jp);
}
}
/**
* Creates the Java 1.5 compliant project
*/
void assert15Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded15) {
jp = createProject(ONE_FIVE_PROJECT_NAME, JavaProjectHelper.TEST_1_5_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_1_8_EE_NAME, true);
cfgs.add(createLaunchConfiguration(jp, "a.b.c.MethodBreakpoints"));
cfgs.add(createLaunchConfiguration(jp, "a.b.c.IntegerAccess"));
cfgs.add(createLaunchConfiguration(jp, "a.b.c.StepIntoSelectionWithGenerics"));
cfgs.add(createLaunchConfiguration(jp, "a.b.c.ConditionalsNearGenerics"));
cfgs.add(createLaunchConfiguration(jp, "a.b.c.bug329294WithGenerics"));
cfgs.add(createLaunchConfiguration(jp, "a.b.c.bug403028"));
cfgs.add(createLaunchConfiguration(jp, "a.b.c.bug484686"));
cfgs.add(createLaunchConfiguration(jp, "a.b.c.PrimitivesTest"));
cfgs.add(createLaunchConfiguration(jp, "a.b.c.GenericMethodEntryTest"));
cfgs.add(createLaunchConfiguration(jp, "org.eclipse.debug.tests.targets.HcrClass", true));
cfgs.add(createLaunchConfiguration(jp, "a.b.c.Bug570988"));
cfgs.add(createLaunchConfiguration(jp, "a.b.c.ExceptionDefaultTest"));
loaded15 = true;
waitForBuild();
}
}
catch(Exception e) {
try {
if(jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
}
catch (CoreException ce) {
//ignore
}
handleProjectCreationException(e, ONE_FIVE_PROJECT_NAME, jp);
}
}
/**
* Creates the Java 1.7 compliant project
*/
synchronized void assert17Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded17) {
jp = createProject(ONE_SEVEN_PROJECT_NAME, JavaProjectHelper.TEST_1_7_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_1_8_EE_NAME, false);
cfgs.add(createLaunchConfiguration(jp, LiteralTests17.LITERAL_TYPE_NAME));
cfgs.add(createLaunchConfiguration(jp, "ThreadNameChange"));
cfgs.add(createLaunchConfiguration(jp, "Bug567801"));
cfgs.add(createLaunchConfiguration(jp, "Bug572782"));
cfgs.add(createLaunchConfiguration(jp, "Bug576829"));
loaded17 = true;
waitForBuild();
}
}
catch(Exception e) {
try {
if(jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
}
catch (CoreException ce) {
//ignore
}
handleProjectCreationException(e, ONE_SEVEN_PROJECT_NAME, jp);
}
}
/**
* Creates the Java 1.8 compliant project
*/
synchronized void assert18Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded18) {
jp = createProject(ONE_EIGHT_PROJECT_NAME, JavaProjectHelper.TEST_1_8_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_1_8_EE_NAME, false);
IPath lib = new Path(JavaTestPlugin.getDefault().getFileInPlugin(new Path("testjars").append("gh275").append("debug-lib.jar")).getAbsolutePath());
JavaProjectHelper.addLibrary(jp, lib);
cfgs.add(createLaunchConfiguration(jp, "EvalTest18"));
cfgs.add(createLaunchConfiguration(jp, "FunctionalCaptureTest18"));
cfgs.add(createLaunchConfiguration(jp, "EvalTestIntf18"));
cfgs.add(createLaunchConfiguration(jp, "EvalIntfSuperDefault"));
cfgs.add(createLaunchConfiguration(jp, "DebugHoverTest18"));
cfgs.add(createLaunchConfiguration(jp, "DebugHoverTest2Lambdas"));
cfgs.add(createLaunchConfiguration(jp, "Bug317045"));
cfgs.add(createLaunchConfiguration(jp, "Bug549394"));
cfgs.add(createLaunchConfiguration(jp, "Bug541110"));
cfgs.add(createLaunchConfiguration(jp, "ClosureVariableTest_Bug542989"));
cfgs.add(createLaunchConfiguration(jp, "Bug404097BreakpointInLocalClass"));
cfgs.add(createLaunchConfiguration(jp, "Bug404097BreakpointInAnonymousLocalClass"));
cfgs.add(createLaunchConfiguration(jp, "Bug404097BreakpointInLambda"));
cfgs.add(createLaunchConfiguration(jp, "Bug404097BreakpointUsingInnerClass"));
cfgs.add(createLaunchConfiguration(jp, "Bug404097BreakpointUsingLocalClass"));
cfgs.add(createLaunchConfiguration(jp, "Bug560392"));
cfgs.add(createLaunchConfiguration(jp, "Bug561715"));
cfgs.add(createLaunchConfiguration(jp, "Bug562056"));
cfgs.add(createLaunchConfiguration(jp, "RemoteEvaluator"));
cfgs.add(createLaunchConfiguration(jp, "AnonymousEvaluator"));
cfgs.add(createLaunchConfiguration(jp, "Bug564486"));
cfgs.add(createLaunchConfiguration(jp, "Bug564801"));
cfgs.add(createLaunchConfiguration(jp, "Bug567801"));
cfgs.add(createLaunchConfiguration(jp, "Bug571230"));
cfgs.add(createLaunchConfiguration(jp, "Bug572629"));
cfgs.add(createLaunchConfiguration(jp, "Bug569413"));
cfgs.add(createLaunchConfiguration(jp, "Bug573589"));
cfgs.add(createLaunchConfiguration(jp, "Bug574395"));
cfgs.add(createLaunchConfiguration(jp, "Bug571310"));
cfgs.add(createLaunchConfiguration(jp, "Bug573547"));
cfgs.add(createLaunchConfiguration(jp, "Bug575551"));
cfgs.add(createLaunchConfiguration(jp, "Bug578145NestedLambda"));
cfgs.add(createLaunchConfiguration(jp, "Bug578145LambdaInConstructor"));
cfgs.add(createLaunchConfiguration(jp, "Bug578145LambdaInFieldDeclaration"));
cfgs.add(createLaunchConfiguration(jp, "Bug578145LambdaInStaticInitializer"));
cfgs.add(createLaunchConfiguration(jp, "Bug578145LambdaInAnonymous"));
cfgs.add(createLaunchConfiguration(jp, "Bug578145LambdaOnChainCalls"));
cfgs.add(createLaunchConfiguration(jp, "LambdaBreakpoints1"));
cfgs.add(createLaunchConfiguration(jp, "GH275"));
cfgs.add(createLaunchConfiguration(jp, "LambdaTest"));
cfgs.add(createLaunchConfiguration(jp, "InnerClassBug"));
cfgs.add(createLaunchConfiguration(jp, "SuperClass"));
cfgs.add(createLaunchConfiguration(jp, "SubClass"));
loaded18 = true;
waitForBuild();
}
}
catch(Exception e) {
try {
if(jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
}
catch (CoreException ce) {
//ignore
}
handleProjectCreationException(e, ONE_EIGHT_PROJECT_NAME, jp);
}
}
/**
* Creates the Java 9 compliant project
*/
synchronized void assert9Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded9) {
jp = createProject(NINE_PROJECT_NAME, JavaProjectHelper.TEST_9_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_9_EE_NAME, false);
cfgs.add(createLaunchConfiguration(jp, "LogicalStructures"));
cfgs.add(createLaunchConfiguration(jp, "Bug575039"));
loaded9 = true;
waitForBuild();
}
} catch (Exception e) {
try {
if (jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
} catch (CoreException ce) {
// ignore
}
handleProjectCreationException(e, NINE_PROJECT_NAME, jp);
}
}
/**
* Creates the Java 16 compliant project
*/
synchronized void assert16_Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded16_) {
jp = createProject(ONESIX_PROJECT_NAME, JavaProjectHelper.TEST_16_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_16_EE_NAME, false);
cfgs.add(createLaunchConfiguration(jp, "RecordTests"));
loaded16_ = true;
waitForBuild();
}
} catch (Exception e) {
try {
if (jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
} catch (CoreException ce) {
// ignore
}
handleProjectCreationException(e, ONESIX_PROJECT_NAME, jp);
}
}
/**
* Creates the Java 21 compliant project
*/
synchronized void assert21Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded21) {
jp = createProject(TWENTYONE_PROJECT_NAME, JavaProjectHelper.TEST_21_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_21_EE_NAME, false);
jp.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
cfgs.add(createLaunchConfiguration(jp, "Main1"));
cfgs.add(createLaunchConfiguration(jp, "Main2"));
loaded21 = true;
waitForBuild();
}
} catch (Exception e) {
try {
if (jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
} catch (CoreException ce) {
// ignore
}
handleProjectCreationException(e, TWENTYONE_PROJECT_NAME, jp);
}
}
synchronized void assertMRProject() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loadedMR) {
jp = createProject(MR_PROJECT_NAME, JavaProjectHelper.TEST_MR_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_21_EE_NAME, false);
jp.setOption(JavaCore.COMPILER_RELEASE, JavaCore.ENABLED);
jp.setOption(JavaCore.COMPILER_COMPLIANCE, "11");
jp.setOption(JavaCore.COMPILER_SOURCE, "11");
jp.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, "11");
IPackageFragmentRoot src17 = JavaProjectHelper.addSourceContainer(jp, "src17", JavaCore.newClasspathAttribute(IClasspathAttribute.RELEASE, "17"));
IPackageFragmentRoot src21 = JavaProjectHelper.addSourceContainer(jp, "src21", JavaCore.newClasspathAttribute(IClasspathAttribute.RELEASE, "21"));
File root = JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.TEST_MR_SRC_DIR);
JavaProjectHelper.importFilesFromDirectory(new File(root, src17.getPath().lastSegment()), src17.getPath(), null);
JavaProjectHelper.importFilesFromDirectory(new File(root, src21.getPath().lastSegment()), src21.getPath(), null);
cfgs.add(createLaunchConfiguration(jp, "p.Main"));
loadedMR = true;
waitForBuild();
}
} catch (Exception e) {
try {
if (jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
} catch (CoreException ce) {
// ignore
}
handleProjectCreationException(e, MR_PROJECT_NAME, jp);
}
}
synchronized void assert23Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded23) {
jp = createProject(TWENTYTHREE_PROJECT_NAME, JavaProjectHelper.TEST_23_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_23_EE_NAME, false);
jp.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_23);
jp.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_23);
cfgs.add(createLaunchConfiguration(jp, "Main21"));
loaded23 = true;
waitForBuild();
assertNoErrorMarkersExist(jp.getProject());
}
} catch (Exception e) {
try {
if (jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
} catch (CoreException ce) {
// ignore
}
handleProjectCreationException(e, TWENTYTHREE_PROJECT_NAME, jp);
}
}
/**
* Creates the Java 24 compliant project
*/
synchronized void assert24Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded24) {
jp = createProject(TWENTYFOUR_PROJECT_NAME, JavaProjectHelper.TEST_24_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_24_EE_NAME, false);
jp.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
jp.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_24);
jp.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_24);
jp.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_24);
cfgs.add(createLaunchConfiguration(jp, "Main21"));
loaded24 = true;
waitForBuild();
assertNoErrorMarkersExist(jp.getProject());
}
} catch (Exception e) {
try {
if (jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
} catch (CoreException ce) {
// ignore
}
handleProjectCreationException(e, TWENTYFOUR_PROJECT_NAME, jp);
}
}
/**
* Creates the Java 25 compliant project
*/
synchronized void assert25Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded25) {
jp = createProject(TWENTYFIVE_PROJECT_NAME, JavaProjectHelper.TEST_25_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_25_EE_NAME, false);
jp.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.DISABLED);
jp.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_25);
jp.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_25);
jp.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_25);
cfgs.add(createLaunchConfiguration(jp, "Main1"));
cfgs.add(createLaunchConfiguration(jp, "Main2"));
loaded25 = true;
waitForBuild();
assertNoErrorMarkersExist(jp.getProject());
}
} catch (Exception e) {
try {
if (jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
} catch (CoreException ce) {
// ignore
}
handleProjectCreationException(e, TWENTYFIVE_PROJECT_NAME, jp);
}
}
synchronized void assert26Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded26) {
jp = createProject(TWENTYSIX_PROJECT_NAME, JavaProjectHelper.TEST_26_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_26_EE_NAME, false);
jp.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.DISABLED);
jp.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_26);
jp.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_26);
jp.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_26);
cfgs.add(createLaunchConfiguration(jp, "Main1"));
cfgs.add(createLaunchConfiguration(jp, "Main2"));
loaded26 = true;
waitForBuild();
assertNoErrorMarkersExist(jp.getProject());
}
} catch (Exception e) {
try {
if (jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
} catch (CoreException ce) {
// ignore
}
handleProjectCreationException(e, TWENTYSIX_PROJECT_NAME, jp);
}
}
/**
* Creates the 'BoundJRE' project used for the JRE testing
*/
synchronized void assertBoundJreProject() {
IJavaProject jp = null;
try {
if (!loadedJRE) {
jp =JavaProjectHelper.createJavaProject(BOUND_JRE_PROJECT_NAME);
JavaProjectHelper.addSourceContainer(jp, JavaProjectHelper.SRC_DIR, JavaProjectHelper.BIN_DIR);
// add VM specific JRE container
IPath path = JavaRuntime.newJREContainerPath(JavaRuntime.getDefaultVMInstall());
JavaProjectHelper.addContainerEntry(jp, path);
loadedJRE = true;
waitForBuild();
}
}
catch(Exception e) {
try {
if(jp != null) {
jp.getProject().delete(true, true, null);
}
}
catch (CoreException ce) {
//ignore
}
handleProjectCreationException(e, BOUND_JRE_PROJECT_NAME, jp);
}
}
/**
* Creates the 'BoundEE' project for EE testing
*/
void assertBoundeEeProject() {
IJavaProject jp = null;
try {
if(!loadedEE) {
// create project with two src folders and output locations
jp = JavaProjectHelper.createJavaProject(BOUND_EE_PROJECT_NAME);
JavaProjectHelper.addSourceContainer(jp, JavaProjectHelper.SRC_DIR, JavaProjectHelper.BIN_DIR);
// add VM specific JRE container
IExecutionEnvironment javase1_8 = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(JavaProjectHelper.JAVA_SE_1_8_EE_NAME);
assertNotNull("Missing JavaSE-1.8 environment", javase1_8);
IPath path = JavaRuntime.newJREContainerPath(javase1_8);
JavaProjectHelper.addContainerEntry(jp, path);
loadedEE = true;
waitForBuild();
}
}
catch(Exception e) {
try {
if(jp != null) {
jp.getProject().delete(true, true, null);
}
}
catch (CoreException ce) {
//ignore
}
handleProjectCreationException(e, BOUND_EE_PROJECT_NAME, jp);
}
}
/**
* Creates the 'MultiOutput' project for source / binary output testing
*/
synchronized void assertMultioutputProject() {
IJavaProject jp = null;
try {
if(!loadedMulti) {
// create project with two src folders and output locations
jp = JavaProjectHelper.createJavaProject(MULTI_OUTPUT_PROJECT_NAME);
JavaProjectHelper.addSourceContainer(jp, "src1", "bin1");
JavaProjectHelper.addSourceContainer(jp, "src2", "bin2");
// add rt.jar
IVMInstall vm = JavaRuntime.getDefaultVMInstall();
assertNotNull("No default JRE", vm);
JavaProjectHelper.addContainerEntry(jp, new Path(JavaRuntime.JRE_CONTAINER));
loadedMulti = true;
waitForBuild();
}
}
catch(Exception e) {
try {
if(jp != null) {
jp.getProject().delete(true, true, null);
}
}
catch (CoreException ce) {
//ignore
}
handleProjectCreationException(e, MULTI_OUTPUT_PROJECT_NAME, jp);
}
}
/**
* Ensure the welcome screen is closed because in 4.x the debug perspective opens a giant fast-view causing issues
*
* @since 3.8
*/
protected final void assertWelcomeScreenClosed() throws Exception {
if(!welcomeClosed && PlatformUI.isWorkbenchRunning()) {
final IWorkbench wb = PlatformUI.getWorkbench();
if (wb == null) {
return;
}
// In UI thread we don't need to run a job
if (Display.getCurrent() != null) {
closeIntro(wb);
return;
}
UIJob job = new UIJob("close welcome screen for debug test suite") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
closeIntro(wb);
return Status.OK_STATUS;
}
};
job.setPriority(Job.INTERACTIVE);
job.setSystem(true);
job.schedule();
}
}
private static void closeIntro(final IWorkbench wb) {
IWorkbenchWindow window = wb.getActiveWorkbenchWindow();
if (window != null) {
IIntroManager im = wb.getIntroManager();
IIntroPart intro = im.getIntro();
if (intro != null) {
welcomeClosed = im.closeIntro(intro);
}
}
}
protected void handleProjectCreationException(Exception e, String pname, IJavaProject jp) {
StringWriter buf = new StringWriter();
String msg = e.getMessage();
if(msg == null) {
msg = "could not acquire message for exception class: " + e.getClass();
}
buf.write("Failed to create the '" + pname + "' test project.\n");
buf.write("'jp' is " + (jp != null ? "not " : "") + " 'null'\n");
buf.write("Stack tace:\n");
e.printStackTrace(new PrintWriter(buf));
fail(buf.toString());
}
/**
* Sets the contents of the given {@link ICompilationUnit} to be the new contents provided
* @param contents the new {@link String} contents, cannot be <code>null</code>
*/
protected void setFileContents(ICompilationUnit unit, String contents) throws JavaModelException {
assertNotNull("You cannot set the new contents of an ICompilationUnit to null", contents);
IBuffer buffer = unit.getBuffer();
buffer.setContents(contents);
unit.save(null, true);
waitForBuild();
}
/**
* Sets the last relevant event set
*
* @param set event set
*/
protected void setEventSet(DebugEvent[] set) {
fEventSet = set;
}
/**
* Returns the last relevant event set
*
* @return event set
*/
protected DebugEvent[] getEventSet() {
return fEventSet;