Lines 10-17
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.core.tests.model; |
11 |
package org.eclipse.jdt.core.tests.model; |
12 |
|
12 |
|
|
|
13 |
import java.util.ArrayList; |
14 |
import java.util.HashSet; |
13 |
import java.util.Hashtable; |
15 |
import java.util.Hashtable; |
|
|
16 |
import java.util.Iterator; |
17 |
import java.util.List; |
14 |
import java.util.Map; |
18 |
import java.util.Map; |
|
|
19 |
import java.util.Set; |
15 |
|
20 |
|
16 |
import junit.framework.Test; |
21 |
import junit.framework.Test; |
17 |
|
22 |
|
Lines 43-48
Link Here
|
43 |
super(name); |
48 |
super(name); |
44 |
} |
49 |
} |
45 |
static { |
50 |
static { |
|
|
51 |
// TESTS_NAMES = new String[] { "testBug324987_Project01", "testBug324987_Project02" }; |
46 |
// TESTS_NUMBERS = new int[] { 125360 }; |
52 |
// TESTS_NUMBERS = new int[] { 125360 }; |
47 |
// TESTS_RANGE = new int[] { 4, -1 }; |
53 |
// TESTS_RANGE = new int[] { 4, -1 }; |
48 |
} |
54 |
} |
Lines 758-763
Link Here
|
758 |
} |
764 |
} |
759 |
} |
765 |
} |
760 |
/** |
766 |
/** |
|
|
767 |
* @bug 346010 - [model] strange initialization dependency in OptionTests |
768 |
* @test Verify that unfortunate order of map entries doesn't spoil intended semantics. |
769 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=346010" |
770 |
* @deprecated As using deprecated constants |
771 |
*/ |
772 |
public void testBug346010() throws CoreException { |
773 |
class ForcedOrderMap extends Hashtable { |
774 |
private static final long serialVersionUID = 8012963985718522218L; |
775 |
Map original; |
776 |
Map.Entry additionalEntry; |
777 |
/* Force (additionalKey,additionalValue) to be served after all entries of original. */ |
778 |
public ForcedOrderMap(Map original, String additionalKey, String additionalValue) { |
779 |
this.original = original; |
780 |
// convert additionalKey->additionalValue to a Map.Entry without inserting into original: |
781 |
Hashtable tmp = new Hashtable(); |
782 |
tmp.put(additionalKey, additionalValue); |
783 |
this.additionalEntry = (Map.Entry) tmp.entrySet().iterator().next(); |
784 |
} |
785 |
public Set entrySet() { |
786 |
return new HashSet() { |
787 |
private static final long serialVersionUID = 1L; |
788 |
public Iterator iterator() { |
789 |
List orderedEntries; |
790 |
orderedEntries = new ArrayList(ForcedOrderMap.this.original.entrySet()); |
791 |
orderedEntries.add(ForcedOrderMap.this.additionalEntry); |
792 |
return orderedEntries.iterator(); |
793 |
} |
794 |
}; |
795 |
} |
796 |
} |
797 |
try { |
798 |
// Set the obsolete option using the IJavaProject API |
799 |
JavaProject project = (JavaProject) createJavaProject("P"); |
800 |
final String obsoleteOption = DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER; |
801 |
Map testOptions = project.getOptions(true); |
802 |
Map orderedOptions = new ForcedOrderMap(testOptions, obsoleteOption, JavaCore.DO_NOT_INSERT); |
803 |
project.setOptions(orderedOptions); |
804 |
// Verify that obsolete preference is not stored |
805 |
assertNull( |
806 |
"Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'", |
807 |
project.getEclipsePreferences().get(obsoleteOption, null)); |
808 |
// Verify that project obsolete option is well retrieved |
809 |
assertEquals( |
810 |
"Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'", |
811 |
JavaCore.INSERT, |
812 |
project.getOption(obsoleteOption, true)); |
813 |
} finally { |
814 |
deleteProject("P"); |
815 |
} |
816 |
} |
817 |
|
818 |
/** |
761 |
* @bug 324987: [formatter] API compatibility problem with Annotation Newline options |
819 |
* @bug 324987: [formatter] API compatibility problem with Annotation Newline options |
762 |
* @test Verify that a deprecated option is well preserved when read through |
820 |
* @test Verify that a deprecated option is well preserved when read through |
763 |
* the IEclipsePreferences (i.e. simulate reading project preferences of a project |
821 |
* the IEclipsePreferences (i.e. simulate reading project preferences of a project |