Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 57041 Details for
Bug 168954
[clean up] Provide Sort Members
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
org.eclipse.jdt.ui (and .ui.test) patch
org.eclipse.jdt.ui.HEAD.patch (text/plain), 207.58 KB, created by
Alex Blewitt
on 2007-01-17 16:30:58 EST
(
hide
)
Description:
org.eclipse.jdt.ui (and .ui.test) patch
Filename:
MIME Type:
Creator:
Alex Blewitt
Created:
2007-01-17 16:30:58 EST
Size:
207.58 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java,v >retrieving revision 1.43 >diff -u -r1.43 MultiFixMessages.java >--- ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java 10 Jan 2007 17:16:22 -0000 1.43 >+++ ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java 17 Jan 2007 21:13:56 -0000 >@@ -94,6 +94,9 @@ > public static String CommentFormatCleanUp_singleLineComments; > public static String CommentFormatFix_description; > >+ public static String SortMembersCleanUp_description; >+ public static String SortMembersFix_description; >+ > static { > // initialize resource bundle > NLS.initializeMessages(BUNDLE_NAME, MultiFixMessages.class); >Index: ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties,v >retrieving revision 1.62 >diff -u -r1.62 MultiFixMessages.properties >--- ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties 10 Jan 2007 17:16:22 -0000 1.62 >+++ ui/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties 17 Jan 2007 21:13:56 -0000 >@@ -76,6 +76,11 @@ > > CodeFormatFix_description=Format code > CodeFormatCleanUp_description=Format source code >+ >+SortMembersFix_description=Sort members >+SortMembersCleanUp_description=Sort members >+SortMembersCleanUp_fields=Sort fields as well >+ > ImportsCleanUp_OrganizeImports_Description=Organize imports > CleanUpSaveParticipantPreferenceConfiguration_clean_up_preference_link=The Clean Up profiles can be managed on the <a>Clean Up</a> preference page. > CleanUpSaveParticipantPreferenceConfiguration_use_clean_up_profile_label=Use Clean &Up profile: >Index: ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java,v >retrieving revision 1.6 >diff -u -r1.6 CleanUpMessages.java >--- ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java 22 Dec 2006 16:50:21 -0000 1.6 >+++ ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java 17 Jan 2007 21:13:57 -0000 >@@ -39,6 +39,10 @@ > public static String CodeFormatingTabPage_Imports_GroupName; > public static String CodeFormatingTabPage_OrganizeImports_CheckBoxLable; > public static String CodeFormatingTabPage_OrganizeImportsSettings_Description; >+ public static String CodeFormatingTabPage_SortMembers_GroupName; >+ public static String CodeFormatingTabPage_SortMembers_CheckBoxLabel; >+ public static String CodeFormatingTabPage_SortMembers_Description; >+ public static String CodeFormatingTabPage_SortMembersFields_CheckBoxLabel; > > public static String CodeFormatingTabPage_RemoveTrailingWhitespace_all_radio; > >Index: ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties,v >retrieving revision 1.8 >diff -u -r1.8 CleanUpMessages.properties >--- ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties 22 Dec 2006 16:50:21 -0000 1.8 >+++ ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties 17 Jan 2007 21:13:59 -0000 >@@ -20,6 +20,10 @@ > CodeFormatingTabPage_CheckboxName_FormatMultiLineComments=Mul&ti line comments > CodeFormatingTabPage_OrganizeImportsSettings_Description=The settings for organizing imports can be changed on the Organize Imports preference page. > CodeFormatingTabPage_CheckboxName_FormatSingleLineComments=&Single line comments >+CodeFormatingTabPage_SortMembers_GroupName=Members >+CodeFormatingTabPage_SortMembers_CheckBoxLabel=Sort members >+CodeFormatingTabPage_SortMembers_Description=The settings for sorting members can be changed on the Members Sort Order preference page. >+CodeFormatingTabPage_SortMembersFields_CheckBoxLabel=Also sort fields, enums and initializers > CodeFormatingTabPage_RemoveTrailingWhitespace_checkbox_text=Remove trailing &whitespace > CodeFormatingTabPage_RemoveTrailingWhitespace_ignoreEmpty_radio=&Ignore empty lines > >Index: ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java,v >retrieving revision 1.5 >diff -u -r1.5 CodeFormatingTabPage.java >--- ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java 10 Jan 2007 17:18:55 -0000 1.5 >+++ ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeFormatingTabPage.java 17 Jan 2007 21:14:00 -0000 >@@ -111,8 +111,8 @@ > allPref.setEnabled(whiteSpace.getChecked()); > ignoreEmptyPref.setEnabled(whiteSpace.getChecked()); > >- PixelConverter pixelConverter= new PixelConverter(composite); >- >+ PixelConverter pixelConverter= new PixelConverter(composite); >+ > if (!fIsSaveParticipantConfiguration) { > createLabel(CleanUpMessages.CodeFormatingTabPage_FormatterSettings_Description, group, numColumns, pixelConverter).setFont(composite.getFont()); > >@@ -121,7 +121,21 @@ > > createLabel(CleanUpMessages.CodeFormatingTabPage_OrganizeImportsSettings_Description, importsGroup, numColumns, pixelConverter).setFont(composite.getFont()); > } >- } >+ Group sortMembersGroup = createGroup(numColumns, composite, CleanUpMessages.CodeFormatingTabPage_SortMembers_GroupName); >+ final CheckboxPreference sortMembersPref = createCheckboxPref(sortMembersGroup, numColumns, CleanUpMessages.CodeFormatingTabPage_SortMembers_CheckBoxLabel, CleanUpConstants.SORT_MEMBERS, CleanUpModifyDialog.FALSE_TRUE); >+ >+ intent(sortMembersGroup); >+ final CheckboxPreference sortMembersFieldsPref = createCheckboxPref(sortMembersGroup, numColumns - 1, CleanUpMessages.CodeFormatingTabPage_SortMembersFields_CheckBoxLabel, CleanUpConstants.SORT_MEMBERS_FIELDS, CleanUpModifyDialog.FALSE_TRUE); >+ >+ sortMembersPref.addObserver( new Observer() { >+ public void update(Observable o, Object arg) { >+ sortMembersFieldsPref.setEnabled(sortMembersPref.getChecked()); >+ } >+ }); >+ sortMembersFieldsPref.setEnabled(sortMembersPref.getChecked()); >+ >+ createLabel(CleanUpMessages.CodeFormatingTabPage_SortMembers_Description, sortMembersGroup, numColumns, pixelConverter).setFont(composite.getFont()); >+ } > > private Label createLabel(String text, Group group, int numColumns, PixelConverter pixelConverter) { > Label label= new Label(group, SWT.WRAP); >@@ -131,13 +145,13 @@ > label.setLayoutData(gridData); > return label; > } >- >+ // NOTE: I think this is supposed to be 'indent' ... > private void intent(Composite composite) { > Label l= new Label(composite, SWT.NONE); >- GridData gd= new GridData(); >- gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(4); >- l.setLayoutData(gd); >- } >+ GridData gd= new GridData(); >+ gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(4); >+ l.setLayoutData(gd); >+ } > > protected void doUpdatePreview() { > fCleanUpPreview.setWorkingValues(fValues); >Index: core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java,v >retrieving revision 1.16 >diff -u -r1.16 CleanUpConstants.java >--- core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java 10 Jan 2007 17:18:55 -0000 1.16 >+++ core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java 17 Jan 2007 21:13:54 -0000 >@@ -948,6 +948,35 @@ > public static final String ORGANIZE_IMPORTS= "cleanup.organize_imports"; //$NON-NLS-1$ > > /** >+ * Should members be sorted? >+ * <br><br> >+ * Possible values: {TRUE, FALSE}<br> >+ * Default value: Value returned by {@link #getEclipseDefaultSettings()}<br> >+ * <br> >+ * >+ * @see #SORT_MEMBERS_FIELDS >+ * @see #TRUE >+ * @see #FALSE >+ * @since 3.3 >+ */ >+ public static final String SORT_MEMBERS = "cleanup.sort_members"; //$NON-NLS-1$ >+ >+ /** >+ * If sorting members, should fields also be sorted? >+ * <br> >+ * <br> >+ * Possible values: {TRUE, FALSE}<br> >+ * Default value: Value returned by {@link #getEclipseDefaultSettings()}<br> >+ * <br> >+ * >+ * @see #SORT_MEMBERS >+ * @see #TRUE >+ * @see #FALSE >+ * @since 3.3 >+ */ >+ public static final String SORT_MEMBERS_FIELDS = "cleanup.sort_members_fields"; //$NON-NLS-1$ >+ >+ /** > * Should the Clean Up Wizard be shown when executing the Clean Up Action? > * <br> > * <br> >@@ -1042,7 +1071,6 @@ > * @since 3.3 > */ > public final static String DEFAULT_SAVE_PARTICIPANT_PROFILE= SAVE_PARTICIPANT_PROFILE; >- > > public static Map getEclipseDefaultSettings() { > final HashMap result= new HashMap(); >@@ -1117,6 +1145,9 @@ > result.put(FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY, FALSE); > > result.put(ORGANIZE_IMPORTS, FALSE); >+ >+ result.put(SORT_MEMBERS, FALSE); >+ result.put(SORT_MEMBERS_FIELDS, FALSE); > > return result; > } >@@ -1194,6 +1225,9 @@ > result.put(FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY, FALSE); > > result.put(ORGANIZE_IMPORTS, TRUE); >+ >+ result.put(SORT_MEMBERS, FALSE); >+ result.put(SORT_MEMBERS_FIELDS, FALSE); > > result.put(CLEANUP_ON_SAVE_ADDITIONAL_OPTIONS, FALSE); > >Index: core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java,v >retrieving revision 1.43 >diff -u -r1.43 CleanUpRefactoring.java >--- core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java 15 Jan 2007 15:36:03 -0000 1.43 >+++ core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java 17 Jan 2007 21:13:55 -0000 >@@ -80,6 +80,7 @@ > import org.eclipse.jdt.internal.ui.fix.ImportsCleanUp; > import org.eclipse.jdt.internal.ui.fix.Java50CleanUp; > import org.eclipse.jdt.internal.ui.fix.PotentialProgrammingProblemsCleanUp; >+import org.eclipse.jdt.internal.ui.fix.SortMembersCleanUp; > import org.eclipse.jdt.internal.ui.fix.StringCleanUp; > import org.eclipse.jdt.internal.ui.fix.UnnecessaryCodeCleanUp; > import org.eclipse.jdt.internal.ui.fix.UnusedCodeCleanUp; >@@ -1014,11 +1015,11 @@ > } > > public static ICleanUp[] createCleanUps() { >- return new ICleanUp[] {new CodeStyleCleanUp(), new ControlStatementsCleanUp(), new ConvertLoopCleanUp(), new VariableDeclarationCleanUp(), new ExpressionsCleanUp(), new UnusedCodeCleanUp(), new Java50CleanUp(), new PotentialProgrammingProblemsCleanUp(), new UnnecessaryCodeCleanUp(), new StringCleanUp(), new ImportsCleanUp(), new CodeFormatCleanUp(), new CommentFormatCleanUp()}; >+ return new ICleanUp[] {new SortMembersCleanUp(), new CodeStyleCleanUp(), new ControlStatementsCleanUp(), new ConvertLoopCleanUp(), new VariableDeclarationCleanUp(), new ExpressionsCleanUp(), new UnusedCodeCleanUp(), new Java50CleanUp(), new PotentialProgrammingProblemsCleanUp(), new UnnecessaryCodeCleanUp(), new StringCleanUp(), new ImportsCleanUp(), new CodeFormatCleanUp(), new CommentFormatCleanUp()}; > } > > public static ICleanUp[] createCleanUps(Map settings) { >- return new ICleanUp[] {new CodeStyleCleanUp(settings), new ControlStatementsCleanUp(settings), new ConvertLoopCleanUp(settings), new VariableDeclarationCleanUp(settings), new ExpressionsCleanUp(settings), new UnusedCodeCleanUp(settings), new Java50CleanUp(settings), new PotentialProgrammingProblemsCleanUp(settings), new UnnecessaryCodeCleanUp(settings), new StringCleanUp(settings), >+ return new ICleanUp[] {new SortMembersCleanUp(settings), new CodeStyleCleanUp(settings), new ControlStatementsCleanUp(settings), new ConvertLoopCleanUp(settings), new VariableDeclarationCleanUp(settings), new ExpressionsCleanUp(settings), new UnusedCodeCleanUp(settings), new Java50CleanUp(settings), new PotentialProgrammingProblemsCleanUp(settings), new UnnecessaryCodeCleanUp(settings), new StringCleanUp(settings), > new ImportsCleanUp(settings), new CodeFormatCleanUp(settings), new CommentFormatCleanUp(settings)}; > } > } >Index: ui/org/eclipse/jdt/internal/ui/fix/SortMembersFix.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/fix/SortMembersFix.java >diff -N ui/org/eclipse/jdt/internal/ui/fix/SortMembersFix.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/fix/SortMembersFix.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,94 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.ui.fix; >+ >+import org.eclipse.text.edits.TextEdit; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+ >+import org.eclipse.ltk.core.refactoring.CategorizedTextEditGroup; >+import org.eclipse.ltk.core.refactoring.GroupCategory; >+import org.eclipse.ltk.core.refactoring.GroupCategorySet; >+import org.eclipse.ltk.core.refactoring.TextChange; >+ >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+import org.eclipse.jdt.core.util.CompilationUnitSorter; >+ >+import org.eclipse.jdt.internal.corext.codemanipulation.SortMembersOperation.DefaultJavaElementComparator; >+import org.eclipse.jdt.internal.corext.fix.IFix; >+import org.eclipse.jdt.internal.corext.refactoring.changes.CompilationUnitChange; >+ >+import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; >+ >+public class SortMembersFix implements IFix { >+ >+ public static IFix createCleanUp(CompilationUnit compilationUnit, boolean sortFields) throws CoreException { >+ >+ ICompilationUnit cu= (ICompilationUnit)compilationUnit.getJavaElement(); >+ cu.becomeWorkingCopy(null, null); >+ >+ IProgressMonitor monitor = null; >+ >+ TextEdit edit = CompilationUnitSorter.sort(compilationUnit,new DefaultJavaElementComparator(!sortFields),0,monitor); >+ >+ // If we've not changed anything, then don't return a change >+ if (edit == null || edit.getLength() == 0) >+ return null; >+ >+ TextChange change= new CompilationUnitChange(MultiFixMessages.SortMembersFix_description, cu); >+ change.setEdit(edit); >+ >+ String label= MultiFixMessages.SortMembersFix_description; >+ change.addTextEditGroup(new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label)))); >+ >+ return new SortMembersFix(change, cu); >+ } >+ >+ >+ private final ICompilationUnit fCompilationUnit; >+ private final TextChange fChange; >+ >+ public SortMembersFix(TextChange change, ICompilationUnit compilationUnit) { >+ fChange= change; >+ fCompilationUnit= compilationUnit; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public TextChange createChange() throws CoreException { >+ return fChange; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public ICompilationUnit getCompilationUnit() { >+ return fCompilationUnit; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getDescription() { >+ return MultiFixMessages.CommentFormatFix_description; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IStatus getStatus() { >+ return StatusInfo.OK_STATUS; >+ } >+} >Index: ui/org/eclipse/jdt/internal/ui/fix/SortMembersCleanUp.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/fix/SortMembersCleanUp.java >diff -N ui/org/eclipse/jdt/internal/ui/fix/SortMembersCleanUp.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/fix/SortMembersCleanUp.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,105 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.ui.fix; >+ >+import java.util.Map; >+ >+import org.eclipse.core.runtime.CoreException; >+ >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; >+import org.eclipse.jdt.internal.corext.fix.IFix; >+import org.eclipse.jdt.ui.text.java.IProblemLocation; >+ >+public class SortMembersCleanUp extends AbstractCleanUp { >+ >+ public SortMembersCleanUp() { >+ super(); >+ } >+ >+ public SortMembersCleanUp(Map options) { >+ super(options); >+ } >+ >+ public IFix createFix(CompilationUnit compilationUnit) throws CoreException { >+ if (compilationUnit == null || !isEnabled(CleanUpConstants.SORT_MEMBERS)) >+ return null; >+ >+ return SortMembersFix.createCleanUp(compilationUnit, isEnabled(CleanUpConstants.SORT_MEMBERS_FIELDS)); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IFix createFix(CompilationUnit compilationUnit, IProblemLocation[] problems) throws CoreException { >+ if (compilationUnit == null) >+ return null; >+ >+ return null; >+ } >+ >+ public Map getRequiredOptions() { >+ return null; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String[] getDescriptions() { >+ if (isEnabled(CleanUpConstants.SORT_MEMBERS)) >+ return new String[] {MultiFixMessages.SortMembersCleanUp_description}; >+ >+ return null; >+ } >+ >+ public String getPreview() { >+ boolean sortMembers = isEnabled(CleanUpConstants.SORT_MEMBERS); >+ boolean sortFields = sortMembers && isEnabled(CleanUpConstants.SORT_MEMBERS_FIELDS); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("public class Engine {\n"); //$NON-NLS-1$ >+ if (sortFields) { >+ buf.append(" private String bar;\n"); //$NON-NLS-1$ >+ buf.append(" private String foo;\n"); //$NON-NLS-1$ >+ } else { >+ buf.append(" private String foo;\n"); //$NON-NLS-1$ >+ buf.append(" private String bar;\n"); //$NON-NLS-1$ >+ } >+ if (sortMembers) { >+ buf.append(" private void bar();\n"); //$NON-NLS-1$ >+ buf.append(" private void foo();\n"); //$NON-NLS-1$ >+ } else { >+ buf.append(" private void foo();\n"); //$NON-NLS-1$ >+ buf.append(" private void bar();\n"); //$NON-NLS-1$ >+ } >+ buf.append("}\n"); //$NON-NLS-1$ >+ >+ return buf.toString(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public int maximalNumberOfFixes(CompilationUnit compilationUnit) { >+ return -1; >+ } >+ >+ public boolean canFix(CompilationUnit compilationUnit, IProblemLocation problem) throws CoreException { >+ return false; >+ } >+ >+ // I have no idea what this is for. I'm presuming it should default to 'true'; the code does need an AST. >+ // The documentation in the interface is less than stellar ... >+ public boolean requireAST(ICompilationUnit unit) throws CoreException { >+ // TODO Should this be false? Or true? >+ return true; >+ } >+} >#P org.eclipse.jdt.ui.tests >Index: performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java,v >retrieving revision 1.23 >diff -u -r1.23 CleanUpPerfTest.java >--- performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java 22 Dec 2006 16:50:34 -0000 1.23 >+++ performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java 17 Jan 2007 21:14:07 -0000 >@@ -50,6 +50,7 @@ > import org.eclipse.jdt.internal.ui.fix.ExpressionsCleanUp; > import org.eclipse.jdt.internal.ui.fix.ICleanUp; > import org.eclipse.jdt.internal.ui.fix.Java50CleanUp; >+import org.eclipse.jdt.internal.ui.fix.SortMembersCleanUp; > import org.eclipse.jdt.internal.ui.fix.StringCleanUp; > import org.eclipse.jdt.internal.ui.fix.UnnecessaryCodeCleanUp; > import org.eclipse.jdt.internal.ui.fix.UnusedCodeCleanUp; >@@ -257,6 +258,9 @@ > > node.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpConstants.TRUE); > >+ node.put(CleanUpConstants.SORT_MEMBERS,CleanUpConstants.TRUE); >+ node.put(CleanUpConstants.SORT_MEMBERS_FIELDS,CleanUpConstants.TRUE); >+ > storeSettings(node); > > ICleanUp[] cleanUps= CleanUpRefactoring.createCleanUps(); >@@ -413,6 +417,31 @@ > } > } > >+ public void testSortMembersCleanUp() throws Exception { >+ CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); >+ addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); >+ >+ Map node= getNullSettings(); >+ >+ node.put(CleanUpConstants.SORT_MEMBERS, CleanUpConstants.TRUE); >+ node.put(CleanUpConstants.SORT_MEMBERS_FIELDS, CleanUpConstants.TRUE); >+ >+ storeSettings(node); >+ >+ cleanUpRefactoring.addCleanUp(new SortMembersCleanUp()); >+ >+ cleanUpRefactoring.checkAllConditions(new NullProgressMonitor()); >+ cleanUpRefactoring.createChange(null); >+ >+ joinBackgroudActivities(); >+ for (int i= 0; i < 10; i++) { >+ startMeasuring(); >+ cleanUpRefactoring.checkAllConditions(new NullProgressMonitor()); >+ cleanUpRefactoring.createChange(null); >+ finishMeasurements(); >+ } >+ } >+ > public void testUnnecessaryCodeCleanUp() throws Exception { > CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); > addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); >Index: ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java,v >retrieving revision 1.80 >diff -u -r1.80 CleanUpTest.java >--- ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java 11 Jan 2007 09:55:43 -0000 1.80 >+++ ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java 17 Jan 2007 21:14:55 -0000 >@@ -146,6 +146,11 @@ > commitProfile(); > } > >+ private void disable(String key) throws CoreException { >+ fProfile.getSettings().put(key, CleanUpConstants.FALSE); >+ commitProfile(); >+ } >+ > private void commitProfile() throws CoreException { > List profiles= CleanUpPreferenceUtil.getBuiltInProfiles(); > profiles.add(fProfile); >@@ -5918,5 +5923,117 @@ > > assertRefactoringResultAsExpected(new ICompilationUnit[] {cu1}, new String[] {expected1}); > } >+ >+ public void testSortMembers01() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test;\n"); >+ buf.append(" public class SM01 {\n"); >+ buf.append(" int b;\n"); >+ buf.append(" int a;\n"); >+ buf.append(" void d() {};\n"); >+ buf.append(" void c() {};\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu1= pack1.createCompilationUnit("SM01.java", buf.toString(), false, null); >+ >+ enable(CleanUpConstants.SORT_MEMBERS); >+ enable(CleanUpConstants.SORT_MEMBERS_FIELDS); >+ >+ buf= new StringBuffer(); >+ buf.append("package test;\n"); >+ buf.append(" public class SM01 {\n"); >+ buf.append(" int a;\n"); >+ buf.append(" int b;\n"); >+ buf.append(" void c() {};\n"); >+ buf.append(" void d() {};\n"); >+ buf.append("}\n"); >+ String expected1= buf.toString(); >+ >+ assertRefactoringResultAsExpected(new ICompilationUnit[] {cu1}, new String[] {expected1}); >+ } >+ >+ public void testSortMembers02() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test;\n"); >+ buf.append(" public class SM02 {\n"); >+ buf.append(" int b;\n"); >+ buf.append(" int a;\n"); >+ buf.append(" void d() {};\n"); >+ buf.append(" void c() {};\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu1= pack1.createCompilationUnit("SM02.java", buf.toString(), false, null); >+ >+ enable(CleanUpConstants.SORT_MEMBERS); >+ disable(CleanUpConstants.SORT_MEMBERS_FIELDS); >+ >+ buf= new StringBuffer(); >+ buf.append("package test;\n"); >+ buf.append(" public class SM02 {\n"); >+ buf.append(" int b;\n"); >+ buf.append(" int a;\n"); >+ buf.append(" void c() {};\n"); >+ buf.append(" void d() {};\n"); >+ buf.append("}\n"); >+ String expected1= buf.toString(); >+ >+ assertRefactoringResultAsExpected(new ICompilationUnit[] {cu1}, new String[] {expected1}); >+ } >+ >+ public void testSortMembers03() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test;\n"); >+ buf.append(" public class SM03 {\n"); >+ buf.append(" int b;\n"); >+ buf.append(" int a;\n"); >+ buf.append(" void d() {};\n"); >+ buf.append(" void c() {};\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu1= pack1.createCompilationUnit("SM03.java", buf.toString(), false, null); >+ >+ disable(CleanUpConstants.SORT_MEMBERS); >+ disable(CleanUpConstants.SORT_MEMBERS_FIELDS); >+ >+ buf= new StringBuffer(); >+ buf.append("package test;\n"); >+ buf.append(" public class SM03 {\n"); >+ buf.append(" int b;\n"); >+ buf.append(" int a;\n"); >+ buf.append(" void d() {};\n"); >+ buf.append(" void c() {};\n"); >+ buf.append("}\n"); >+ String expected1= buf.toString(); >+ >+ assertRefactoringResultAsExpected(new ICompilationUnit[] {cu1}, new String[] {expected1}); >+ } >+ >+ public void testSortMembers04() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test;\n"); >+ buf.append(" public class SM04 {\n"); >+ buf.append(" int b;\n"); >+ buf.append(" int a;\n"); >+ buf.append(" void d() {};\n"); >+ buf.append(" void c() {};\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu1= pack1.createCompilationUnit("SM04.java", buf.toString(), false, null); >+ >+ disable(CleanUpConstants.SORT_MEMBERS); >+ enable(CleanUpConstants.SORT_MEMBERS_FIELDS); >+ >+ buf= new StringBuffer(); >+ buf.append("package test;\n"); >+ buf.append(" public class SM04 {\n"); >+ buf.append(" int b;\n"); >+ buf.append(" int a;\n"); >+ buf.append(" void d() {};\n"); >+ buf.append(" void c() {};\n"); >+ buf.append("}\n"); >+ String expected1= buf.toString(); >+ >+ assertRefactoringResultAsExpected(new ICompilationUnit[] {cu1}, new String[] {expected1}); >+ } > > } >Index: ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java,v >retrieving revision 1.14 >diff -u -r1.14 CleanUpStressTest.java >--- ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java 8 Jan 2007 14:49:49 -0000 1.14 >+++ ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java 17 Jan 2007 21:14:28 -0000 >@@ -165,22 +165,88 @@ > buf.append(" * Sardinia during XP2000.\n"); > buf.append(" */\n"); > buf.append("public abstract class BaseTestRunner implements TestListener {\n"); >- buf.append(" public static final String SUITE_METHODNAME = \"suite\"; //$NON-NLS-1$\n"); >+ buf.append(" static boolean fgFilterStack = true;\n"); > buf.append("\n"); >- buf.append(" private static Properties fPreferences;\n"); > buf.append(" static int fgMaxMessageLength = 500;\n"); >- buf.append(" static boolean fgFilterStack = true;\n"); >- buf.append(" boolean fLoading = true;\n"); >+ buf.append(" private static Properties fPreferences;\n"); >+ buf.append(" public static final String SUITE_METHODNAME = \"suite\"; //$NON-NLS-1$\n"); >+ buf.append(" static {\n"); >+ buf.append(" BaseTestRunner.fgMaxMessageLength = BaseTestRunner.getPreference(\n"); >+ buf.append(" \"maxmessage\", BaseTestRunner.fgMaxMessageLength); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); > buf.append("\n"); >- buf.append(" /*\n"); >- buf.append(" * Implementation of TestListener\n"); >+ buf.append(" static boolean filterLine(final String line) {\n"); >+ buf.append(" final String[] patterns = new String[]{\"junit.framework.TestCase\", //$NON-NLS-1$\n"); >+ buf.append(" \"junit.framework.TestResult\", //$NON-NLS-1$\n"); >+ buf.append(" \"junit.framework.TestSuite\", //$NON-NLS-1$\n"); >+ buf.append(" \"junit.framework.Assert.\", // don't filter AssertionFailure\n"); >+ buf.append(" // //$NON-NLS-1$\n"); >+ buf.append(" \"junit.swingui.TestRunner\", //$NON-NLS-1$\n"); >+ buf.append(" \"junit.awtui.TestRunner\", //$NON-NLS-1$\n"); >+ buf.append(" \"junit.textui.TestRunner\", //$NON-NLS-1$\n"); >+ buf.append(" \"java.lang.reflect.Method.invoke(\" //$NON-NLS-1$\n"); >+ buf.append(" };\n"); >+ buf.append(" for (final String element : patterns) {\n"); >+ buf.append(" if (line.indexOf(element) > 0) {\n"); >+ buf.append(" return true;\n"); >+ buf.append(" }\n"); >+ buf.append(" }\n"); >+ buf.append(" return false;\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Filters stack frames from internal JUnit classes\n"); > buf.append(" */\n"); >- buf.append(" public synchronized void startTest(final Test test) {\n"); >- buf.append(" this.testStarted(test.toString());\n"); >+ buf.append(" public static String getFilteredTrace(final String stack) {\n"); >+ buf.append(" if (BaseTestRunner.showStackRaw()) {\n"); >+ buf.append(" return stack;\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" final StringWriter sw = new StringWriter();\n"); >+ buf.append(" final PrintWriter pw = new PrintWriter(sw);\n"); >+ buf.append(" final StringReader sr = new StringReader(stack);\n"); >+ buf.append(" final BufferedReader br = new BufferedReader(sr);\n"); >+ buf.append("\n"); >+ buf.append(" String line;\n"); >+ buf.append(" try {\n"); >+ buf.append(" while ((line = br.readLine()) != null) {\n"); >+ buf.append(" if (!BaseTestRunner.filterLine(line)) {\n"); >+ buf.append(" pw.println(line);\n"); >+ buf.append(" }\n"); >+ buf.append(" }\n"); >+ buf.append(" } catch (final Exception IOException) {\n"); >+ buf.append(" return stack; // return the stack unfiltered\n"); >+ buf.append(" }\n"); >+ buf.append(" return sw.toString();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" protected static void setPreferences(final Properties preferences) {\n"); >- buf.append(" BaseTestRunner.fPreferences = preferences;\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Returns a filtered stack trace\n"); >+ buf.append(" */\n"); >+ buf.append(" public static String getFilteredTrace(final Throwable t) {\n"); >+ buf.append(" final StringWriter stringWriter = new StringWriter();\n"); >+ buf.append(" final PrintWriter writer = new PrintWriter(stringWriter);\n"); >+ buf.append(" t.printStackTrace(writer);\n"); >+ buf.append(" final StringBuffer buffer = stringWriter.getBuffer();\n"); >+ buf.append(" final String trace = buffer.toString();\n"); >+ buf.append(" return BaseTestRunner.getFilteredTrace(trace);\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" public static String getPreference(final String key) {\n"); >+ buf.append(" return BaseTestRunner.getPreferences().getProperty(key);\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" public static int getPreference(final String key, final int dflt) {\n"); >+ buf.append(" final String value = BaseTestRunner.getPreference(key);\n"); >+ buf.append(" int intValue = dflt;\n"); >+ buf.append(" if (value == null) {\n"); >+ buf.append(" return intValue;\n"); >+ buf.append(" }\n"); >+ buf.append(" try {\n"); >+ buf.append(" intValue = Integer.parseInt(value);\n"); >+ buf.append(" } catch (final NumberFormatException ne) {\n"); >+ buf.append(" }\n"); >+ buf.append(" return intValue;\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" protected static Properties getPreferences() {\n"); >@@ -193,6 +259,39 @@ > buf.append(" return BaseTestRunner.fPreferences;\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" private static File getPreferencesFile() {\n"); >+ buf.append(" final String home = System.getProperty(\"user.home\"); //$NON-NLS-1$\n"); >+ buf.append(" return new File(home, \"junit.properties\"); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" public static boolean inVAJava() {\n"); >+ buf.append(" try {\n"); >+ buf.append(" Class.forName(\"com.ibm.uvm.tools.DebugSupport\"); //$NON-NLS-1$\n"); >+ buf.append(" } catch (final Exception e) {\n"); >+ buf.append(" return false;\n"); >+ buf.append(" }\n"); >+ buf.append(" return true;\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" // TestRunListener implementation\n"); >+ buf.append("\n"); >+ buf.append(" private static void readPreferences() {\n"); >+ buf.append(" InputStream is = null;\n"); >+ buf.append(" try {\n"); >+ buf.append(" is = new FileInputStream(BaseTestRunner.getPreferencesFile());\n"); >+ buf.append(" BaseTestRunner.setPreferences(new Properties(BaseTestRunner\n"); >+ buf.append(" .getPreferences()));\n"); >+ buf.append(" BaseTestRunner.getPreferences().load(is);\n"); >+ buf.append(" } catch (final IOException e) {\n"); >+ buf.append(" try {\n"); >+ buf.append(" if (is != null) {\n"); >+ buf.append(" is.close();\n"); >+ buf.append(" }\n"); >+ buf.append(" } catch (final IOException e1) {\n"); >+ buf.append(" }\n"); >+ buf.append(" }\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" public static void savePreferences() throws IOException {\n"); > buf.append(" final FileOutputStream fos = new FileOutputStream(BaseTestRunner\n"); > buf.append(" .getPreferencesFile());\n"); >@@ -203,30 +302,71 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void setPreference(final String key, final String value) {\n"); >- buf.append(" BaseTestRunner.getPreferences().setProperty(key, value);\n"); >+ buf.append(" protected static void setPreferences(final Properties preferences) {\n"); >+ buf.append(" BaseTestRunner.fPreferences = preferences;\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public synchronized void endTest(final Test test) {\n"); >- buf.append(" this.testEnded(test.toString());\n"); >+ buf.append(" protected static boolean showStackRaw() {\n"); >+ buf.append(" return !BaseTestRunner.getPreference(\"filterstack\").equals(\"true\") || (BaseTestRunner.fgFilterStack == false); //$NON-NLS-1$ //$NON-NLS-2$\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Truncates a String to the maximum length.\n"); >+ buf.append(" */\n"); >+ buf.append(" public static String truncate(String s) {\n"); >+ buf.append(" if ((BaseTestRunner.fgMaxMessageLength != -1)\n"); >+ buf.append(" && (s.length() > BaseTestRunner.fgMaxMessageLength)) {\n"); >+ buf.append(" s = s.substring(0, BaseTestRunner.fgMaxMessageLength) + \"...\"; //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append(" return s;\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" boolean fLoading = true;\n"); >+ buf.append("\n"); > buf.append(" public synchronized void addError(final Test test, final Throwable t) {\n"); > buf.append(" this.testFailed(TestRunListener.STATUS_ERROR, test, t);\n"); > buf.append(" }\n"); >- buf.append("\n"); > buf.append(" public synchronized void addFailure(final Test test,\n"); > buf.append(" final AssertionFailedError t) {\n"); > buf.append(" this.testFailed(TestRunListener.STATUS_FAILURE, test, t);\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" // TestRunListener implementation\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Clears the status message.\n"); >+ buf.append(" */\n"); >+ buf.append(" protected void clearStatus() { // Belongs in the GUI TestRunner class\n"); >+ buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public abstract void testStarted(String testName);\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Returns the formatted string of the elapsed time.\n"); >+ buf.append(" */\n"); >+ buf.append(" public String elapsedTimeAsString(final long runTime) {\n"); >+ buf.append(" return NumberFormat.getInstance().format((double) runTime / 1000);\n"); >+ buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public abstract void testEnded(String testName);\n"); >+ buf.append(" public synchronized void endTest(final Test test) {\n"); >+ buf.append(" this.testEnded(test.toString());\n"); >+ buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public abstract void testFailed(int status, Test test, Throwable t);\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Extract the class name from a String in VA/Java style\n"); >+ buf.append(" */\n"); >+ buf.append(" public String extractClassName(final String className) {\n"); >+ buf.append(" if (className.startsWith(\"Default package for\")) {\n"); >+ buf.append(" return className.substring(className.lastIndexOf(\".\") + 1); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append(" return className;\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Returns the loader to be used.\n"); >+ buf.append(" */\n"); >+ buf.append(" public TestSuiteLoader getLoader() {\n"); >+ buf.append(" if (this.useReloadingTestSuiteLoader()) {\n"); >+ buf.append(" return new ReloadingTestSuiteLoader();\n"); >+ buf.append(" }\n"); >+ buf.append(" return new StandardTestSuiteLoader();\n"); >+ buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); > buf.append(" * Returns the Test corresponding to the given suite. This is a template\n"); >@@ -285,10 +425,11 @@ > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >- buf.append(" * Returns the formatted string of the elapsed time.\n"); >+ buf.append(" * Returns the loaded Class for a suite name.\n"); > buf.append(" */\n"); >- buf.append(" public String elapsedTimeAsString(final long runTime) {\n"); >- buf.append(" return NumberFormat.getInstance().format((double) runTime / 1000);\n"); >+ buf.append(" protected Class loadSuiteClass(final String suiteClassName)\n"); >+ buf.append(" throws ClassNotFoundException {\n"); >+ buf.append(" return this.getLoader().load(suiteClassName);\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >@@ -317,177 +458,36 @@ > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >- buf.append(" * Sets the loading behaviour of the test runner\n"); >- buf.append(" */\n"); >- buf.append(" public void setLoading(final boolean enable) {\n"); >- buf.append(" this.fLoading = enable;\n"); >- buf.append(" }\n"); >- buf.append(" /**\n"); >- buf.append(" * Extract the class name from a String in VA/Java style\n"); >- buf.append(" */\n"); >- buf.append(" public String extractClassName(final String className) {\n"); >- buf.append(" if (className.startsWith(\"Default package for\")) {\n"); >- buf.append(" return className.substring(className.lastIndexOf(\".\") + 1); //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append(" return className;\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Truncates a String to the maximum length.\n"); >- buf.append(" */\n"); >- buf.append(" public static String truncate(String s) {\n"); >- buf.append(" if ((BaseTestRunner.fgMaxMessageLength != -1)\n"); >- buf.append(" && (s.length() > BaseTestRunner.fgMaxMessageLength)) {\n"); >- buf.append(" s = s.substring(0, BaseTestRunner.fgMaxMessageLength) + \"...\"; //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append(" return s;\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" /**\n"); > buf.append(" * Override to define how to handle a failed loading of a test suite.\n"); > buf.append(" */\n"); > buf.append(" protected abstract void runFailed(String message);\n"); > buf.append("\n"); > buf.append(" /**\n"); >- buf.append(" * Returns the loaded Class for a suite name.\n"); >- buf.append(" */\n"); >- buf.append(" protected Class loadSuiteClass(final String suiteClassName)\n"); >- buf.append(" throws ClassNotFoundException {\n"); >- buf.append(" return this.getLoader().load(suiteClassName);\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Clears the status message.\n"); >- buf.append(" */\n"); >- buf.append(" protected void clearStatus() { // Belongs in the GUI TestRunner class\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Returns the loader to be used.\n"); >+ buf.append(" * Sets the loading behaviour of the test runner\n"); > buf.append(" */\n"); >- buf.append(" public TestSuiteLoader getLoader() {\n"); >- buf.append(" if (this.useReloadingTestSuiteLoader()) {\n"); >- buf.append(" return new ReloadingTestSuiteLoader();\n"); >- buf.append(" }\n"); >- buf.append(" return new StandardTestSuiteLoader();\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" protected boolean useReloadingTestSuiteLoader() {\n"); >- buf.append(" return BaseTestRunner.getPreference(\"loading\").equals(\"true\") && !BaseTestRunner.inVAJava() && this.fLoading; //$NON-NLS-1$ //$NON-NLS-2$\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" private static File getPreferencesFile() {\n"); >- buf.append(" final String home = System.getProperty(\"user.home\"); //$NON-NLS-1$\n"); >- buf.append(" return new File(home, \"junit.properties\"); //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" private static void readPreferences() {\n"); >- buf.append(" InputStream is = null;\n"); >- buf.append(" try {\n"); >- buf.append(" is = new FileInputStream(BaseTestRunner.getPreferencesFile());\n"); >- buf.append(" BaseTestRunner.setPreferences(new Properties(BaseTestRunner\n"); >- buf.append(" .getPreferences()));\n"); >- buf.append(" BaseTestRunner.getPreferences().load(is);\n"); >- buf.append(" } catch (final IOException e) {\n"); >- buf.append(" try {\n"); >- buf.append(" if (is != null) {\n"); >- buf.append(" is.close();\n"); >- buf.append(" }\n"); >- buf.append(" } catch (final IOException e1) {\n"); >- buf.append(" }\n"); >- buf.append(" }\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public static String getPreference(final String key) {\n"); >- buf.append(" return BaseTestRunner.getPreferences().getProperty(key);\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public static int getPreference(final String key, final int dflt) {\n"); >- buf.append(" final String value = BaseTestRunner.getPreference(key);\n"); >- buf.append(" int intValue = dflt;\n"); >- buf.append(" if (value == null) {\n"); >- buf.append(" return intValue;\n"); >- buf.append(" }\n"); >- buf.append(" try {\n"); >- buf.append(" intValue = Integer.parseInt(value);\n"); >- buf.append(" } catch (final NumberFormatException ne) {\n"); >- buf.append(" }\n"); >- buf.append(" return intValue;\n"); >+ buf.append(" public void setLoading(final boolean enable) {\n"); >+ buf.append(" this.fLoading = enable;\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public static boolean inVAJava() {\n"); >- buf.append(" try {\n"); >- buf.append(" Class.forName(\"com.ibm.uvm.tools.DebugSupport\"); //$NON-NLS-1$\n"); >- buf.append(" } catch (final Exception e) {\n"); >- buf.append(" return false;\n"); >- buf.append(" }\n"); >- buf.append(" return true;\n"); >+ buf.append(" public void setPreference(final String key, final String value) {\n"); >+ buf.append(" BaseTestRunner.getPreferences().setProperty(key, value);\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Returns a filtered stack trace\n"); >+ buf.append(" /*\n"); >+ buf.append(" * Implementation of TestListener\n"); > buf.append(" */\n"); >- buf.append(" public static String getFilteredTrace(final Throwable t) {\n"); >- buf.append(" final StringWriter stringWriter = new StringWriter();\n"); >- buf.append(" final PrintWriter writer = new PrintWriter(stringWriter);\n"); >- buf.append(" t.printStackTrace(writer);\n"); >- buf.append(" final StringBuffer buffer = stringWriter.getBuffer();\n"); >- buf.append(" final String trace = buffer.toString();\n"); >- buf.append(" return BaseTestRunner.getFilteredTrace(trace);\n"); >+ buf.append(" public synchronized void startTest(final Test test) {\n"); >+ buf.append(" this.testStarted(test.toString());\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Filters stack frames from internal JUnit classes\n"); >- buf.append(" */\n"); >- buf.append(" public static String getFilteredTrace(final String stack) {\n"); >- buf.append(" if (BaseTestRunner.showStackRaw()) {\n"); >- buf.append(" return stack;\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" final StringWriter sw = new StringWriter();\n"); >- buf.append(" final PrintWriter pw = new PrintWriter(sw);\n"); >- buf.append(" final StringReader sr = new StringReader(stack);\n"); >- buf.append(" final BufferedReader br = new BufferedReader(sr);\n"); >- buf.append("\n"); >- buf.append(" String line;\n"); >- buf.append(" try {\n"); >- buf.append(" while ((line = br.readLine()) != null) {\n"); >- buf.append(" if (!BaseTestRunner.filterLine(line)) {\n"); >- buf.append(" pw.println(line);\n"); >- buf.append(" }\n"); >- buf.append(" }\n"); >- buf.append(" } catch (final Exception IOException) {\n"); >- buf.append(" return stack; // return the stack unfiltered\n"); >- buf.append(" }\n"); >- buf.append(" return sw.toString();\n"); >- buf.append(" }\n"); >+ buf.append(" public abstract void testEnded(String testName);\n"); > buf.append("\n"); >- buf.append(" protected static boolean showStackRaw() {\n"); >- buf.append(" return !BaseTestRunner.getPreference(\"filterstack\").equals(\"true\") || (BaseTestRunner.fgFilterStack == false); //$NON-NLS-1$ //$NON-NLS-2$\n"); >- buf.append(" }\n"); >+ buf.append(" public abstract void testFailed(int status, Test test, Throwable t);\n"); > buf.append("\n"); >- buf.append(" static boolean filterLine(final String line) {\n"); >- buf.append(" final String[] patterns = new String[]{\"junit.framework.TestCase\", //$NON-NLS-1$\n"); >- buf.append(" \"junit.framework.TestResult\", //$NON-NLS-1$\n"); >- buf.append(" \"junit.framework.TestSuite\", //$NON-NLS-1$\n"); >- buf.append(" \"junit.framework.Assert.\", // don't filter AssertionFailure\n"); >- buf.append(" // //$NON-NLS-1$\n"); >- buf.append(" \"junit.swingui.TestRunner\", //$NON-NLS-1$\n"); >- buf.append(" \"junit.awtui.TestRunner\", //$NON-NLS-1$\n"); >- buf.append(" \"junit.textui.TestRunner\", //$NON-NLS-1$\n"); >- buf.append(" \"java.lang.reflect.Method.invoke(\" //$NON-NLS-1$\n"); >- buf.append(" };\n"); >- buf.append(" for (final String element : patterns) {\n"); >- buf.append(" if (line.indexOf(element) > 0) {\n"); >- buf.append(" return true;\n"); >- buf.append(" }\n"); >- buf.append(" }\n"); >- buf.append(" return false;\n"); >- buf.append(" }\n"); >+ buf.append(" public abstract void testStarted(String testName);\n"); > buf.append("\n"); >- buf.append(" static {\n"); >- buf.append(" BaseTestRunner.fgMaxMessageLength = BaseTestRunner.getPreference(\n"); >- buf.append(" \"maxmessage\", BaseTestRunner.fgMaxMessageLength); //$NON-NLS-1$\n"); >+ buf.append(" protected boolean useReloadingTestSuiteLoader() {\n"); >+ buf.append(" return BaseTestRunner.getPreference(\"loading\").equals(\"true\") && !BaseTestRunner.inVAJava() && this.fLoading; //$NON-NLS-1$ //$NON-NLS-2$\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append("}"); >@@ -602,35 +602,35 @@ > buf.append(" Assert.fail();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testAssertPosInfinityNotEqualsNegInfinity() {\n"); >+ buf.append(" public void testAssertNegInfinityEqualsInfinity() {\n"); >+ buf.append(" Assert.assertEquals(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY,\n"); >+ buf.append(" 0.0);\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" public void testAssertPosInfinityEqualsInfinity() {\n"); >+ buf.append(" Assert.assertEquals(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY,\n"); >+ buf.append(" 0.0);\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" public void testAssertPosInfinityNotEquals() {\n"); > buf.append(" try {\n"); >- buf.append(" Assert.assertEquals(Double.POSITIVE_INFINITY,\n"); >- buf.append(" Double.NEGATIVE_INFINITY, 0.0);\n"); >+ buf.append(" Assert.assertEquals(Double.POSITIVE_INFINITY, 1.23, 0.0);\n"); > buf.append(" } catch (final AssertionFailedError e) {\n"); > buf.append(" return;\n"); > buf.append(" }\n"); > buf.append(" Assert.fail();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testAssertPosInfinityNotEquals() {\n"); >+ buf.append(" public void testAssertPosInfinityNotEqualsNegInfinity() {\n"); > buf.append(" try {\n"); >- buf.append(" Assert.assertEquals(Double.POSITIVE_INFINITY, 1.23, 0.0);\n"); >+ buf.append(" Assert.assertEquals(Double.POSITIVE_INFINITY,\n"); >+ buf.append(" Double.NEGATIVE_INFINITY, 0.0);\n"); > buf.append(" } catch (final AssertionFailedError e) {\n"); > buf.append(" return;\n"); > buf.append(" }\n"); > buf.append(" Assert.fail();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testAssertPosInfinityEqualsInfinity() {\n"); >- buf.append(" Assert.assertEquals(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY,\n"); >- buf.append(" 0.0);\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public void testAssertNegInfinityEqualsInfinity() {\n"); >- buf.append(" Assert.assertEquals(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY,\n"); >- buf.append(" 0.0);\n"); >- buf.append(" }\n"); >- buf.append("\n"); > buf.append("}\n"); > buf.append(""); > fExpectedChangesAllTests.put("junit.tests.framework.DoublePrecisionAssertTest.java", buf.toString()); >@@ -644,22 +644,6 @@ > buf.append("\n"); > buf.append("public class AssertTest extends TestCase {\n"); > buf.append("\n"); >- buf.append(" /*\n"); >- buf.append(" * In the tests that follow, we can't use standard formatting for exception\n"); >- buf.append(" * tests: try { somethingThatShouldThrow(); fail(); catch\n"); >- buf.append(" * (AssertionFailedError e) { } because fail() would never be reported.\n"); >- buf.append(" */\n"); >- buf.append(" public void testFail() {\n"); >- buf.append(" // Also, we are testing fail, so we can't rely on fail() working.\n"); >- buf.append(" // We have to throw the exception manually, .\n"); >- buf.append(" try {\n"); >- buf.append(" Assert.fail();\n"); >- buf.append(" } catch (final AssertionFailedError e) {\n"); >- buf.append(" return;\n"); >- buf.append(" }\n"); >- buf.append(" throw new AssertionFailedError();\n"); >- buf.append(" }\n"); >- buf.append("\n"); > buf.append(" public void testAssertEquals() {\n"); > buf.append(" final Object o = new Object();\n"); > buf.append(" Assert.assertEquals(o, o);\n"); >@@ -675,75 +659,74 @@ > buf.append(" Assert.assertEquals(null, null);\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testAssertStringEquals() {\n"); >- buf.append(" Assert.assertEquals(\"a\", \"a\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public void testAssertNullNotEqualsString() {\n"); >+ buf.append(" public void testAssertFalse() {\n"); >+ buf.append(" Assert.assertFalse(false);\n"); > buf.append(" try {\n"); >- buf.append(" Assert.assertEquals(null, \"foo\"); //$NON-NLS-1$\n"); >- buf.append(" Assert.fail();\n"); >- buf.append(" } catch (final ComparisonFailure e) {\n"); >+ buf.append(" Assert.assertFalse(true);\n"); >+ buf.append(" } catch (final AssertionFailedError e) {\n"); >+ buf.append(" return;\n"); > buf.append(" }\n"); >+ buf.append(" Assert.fail();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testAssertStringNotEqualsNull() {\n"); >+ buf.append(" public void testAssertNotNull() {\n"); >+ buf.append(" Assert.assertNotNull(new Object());\n"); > buf.append(" try {\n"); >- buf.append(" Assert.assertEquals(\"foo\", null); //$NON-NLS-1$\n"); >- buf.append(" Assert.fail();\n"); >- buf.append(" } catch (final ComparisonFailure e) {\n"); >- buf.append(" e.getMessage(); // why no assertion?\n"); >+ buf.append(" Assert.assertNotNull(null);\n"); >+ buf.append(" } catch (final AssertionFailedError e) {\n"); >+ buf.append(" return;\n"); > buf.append(" }\n"); >+ buf.append(" Assert.fail();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testAssertNullNotEqualsNull() {\n"); >+ buf.append(" public void testAssertNotSame() {\n"); >+ buf.append(" Assert.assertNotSame(new Integer(1), null);\n"); >+ buf.append(" Assert.assertNotSame(null, new Integer(1));\n"); >+ buf.append(" Assert.assertNotSame(new Integer(1), new Integer(1));\n"); > buf.append(" try {\n"); >- buf.append(" Assert.assertEquals(null, new Object());\n"); >+ buf.append(" final Integer obj = new Integer(1);\n"); >+ buf.append(" Assert.assertNotSame(obj, obj);\n"); > buf.append(" } catch (final AssertionFailedError e) {\n"); >- buf.append(" e.getMessage(); // why no assertion?\n"); > buf.append(" return;\n"); > buf.append(" }\n"); > buf.append(" Assert.fail();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testAssertNull() {\n"); >- buf.append(" Assert.assertNull(null);\n"); >+ buf.append(" public void testAssertNotSameFailsNull() {\n"); > buf.append(" try {\n"); >- buf.append(" Assert.assertNull(new Object());\n"); >+ buf.append(" Assert.assertNotSame(null, null);\n"); > buf.append(" } catch (final AssertionFailedError e) {\n"); > buf.append(" return;\n"); > buf.append(" }\n"); > buf.append(" Assert.fail();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testAssertNotNull() {\n"); >- buf.append(" Assert.assertNotNull(new Object());\n"); >+ buf.append(" public void testAssertNull() {\n"); >+ buf.append(" Assert.assertNull(null);\n"); > buf.append(" try {\n"); >- buf.append(" Assert.assertNotNull(null);\n"); >+ buf.append(" Assert.assertNull(new Object());\n"); > buf.append(" } catch (final AssertionFailedError e) {\n"); > buf.append(" return;\n"); > buf.append(" }\n"); > buf.append(" Assert.fail();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testAssertTrue() {\n"); >- buf.append(" Assert.assertTrue(true);\n"); >+ buf.append(" public void testAssertNullNotEqualsNull() {\n"); > buf.append(" try {\n"); >- buf.append(" Assert.assertTrue(false);\n"); >+ buf.append(" Assert.assertEquals(null, new Object());\n"); > buf.append(" } catch (final AssertionFailedError e) {\n"); >+ buf.append(" e.getMessage(); // why no assertion?\n"); > buf.append(" return;\n"); > buf.append(" }\n"); > buf.append(" Assert.fail();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testAssertFalse() {\n"); >- buf.append(" Assert.assertFalse(false);\n"); >+ buf.append(" public void testAssertNullNotEqualsString() {\n"); > buf.append(" try {\n"); >- buf.append(" Assert.assertFalse(true);\n"); >- buf.append(" } catch (final AssertionFailedError e) {\n"); >- buf.append(" return;\n"); >+ buf.append(" Assert.assertEquals(null, \"foo\"); //$NON-NLS-1$\n"); >+ buf.append(" Assert.fail();\n"); >+ buf.append(" } catch (final ComparisonFailure e) {\n"); > buf.append(" }\n"); >- buf.append(" Assert.fail();\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" public void testAssertSame() {\n"); >@@ -757,26 +740,43 @@ > buf.append(" Assert.fail();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testAssertNotSame() {\n"); >- buf.append(" Assert.assertNotSame(new Integer(1), null);\n"); >- buf.append(" Assert.assertNotSame(null, new Integer(1));\n"); >- buf.append(" Assert.assertNotSame(new Integer(1), new Integer(1));\n"); >+ buf.append(" public void testAssertStringEquals() {\n"); >+ buf.append(" Assert.assertEquals(\"a\", \"a\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" public void testAssertStringNotEqualsNull() {\n"); > buf.append(" try {\n"); >- buf.append(" final Integer obj = new Integer(1);\n"); >- buf.append(" Assert.assertNotSame(obj, obj);\n"); >+ buf.append(" Assert.assertEquals(\"foo\", null); //$NON-NLS-1$\n"); >+ buf.append(" Assert.fail();\n"); >+ buf.append(" } catch (final ComparisonFailure e) {\n"); >+ buf.append(" e.getMessage(); // why no assertion?\n"); >+ buf.append(" }\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" public void testAssertTrue() {\n"); >+ buf.append(" Assert.assertTrue(true);\n"); >+ buf.append(" try {\n"); >+ buf.append(" Assert.assertTrue(false);\n"); > buf.append(" } catch (final AssertionFailedError e) {\n"); > buf.append(" return;\n"); > buf.append(" }\n"); > buf.append(" Assert.fail();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testAssertNotSameFailsNull() {\n"); >+ buf.append(" /*\n"); >+ buf.append(" * In the tests that follow, we can't use standard formatting for exception\n"); >+ buf.append(" * tests: try { somethingThatShouldThrow(); fail(); catch\n"); >+ buf.append(" * (AssertionFailedError e) { } because fail() would never be reported.\n"); >+ buf.append(" */\n"); >+ buf.append(" public void testFail() {\n"); >+ buf.append(" // Also, we are testing fail, so we can't rely on fail() working.\n"); >+ buf.append(" // We have to throw the exception manually, .\n"); > buf.append(" try {\n"); >- buf.append(" Assert.assertNotSame(null, null);\n"); >+ buf.append(" Assert.fail();\n"); > buf.append(" } catch (final AssertionFailedError e) {\n"); > buf.append(" return;\n"); > buf.append(" }\n"); >- buf.append(" Assert.fail();\n"); >+ buf.append(" throw new AssertionFailedError();\n"); > buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.tests.framework.AssertTest.java", buf.toString()); >@@ -822,21 +822,21 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" static public class ThrowRuntimeExceptionTestCase extends ExceptionTestCase {\n"); >- buf.append(" public ThrowRuntimeExceptionTestCase(final String name,\n"); >- buf.append(" final Class exception) {\n"); >+ buf.append(" static public class ThrowNoExceptionTestCase extends ExceptionTestCase {\n"); >+ buf.append(" public ThrowNoExceptionTestCase(final String name, final Class exception) {\n"); > buf.append(" super(name, exception);\n"); > buf.append(" }\n"); > buf.append(" public void test() {\n"); >- buf.append(" throw new RuntimeException();\n"); > buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" static public class ThrowNoExceptionTestCase extends ExceptionTestCase {\n"); >- buf.append(" public ThrowNoExceptionTestCase(final String name, final Class exception) {\n"); >+ buf.append(" static public class ThrowRuntimeExceptionTestCase extends ExceptionTestCase {\n"); >+ buf.append(" public ThrowRuntimeExceptionTestCase(final String name,\n"); >+ buf.append(" final Class exception) {\n"); > buf.append(" super(name, exception);\n"); > buf.append(" }\n"); > buf.append(" public void test() {\n"); >+ buf.append(" throw new RuntimeException();\n"); > buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); >@@ -891,11 +891,11 @@ > buf.append("import junit.framework.TestResult;\n"); > buf.append("\n"); > buf.append("public class TestListenerTest extends TestCase implements TestListener {\n"); >- buf.append(" private TestResult fResult;\n"); >- buf.append(" private int fStartCount;\n"); > buf.append(" private int fEndCount;\n"); >- buf.append(" private int fFailureCount;\n"); > buf.append(" private int fErrorCount;\n"); >+ buf.append(" private int fFailureCount;\n"); >+ buf.append(" private TestResult fResult;\n"); >+ buf.append(" private int fStartCount;\n"); > buf.append("\n"); > buf.append(" public void addError(final Test test, final Throwable t) {\n"); > buf.append(" this.fErrorCount++;\n"); >@@ -1086,6 +1086,10 @@ > buf.append(" public int countTestCases() {\n"); > buf.append(" return this.fTest.countTestCases();\n"); > buf.append(" }\n"); >+ buf.append(" public Test getTest() {\n"); >+ buf.append(" return this.fTest;\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" public void run(final TestResult result) {\n"); > buf.append(" this.basicRun(result);\n"); > buf.append(" }\n"); >@@ -1094,10 +1098,6 @@ > buf.append(" public String toString() {\n"); > buf.append(" return this.fTest.toString();\n"); > buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public Test getTest() {\n"); >- buf.append(" return this.fTest;\n"); >- buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.extensions.TestDecorator.java", buf.toString()); > buf= new StringBuffer(); >@@ -1128,8 +1128,8 @@ > buf.append(" * @see Test\n"); > buf.append(" */\n"); > buf.append("public class TestResult extends Object {\n"); >- buf.append(" protected Vector fFailures;\n"); > buf.append(" protected Vector fErrors;\n"); >+ buf.append(" protected Vector fFailures;\n"); > buf.append(" protected Vector fListeners;\n"); > buf.append(" protected int fRunTests;\n"); > buf.append(" private boolean fStop;\n"); >@@ -1171,12 +1171,6 @@ > buf.append(" this.fListeners.addElement(listener);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Unregisters a TestListener\n"); >- buf.append(" */\n"); >- buf.append(" public synchronized void removeListener(final TestListener listener) {\n"); >- buf.append(" this.fListeners.removeElement(listener);\n"); >- buf.append(" }\n"); >- buf.append(" /**\n"); > buf.append(" * Returns a copy of the listeners.\n"); > buf.append(" */\n"); > buf.append(" private synchronized Vector cloneListeners() {\n"); >@@ -1216,6 +1210,12 @@ > buf.append(" return this.fFailures.elements();\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >+ buf.append(" * Unregisters a TestListener\n"); >+ buf.append(" */\n"); >+ buf.append(" public synchronized void removeListener(final TestListener listener) {\n"); >+ buf.append(" this.fListeners.removeElement(listener);\n"); >+ buf.append(" }\n"); >+ buf.append(" /**\n"); > buf.append(" * Runs a TestCase.\n"); > buf.append(" */\n"); > buf.append(" protected void run(final TestCase test) {\n"); >@@ -1319,14 +1319,14 @@ > buf.append(" super(theClass);\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public ActiveTestSuite(final String name) {\n"); >- buf.append(" super(name);\n"); >- buf.append(" }\n"); >- buf.append("\n"); > buf.append(" public ActiveTestSuite(final Class theClass, final String name) {\n"); > buf.append(" super(theClass, name);\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" public ActiveTestSuite(final String name) {\n"); >+ buf.append(" super(name);\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" @Override\n"); > buf.append(" public void run(final TestResult result) {\n"); > buf.append(" this.fActiveTestDeathCount = 0;\n"); >@@ -1334,6 +1334,11 @@ > buf.append(" this.waitUntilFinished();\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" synchronized public void runFinished(final Test test) {\n"); >+ buf.append(" this.fActiveTestDeathCount++;\n"); >+ buf.append(" this.notifyAll();\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" @Override\n"); > buf.append(" public void runTest(final Test test, final TestResult result) {\n"); > buf.append(" final Thread t = new Thread() {\n"); >@@ -1360,11 +1365,6 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" synchronized public void runFinished(final Test test) {\n"); >- buf.append(" this.fActiveTestDeathCount++;\n"); >- buf.append(" this.notifyAll();\n"); >- buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.extensions.ActiveTestSuite.java", buf.toString()); > buf= new StringBuffer(); >@@ -1381,14 +1381,6 @@ > buf.append(" * \n"); > buf.append(" */\n"); > buf.append("public class SuiteTest extends TestCase {\n"); >- buf.append(" protected TestResult fResult;\n"); >- buf.append(" public SuiteTest(final String name) {\n"); >- buf.append(" super(name);\n"); >- buf.append(" }\n"); >- buf.append(" @Override\n"); >- buf.append(" protected void setUp() {\n"); >- buf.append(" this.fResult = new TestResult();\n"); >- buf.append(" }\n"); > buf.append(" public static Test suite() {\n"); > buf.append(" final TestSuite suite = new TestSuite(\"Suite Tests\"); //$NON-NLS-1$\n"); > buf.append(" // build the suite manually, because some of the suites are testing\n"); >@@ -1405,6 +1397,20 @@ > buf.append("\n"); > buf.append(" return suite;\n"); > buf.append(" }\n"); >+ buf.append(" protected TestResult fResult;\n"); >+ buf.append(" public SuiteTest(final String name) {\n"); >+ buf.append(" super(name);\n"); >+ buf.append(" }\n"); >+ buf.append(" @Override\n"); >+ buf.append(" protected void setUp() {\n"); >+ buf.append(" this.fResult = new TestResult();\n"); >+ buf.append(" }\n"); >+ buf.append(" public void testAddTestSuite() {\n"); >+ buf.append(" final TestSuite suite = new TestSuite();\n"); >+ buf.append(" suite.addTestSuite(OneTestCase.class);\n"); >+ buf.append(" suite.run(this.fResult);\n"); >+ buf.append(" Assert.assertEquals(1, this.fResult.runCount());\n"); >+ buf.append(" }\n"); > buf.append(" public void testInheritedTests() {\n"); > buf.append(" final TestSuite suite = new TestSuite(InheritedTestCase.class);\n"); > buf.append(" suite.run(this.fResult);\n"); >@@ -1453,12 +1459,6 @@ > buf.append(" suite.run(this.fResult);\n"); > buf.append(" Assert.assertEquals(1, this.fResult.runCount());\n"); > buf.append(" }\n"); >- buf.append(" public void testAddTestSuite() {\n"); >- buf.append(" final TestSuite suite = new TestSuite();\n"); >- buf.append(" suite.addTestSuite(OneTestCase.class);\n"); >- buf.append(" suite.run(this.fResult);\n"); >- buf.append(" Assert.assertEquals(1, this.fResult.runCount());\n"); >- buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.tests.framework.SuiteTest.java", buf.toString()); > buf= new StringBuffer(); >@@ -1557,19 +1557,6 @@ > buf.append(" this.fLoader = new TestCaseClassLoader();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" @Override\n"); >- buf.append(" protected boolean isTestClass(final String classFileName) {\n"); >- buf.append(" try {\n"); >- buf.append(" if (classFileName.endsWith(\".class\")) { //$NON-NLS-1$\n"); >- buf.append(" final Class testClass = this.classFromFile(classFileName);\n"); >- buf.append(" return (testClass != null) && this.isTestClass(testClass);\n"); >- buf.append(" }\n"); >- buf.append(" } catch (final ClassNotFoundException expected) {\n"); >- buf.append(" } catch (final NoClassDefFoundError notFatal) {\n"); >- buf.append(" }\n"); >- buf.append(" return false;\n"); >- buf.append(" }\n"); >- buf.append("\n"); > buf.append(" Class classFromFile(final String classFileName)\n"); > buf.append(" throws ClassNotFoundException {\n"); > buf.append(" final String className = this.classNameFromFile(classFileName);\n"); >@@ -1579,16 +1566,13 @@ > buf.append(" return null;\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" boolean isTestClass(final Class testClass) {\n"); >- buf.append(" if (this.hasSuiteMethod(testClass)) {\n"); >- buf.append(" return true;\n"); >- buf.append(" }\n"); >- buf.append(" if (Test.class.isAssignableFrom(testClass)\n"); >- buf.append(" && Modifier.isPublic(testClass.getModifiers())\n"); >- buf.append(" && this.hasPublicConstructor(testClass)) {\n"); >- buf.append(" return true;\n"); >+ buf.append(" boolean hasPublicConstructor(final Class testClass) {\n"); >+ buf.append(" try {\n"); >+ buf.append(" TestSuite.getTestConstructor(testClass);\n"); >+ buf.append(" } catch (final NoSuchMethodException e) {\n"); >+ buf.append(" return false;\n"); > buf.append(" }\n"); >- buf.append(" return false;\n"); >+ buf.append(" return true;\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" boolean hasSuiteMethod(final Class testClass) {\n"); >@@ -1600,13 +1584,29 @@ > buf.append(" return true;\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" boolean hasPublicConstructor(final Class testClass) {\n"); >+ buf.append(" boolean isTestClass(final Class testClass) {\n"); >+ buf.append(" if (this.hasSuiteMethod(testClass)) {\n"); >+ buf.append(" return true;\n"); >+ buf.append(" }\n"); >+ buf.append(" if (Test.class.isAssignableFrom(testClass)\n"); >+ buf.append(" && Modifier.isPublic(testClass.getModifiers())\n"); >+ buf.append(" && this.hasPublicConstructor(testClass)) {\n"); >+ buf.append(" return true;\n"); >+ buf.append(" }\n"); >+ buf.append(" return false;\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" @Override\n"); >+ buf.append(" protected boolean isTestClass(final String classFileName) {\n"); > buf.append(" try {\n"); >- buf.append(" TestSuite.getTestConstructor(testClass);\n"); >- buf.append(" } catch (final NoSuchMethodException e) {\n"); >- buf.append(" return false;\n"); >+ buf.append(" if (classFileName.endsWith(\".class\")) { //$NON-NLS-1$\n"); >+ buf.append(" final Class testClass = this.classFromFile(classFileName);\n"); >+ buf.append(" return (testClass != null) && this.isTestClass(testClass);\n"); >+ buf.append(" }\n"); >+ buf.append(" } catch (final ClassNotFoundException expected) {\n"); >+ buf.append(" } catch (final NoClassDefFoundError notFatal) {\n"); > buf.append(" }\n"); >- buf.append(" return true;\n"); >+ buf.append(" return false;\n"); > buf.append(" }\n"); > buf.append("}\n"); > buf.append(""); >@@ -1642,17 +1642,17 @@ > buf.append(" */\n"); > buf.append("\n"); > buf.append("public class TestCaseClassLoader extends ClassLoader {\n"); >- buf.append(" /** scanned class path */\n"); >- buf.append(" private Vector fPathItems;\n"); >+ buf.append(" /** name of excluded properties file */\n"); >+ buf.append(" static final String EXCLUDED_FILE = \"excluded.properties\"; //$NON-NLS-1$\n"); > buf.append(" /** default excluded paths */\n"); > buf.append(" private final String[] defaultExclusions = {\"junit.framework.\", //$NON-NLS-1$\n"); > buf.append(" \"junit.extensions.\", //$NON-NLS-1$\n"); > buf.append(" \"junit.runner.\" //$NON-NLS-1$\n"); > buf.append(" };\n"); >- buf.append(" /** name of excluded properties file */\n"); >- buf.append(" static final String EXCLUDED_FILE = \"excluded.properties\"; //$NON-NLS-1$\n"); > buf.append(" /** excluded paths */\n"); > buf.append(" private Vector fExcluded;\n"); >+ buf.append(" /** scanned class path */\n"); >+ buf.append(" private Vector fPathItems;\n"); > buf.append("\n"); > buf.append(" /**\n"); > buf.append(" * Constructs a TestCaseLoader. It scans the class path and the excluded\n"); >@@ -1671,13 +1671,22 @@ > buf.append(" this.readExcludedPackages();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" private void scanPath(final String classPath) {\n"); >- buf.append(" final String separator = System.getProperty(\"path.separator\"); //$NON-NLS-1$\n"); >- buf.append(" this.fPathItems = new Vector(10);\n"); >- buf.append(" final StringTokenizer st = new StringTokenizer(classPath, separator);\n"); >- buf.append(" while (st.hasMoreTokens()) {\n"); >- buf.append(" this.fPathItems.addElement(st.nextToken());\n"); >+ buf.append(" private byte[] getClassData(final File f) {\n"); >+ buf.append(" try {\n"); >+ buf.append(" final FileInputStream stream = new FileInputStream(f);\n"); >+ buf.append(" final ByteArrayOutputStream out = new ByteArrayOutputStream(1000);\n"); >+ buf.append(" final byte[] b = new byte[1000];\n"); >+ buf.append(" int n;\n"); >+ buf.append(" while ((n = stream.read(b)) != -1) {\n"); >+ buf.append(" out.write(b, 0, n);\n"); >+ buf.append(" }\n"); >+ buf.append(" stream.close();\n"); >+ buf.append(" out.close();\n"); >+ buf.append(" return out.toByteArray();\n"); >+ buf.append("\n"); >+ buf.append(" } catch (final IOException e) {\n"); > buf.append(" }\n"); >+ buf.append(" return null;\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" @Override\n"); >@@ -1699,6 +1708,10 @@ > buf.append(" return false;\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" boolean isJar(final String pathEntry) {\n"); >+ buf.append(" return pathEntry.endsWith(\".jar\") || pathEntry.endsWith(\".zip\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" @Override\n"); > buf.append(" public synchronized Class loadClass(final String name, final boolean resolve)\n"); > buf.append(" throws ClassNotFoundException {\n"); >@@ -1732,28 +1745,6 @@ > buf.append(" return c;\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" private byte[] lookupClassData(final String className)\n"); >- buf.append(" throws ClassNotFoundException {\n"); >- buf.append(" byte[] data = null;\n"); >- buf.append(" for (int i = 0; i < this.fPathItems.size(); i++) {\n"); >- buf.append(" final String path = (String) this.fPathItems.elementAt(i);\n"); >- buf.append(" final String fileName = className.replace('.', '/') + \".class\"; //$NON-NLS-1$\n"); >- buf.append(" if (this.isJar(path)) {\n"); >- buf.append(" data = this.loadJarData(path, fileName);\n"); >- buf.append(" } else {\n"); >- buf.append(" data = this.loadFileData(path, fileName);\n"); >- buf.append(" }\n"); >- buf.append(" if (data != null) {\n"); >- buf.append(" return data;\n"); >- buf.append(" }\n"); >- buf.append(" }\n"); >- buf.append(" throw new ClassNotFoundException(className);\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" boolean isJar(final String pathEntry) {\n"); >- buf.append(" return pathEntry.endsWith(\".jar\") || pathEntry.endsWith(\".zip\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >- buf.append(" }\n"); >- buf.append("\n"); > buf.append(" private byte[] loadFileData(final String path, final String fileName) {\n"); > buf.append(" final File file = new File(path, fileName);\n"); > buf.append(" if (file.exists()) {\n"); >@@ -1762,24 +1753,6 @@ > buf.append(" return null;\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" private byte[] getClassData(final File f) {\n"); >- buf.append(" try {\n"); >- buf.append(" final FileInputStream stream = new FileInputStream(f);\n"); >- buf.append(" final ByteArrayOutputStream out = new ByteArrayOutputStream(1000);\n"); >- buf.append(" final byte[] b = new byte[1000];\n"); >- buf.append(" int n;\n"); >- buf.append(" while ((n = stream.read(b)) != -1) {\n"); >- buf.append(" out.write(b, 0, n);\n"); >- buf.append(" }\n"); >- buf.append(" stream.close();\n"); >- buf.append(" out.close();\n"); >- buf.append(" return out.toByteArray();\n"); >- buf.append("\n"); >- buf.append(" } catch (final IOException e) {\n"); >- buf.append(" }\n"); >- buf.append(" return null;\n"); >- buf.append(" }\n"); >- buf.append("\n"); > buf.append(" private byte[] loadJarData(final String path, final String fileName) {\n"); > buf.append(" ZipFile zipFile = null;\n"); > buf.append(" InputStream stream = null;\n"); >@@ -1819,6 +1792,24 @@ > buf.append(" return null;\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" private byte[] lookupClassData(final String className)\n"); >+ buf.append(" throws ClassNotFoundException {\n"); >+ buf.append(" byte[] data = null;\n"); >+ buf.append(" for (int i = 0; i < this.fPathItems.size(); i++) {\n"); >+ buf.append(" final String path = (String) this.fPathItems.elementAt(i);\n"); >+ buf.append(" final String fileName = className.replace('.', '/') + \".class\"; //$NON-NLS-1$\n"); >+ buf.append(" if (this.isJar(path)) {\n"); >+ buf.append(" data = this.loadJarData(path, fileName);\n"); >+ buf.append(" } else {\n"); >+ buf.append(" data = this.loadFileData(path, fileName);\n"); >+ buf.append(" }\n"); >+ buf.append(" if (data != null) {\n"); >+ buf.append(" return data;\n"); >+ buf.append(" }\n"); >+ buf.append(" }\n"); >+ buf.append(" throw new ClassNotFoundException(className);\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" private void readExcludedPackages() {\n"); > buf.append(" this.fExcluded = new Vector(10);\n"); > buf.append(" for (final String element : this.defaultExclusions) {\n"); >@@ -1855,6 +1846,15 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" private void scanPath(final String classPath) {\n"); >+ buf.append(" final String separator = System.getProperty(\"path.separator\"); //$NON-NLS-1$\n"); >+ buf.append(" this.fPathItems = new Vector(10);\n"); >+ buf.append(" final StringTokenizer st = new StringTokenizer(classPath, separator);\n"); >+ buf.append(" while (st.hasMoreTokens()) {\n"); >+ buf.append(" this.fPathItems.addElement(st.nextToken());\n"); >+ buf.append(" }\n"); >+ buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.runner.TestCaseClassLoader.java", buf.toString()); > buf= new StringBuffer(); >@@ -1898,13 +1898,8 @@ > buf.append(" * \n"); > buf.append(" */\n"); > buf.append("public class SimpleTest extends TestCase {\n"); >- buf.append(" protected int fValue1;\n"); >- buf.append(" protected int fValue2;\n"); >- buf.append("\n"); >- buf.append(" @Override\n"); >- buf.append(" protected void setUp() {\n"); >- buf.append(" this.fValue1 = 2;\n"); >- buf.append(" this.fValue2 = 3;\n"); >+ buf.append(" public static void main(final String[] args) {\n"); >+ buf.append(" junit.textui.TestRunner.run(SimpleTest.suite());\n"); > buf.append(" }\n"); > buf.append(" public static Test suite() {\n"); > buf.append("\n"); >@@ -1923,6 +1918,14 @@ > buf.append(" */\n"); > buf.append(" return new TestSuite(SimpleTest.class);\n"); > buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" protected int fValue1;\n"); >+ buf.append(" protected int fValue2;\n"); >+ buf.append(" @Override\n"); >+ buf.append(" protected void setUp() {\n"); >+ buf.append(" this.fValue1 = 2;\n"); >+ buf.append(" this.fValue2 = 3;\n"); >+ buf.append(" }\n"); > buf.append(" public void testAdd() {\n"); > buf.append(" final double result = this.fValue1 + this.fValue2;\n"); > buf.append(" // forced failure result == 5\n"); >@@ -1939,9 +1942,6 @@ > buf.append(" Assert.assertEquals(\"Size\", 12, 13); //$NON-NLS-1$\n"); > buf.append(" Assert.assertEquals(\"Capacity\", 12.0, 11.99, 0.0); //$NON-NLS-1$\n"); > buf.append(" }\n"); >- buf.append(" public static void main(final String[] args) {\n"); >- buf.append(" junit.textui.TestRunner.run(SimpleTest.suite());\n"); >- buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.samples.SimpleTest.java", buf.toString()); > buf= new StringBuffer(); >@@ -1951,13 +1951,13 @@ > buf.append(" * This class defines the current version of JUnit\n"); > buf.append(" */\n"); > buf.append("public class Version {\n"); >- buf.append(" private Version() {\n"); >- buf.append(" // don't instantiate\n"); >- buf.append(" }\n"); >- buf.append("\n"); > buf.append(" public static String id() {\n"); > buf.append(" return \"3.8.1\"; //$NON-NLS-1$\n"); > buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" private Version() {\n"); >+ buf.append(" // don't instantiate\n"); >+ buf.append(" }\n"); > buf.append("}\n"); > buf.append(""); > fExpectedChangesAllTests.put("junit.runner.Version.java", buf.toString()); >@@ -2059,23 +2059,86 @@ > buf.append(" */\n"); > buf.append("public class TestSuite implements Test {\n"); > buf.append("\n"); >- buf.append(" private final Vector fTests = new Vector(10);\n"); >- buf.append(" private String fName;\n"); >+ buf.append(" /**\n"); >+ buf.append(" * ...as the moon sets over the early morning Merlin, Oregon mountains, our\n"); >+ buf.append(" * intrepid adventurers type...\n"); >+ buf.append(" */\n"); >+ buf.append(" static public Test createTest(final Class theClass, final String name) {\n"); >+ buf.append(" Constructor constructor;\n"); >+ buf.append(" try {\n"); >+ buf.append(" constructor = TestSuite.getTestConstructor(theClass);\n"); >+ buf.append(" } catch (final NoSuchMethodException e) {\n"); >+ buf.append(" return TestSuite\n"); >+ buf.append(" .warning(\"Class \" + theClass.getName() + \" has no public constructor TestCase(String name) or TestCase()\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >+ buf.append(" }\n"); >+ buf.append(" Object test;\n"); >+ buf.append(" try {\n"); >+ buf.append(" if (constructor.getParameterTypes().length == 0) {\n"); >+ buf.append(" test = constructor.newInstance(new Object[0]);\n"); >+ buf.append(" if (test instanceof TestCase) {\n"); >+ buf.append(" ((TestCase) test).setName(name);\n"); >+ buf.append(" }\n"); >+ buf.append(" } else {\n"); >+ buf.append(" test = constructor.newInstance(new Object[]{name});\n"); >+ buf.append(" }\n"); >+ buf.append(" } catch (final InstantiationException e) {\n"); >+ buf.append(" return (TestSuite\n"); >+ buf.append(" .warning(\"Cannot instantiate test case: \" + name + \" (\" + TestSuite.exceptionToString(e) + \")\")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); >+ buf.append(" } catch (final InvocationTargetException e) {\n"); >+ buf.append(" return (TestSuite\n"); >+ buf.append(" .warning(\"Exception in constructor: \" + name + \" (\" + TestSuite.exceptionToString(e.getTargetException()) + \")\")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); >+ buf.append(" } catch (final IllegalAccessException e) {\n"); >+ buf.append(" return (TestSuite\n"); >+ buf.append(" .warning(\"Cannot access test case: \" + name + \" (\" + TestSuite.exceptionToString(e) + \")\")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); >+ buf.append(" }\n"); >+ buf.append(" return (Test) test;\n"); >+ buf.append(" }\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Converts the stack trace into a string\n"); >+ buf.append(" */\n"); >+ buf.append(" private static String exceptionToString(final Throwable t) {\n"); >+ buf.append(" final StringWriter stringWriter = new StringWriter();\n"); >+ buf.append(" final PrintWriter writer = new PrintWriter(stringWriter);\n"); >+ buf.append(" t.printStackTrace(writer);\n"); >+ buf.append(" return stringWriter.toString();\n"); >+ buf.append("\n"); >+ buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >- buf.append(" * Constructs an empty TestSuite.\n"); >+ buf.append(" * Gets a constructor which takes a single String as its argument or a no\n"); >+ buf.append(" * arg constructor.\n"); > buf.append(" */\n"); >- buf.append(" public TestSuite() {\n"); >+ buf.append(" public static Constructor getTestConstructor(final Class theClass)\n"); >+ buf.append(" throws NoSuchMethodException {\n"); >+ buf.append(" final Class[] args = {String.class};\n"); >+ buf.append(" try {\n"); >+ buf.append(" return theClass.getConstructor(args);\n"); >+ buf.append(" } catch (final NoSuchMethodException e) {\n"); >+ buf.append(" // fall through\n"); >+ buf.append(" }\n"); >+ buf.append(" return theClass.getConstructor(new Class[0]);\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >- buf.append(" * Constructs a TestSuite from the given class with the given name.\n"); >- buf.append(" * \n"); >- buf.append(" * @see TestSuite#TestSuite(Class)\n"); >+ buf.append(" * Returns a test which will fail and log a warning message.\n"); > buf.append(" */\n"); >- buf.append(" public TestSuite(final Class theClass, final String name) {\n"); >- buf.append(" this(theClass);\n"); >- buf.append(" this.setName(name);\n"); >+ buf.append(" private static Test warning(final String message) {\n"); >+ buf.append(" return new TestCase(\"warning\") { //$NON-NLS-1$\n"); >+ buf.append(" @Override\n"); >+ buf.append(" protected void runTest() {\n"); >+ buf.append(" Assert.fail(message);\n"); >+ buf.append(" }\n"); >+ buf.append(" };\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" private String fName;\n"); >+ buf.append("\n"); >+ buf.append(" private final Vector fTests = new Vector(10);\n"); >+ buf.append("\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Constructs an empty TestSuite.\n"); >+ buf.append(" */\n"); >+ buf.append(" public TestSuite() {\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >@@ -2117,6 +2180,16 @@ > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >+ buf.append(" * Constructs a TestSuite from the given class with the given name.\n"); >+ buf.append(" * \n"); >+ buf.append(" * @see TestSuite#TestSuite(Class)\n"); >+ buf.append(" */\n"); >+ buf.append(" public TestSuite(final Class theClass, final String name) {\n"); >+ buf.append(" this(theClass);\n"); >+ buf.append(" this.setName(name);\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" /**\n"); > buf.append(" * Constructs an empty TestSuite.\n"); > buf.append(" */\n"); > buf.append(" public TestSuite(final String name) {\n"); >@@ -2130,13 +2203,6 @@ > buf.append(" this.fTests.addElement(test);\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Adds the tests from the given class to the suite\n"); >- buf.append(" */\n"); >- buf.append(" public void addTestSuite(final Class testClass) {\n"); >- buf.append(" this.addTest(new TestSuite(testClass));\n"); >- buf.append(" }\n"); >- buf.append("\n"); > buf.append(" private void addTestMethod(final Method m, final Vector names,\n"); > buf.append(" final Class theClass) {\n"); > buf.append(" final String name = m.getName();\n"); >@@ -2155,49 +2221,10 @@ > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >- buf.append(" * ...as the moon sets over the early morning Merlin, Oregon mountains, our\n"); >- buf.append(" * intrepid adventurers type...\n"); >- buf.append(" */\n"); >- buf.append(" static public Test createTest(final Class theClass, final String name) {\n"); >- buf.append(" Constructor constructor;\n"); >- buf.append(" try {\n"); >- buf.append(" constructor = TestSuite.getTestConstructor(theClass);\n"); >- buf.append(" } catch (final NoSuchMethodException e) {\n"); >- buf.append(" return TestSuite\n"); >- buf.append(" .warning(\"Class \" + theClass.getName() + \" has no public constructor TestCase(String name) or TestCase()\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >- buf.append(" }\n"); >- buf.append(" Object test;\n"); >- buf.append(" try {\n"); >- buf.append(" if (constructor.getParameterTypes().length == 0) {\n"); >- buf.append(" test = constructor.newInstance(new Object[0]);\n"); >- buf.append(" if (test instanceof TestCase) {\n"); >- buf.append(" ((TestCase) test).setName(name);\n"); >- buf.append(" }\n"); >- buf.append(" } else {\n"); >- buf.append(" test = constructor.newInstance(new Object[]{name});\n"); >- buf.append(" }\n"); >- buf.append(" } catch (final InstantiationException e) {\n"); >- buf.append(" return (TestSuite\n"); >- buf.append(" .warning(\"Cannot instantiate test case: \" + name + \" (\" + TestSuite.exceptionToString(e) + \")\")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); >- buf.append(" } catch (final InvocationTargetException e) {\n"); >- buf.append(" return (TestSuite\n"); >- buf.append(" .warning(\"Exception in constructor: \" + name + \" (\" + TestSuite.exceptionToString(e.getTargetException()) + \")\")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); >- buf.append(" } catch (final IllegalAccessException e) {\n"); >- buf.append(" return (TestSuite\n"); >- buf.append(" .warning(\"Cannot access test case: \" + name + \" (\" + TestSuite.exceptionToString(e) + \")\")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); >- buf.append(" }\n"); >- buf.append(" return (Test) test;\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Converts the stack trace into a string\n"); >+ buf.append(" * Adds the tests from the given class to the suite\n"); > buf.append(" */\n"); >- buf.append(" private static String exceptionToString(final Throwable t) {\n"); >- buf.append(" final StringWriter stringWriter = new StringWriter();\n"); >- buf.append(" final PrintWriter writer = new PrintWriter(stringWriter);\n"); >- buf.append(" t.printStackTrace(writer);\n"); >- buf.append(" return stringWriter.toString();\n"); >- buf.append("\n"); >+ buf.append(" public void addTestSuite(final Class testClass) {\n"); >+ buf.append(" this.addTest(new TestSuite(testClass));\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >@@ -2213,18 +2240,11 @@ > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >- buf.append(" * Gets a constructor which takes a single String as its argument or a no\n"); >- buf.append(" * arg constructor.\n"); >+ buf.append(" * Returns the name of the suite. Not all test suites have a name and this\n"); >+ buf.append(" * method can return null.\n"); > buf.append(" */\n"); >- buf.append(" public static Constructor getTestConstructor(final Class theClass)\n"); >- buf.append(" throws NoSuchMethodException {\n"); >- buf.append(" final Class[] args = {String.class};\n"); >- buf.append(" try {\n"); >- buf.append(" return theClass.getConstructor(args);\n"); >- buf.append(" } catch (final NoSuchMethodException e) {\n"); >- buf.append(" // fall through\n"); >- buf.append(" }\n"); >- buf.append(" return theClass.getConstructor(new Class[0]);\n"); >+ buf.append(" public String getName() {\n"); >+ buf.append(" return this.fName;\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" private boolean isPublicTestMethod(final Method m) {\n"); >@@ -2257,6 +2277,16 @@ > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >+ buf.append(" * Sets the name of the suite.\n"); >+ buf.append(" * \n"); >+ buf.append(" * @param name\n"); >+ buf.append(" * The name to set\n"); >+ buf.append(" */\n"); >+ buf.append(" public void setName(final String name) {\n"); >+ buf.append(" this.fName = name;\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" /**\n"); > buf.append(" * Returns the test at the given index\n"); > buf.append(" */\n"); > buf.append(" public Test testAt(final int index) {\n"); >@@ -2286,36 +2316,6 @@ > buf.append(" }\n"); > buf.append(" return super.toString();\n"); > buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Sets the name of the suite.\n"); >- buf.append(" * \n"); >- buf.append(" * @param name\n"); >- buf.append(" * The name to set\n"); >- buf.append(" */\n"); >- buf.append(" public void setName(final String name) {\n"); >- buf.append(" this.fName = name;\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Returns the name of the suite. Not all test suites have a name and this\n"); >- buf.append(" * method can return null.\n"); >- buf.append(" */\n"); >- buf.append(" public String getName() {\n"); >- buf.append(" return this.fName;\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Returns a test which will fail and log a warning message.\n"); >- buf.append(" */\n"); >- buf.append(" private static Test warning(final String message) {\n"); >- buf.append(" return new TestCase(\"warning\") { //$NON-NLS-1$\n"); >- buf.append(" @Override\n"); >- buf.append(" protected void runTest() {\n"); >- buf.append(" Assert.fail(message);\n"); >- buf.append(" }\n"); >- buf.append(" };\n"); >- buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.framework.TestSuite.java", buf.toString()); > buf= new StringBuffer(); >@@ -2378,66 +2378,51 @@ > buf.append("\n"); > buf.append("public class Assert {\n"); > buf.append(" /**\n"); >- buf.append(" * Protect constructor since it is a static only class\n"); >+ buf.append(" * Asserts that two booleans are equal.\n"); > buf.append(" */\n"); >- buf.append(" protected Assert() {\n"); >+ buf.append(" static public void assertEquals(final boolean expected, final boolean actual) {\n"); >+ buf.append(" Assert.assertEquals(null, expected, actual);\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that a condition is true. If it isn't it throws an\n"); >- buf.append(" * AssertionFailedError with the given message.\n"); >- buf.append(" */\n"); >- buf.append(" static public void assertTrue(final String message, boolean condition) {\n"); >- buf.append(" if (!condition) {\n"); >- buf.append(" Assert.fail(message);\n"); >- buf.append(" }\n"); >- buf.append(" }\n"); >- buf.append(" /**\n"); >- buf.append(" * Asserts that a condition is true. If it isn't it throws an\n"); >- buf.append(" * AssertionFailedError.\n"); >+ buf.append(" * Asserts that two bytes are equal.\n"); > buf.append(" */\n"); >- buf.append(" static public void assertTrue(final boolean condition) {\n"); >- buf.append(" Assert.assertTrue(null, condition);\n"); >+ buf.append(" static public void assertEquals(final byte expected, final byte actual) {\n"); >+ buf.append(" Assert.assertEquals(null, expected, actual);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that a condition is false. If it isn't it throws an\n"); >- buf.append(" * AssertionFailedError with the given message.\n"); >+ buf.append(" * Asserts that two chars are equal.\n"); > buf.append(" */\n"); >- buf.append(" static public void assertFalse(final String message, boolean condition) {\n"); >- buf.append(" Assert.assertTrue(message, !condition);\n"); >+ buf.append(" static public void assertEquals(final char expected, final char actual) {\n"); >+ buf.append(" Assert.assertEquals(null, expected, actual);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that a condition is false. If it isn't it throws an\n"); >- buf.append(" * AssertionFailedError.\n"); >+ buf.append(" * Asserts that two doubles are equal concerning a delta. If the expected\n"); >+ buf.append(" * value is infinity then the delta value is ignored.\n"); > buf.append(" */\n"); >- buf.append(" static public void assertFalse(final boolean condition) {\n"); >- buf.append(" Assert.assertFalse(null, condition);\n"); >+ buf.append(" static public void assertEquals(final double expected, final double actual,\n"); >+ buf.append(" final double delta) {\n"); >+ buf.append(" Assert.assertEquals(null, expected, actual, delta);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Fails a test with the given message.\n"); >+ buf.append(" * Asserts that two floats are equal concerning a delta. If the expected\n"); >+ buf.append(" * value is infinity then the delta value is ignored.\n"); > buf.append(" */\n"); >- buf.append(" static public void fail(final String message) {\n"); >- buf.append(" throw new AssertionFailedError(message);\n"); >+ buf.append(" static public void assertEquals(final float expected, final float actual,\n"); >+ buf.append(" final float delta) {\n"); >+ buf.append(" Assert.assertEquals(null, expected, actual, delta);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Fails a test with no message.\n"); >+ buf.append(" * Asserts that two ints are equal.\n"); > buf.append(" */\n"); >- buf.append(" static public void fail() {\n"); >- buf.append(" Assert.fail(null);\n"); >+ buf.append(" static public void assertEquals(final int expected, final int actual) {\n"); >+ buf.append(" Assert.assertEquals(null, expected, actual);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that two objects are equal. If they are not an\n"); >- buf.append(" * AssertionFailedError is thrown with the given message.\n"); >+ buf.append(" * Asserts that two longs are equal.\n"); > buf.append(" */\n"); >- buf.append(" static public void assertEquals(final String message,\n"); >- buf.append(" final Object expected, final Object actual) {\n"); >- buf.append(" if ((expected == null) && (actual == null)) {\n"); >- buf.append(" return;\n"); >- buf.append(" }\n"); >- buf.append(" if ((expected != null) && expected.equals(actual)) {\n"); >- buf.append(" return;\n"); >- buf.append(" }\n"); >- buf.append(" Assert.failNotEquals(message, expected, actual);\n"); >+ buf.append(" static public void assertEquals(final long expected, final long actual) {\n"); >+ buf.append(" Assert.assertEquals(null, expected, actual);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); > buf.append(" * Asserts that two objects are equal. If they are not an\n"); >@@ -2447,23 +2432,37 @@ > buf.append(" Assert.assertEquals(null, expected, actual);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that two Strings are equal.\n"); >+ buf.append(" * Asserts that two shorts are equal.\n"); >+ buf.append(" */\n"); >+ buf.append(" static public void assertEquals(final short expected, final short actual) {\n"); >+ buf.append(" Assert.assertEquals(null, expected, actual);\n"); >+ buf.append(" }\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Asserts that two booleans are equal. If they are not an\n"); >+ buf.append(" * AssertionFailedError is thrown with the given message.\n"); > buf.append(" */\n"); > buf.append(" static public void assertEquals(final String message,\n"); >- buf.append(" final String expected, final String actual) {\n"); >- buf.append(" if ((expected == null) && (actual == null)) {\n"); >- buf.append(" return;\n"); >- buf.append(" }\n"); >- buf.append(" if ((expected != null) && expected.equals(actual)) {\n"); >- buf.append(" return;\n"); >- buf.append(" }\n"); >- buf.append(" throw new ComparisonFailure(message, expected, actual);\n"); >+ buf.append(" final boolean expected, final boolean actual) {\n"); >+ buf.append(" Assert\n"); >+ buf.append(" .assertEquals(message, new Boolean(expected), new Boolean(\n"); >+ buf.append(" actual));\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that two Strings are equal.\n"); >+ buf.append(" * Asserts that two bytes are equal. If they are not an AssertionFailedError\n"); >+ buf.append(" * is thrown with the given message.\n"); > buf.append(" */\n"); >- buf.append(" static public void assertEquals(final String expected, final String actual) {\n"); >- buf.append(" Assert.assertEquals(null, expected, actual);\n"); >+ buf.append(" static public void assertEquals(final String message, final byte expected,\n"); >+ buf.append(" final byte actual) {\n"); >+ buf.append(" Assert.assertEquals(message, new Byte(expected), new Byte(actual));\n"); >+ buf.append(" }\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Asserts that two chars are equal. If they are not an AssertionFailedError\n"); >+ buf.append(" * is thrown with the given message.\n"); >+ buf.append(" */\n"); >+ buf.append(" static public void assertEquals(final String message, final char expected,\n"); >+ buf.append(" final char actual) {\n"); >+ buf.append(" Assert.assertEquals(message, new Character(expected), new Character(\n"); >+ buf.append(" actual));\n"); > buf.append(" }\n"); > buf.append(" /**\n"); > buf.append(" * Asserts that two doubles are equal concerning a delta. If they are not an\n"); >@@ -2486,14 +2485,6 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that two doubles are equal concerning a delta. If the expected\n"); >- buf.append(" * value is infinity then the delta value is ignored.\n"); >- buf.append(" */\n"); >- buf.append(" static public void assertEquals(final double expected, final double actual,\n"); >- buf.append(" final double delta) {\n"); >- buf.append(" Assert.assertEquals(null, expected, actual, delta);\n"); >- buf.append(" }\n"); >- buf.append(" /**\n"); > buf.append(" * Asserts that two floats are equal concerning a delta. If they are not an\n"); > buf.append(" * AssertionFailedError is thrown with the given message. If the expected\n"); > buf.append(" * value is infinity then the delta value is ignored.\n"); >@@ -2514,12 +2505,14 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that two floats are equal concerning a delta. If the expected\n"); >- buf.append(" * value is infinity then the delta value is ignored.\n"); >+ buf.append(" * Asserts that two ints are equal. If they are not an AssertionFailedError\n"); >+ buf.append(" * is thrown with the given message.\n"); > buf.append(" */\n"); >- buf.append(" static public void assertEquals(final float expected, final float actual,\n"); >- buf.append(" final float delta) {\n"); >- buf.append(" Assert.assertEquals(null, expected, actual, delta);\n"); >+ buf.append(" static public void assertEquals(final String message, final int expected,\n"); >+ buf.append(" final int actual) {\n"); >+ buf.append(" Assert\n"); >+ buf.append(" .assertEquals(message, new Integer(expected), new Integer(\n"); >+ buf.append(" actual));\n"); > buf.append(" }\n"); > buf.append(" /**\n"); > buf.append(" * Asserts that two longs are equal. If they are not an AssertionFailedError\n"); >@@ -2530,55 +2523,18 @@ > buf.append(" Assert.assertEquals(message, new Long(expected), new Long(actual));\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that two longs are equal.\n"); >- buf.append(" */\n"); >- buf.append(" static public void assertEquals(final long expected, final long actual) {\n"); >- buf.append(" Assert.assertEquals(null, expected, actual);\n"); >- buf.append(" }\n"); >- buf.append(" /**\n"); >- buf.append(" * Asserts that two booleans are equal. If they are not an\n"); >+ buf.append(" * Asserts that two objects are equal. If they are not an\n"); > buf.append(" * AssertionFailedError is thrown with the given message.\n"); > buf.append(" */\n"); > buf.append(" static public void assertEquals(final String message,\n"); >- buf.append(" final boolean expected, final boolean actual) {\n"); >- buf.append(" Assert\n"); >- buf.append(" .assertEquals(message, new Boolean(expected), new Boolean(\n"); >- buf.append(" actual));\n"); >- buf.append(" }\n"); >- buf.append(" /**\n"); >- buf.append(" * Asserts that two booleans are equal.\n"); >- buf.append(" */\n"); >- buf.append(" static public void assertEquals(final boolean expected, final boolean actual) {\n"); >- buf.append(" Assert.assertEquals(null, expected, actual);\n"); >- buf.append(" }\n"); >- buf.append(" /**\n"); >- buf.append(" * Asserts that two bytes are equal. If they are not an AssertionFailedError\n"); >- buf.append(" * is thrown with the given message.\n"); >- buf.append(" */\n"); >- buf.append(" static public void assertEquals(final String message, final byte expected,\n"); >- buf.append(" final byte actual) {\n"); >- buf.append(" Assert.assertEquals(message, new Byte(expected), new Byte(actual));\n"); >- buf.append(" }\n"); >- buf.append(" /**\n"); >- buf.append(" * Asserts that two bytes are equal.\n"); >- buf.append(" */\n"); >- buf.append(" static public void assertEquals(final byte expected, final byte actual) {\n"); >- buf.append(" Assert.assertEquals(null, expected, actual);\n"); >- buf.append(" }\n"); >- buf.append(" /**\n"); >- buf.append(" * Asserts that two chars are equal. If they are not an AssertionFailedError\n"); >- buf.append(" * is thrown with the given message.\n"); >- buf.append(" */\n"); >- buf.append(" static public void assertEquals(final String message, final char expected,\n"); >- buf.append(" final char actual) {\n"); >- buf.append(" Assert.assertEquals(message, new Character(expected), new Character(\n"); >- buf.append(" actual));\n"); >- buf.append(" }\n"); >- buf.append(" /**\n"); >- buf.append(" * Asserts that two chars are equal.\n"); >- buf.append(" */\n"); >- buf.append(" static public void assertEquals(final char expected, final char actual) {\n"); >- buf.append(" Assert.assertEquals(null, expected, actual);\n"); >+ buf.append(" final Object expected, final Object actual) {\n"); >+ buf.append(" if ((expected == null) && (actual == null)) {\n"); >+ buf.append(" return;\n"); >+ buf.append(" }\n"); >+ buf.append(" if ((expected != null) && expected.equals(actual)) {\n"); >+ buf.append(" return;\n"); >+ buf.append(" }\n"); >+ buf.append(" Assert.failNotEquals(message, expected, actual);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); > buf.append(" * Asserts that two shorts are equal. If they are not an\n"); >@@ -2589,26 +2545,37 @@ > buf.append(" Assert.assertEquals(message, new Short(expected), new Short(actual));\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that two shorts are equal.\n"); >+ buf.append(" * Asserts that two Strings are equal.\n"); > buf.append(" */\n"); >- buf.append(" static public void assertEquals(final short expected, final short actual) {\n"); >+ buf.append(" static public void assertEquals(final String expected, final String actual) {\n"); > buf.append(" Assert.assertEquals(null, expected, actual);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that two ints are equal. If they are not an AssertionFailedError\n"); >- buf.append(" * is thrown with the given message.\n"); >+ buf.append(" * Asserts that two Strings are equal.\n"); > buf.append(" */\n"); >- buf.append(" static public void assertEquals(final String message, final int expected,\n"); >- buf.append(" final int actual) {\n"); >- buf.append(" Assert\n"); >- buf.append(" .assertEquals(message, new Integer(expected), new Integer(\n"); >- buf.append(" actual));\n"); >+ buf.append(" static public void assertEquals(final String message,\n"); >+ buf.append(" final String expected, final String actual) {\n"); >+ buf.append(" if ((expected == null) && (actual == null)) {\n"); >+ buf.append(" return;\n"); >+ buf.append(" }\n"); >+ buf.append(" if ((expected != null) && expected.equals(actual)) {\n"); >+ buf.append(" return;\n"); >+ buf.append(" }\n"); >+ buf.append(" throw new ComparisonFailure(message, expected, actual);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that two ints are equal.\n"); >+ buf.append(" * Asserts that a condition is false. If it isn't it throws an\n"); >+ buf.append(" * AssertionFailedError.\n"); > buf.append(" */\n"); >- buf.append(" static public void assertEquals(final int expected, final int actual) {\n"); >- buf.append(" Assert.assertEquals(null, expected, actual);\n"); >+ buf.append(" static public void assertFalse(final boolean condition) {\n"); >+ buf.append(" Assert.assertFalse(null, condition);\n"); >+ buf.append(" }\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Asserts that a condition is false. If it isn't it throws an\n"); >+ buf.append(" * AssertionFailedError with the given message.\n"); >+ buf.append(" */\n"); >+ buf.append(" static public void assertFalse(final String message, boolean condition) {\n"); >+ buf.append(" Assert.assertTrue(message, !condition);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); > buf.append(" * Asserts that an object isn't null.\n"); >@@ -2624,6 +2591,23 @@ > buf.append(" Assert.assertTrue(message, object != null);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >+ buf.append(" * Asserts that two objects refer to the same object. If they are not the\n"); >+ buf.append(" * same an AssertionFailedError is thrown.\n"); >+ buf.append(" */\n"); >+ buf.append(" static public void assertNotSame(final Object expected, final Object actual) {\n"); >+ buf.append(" Assert.assertNotSame(null, expected, actual);\n"); >+ buf.append(" }\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Asserts that two objects refer to the same object. If they are not an\n"); >+ buf.append(" * AssertionFailedError is thrown with the given message.\n"); >+ buf.append(" */\n"); >+ buf.append(" static public void assertNotSame(final String message,\n"); >+ buf.append(" final Object expected, final Object actual) {\n"); >+ buf.append(" if (expected == actual) {\n"); >+ buf.append(" Assert.failSame(message);\n"); >+ buf.append(" }\n"); >+ buf.append(" }\n"); >+ buf.append(" /**\n"); > buf.append(" * Asserts that an object is null.\n"); > buf.append(" */\n"); > buf.append(" static public void assertNull(final Object object) {\n"); >@@ -2637,6 +2621,13 @@ > buf.append(" Assert.assertTrue(message, object == null);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >+ buf.append(" * Asserts that two objects refer to the same object. If they are not the\n"); >+ buf.append(" * same an AssertionFailedError is thrown.\n"); >+ buf.append(" */\n"); >+ buf.append(" static public void assertSame(final Object expected, final Object actual) {\n"); >+ buf.append(" Assert.assertSame(null, expected, actual);\n"); >+ buf.append(" }\n"); >+ buf.append(" /**\n"); > buf.append(" * Asserts that two objects refer to the same object. If they are not an\n"); > buf.append(" * AssertionFailedError is thrown with the given message.\n"); > buf.append(" */\n"); >@@ -2648,36 +2639,36 @@ > buf.append(" Assert.failNotSame(message, expected, actual);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that two objects refer to the same object. If they are not the\n"); >- buf.append(" * same an AssertionFailedError is thrown.\n"); >+ buf.append(" * Asserts that a condition is true. If it isn't it throws an\n"); >+ buf.append(" * AssertionFailedError.\n"); > buf.append(" */\n"); >- buf.append(" static public void assertSame(final Object expected, final Object actual) {\n"); >- buf.append(" Assert.assertSame(null, expected, actual);\n"); >+ buf.append(" static public void assertTrue(final boolean condition) {\n"); >+ buf.append(" Assert.assertTrue(null, condition);\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that two objects refer to the same object. If they are not an\n"); >- buf.append(" * AssertionFailedError is thrown with the given message.\n"); >+ buf.append(" * Asserts that a condition is true. If it isn't it throws an\n"); >+ buf.append(" * AssertionFailedError with the given message.\n"); > buf.append(" */\n"); >- buf.append(" static public void assertNotSame(final String message,\n"); >- buf.append(" final Object expected, final Object actual) {\n"); >- buf.append(" if (expected == actual) {\n"); >- buf.append(" Assert.failSame(message);\n"); >+ buf.append(" static public void assertTrue(final String message, boolean condition) {\n"); >+ buf.append(" if (!condition) {\n"); >+ buf.append(" Assert.fail(message);\n"); > buf.append(" }\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >- buf.append(" * Asserts that two objects refer to the same object. If they are not the\n"); >- buf.append(" * same an AssertionFailedError is thrown.\n"); >+ buf.append(" * Fails a test with no message.\n"); > buf.append(" */\n"); >- buf.append(" static public void assertNotSame(final Object expected, final Object actual) {\n"); >- buf.append(" Assert.assertNotSame(null, expected, actual);\n"); >+ buf.append(" static public void fail() {\n"); >+ buf.append(" Assert.fail(null);\n"); > buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" static private void failSame(final String message) {\n"); >- buf.append(" String formatted = \"\"; //$NON-NLS-1$\n"); >- buf.append(" if (message != null) {\n"); >- buf.append(" formatted = message + \" \"; //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append(" Assert.fail(formatted + \"expected not same\"); //$NON-NLS-1$\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Fails a test with the given message.\n"); >+ buf.append(" */\n"); >+ buf.append(" static public void fail(final String message) {\n"); >+ buf.append(" throw new AssertionFailedError(message);\n"); >+ buf.append(" }\n"); >+ buf.append(" static private void failNotEquals(final String message,\n"); >+ buf.append(" final Object expected, final Object actual) {\n"); >+ buf.append(" Assert.fail(Assert.format(message, expected, actual));\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" static private void failNotSame(final String message,\n"); >@@ -2690,9 +2681,12 @@ > buf.append(" + \"expected same:<\" + expected + \"> was not:<\" + actual + \">\"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" static private void failNotEquals(final String message,\n"); >- buf.append(" final Object expected, final Object actual) {\n"); >- buf.append(" Assert.fail(Assert.format(message, expected, actual));\n"); >+ buf.append(" static private void failSame(final String message) {\n"); >+ buf.append(" String formatted = \"\"; //$NON-NLS-1$\n"); >+ buf.append(" if (message != null) {\n"); >+ buf.append(" formatted = message + \" \"; //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append(" Assert.fail(formatted + \"expected not same\"); //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" static String format(final String message, final Object expected,\n"); >@@ -2704,6 +2698,12 @@ > buf.append(" return formatted\n"); > buf.append(" + \"expected:<\" + expected + \"> but was:<\" + actual + \">\"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); > buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Protect constructor since it is a static only class\n"); >+ buf.append(" */\n"); >+ buf.append(" protected Assert() {\n"); >+ buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.framework.Assert.java", buf.toString()); > buf= new StringBuffer(); >@@ -2729,10 +2729,15 @@ > buf.append(" public ClassPathTestCollector() {\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public Enumeration collectTests() {\n"); >- buf.append(" final String classPath = System.getProperty(\"java.class.path\"); //$NON-NLS-1$\n"); >- buf.append(" final Hashtable result = this.collectFilesInPath(classPath);\n"); >- buf.append(" return result.elements();\n"); >+ buf.append(" protected String classNameFromFile(final String classFileName) {\n"); >+ buf.append(" // convert /a/b.class to a.b\n"); >+ buf.append(" final String s = classFileName.substring(0, classFileName.length()\n"); >+ buf.append(" - ClassPathTestCollector.SUFFIX_LENGTH);\n"); >+ buf.append(" final String s2 = s.replace(File.separatorChar, '.');\n"); >+ buf.append(" if (s2.startsWith(\".\")) {\n"); >+ buf.append(" return s2.substring(1);\n"); >+ buf.append(" }\n"); >+ buf.append(" return s2;\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" public Hashtable collectFilesInPath(final String classPath) {\n"); >@@ -2750,6 +2755,12 @@ > buf.append(" return result;\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" public Enumeration collectTests() {\n"); >+ buf.append(" final String classPath = System.getProperty(\"java.class.path\"); //$NON-NLS-1$\n"); >+ buf.append(" final Hashtable result = this.collectFilesInPath(classPath);\n"); >+ buf.append(" return result.elements();\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" void gatherFiles(final File classRoot, final String classFileName,\n"); > buf.append(" final Hashtable result) {\n"); > buf.append(" final File thisRoot = new File(classRoot, classFileName);\n"); >@@ -2769,6 +2780,12 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" protected boolean isTestClass(final String classFileName) {\n"); >+ buf.append(" return classFileName.endsWith(\".class\") && //$NON-NLS-1$\n"); >+ buf.append(" (classFileName.indexOf('$') < 0)\n"); >+ buf.append(" && (classFileName.indexOf(\"Test\") > 0); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" Vector splitClassPath(final String classPath) {\n"); > buf.append(" final Vector result = new Vector();\n"); > buf.append(" final String separator = System.getProperty(\"path.separator\"); //$NON-NLS-1$\n"); >@@ -2779,23 +2796,6 @@ > buf.append(" }\n"); > buf.append(" return result;\n"); > buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" protected boolean isTestClass(final String classFileName) {\n"); >- buf.append(" return classFileName.endsWith(\".class\") && //$NON-NLS-1$\n"); >- buf.append(" (classFileName.indexOf('$') < 0)\n"); >- buf.append(" && (classFileName.indexOf(\"Test\") > 0); //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" protected String classNameFromFile(final String classFileName) {\n"); >- buf.append(" // convert /a/b.class to a.b\n"); >- buf.append(" final String s = classFileName.substring(0, classFileName.length()\n"); >- buf.append(" - ClassPathTestCollector.SUFFIX_LENGTH);\n"); >- buf.append(" final String s2 = s.replace(File.separatorChar, '.');\n"); >- buf.append(" if (s2.startsWith(\".\")) {\n"); >- buf.append(" return s2.substring(1);\n"); >- buf.append(" }\n"); >- buf.append(" return s2;\n"); >- buf.append(" }\n"); > buf.append("}\n"); > buf.append(""); > fExpectedChangesAllTests.put("junit.runner.ClassPathTestCollector.java", buf.toString()); >@@ -2846,13 +2846,12 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testActiveTest() {\n"); >- buf.append(" final Test test = this.createActiveTestSuite();\n"); >- buf.append(" final TestResult result = new TestResult();\n"); >- buf.append(" test.run(result);\n"); >- buf.append(" Assert.assertEquals(100, result.runCount());\n"); >- buf.append(" Assert.assertEquals(0, result.failureCount());\n"); >- buf.append(" Assert.assertEquals(0, result.errorCount());\n"); >+ buf.append(" ActiveTestSuite createActiveTestSuite() {\n"); >+ buf.append(" final ActiveTestSuite suite = new ActiveTestSuite();\n"); >+ buf.append(" for (int i = 0; i < 100; i++) {\n"); >+ buf.append(" suite.addTest(new SuccessTest());\n"); >+ buf.append(" }\n"); >+ buf.append(" return suite;\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" public void testActiveRepeatedTest() {\n"); >@@ -2882,12 +2881,13 @@ > buf.append(" Assert.assertEquals(0, result.errorCount());\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" ActiveTestSuite createActiveTestSuite() {\n"); >- buf.append(" final ActiveTestSuite suite = new ActiveTestSuite();\n"); >- buf.append(" for (int i = 0; i < 100; i++) {\n"); >- buf.append(" suite.addTest(new SuccessTest());\n"); >- buf.append(" }\n"); >- buf.append(" return suite;\n"); >+ buf.append(" public void testActiveTest() {\n"); >+ buf.append(" final Test test = this.createActiveTestSuite();\n"); >+ buf.append(" final TestResult result = new TestResult();\n"); >+ buf.append(" test.run(result);\n"); >+ buf.append(" Assert.assertEquals(100, result.runCount());\n"); >+ buf.append(" Assert.assertEquals(0, result.failureCount());\n"); >+ buf.append(" Assert.assertEquals(0, result.errorCount());\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append("}"); >@@ -2931,6 +2931,10 @@ > buf.append(" */\n"); > buf.append(" public abstract IMoney addMoneyBag(MoneyBag s);\n"); > buf.append(" /**\n"); >+ buf.append(" * Append this to a MoneyBag m.\n"); >+ buf.append(" */\n"); >+ buf.append(" public abstract void appendTo(MoneyBag m);\n"); >+ buf.append(" /**\n"); > buf.append(" * Tests whether this money is zero\n"); > buf.append(" */\n"); > buf.append(" public abstract boolean isZero();\n"); >@@ -2946,10 +2950,6 @@ > buf.append(" * Subtracts a money from this money.\n"); > buf.append(" */\n"); > buf.append(" public abstract IMoney subtract(IMoney m);\n"); >- buf.append(" /**\n"); >- buf.append(" * Append this to a MoneyBag m.\n"); >- buf.append(" */\n"); >- buf.append(" public abstract void appendTo(MoneyBag m);\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.samples.money.IMoney.java", buf.toString()); > buf= new StringBuffer(); >@@ -2984,31 +2984,22 @@ > buf.append(" * the end.\n"); > buf.append(" */\n"); > buf.append("public class TestRunner extends BaseTestRunner {\n"); >- buf.append(" private ResultPrinter fPrinter;\n"); >- buf.append("\n"); >- buf.append(" public static final int SUCCESS_EXIT = 0;\n"); >- buf.append(" public static final int FAILURE_EXIT = 1;\n"); > buf.append(" public static final int EXCEPTION_EXIT = 2;\n"); > buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Constructs a TestRunner.\n"); >- buf.append(" */\n"); >- buf.append(" public TestRunner() {\n"); >- buf.append(" this(System.out);\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Constructs a TestRunner using the given stream for all the output\n"); >- buf.append(" */\n"); >- buf.append(" public TestRunner(final PrintStream writer) {\n"); >- buf.append(" this(new ResultPrinter(writer));\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Constructs a TestRunner using the given ResultPrinter all the output\n"); >- buf.append(" */\n"); >- buf.append(" public TestRunner(final ResultPrinter printer) {\n"); >- buf.append(" this.fPrinter = printer;\n"); >+ buf.append(" public static final int FAILURE_EXIT = 1;\n"); >+ buf.append(" public static final int SUCCESS_EXIT = 0;\n"); >+ buf.append(" public static void main(final String args[]) {\n"); >+ buf.append(" final TestRunner aTestRunner = new TestRunner();\n"); >+ buf.append(" try {\n"); >+ buf.append(" final TestResult r = aTestRunner.start(args);\n"); >+ buf.append(" if (!r.wasSuccessful()) {\n"); >+ buf.append(" System.exit(TestRunner.FAILURE_EXIT);\n"); >+ buf.append(" }\n"); >+ buf.append(" System.exit(TestRunner.SUCCESS_EXIT);\n"); >+ buf.append(" } catch (final Exception e) {\n"); >+ buf.append(" System.err.println(e.getMessage());\n"); >+ buf.append(" System.exit(TestRunner.EXCEPTION_EXIT);\n"); >+ buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >@@ -3041,24 +3032,27 @@ > buf.append(" aTestRunner.doRun(suite, true);\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" private ResultPrinter fPrinter;\n"); >+ buf.append("\n"); > buf.append(" /**\n"); >- buf.append(" * Always use the StandardTestSuiteLoader. Overridden from BaseTestRunner.\n"); >+ buf.append(" * Constructs a TestRunner.\n"); > buf.append(" */\n"); >- buf.append(" @Override\n"); >- buf.append(" public TestSuiteLoader getLoader() {\n"); >- buf.append(" return new StandardTestSuiteLoader();\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" @Override\n"); >- buf.append(" public void testFailed(final int status, final Test test, final Throwable t) {\n"); >+ buf.append(" public TestRunner() {\n"); >+ buf.append(" this(System.out);\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" @Override\n"); >- buf.append(" public void testStarted(final String testName) {\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Constructs a TestRunner using the given stream for all the output\n"); >+ buf.append(" */\n"); >+ buf.append(" public TestRunner(final PrintStream writer) {\n"); >+ buf.append(" this(new ResultPrinter(writer));\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" @Override\n"); >- buf.append(" public void testEnded(final String testName) {\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Constructs a TestRunner using the given ResultPrinter all the output\n"); >+ buf.append(" */\n"); >+ buf.append(" public TestRunner(final ResultPrinter printer) {\n"); >+ buf.append(" this.fPrinter = printer;\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >@@ -3085,6 +3079,14 @@ > buf.append(" return result;\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Always use the StandardTestSuiteLoader. Overridden from BaseTestRunner.\n"); >+ buf.append(" */\n"); >+ buf.append(" @Override\n"); >+ buf.append(" public TestSuiteLoader getLoader() {\n"); >+ buf.append(" return new StandardTestSuiteLoader();\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" protected void pause(boolean wait) {\n"); > buf.append(" if (!wait) {\n"); > buf.append(" return;\n"); >@@ -3096,18 +3098,14 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public static void main(final String args[]) {\n"); >- buf.append(" final TestRunner aTestRunner = new TestRunner();\n"); >- buf.append(" try {\n"); >- buf.append(" final TestResult r = aTestRunner.start(args);\n"); >- buf.append(" if (!r.wasSuccessful()) {\n"); >- buf.append(" System.exit(TestRunner.FAILURE_EXIT);\n"); >- buf.append(" }\n"); >- buf.append(" System.exit(TestRunner.SUCCESS_EXIT);\n"); >- buf.append(" } catch (final Exception e) {\n"); >- buf.append(" System.err.println(e.getMessage());\n"); >- buf.append(" System.exit(TestRunner.EXCEPTION_EXIT);\n"); >- buf.append(" }\n"); >+ buf.append(" @Override\n"); >+ buf.append(" protected void runFailed(final String message) {\n"); >+ buf.append(" System.err.println(message);\n"); >+ buf.append(" System.exit(TestRunner.FAILURE_EXIT);\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" public void setPrinter(final ResultPrinter printer) {\n"); >+ buf.append(" this.fPrinter = printer;\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >@@ -3145,13 +3143,15 @@ > buf.append(" }\n"); > buf.append("\n"); > buf.append(" @Override\n"); >- buf.append(" protected void runFailed(final String message) {\n"); >- buf.append(" System.err.println(message);\n"); >- buf.append(" System.exit(TestRunner.FAILURE_EXIT);\n"); >+ buf.append(" public void testEnded(final String testName) {\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void setPrinter(final ResultPrinter printer) {\n"); >- buf.append(" this.fPrinter = printer;\n"); >+ buf.append(" @Override\n"); >+ buf.append(" public void testFailed(final int status, final Test test, final Throwable t) {\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" @Override\n"); >+ buf.append(" public void testStarted(final String testName) {\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append("}"); >@@ -3168,14 +3168,14 @@ > buf.append("public class ClassLoaderTest extends Assert {\n"); > buf.append(" public ClassLoaderTest() {\n"); > buf.append(" }\n"); >- buf.append(" public void verify() {\n"); >- buf.append(" this.verifyApplicationClassLoadedByTestLoader();\n"); >- buf.append(" this.verifySystemClassNotLoadedByTestLoader();\n"); >- buf.append(" }\n"); > buf.append(" private boolean isTestCaseClassLoader(final ClassLoader cl) {\n"); > buf.append(" return ((cl != null) && cl.getClass().getName().equals(\n"); > buf.append(" junit.runner.TestCaseClassLoader.class.getName()));\n"); > buf.append(" }\n"); >+ buf.append(" public void verify() {\n"); >+ buf.append(" this.verifyApplicationClassLoadedByTestLoader();\n"); >+ buf.append(" this.verifySystemClassNotLoadedByTestLoader();\n"); >+ buf.append(" }\n"); > buf.append(" private void verifyApplicationClassLoadedByTestLoader() {\n"); > buf.append(" Assert.assertTrue(this.isTestCaseClassLoader(this.getClass()\n"); > buf.append(" .getClassLoader()));\n"); >@@ -3200,12 +3200,12 @@ > buf.append(" public static final int STATUS_ERROR = 1;\n"); > buf.append(" public static final int STATUS_FAILURE = 2;\n"); > buf.append("\n"); >- buf.append(" public void testRunStarted(String testSuiteName, int testCount);\n"); >+ buf.append(" public void testEnded(String testName);\n"); >+ buf.append(" public void testFailed(int status, String testName, String trace);\n"); > buf.append(" public void testRunEnded(long elapsedTime);\n"); >+ buf.append(" public void testRunStarted(String testSuiteName, int testCount);\n"); > buf.append(" public void testRunStopped(long elapsedTime);\n"); > buf.append(" public void testStarted(String testName);\n"); >- buf.append(" public void testEnded(String testName);\n"); >- buf.append(" public void testFailed(int status, String testName, String trace);\n"); > buf.append("}\n"); > buf.append(""); > fExpectedChangesAllTests.put("junit.runner.TestRunListener.java", buf.toString()); >@@ -3225,9 +3225,6 @@ > buf.append("import junit.textui.TestRunner;\n"); > buf.append("\n"); > buf.append("public class TextFeedbackTest extends TestCase {\n"); >- buf.append(" OutputStream output;\n"); >- buf.append(" TestRunner runner;\n"); >- buf.append("\n"); > buf.append(" class TestResultPrinter extends ResultPrinter {\n"); > buf.append(" TestResultPrinter(final PrintStream writer) {\n"); > buf.append(" super(writer);\n"); >@@ -3241,11 +3238,23 @@ > buf.append(" return \"0\"; //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append(" }\n"); >- buf.append("\n"); > buf.append(" public static void main(final String[] args) {\n"); > buf.append(" TestRunner.run(TextFeedbackTest.class);\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" OutputStream output;\n"); >+ buf.append("\n"); >+ buf.append(" TestRunner runner;\n"); >+ buf.append("\n"); >+ buf.append(" private String expected(final String[] lines) {\n"); >+ buf.append(" final OutputStream expected = new ByteArrayOutputStream();\n"); >+ buf.append(" final PrintStream expectedWriter = new PrintStream(expected);\n"); >+ buf.append(" for (final String element : lines) {\n"); >+ buf.append(" expectedWriter.println(element);\n"); >+ buf.append(" }\n"); >+ buf.append(" return expected.toString();\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" @Override\n"); > buf.append(" public void setUp() {\n"); > buf.append(" this.output = new ByteArrayOutputStream();\n"); >@@ -3260,31 +3269,23 @@ > buf.append(" Assert.assertEquals(expected.toString(), this.output.toString());\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testOneTest() {\n"); >- buf.append(" final String expected = this.expected(new String[]{\n"); >- buf.append(" \".\", \"Time: 0\", \"\", \"OK (1 test)\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$\n"); >- buf.append(" final TestSuite suite = new TestSuite();\n"); >- buf.append(" suite.addTest(new TestCase() {\n"); >+ buf.append(" public void testError() {\n"); >+ buf.append(" final String expected = this\n"); >+ buf.append(" .expected(new String[]{\n"); >+ buf.append(" \".E\", \"Time: 0\", \"Errors here\", \"\", \"FAILURES!!!\", \"Tests run: 1, Failures: 0, Errors: 1\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$\n"); >+ buf.append(" final ResultPrinter printer = new TestResultPrinter(new PrintStream(\n"); >+ buf.append(" this.output)) {\n"); > buf.append(" @Override\n"); >- buf.append(" public void runTest() {\n"); >+ buf.append(" public void printErrors(TestResult result) {\n"); >+ buf.append(" this.getWriter().println(\"Errors here\"); //$NON-NLS-1$\n"); > buf.append(" }\n"); >- buf.append(" });\n"); >- buf.append(" this.runner.doRun(suite);\n"); >- buf.append(" Assert.assertEquals(expected.toString(), this.output.toString());\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public void testTwoTests() {\n"); >- buf.append(" final String expected = this.expected(new String[]{\n"); >- buf.append(" \"..\", \"Time: 0\", \"\", \"OK (2 tests)\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$\n"); >+ buf.append(" };\n"); >+ buf.append(" this.runner.setPrinter(printer);\n"); > buf.append(" final TestSuite suite = new TestSuite();\n"); > buf.append(" suite.addTest(new TestCase() {\n"); > buf.append(" @Override\n"); >- buf.append(" public void runTest() {\n"); >- buf.append(" }\n"); >- buf.append(" });\n"); >- buf.append(" suite.addTest(new TestCase() {\n"); >- buf.append(" @Override\n"); >- buf.append(" public void runTest() {\n"); >+ buf.append(" public void runTest() throws Exception {\n"); >+ buf.append(" throw new Exception();\n"); > buf.append(" }\n"); > buf.append(" });\n"); > buf.append(" this.runner.doRun(suite);\n"); >@@ -3314,36 +3315,35 @@ > buf.append(" Assert.assertEquals(expected.toString(), this.output.toString());\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testError() {\n"); >- buf.append(" final String expected = this\n"); >- buf.append(" .expected(new String[]{\n"); >- buf.append(" \".E\", \"Time: 0\", \"Errors here\", \"\", \"FAILURES!!!\", \"Tests run: 1, Failures: 0, Errors: 1\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$\n"); >- buf.append(" final ResultPrinter printer = new TestResultPrinter(new PrintStream(\n"); >- buf.append(" this.output)) {\n"); >- buf.append(" @Override\n"); >- buf.append(" public void printErrors(TestResult result) {\n"); >- buf.append(" this.getWriter().println(\"Errors here\"); //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append(" };\n"); >- buf.append(" this.runner.setPrinter(printer);\n"); >+ buf.append(" public void testOneTest() {\n"); >+ buf.append(" final String expected = this.expected(new String[]{\n"); >+ buf.append(" \".\", \"Time: 0\", \"\", \"OK (1 test)\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$\n"); > buf.append(" final TestSuite suite = new TestSuite();\n"); > buf.append(" suite.addTest(new TestCase() {\n"); > buf.append(" @Override\n"); >- buf.append(" public void runTest() throws Exception {\n"); >- buf.append(" throw new Exception();\n"); >+ buf.append(" public void runTest() {\n"); > buf.append(" }\n"); > buf.append(" });\n"); > buf.append(" this.runner.doRun(suite);\n"); > buf.append(" Assert.assertEquals(expected.toString(), this.output.toString());\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" private String expected(final String[] lines) {\n"); >- buf.append(" final OutputStream expected = new ByteArrayOutputStream();\n"); >- buf.append(" final PrintStream expectedWriter = new PrintStream(expected);\n"); >- buf.append(" for (final String element : lines) {\n"); >- buf.append(" expectedWriter.println(element);\n"); >- buf.append(" }\n"); >- buf.append(" return expected.toString();\n"); >+ buf.append(" public void testTwoTests() {\n"); >+ buf.append(" final String expected = this.expected(new String[]{\n"); >+ buf.append(" \"..\", \"Time: 0\", \"\", \"OK (2 tests)\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$\n"); >+ buf.append(" final TestSuite suite = new TestSuite();\n"); >+ buf.append(" suite.addTest(new TestCase() {\n"); >+ buf.append(" @Override\n"); >+ buf.append(" public void runTest() {\n"); >+ buf.append(" }\n"); >+ buf.append(" });\n"); >+ buf.append(" suite.addTest(new TestCase() {\n"); >+ buf.append(" @Override\n"); >+ buf.append(" public void runTest() {\n"); >+ buf.append(" }\n"); >+ buf.append(" });\n"); >+ buf.append(" this.runner.doRun(suite);\n"); >+ buf.append(" Assert.assertEquals(expected.toString(), this.output.toString());\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append("}\n"); >@@ -3484,13 +3484,13 @@ > buf.append("import junit.framework.Assert;\n"); > buf.append("\n"); > buf.append("public class LoadedFromJar extends Assert {\n"); >- buf.append(" public void verify() {\n"); >- buf.append(" this.verifyApplicationClassLoadedByTestLoader();\n"); >- buf.append(" }\n"); > buf.append(" private boolean isTestCaseClassLoader(final ClassLoader cl) {\n"); > buf.append(" return ((cl != null) && cl.getClass().getName().equals(\n"); > buf.append(" junit.runner.TestCaseClassLoader.class.getName()));\n"); > buf.append(" }\n"); >+ buf.append(" public void verify() {\n"); >+ buf.append(" this.verifyApplicationClassLoadedByTestLoader();\n"); >+ buf.append(" }\n"); > buf.append(" private void verifyApplicationClassLoadedByTestLoader() {\n"); > buf.append(" Assert.assertTrue(this.isTestCaseClassLoader(this.getClass()\n"); > buf.append(" .getClassLoader()));\n"); >@@ -3506,23 +3506,37 @@ > buf.append("\n"); > buf.append("public class ComparisonFailureTest extends TestCase {\n"); > buf.append("\n"); >+ buf.append(" public void testComparisonErrorEndSame() {\n"); >+ buf.append(" final ComparisonFailure failure = new ComparisonFailure(null,\n"); >+ buf.append(" \"ab\", \"cb\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >+ buf.append(" Assert.assertEquals(\n"); >+ buf.append(" \"expected:<a...> but was:<c...>\", failure.getMessage()); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" public void testComparisonErrorEndSameComplete() {\n"); >+ buf.append(" final ComparisonFailure failure = new ComparisonFailure(null,\n"); >+ buf.append(" \"bc\", \"abc\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >+ buf.append(" Assert.assertEquals(\n"); >+ buf.append(" \"expected:<...> but was:<a...>\", failure.getMessage()); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" public void testComparisonErrorMessage() {\n"); > buf.append(" final ComparisonFailure failure = new ComparisonFailure(\"a\", \"b\", \"c\"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); > buf.append(" Assert.assertEquals(\"a expected:<b> but was:<c>\", failure.getMessage()); //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testComparisonErrorStartSame() {\n"); >+ buf.append(" public void testComparisonErrorOverlapingMatches() {\n"); > buf.append(" final ComparisonFailure failure = new ComparisonFailure(null,\n"); >- buf.append(" \"ba\", \"bc\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >+ buf.append(" \"abc\", \"abbc\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); > buf.append(" Assert.assertEquals(\n"); >- buf.append(" \"expected:<...a> but was:<...c>\", failure.getMessage()); //$NON-NLS-1$\n"); >+ buf.append(" \"expected:<......> but was:<...b...>\", failure.getMessage()); //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testComparisonErrorEndSame() {\n"); >+ buf.append(" public void testComparisonErrorOverlapingMatches2() {\n"); > buf.append(" final ComparisonFailure failure = new ComparisonFailure(null,\n"); >- buf.append(" \"ab\", \"cb\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >+ buf.append(" \"abcdde\", \"abcde\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); > buf.append(" Assert.assertEquals(\n"); >- buf.append(" \"expected:<a...> but was:<c...>\", failure.getMessage()); //$NON-NLS-1$\n"); >+ buf.append(" \"expected:<...d...> but was:<......>\", failure.getMessage()); //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" public void testComparisonErrorSame() {\n"); >@@ -3538,32 +3552,18 @@ > buf.append(" \"expected:<...b...> but was:<...d...>\", failure.getMessage()); //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testComparisonErrorStartSameComplete() {\n"); >- buf.append(" final ComparisonFailure failure = new ComparisonFailure(null,\n"); >- buf.append(" \"ab\", \"abc\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >- buf.append(" Assert.assertEquals(\n"); >- buf.append(" \"expected:<...> but was:<...c>\", failure.getMessage()); //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public void testComparisonErrorEndSameComplete() {\n"); >- buf.append(" final ComparisonFailure failure = new ComparisonFailure(null,\n"); >- buf.append(" \"bc\", \"abc\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >- buf.append(" Assert.assertEquals(\n"); >- buf.append(" \"expected:<...> but was:<a...>\", failure.getMessage()); //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public void testComparisonErrorOverlapingMatches() {\n"); >+ buf.append(" public void testComparisonErrorStartSame() {\n"); > buf.append(" final ComparisonFailure failure = new ComparisonFailure(null,\n"); >- buf.append(" \"abc\", \"abbc\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >+ buf.append(" \"ba\", \"bc\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); > buf.append(" Assert.assertEquals(\n"); >- buf.append(" \"expected:<......> but was:<...b...>\", failure.getMessage()); //$NON-NLS-1$\n"); >+ buf.append(" \"expected:<...a> but was:<...c>\", failure.getMessage()); //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testComparisonErrorOverlapingMatches2() {\n"); >+ buf.append(" public void testComparisonErrorStartSameComplete() {\n"); > buf.append(" final ComparisonFailure failure = new ComparisonFailure(null,\n"); >- buf.append(" \"abcdde\", \"abcde\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); >+ buf.append(" \"ab\", \"abc\"); //$NON-NLS-1$ //$NON-NLS-2$\n"); > buf.append(" Assert.assertEquals(\n"); >- buf.append(" \"expected:<...d...> but was:<......>\", failure.getMessage()); //$NON-NLS-1$\n"); >+ buf.append(" \"expected:<...> but was:<...c>\", failure.getMessage()); //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" public void testComparisonErrorWithActualNull() {\n"); >@@ -3597,8 +3597,8 @@ > buf.append("import junit.runner.BaseTestRunner;\n"); > buf.append("\n"); > buf.append("public class ResultPrinter implements TestListener {\n"); >- buf.append(" PrintStream fWriter;\n"); > buf.append(" int fColumn = 0;\n"); >+ buf.append(" PrintStream fWriter;\n"); > buf.append("\n"); > buf.append(" public ResultPrinter(final PrintStream writer) {\n"); > buf.append(" this.fWriter = writer;\n"); >@@ -3608,48 +3608,47 @@ > buf.append(" * API for use by textui.TestRunner\n"); > buf.append(" */\n"); > buf.append("\n"); >- buf.append(" synchronized void print(final TestResult result, final long runTime) {\n"); >- buf.append(" this.printHeader(runTime);\n"); >- buf.append(" this.printErrors(result);\n"); >- buf.append(" this.printFailures(result);\n"); >- buf.append(" this.printFooter(result);\n"); >+ buf.append(" /**\n"); >+ buf.append(" * @see junit.framework.TestListener#addError(Test, Throwable)\n"); >+ buf.append(" */\n"); >+ buf.append(" public void addError(final Test test, final Throwable t) {\n"); >+ buf.append(" this.getWriter().print(\"E\"); //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" void printWaitPrompt() {\n"); >- buf.append(" this.getWriter().println();\n"); >- buf.append(" this.getWriter().println(\"<RETURN> to continue\"); //$NON-NLS-1$\n"); >+ buf.append(" /**\n"); >+ buf.append(" * @see junit.framework.TestListener#addFailure(Test, AssertionFailedError)\n"); >+ buf.append(" */\n"); >+ buf.append(" public void addFailure(final Test test, final AssertionFailedError t) {\n"); >+ buf.append(" this.getWriter().print(\"F\"); //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /*\n"); > buf.append(" * Internal methods\n"); > buf.append(" */\n"); > buf.append("\n"); >- buf.append(" protected void printHeader(final long runTime) {\n"); >- buf.append(" this.getWriter().println();\n"); >- buf.append(" this.getWriter().println(\"Time: \" + this.elapsedTimeAsString(runTime)); //$NON-NLS-1$\n"); >+ buf.append(" /**\n"); >+ buf.append(" * Returns the formatted string of the elapsed time. Duplicated from\n"); >+ buf.append(" * BaseTestRunner. Fix it.\n"); >+ buf.append(" */\n"); >+ buf.append(" protected String elapsedTimeAsString(final long runTime) {\n"); >+ buf.append(" return NumberFormat.getInstance().format((double) runTime / 1000);\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" protected void printErrors(final TestResult result) {\n"); >- buf.append(" this.printDefects(result.errors(), result.errorCount(), \"error\"); //$NON-NLS-1$\n"); >+ buf.append(" /**\n"); >+ buf.append(" * @see junit.framework.TestListener#endTest(Test)\n"); >+ buf.append(" */\n"); >+ buf.append(" public void endTest(final Test test) {\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" protected void printFailures(final TestResult result) {\n"); >- buf.append(" this.printDefects(result.failures(), result.failureCount(), \"failure\"); //$NON-NLS-1$\n"); >+ buf.append(" public PrintStream getWriter() {\n"); >+ buf.append(" return this.fWriter;\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" protected void printDefects(final Enumeration booBoos, final int count,\n"); >- buf.append(" final String type) {\n"); >- buf.append(" if (count == 0) {\n"); >- buf.append(" return;\n"); >- buf.append(" }\n"); >- buf.append(" if (count == 1) {\n"); >- buf.append(" this.getWriter().println(\"There was \" + count + \" \" + type + \":\"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); >- buf.append(" } else {\n"); >- buf.append(" this.getWriter().println(\"There were \" + count + \" \" + type + \"s:\"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); >- buf.append(" }\n"); >- buf.append(" for (int i = 1; booBoos.hasMoreElements(); i++) {\n"); >- buf.append(" this.printDefect((TestFailure) booBoos.nextElement(), i);\n"); >- buf.append(" }\n"); >+ buf.append(" synchronized void print(final TestResult result, final long runTime) {\n"); >+ buf.append(" this.printHeader(runTime);\n"); >+ buf.append(" this.printErrors(result);\n"); >+ buf.append(" this.printFailures(result);\n"); >+ buf.append(" this.printFooter(result);\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" public void printDefect(final TestFailure booBoo, final int count) { // only\n"); >@@ -3668,10 +3667,32 @@ > buf.append(" this.getWriter().print(count + \") \" + booBoo.failedTest()); //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" protected void printDefects(final Enumeration booBoos, final int count,\n"); >+ buf.append(" final String type) {\n"); >+ buf.append(" if (count == 0) {\n"); >+ buf.append(" return;\n"); >+ buf.append(" }\n"); >+ buf.append(" if (count == 1) {\n"); >+ buf.append(" this.getWriter().println(\"There was \" + count + \" \" + type + \":\"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); >+ buf.append(" } else {\n"); >+ buf.append(" this.getWriter().println(\"There were \" + count + \" \" + type + \"s:\"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); >+ buf.append(" }\n"); >+ buf.append(" for (int i = 1; booBoos.hasMoreElements(); i++) {\n"); >+ buf.append(" this.printDefect((TestFailure) booBoos.nextElement(), i);\n"); >+ buf.append(" }\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" protected void printDefectTrace(final TestFailure booBoo) {\n"); > buf.append(" this.getWriter().print(BaseTestRunner.getFilteredTrace(booBoo.trace()));\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" protected void printErrors(final TestResult result) {\n"); >+ buf.append(" this.printDefects(result.errors(), result.errorCount(), \"error\"); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" protected void printFailures(final TestResult result) {\n"); >+ buf.append(" this.printDefects(result.failures(), result.failureCount(), \"failure\"); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); > buf.append(" protected void printFooter(final TestResult result) {\n"); > buf.append(" if (result.wasSuccessful()) {\n"); > buf.append(" this.getWriter().println();\n"); >@@ -3691,35 +3712,14 @@ > buf.append(" this.getWriter().println();\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * Returns the formatted string of the elapsed time. Duplicated from\n"); >- buf.append(" * BaseTestRunner. Fix it.\n"); >- buf.append(" */\n"); >- buf.append(" protected String elapsedTimeAsString(final long runTime) {\n"); >- buf.append(" return NumberFormat.getInstance().format((double) runTime / 1000);\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public PrintStream getWriter() {\n"); >- buf.append(" return this.fWriter;\n"); >- buf.append(" }\n"); >- buf.append(" /**\n"); >- buf.append(" * @see junit.framework.TestListener#addError(Test, Throwable)\n"); >- buf.append(" */\n"); >- buf.append(" public void addError(final Test test, final Throwable t) {\n"); >- buf.append(" this.getWriter().print(\"E\"); //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * @see junit.framework.TestListener#addFailure(Test, AssertionFailedError)\n"); >- buf.append(" */\n"); >- buf.append(" public void addFailure(final Test test, final AssertionFailedError t) {\n"); >- buf.append(" this.getWriter().print(\"F\"); //$NON-NLS-1$\n"); >+ buf.append(" protected void printHeader(final long runTime) {\n"); >+ buf.append(" this.getWriter().println();\n"); >+ buf.append(" this.getWriter().println(\"Time: \" + this.elapsedTimeAsString(runTime)); //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" /**\n"); >- buf.append(" * @see junit.framework.TestListener#endTest(Test)\n"); >- buf.append(" */\n"); >- buf.append(" public void endTest(final Test test) {\n"); >+ buf.append(" void printWaitPrompt() {\n"); >+ buf.append(" this.getWriter().println();\n"); >+ buf.append(" this.getWriter().println(\"<RETURN> to continue\"); //$NON-NLS-1$\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" /**\n"); >@@ -3751,12 +3751,15 @@ > buf.append(" * \n"); > buf.append(" */\n"); > buf.append("public class VectorTest extends TestCase {\n"); >- buf.append(" protected Vector fEmpty;\n"); >- buf.append(" protected Vector fFull;\n"); >- buf.append("\n"); > buf.append(" public static void main(final String[] args) {\n"); > buf.append(" junit.textui.TestRunner.run(VectorTest.suite());\n"); > buf.append(" }\n"); >+ buf.append(" public static Test suite() {\n"); >+ buf.append(" return new TestSuite(VectorTest.class);\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" protected Vector fEmpty;\n"); >+ buf.append(" protected Vector fFull;\n"); > buf.append(" @Override\n"); > buf.append(" protected void setUp() {\n"); > buf.append(" this.fEmpty = new Vector();\n"); >@@ -3765,9 +3768,6 @@ > buf.append(" this.fFull.addElement(new Integer(2));\n"); > buf.append(" this.fFull.addElement(new Integer(3));\n"); > buf.append(" }\n"); >- buf.append(" public static Test suite() {\n"); >- buf.append(" return new TestSuite(VectorTest.class);\n"); >- buf.append(" }\n"); > buf.append(" public void testCapacity() {\n"); > buf.append(" final int size = this.fFull.size();\n"); > buf.append(" for (int i = 0; i < 100; i++) {\n"); >@@ -3818,8 +3818,8 @@ > buf.append("public class ComparisonFailure extends AssertionFailedError {\n"); > buf.append(" /* Test */\n"); > buf.append(" private static final long serialVersionUID = 1L;\n"); >- buf.append(" private final String fExpected;\n"); > buf.append(" private final String fActual;\n"); >+ buf.append(" private final String fExpected;\n"); > buf.append("\n"); > buf.append(" /**\n"); > buf.append(" * Constructs a comparison failure.\n"); >@@ -3914,13 +3914,13 @@ > buf.append(" boolean fTornDown = false;\n"); > buf.append("\n"); > buf.append(" @Override\n"); >- buf.append(" protected void tearDown() {\n"); >- buf.append(" this.fTornDown = true;\n"); >- buf.append(" }\n"); >- buf.append(" @Override\n"); > buf.append(" protected void runTest() {\n"); > buf.append(" throw new Error();\n"); > buf.append(" }\n"); >+ buf.append(" @Override\n"); >+ buf.append(" protected void tearDown() {\n"); >+ buf.append(" this.fTornDown = true;\n"); >+ buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); > buf.append(" public void testCaseToString() {\n"); >@@ -3940,29 +3940,72 @@ > buf.append(" };\n"); > buf.append(" this.verifyError(error);\n"); > buf.append(" }\n"); >+ buf.append(" public void testExceptionRunningAndTearDown() {\n"); >+ buf.append(" // This test documents the current behavior. With 1.4, we should\n"); >+ buf.append(" // wrap the exception thrown while running with the exception thrown\n"); >+ buf.append(" // while tearing down\n"); >+ buf.append(" final Test t = new TornDown() {\n"); >+ buf.append(" @Override\n"); >+ buf.append(" public void tearDown() {\n"); >+ buf.append(" throw new Error(\"tearDown\"); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append(" };\n"); >+ buf.append(" final TestResult result = new TestResult();\n"); >+ buf.append(" t.run(result);\n"); >+ buf.append(" final TestFailure failure = (TestFailure) result.errors().nextElement();\n"); >+ buf.append(" Assert.assertEquals(\"tearDown\", failure.thrownException().getMessage()); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append(" public void testFailure() {\n"); >+ buf.append(" final TestCase failure = new TestCase(\"failure\") { //$NON-NLS-1$\n"); >+ buf.append(" @Override\n"); >+ buf.append(" protected void runTest() {\n"); >+ buf.append(" Assert.fail();\n"); >+ buf.append(" }\n"); >+ buf.append(" };\n"); >+ buf.append(" this.verifyFailure(failure);\n"); >+ buf.append(" }\n"); >+ buf.append(" public void testNamelessTestCase() {\n"); >+ buf.append(" final TestCase t = new TestCase() {\n"); >+ buf.append(" };\n"); >+ buf.append(" try {\n"); >+ buf.append(" t.run();\n"); >+ buf.append(" Assert.fail();\n"); >+ buf.append(" } catch (final AssertionFailedError e) {\n"); >+ buf.append(" }\n"); >+ buf.append(" }\n"); >+ buf.append(" public void testNoArgTestCasePasses() {\n"); >+ buf.append(" final Test t = new TestSuite(NoArgTestCaseTest.class);\n"); >+ buf.append(" final TestResult result = new TestResult();\n"); >+ buf.append(" t.run(result);\n"); >+ buf.append(" Assert.assertTrue(result.runCount() == 1);\n"); >+ buf.append(" Assert.assertTrue(result.failureCount() == 0);\n"); >+ buf.append(" Assert.assertTrue(result.errorCount() == 0);\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" public void testRunAndTearDownFails() {\n"); > buf.append(" final TornDown fails = new TornDown() {\n"); > buf.append(" @Override\n"); >- buf.append(" protected void tearDown() {\n"); >- buf.append(" super.tearDown();\n"); >+ buf.append(" protected void runTest() {\n"); > buf.append(" throw new Error();\n"); > buf.append(" }\n"); > buf.append(" @Override\n"); >- buf.append(" protected void runTest() {\n"); >+ buf.append(" protected void tearDown() {\n"); >+ buf.append(" super.tearDown();\n"); > buf.append(" throw new Error();\n"); > buf.append(" }\n"); > buf.append(" };\n"); > buf.append(" this.verifyError(fails);\n"); > buf.append(" Assert.assertTrue(fails.fTornDown);\n"); > buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" public void testSetupFails() {\n"); > buf.append(" final TestCase fails = new TestCase(\"success\") { //$NON-NLS-1$\n"); > buf.append(" @Override\n"); >- buf.append(" protected void setUp() {\n"); >- buf.append(" throw new Error();\n"); >+ buf.append(" protected void runTest() {\n"); > buf.append(" }\n"); > buf.append(" @Override\n"); >- buf.append(" protected void runTest() {\n"); >+ buf.append(" protected void setUp() {\n"); >+ buf.append(" throw new Error();\n"); > buf.append(" }\n"); > buf.append(" };\n"); > buf.append(" this.verifyError(fails);\n"); >@@ -3975,34 +4018,24 @@ > buf.append(" };\n"); > buf.append(" this.verifySuccess(success);\n"); > buf.append(" }\n"); >- buf.append(" public void testFailure() {\n"); >- buf.append(" final TestCase failure = new TestCase(\"failure\") { //$NON-NLS-1$\n"); >- buf.append(" @Override\n"); >- buf.append(" protected void runTest() {\n"); >- buf.append(" Assert.fail();\n"); >- buf.append(" }\n"); >- buf.append(" };\n"); >- buf.append(" this.verifyFailure(failure);\n"); >- buf.append(" }\n"); >- buf.append("\n"); > buf.append(" public void testTearDownAfterError() {\n"); > buf.append(" final TornDown fails = new TornDown();\n"); > buf.append(" this.verifyError(fails);\n"); > buf.append(" Assert.assertTrue(fails.fTornDown);\n"); > buf.append(" }\n"); >- buf.append("\n"); > buf.append(" public void testTearDownFails() {\n"); > buf.append(" final TestCase fails = new TestCase(\"success\") { //$NON-NLS-1$\n"); > buf.append(" @Override\n"); >- buf.append(" protected void tearDown() {\n"); >- buf.append(" throw new Error();\n"); >+ buf.append(" protected void runTest() {\n"); > buf.append(" }\n"); > buf.append(" @Override\n"); >- buf.append(" protected void runTest() {\n"); >+ buf.append(" protected void tearDown() {\n"); >+ buf.append(" throw new Error();\n"); > buf.append(" }\n"); > buf.append(" };\n"); > buf.append(" this.verifyError(fails);\n"); > buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" public void testTearDownSetupFails() {\n"); > buf.append(" final TornDown fails = new TornDown() {\n"); > buf.append(" @Override\n"); >@@ -4013,45 +4046,12 @@ > buf.append(" this.verifyError(fails);\n"); > buf.append(" Assert.assertTrue(!fails.fTornDown);\n"); > buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" public void testWasRun() {\n"); > buf.append(" final WasRun test = new WasRun();\n"); > buf.append(" test.run();\n"); > buf.append(" Assert.assertTrue(test.fWasRun);\n"); > buf.append(" }\n"); >- buf.append(" public void testExceptionRunningAndTearDown() {\n"); >- buf.append(" // This test documents the current behavior. With 1.4, we should\n"); >- buf.append(" // wrap the exception thrown while running with the exception thrown\n"); >- buf.append(" // while tearing down\n"); >- buf.append(" final Test t = new TornDown() {\n"); >- buf.append(" @Override\n"); >- buf.append(" public void tearDown() {\n"); >- buf.append(" throw new Error(\"tearDown\"); //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append(" };\n"); >- buf.append(" final TestResult result = new TestResult();\n"); >- buf.append(" t.run(result);\n"); >- buf.append(" final TestFailure failure = (TestFailure) result.errors().nextElement();\n"); >- buf.append(" Assert.assertEquals(\"tearDown\", failure.thrownException().getMessage()); //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public void testNoArgTestCasePasses() {\n"); >- buf.append(" final Test t = new TestSuite(NoArgTestCaseTest.class);\n"); >- buf.append(" final TestResult result = new TestResult();\n"); >- buf.append(" t.run(result);\n"); >- buf.append(" Assert.assertTrue(result.runCount() == 1);\n"); >- buf.append(" Assert.assertTrue(result.failureCount() == 0);\n"); >- buf.append(" Assert.assertTrue(result.errorCount() == 0);\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public void testNamelessTestCase() {\n"); >- buf.append(" final TestCase t = new TestCase() {\n"); >- buf.append(" };\n"); >- buf.append(" try {\n"); >- buf.append(" t.run();\n"); >- buf.append(" Assert.fail();\n"); >- buf.append(" } catch (final AssertionFailedError e) {\n"); >- buf.append(" }\n"); >- buf.append(" }\n"); > buf.append("\n"); > buf.append(" void verifyError(final TestCase test) {\n"); > buf.append(" final TestResult result = test.run();\n"); >@@ -4096,12 +4096,18 @@ > buf.append(" this.fFailedTest = failedTest;\n"); > buf.append(" this.fThrownException = thrownException;\n"); > buf.append(" }\n"); >+ buf.append(" public String exceptionMessage() {\n"); >+ buf.append(" return this.thrownException().getMessage();\n"); >+ buf.append(" }\n"); > buf.append(" /**\n"); > buf.append(" * Gets the failed test.\n"); > buf.append(" */\n"); > buf.append(" public Test failedTest() {\n"); > buf.append(" return this.fFailedTest;\n"); > buf.append(" }\n"); >+ buf.append(" public boolean isFailure() {\n"); >+ buf.append(" return this.thrownException() instanceof AssertionFailedError;\n"); >+ buf.append(" }\n"); > buf.append(" /**\n"); > buf.append(" * Gets the thrown exception.\n"); > buf.append(" */\n"); >@@ -4125,12 +4131,6 @@ > buf.append(" final StringBuffer buffer = stringWriter.getBuffer();\n"); > buf.append(" return buffer.toString();\n"); > buf.append(" }\n"); >- buf.append(" public String exceptionMessage() {\n"); >- buf.append(" return this.thrownException().getMessage();\n"); >- buf.append(" }\n"); >- buf.append(" public boolean isFailure() {\n"); >- buf.append(" return this.thrownException() instanceof AssertionFailedError;\n"); >- buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.framework.TestFailure.java", buf.toString()); > buf= new StringBuffer(); >@@ -4141,6 +4141,10 @@ > buf.append(" */\n"); > buf.append("public class ReloadingTestSuiteLoader implements TestSuiteLoader {\n"); > buf.append("\n"); >+ buf.append(" protected TestCaseClassLoader createLoader() {\n"); >+ buf.append(" return new TestCaseClassLoader();\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" public Class load(final String suiteClassName)\n"); > buf.append(" throws ClassNotFoundException {\n"); > buf.append(" return this.createLoader().loadClass(suiteClassName, true);\n"); >@@ -4149,10 +4153,6 @@ > buf.append(" public Class reload(final Class aClass) throws ClassNotFoundException {\n"); > buf.append(" return this.createLoader().loadClass(aClass.getName(), true);\n"); > buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" protected TestCaseClassLoader createLoader() {\n"); >- buf.append(" return new TestCaseClassLoader();\n"); >- buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.runner.ReloadingTestSuiteLoader.java", buf.toString()); > buf= new StringBuffer(); >@@ -4234,18 +4234,6 @@ > buf.append("\n"); > buf.append("public class TextRunnerTest extends TestCase {\n"); > buf.append("\n"); >- buf.append(" public void testFailure() throws Exception {\n"); >- buf.append(" this.execTest(\"junit.tests.framework.Failure\", false); //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public void testSuccess() throws Exception {\n"); >- buf.append(" this.execTest(\"junit.tests.framework.Success\", true); //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public void testError() throws Exception {\n"); >- buf.append(" this.execTest(\"junit.tests.BogusDude\", false); //$NON-NLS-1$\n"); >- buf.append(" }\n"); >- buf.append("\n"); > buf.append(" void execTest(final String testClass, final boolean success)\n"); > buf.append(" throws Exception {\n"); > buf.append(" final String java = System.getProperty(\"java.home\") + File.separator + \"bin\" + File.separator + \"java\"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); >@@ -4269,6 +4257,14 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" public void testError() throws Exception {\n"); >+ buf.append(" this.execTest(\"junit.tests.BogusDude\", false); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" public void testFailure() throws Exception {\n"); >+ buf.append(" this.execTest(\"junit.tests.framework.Failure\", false); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" public void testRunReturnsResult() {\n"); > buf.append(" final PrintStream oldOut = System.out;\n"); > buf.append(" System.setOut(new PrintStream(new OutputStream() {\n"); >@@ -4285,6 +4281,10 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" public void testSuccess() throws Exception {\n"); >+ buf.append(" this.execTest(\"junit.tests.framework.Success\", true); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.tests.runner.TextRunnerTest.java", buf.toString()); > buf= new StringBuffer(); >@@ -4456,8 +4456,6 @@ > buf.append(" */\n"); > buf.append("\n"); > buf.append("public class RepeatedTestTest extends TestCase {\n"); >- buf.append(" private final TestSuite fSuite;\n"); >- buf.append("\n"); > buf.append(" public static class SuccessTest extends TestCase {\n"); > buf.append("\n"); > buf.append(" @Override\n"); >@@ -4465,6 +4463,8 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append("\n"); >+ buf.append(" private final TestSuite fSuite;\n"); >+ buf.append("\n"); > buf.append(" public RepeatedTestTest(final String name) {\n"); > buf.append(" super(name);\n"); > buf.append(" this.fSuite = new TestSuite();\n"); >@@ -4472,14 +4472,6 @@ > buf.append(" this.fSuite.addTest(new SuccessTest());\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testRepeatedOnce() {\n"); >- buf.append(" final Test test = new RepeatedTest(this.fSuite, 1);\n"); >- buf.append(" Assert.assertEquals(2, test.countTestCases());\n"); >- buf.append(" final TestResult result = new TestResult();\n"); >- buf.append(" test.run(result);\n"); >- buf.append(" Assert.assertEquals(2, result.runCount());\n"); >- buf.append(" }\n"); >- buf.append("\n"); > buf.append(" public void testRepeatedMoreThanOnce() {\n"); > buf.append(" final Test test = new RepeatedTest(this.fSuite, 3);\n"); > buf.append(" Assert.assertEquals(6, test.countTestCases());\n"); >@@ -4488,14 +4480,6 @@ > buf.append(" Assert.assertEquals(6, result.runCount());\n"); > buf.append(" }\n"); > buf.append("\n"); >- buf.append(" public void testRepeatedZero() {\n"); >- buf.append(" final Test test = new RepeatedTest(this.fSuite, 0);\n"); >- buf.append(" Assert.assertEquals(0, test.countTestCases());\n"); >- buf.append(" final TestResult result = new TestResult();\n"); >- buf.append(" test.run(result);\n"); >- buf.append(" Assert.assertEquals(0, result.runCount());\n"); >- buf.append(" }\n"); >- buf.append("\n"); > buf.append(" public void testRepeatedNegative() {\n"); > buf.append(" try {\n"); > buf.append(" new RepeatedTest(this.fSuite, -1);\n"); >@@ -4504,6 +4488,22 @@ > buf.append(" }\n"); > buf.append(" Assert.fail(\"Should throw an IllegalArgumentException\"); //$NON-NLS-1$\n"); > buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" public void testRepeatedOnce() {\n"); >+ buf.append(" final Test test = new RepeatedTest(this.fSuite, 1);\n"); >+ buf.append(" Assert.assertEquals(2, test.countTestCases());\n"); >+ buf.append(" final TestResult result = new TestResult();\n"); >+ buf.append(" test.run(result);\n"); >+ buf.append(" Assert.assertEquals(2, result.runCount());\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" public void testRepeatedZero() {\n"); >+ buf.append(" final Test test = new RepeatedTest(this.fSuite, 0);\n"); >+ buf.append(" Assert.assertEquals(0, test.countTestCases());\n"); >+ buf.append(" final TestResult result = new TestResult();\n"); >+ buf.append(" test.run(result);\n"); >+ buf.append(" Assert.assertEquals(0, result.runCount());\n"); >+ buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.tests.extensions.RepeatedTestTest.java", buf.toString()); > buf= new StringBuffer(); >@@ -4519,6 +4519,11 @@ > buf.append(" */\n"); > buf.append("public class AllTests {\n"); > buf.append("\n"); >+ buf.append(" static boolean isJDK11() {\n"); >+ buf.append(" final String version = System.getProperty(\"java.version\"); //$NON-NLS-1$\n"); >+ buf.append(" return version.startsWith(\"1.1\"); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" public static void main(final String[] args) {\n"); > buf.append(" junit.textui.TestRunner.run(AllTests.suite());\n"); > buf.append(" }\n"); >@@ -4539,11 +4544,6 @@ > buf.append(" }\n"); > buf.append(" return suite;\n"); > buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" static boolean isJDK11() {\n"); >- buf.append(" final String version = System.getProperty(\"java.version\"); //$NON-NLS-1$\n"); >- buf.append(" return version.startsWith(\"1.1\"); //$NON-NLS-1$\n"); >- buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.tests.runner.AllTests.java", buf.toString()); > buf= new StringBuffer(); >@@ -4581,14 +4581,14 @@ > buf.append(" * constructors to create a MoneyBag.\n"); > buf.append(" */\n"); > buf.append("class MoneyBag implements IMoney {\n"); >- buf.append(" private final Vector fMonies = new Vector(5);\n"); >- buf.append("\n"); > buf.append(" static IMoney create(final IMoney m1, final IMoney m2) {\n"); > buf.append(" final MoneyBag result = new MoneyBag();\n"); > buf.append(" m1.appendTo(result);\n"); > buf.append(" m2.appendTo(result);\n"); > buf.append(" return result.simplify();\n"); > buf.append(" }\n"); >+ buf.append("\n"); >+ buf.append(" private final Vector fMonies = new Vector(5);\n"); > buf.append(" public IMoney add(final IMoney m) {\n"); > buf.append(" return m.addMoneyBag(this);\n"); > buf.append(" }\n"); >@@ -4619,6 +4619,16 @@ > buf.append(" }\n"); > buf.append(" this.fMonies.addElement(sum);\n"); > buf.append(" }\n"); >+ buf.append(" public void appendTo(final MoneyBag m) {\n"); >+ buf.append(" m.appendBag(this);\n"); >+ buf.append(" }\n"); >+ buf.append(" private boolean contains(final Money m) {\n"); >+ buf.append(" final Money found = this.findMoney(m.currency());\n"); >+ buf.append(" if (found == null) {\n"); >+ buf.append(" return false;\n"); >+ buf.append(" }\n"); >+ buf.append(" return found.amount() == m.amount();\n"); >+ buf.append(" }\n"); > buf.append(" @Override\n"); > buf.append(" public boolean equals(final Object anObject) {\n"); > buf.append(" if (this.isZero()) {\n"); >@@ -4653,13 +4663,6 @@ > buf.append(" }\n"); > buf.append(" return null;\n"); > buf.append(" }\n"); >- buf.append(" private boolean contains(final Money m) {\n"); >- buf.append(" final Money found = this.findMoney(m.currency());\n"); >- buf.append(" if (found == null) {\n"); >- buf.append(" return false;\n"); >- buf.append(" }\n"); >- buf.append(" return found.amount() == m.amount();\n"); >- buf.append(" }\n"); > buf.append(" @Override\n"); > buf.append(" public int hashCode() {\n"); > buf.append(" int hash = 0;\n"); >@@ -4710,9 +4713,6 @@ > buf.append(" buffer.append(\"}\"); //$NON-NLS-1$\n"); > buf.append(" return buffer.toString();\n"); > buf.append(" }\n"); >- buf.append(" public void appendTo(final MoneyBag m) {\n"); >- buf.append(" m.appendBag(this);\n"); >- buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.samples.money.MoneyBag.java", buf.toString()); > buf= new StringBuffer(); >@@ -4847,6 +4847,14 @@ > buf.append(" return new TestResult();\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >+ buf.append(" * Gets the name of a TestCase\n"); >+ buf.append(" * \n"); >+ buf.append(" * @return returns a String\n"); >+ buf.append(" */\n"); >+ buf.append(" public String getName() {\n"); >+ buf.append(" return this.fName;\n"); >+ buf.append(" }\n"); >+ buf.append(" /**\n"); > buf.append(" * A convenience method to run this test, collecting the results with a\n"); > buf.append(" * default TestResult object.\n"); > buf.append(" * \n"); >@@ -4910,6 +4918,15 @@ > buf.append(" }\n"); > buf.append(" }\n"); > buf.append(" /**\n"); >+ buf.append(" * Sets the name of a TestCase\n"); >+ buf.append(" * \n"); >+ buf.append(" * @param name\n"); >+ buf.append(" * The name to set\n"); >+ buf.append(" */\n"); >+ buf.append(" public void setName(final String name) {\n"); >+ buf.append(" this.fName = name;\n"); >+ buf.append(" }\n"); >+ buf.append(" /**\n"); > buf.append(" * Sets up the fixture, for example, open a network connection. This method\n"); > buf.append(" * is called before a test is executed.\n"); > buf.append(" */\n"); >@@ -4928,23 +4945,6 @@ > buf.append(" public String toString() {\n"); > buf.append(" return this.getName() + \"(\" + this.getClass().getName() + \")\"; //$NON-NLS-1$ //$NON-NLS-2$\n"); > buf.append(" }\n"); >- buf.append(" /**\n"); >- buf.append(" * Gets the name of a TestCase\n"); >- buf.append(" * \n"); >- buf.append(" * @return returns a String\n"); >- buf.append(" */\n"); >- buf.append(" public String getName() {\n"); >- buf.append(" return this.fName;\n"); >- buf.append(" }\n"); >- buf.append(" /**\n"); >- buf.append(" * Sets the name of a TestCase\n"); >- buf.append(" * \n"); >- buf.append(" * @param name\n"); >- buf.append(" * The name to set\n"); >- buf.append(" */\n"); >- buf.append(" public void setName(final String name) {\n"); >- buf.append(" this.fName = name;\n"); >- buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.framework.TestCase.java", buf.toString()); > buf= new StringBuffer(); >@@ -4954,17 +4954,17 @@ > buf.append("import junit.framework.TestCase;\n"); > buf.append("\n"); > buf.append("public class MoneyTest extends TestCase {\n"); >+ buf.append(" public static void main(final String args[]) {\n"); >+ buf.append(" junit.textui.TestRunner.run(MoneyTest.class);\n"); >+ buf.append(" }\n"); > buf.append(" private Money f12CHF;\n"); > buf.append(" private Money f14CHF;\n"); >- buf.append(" private Money f7USD;\n"); > buf.append(" private Money f21USD;\n"); > buf.append("\n"); >+ buf.append(" private Money f7USD;\n"); > buf.append(" private IMoney fMB1;\n"); >- buf.append(" private IMoney fMB2;\n"); > buf.append("\n"); >- buf.append(" public static void main(final String args[]) {\n"); >- buf.append(" junit.textui.TestRunner.run(MoneyTest.class);\n"); >- buf.append(" }\n"); >+ buf.append(" private IMoney fMB2;\n"); > buf.append(" @Override\n"); > buf.append(" protected void setUp() {\n"); > buf.append(" this.f12CHF = new Money(12, \"CHF\"); //$NON-NLS-1$\n"); >@@ -4989,6 +4989,10 @@ > buf.append(" new Money(-12, \"CHF\"), new Money(-7, \"USD\")); //$NON-NLS-1$ //$NON-NLS-2$\n"); > buf.append(" Assert.assertEquals(expected, this.fMB1.negate());\n"); > buf.append(" }\n"); >+ buf.append(" public void testBagNotEquals() {\n"); >+ buf.append(" final IMoney bag = MoneyBag.create(this.f12CHF, this.f7USD);\n"); >+ buf.append(" Assert.assertFalse(bag.equals(new Money(12, \"DEM\").add(this.f7USD))); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); > buf.append(" public void testBagSimpleAdd() {\n"); > buf.append(" // {[12 CHF][7 USD]} + [14 CHF] == {[26 CHF][7 USD]}\n"); > buf.append(" final IMoney expected = MoneyBag.create(\n"); >@@ -5017,10 +5021,6 @@ > buf.append(" final IMoney expected = MoneyBag.create(this.f12CHF, this.f7USD);\n"); > buf.append(" Assert.assertEquals(expected, this.f12CHF.add(this.f7USD));\n"); > buf.append(" }\n"); >- buf.append(" public void testBagNotEquals() {\n"); >- buf.append(" final IMoney bag = MoneyBag.create(this.f12CHF, this.f7USD);\n"); >- buf.append(" Assert.assertFalse(bag.equals(new Money(12, \"DEM\").add(this.f7USD))); //$NON-NLS-1$\n"); >- buf.append(" }\n"); > buf.append(" public void testMoneyBagEquals() {\n"); > buf.append(" Assert.assertTrue(!this.fMB1.equals(null));\n"); > buf.append("\n"); >@@ -5050,11 +5050,6 @@ > buf.append(" final Money equal = new Money(12, \"CHF\"); //$NON-NLS-1$\n"); > buf.append(" Assert.assertEquals(this.f12CHF.hashCode(), equal.hashCode());\n"); > buf.append(" }\n"); >- buf.append(" public void testSimplify() {\n"); >- buf.append(" final IMoney money = MoneyBag.create(\n"); >- buf.append(" new Money(26, \"CHF\"), new Money(28, \"CHF\")); //$NON-NLS-1$ //$NON-NLS-2$\n"); >- buf.append(" Assert.assertEquals(new Money(54, \"CHF\"), money); //$NON-NLS-1$\n"); >- buf.append(" }\n"); > buf.append(" public void testNormalize2() {\n"); > buf.append(" // {[12 CHF][7 USD]} - [12 CHF] == [7 USD]\n"); > buf.append(" final Money expected = new Money(7, \"USD\"); //$NON-NLS-1$\n"); >@@ -5103,6 +5098,11 @@ > buf.append(" final Money expected = new Money(2, \"CHF\"); //$NON-NLS-1$\n"); > buf.append(" Assert.assertEquals(expected, this.f14CHF.subtract(this.f12CHF));\n"); > buf.append(" }\n"); >+ buf.append(" public void testSimplify() {\n"); >+ buf.append(" final IMoney money = MoneyBag.create(\n"); >+ buf.append(" new Money(26, \"CHF\"), new Money(28, \"CHF\")); //$NON-NLS-1$ //$NON-NLS-2$\n"); >+ buf.append(" Assert.assertEquals(new Money(54, \"CHF\"), money); //$NON-NLS-1$\n"); >+ buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.samples.money.MoneyTest.java", buf.toString()); > buf= new StringBuffer(); >@@ -5234,6 +5234,9 @@ > buf.append(" public int amount() {\n"); > buf.append(" return this.fAmount;\n"); > buf.append(" }\n"); >+ buf.append(" public/* this makes no sense */void appendTo(final MoneyBag m) {\n"); >+ buf.append(" m.appendMoney(this);\n"); >+ buf.append(" }\n"); > buf.append(" public String currency() {\n"); > buf.append(" return this.fCurrency;\n"); > buf.append(" }\n"); >@@ -5273,9 +5276,6 @@ > buf.append(" buffer.append(\"[\" + this.amount() + \" \" + this.currency() + \"]\"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n"); > buf.append(" return buffer.toString();\n"); > buf.append(" }\n"); >- buf.append(" public/* this makes no sense */void appendTo(final MoneyBag m) {\n"); >- buf.append(" m.appendMoney(this);\n"); >- buf.append(" }\n"); > buf.append("}"); > fExpectedChangesAllTests.put("junit.samples.money.Money.java", buf.toString()); > } >@@ -5341,6 +5341,9 @@ > > node.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpConstants.TRUE); > >+ node.put(CleanUpConstants.SORT_MEMBERS, CleanUpConstants.TRUE); >+ node.put(CleanUpConstants.SORT_MEMBERS_FIELDS, CleanUpConstants.TRUE); >+ > ProfileManager.CustomProfile profile= new ProfileManager.CustomProfile("testProfile", node, CleanUpProfileVersioner.CURRENT_VERSION, CleanUpProfileVersioner.PROFILE_KIND); > new InstanceScope().getNode(JavaUI.ID_PLUGIN).put(CleanUpConstants.CLEANUP_PROFILE, profile.getID()); > >@@ -5406,7 +5409,7 @@ > return buf.toString(); > } > >-// Do not remove, used to generate the table >+ // Do not remove, used to generate the table > // private static final String[] CU_ORDER= new String[71]; > // static { > // CU_ORDER[0]= "junit.runner.BaseTestRunner.java";
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 168954
:
56111
|
56112
|
56314
|
56315
|
56440
|
56470
|
57040
|
57041
|
57408