Bug 20157 junit: exception on 'recreate suite' if file read-only [JUnit]
F3 (everything using the junit wizards) a. create a test class b. create a suite for this class c. add one more test class d. make the test suite class read-only (its compilation unit) e. select that file and choose 'recreate test suite...' f. check both boxes Java Model Exception: Java Model Status [AllTEsts.java is read-only.] at org.eclipse.jdt.internal.core.Openable.save(Openable.java:448) at org.eclipse.jdt.internal.junit.wizards.UpdateTestSuite.updateTestCasesInSuite (UpdateTestSuite.java:181) at org.eclipse.jdt.internal.junit.wizards.UpdateTestSuite.access$1 (UpdateTestSuite.java:149) at org.eclipse.jdt.internal.junit.wizards.UpdateTestSuite$1.run (UpdateTestSuite.java:195) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:299) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.jdt.internal.junit.wizards.UpdateTestSuite.run (UpdateTestSuite.java:113) at org.eclipse.ui.internal.PluginAction.runWithEvent (PluginAction.java:210) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Menu.setVisible(Menu.java:920) at org.eclipse.swt.widgets.Control.WM_CONTEXTMENU(Control.java:2818) at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled Code)) at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled Code)) at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method) at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java(Compiled Code)) at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java(Compiled Code)) at org.eclipse.swt.widgets.Control.WM_RBUTTONUP(Control.java:3707) at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled Code)) at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled Code)) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java(Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1160) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:739) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:248) at org.eclipse.core.launcher.Main.run(Main.java:697) at org.eclipse.core.launcher.Main.main(Main.java:530)
org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/wizards/UpdateTestSuite.java
}
	
	private void updateTestCasesInSuite(IProgressMonitor monitor) {
		try {
			monitor.beginTask(WizardMessages.getString("UpdateAllTests.beginTask"), 5); 
			ISourceRange range= fSuiteMethod.getSourceRange();
			IBuffer buf= fTestSuite.getBuffer();
			String originalContent= buf.getText(range.getOffset(), range.getLength());
			StringBuffer source= new StringBuffer(originalContent);
			
			
			int start= source.toString().indexOf(NewTestSuiteCreationWizardPage.START_MARKER);
			if (start > -1) {
				
				
				int end= source.toString().indexOf(NewTestSuiteCreationWizardPage.END_MARKER, start);
				if (end > -1) {
					monitor.worked(1);
					end += NewTestSuiteCreationWizardPage.END_MARKER.length();
					
					source.replace(start, end, NewTestSuiteCreationWizardPage.getUpdatableString(fSelectedTestCases));
					buf.replace(range.getOffset(), range.getLength(), source.toString());
					monitor.worked(1);
					fTestSuite.reconcile();
					originalContent= buf.getText(0, buf.getLength());
					monitor.worked(1);
					String formattedContent=
						JUnitStubUtility.codeFormat(
							originalContent,
							0,