/**
  * @bug 152578: [prefs] IJavaProject.setOption(Object,Object) wrongly removes key when value is
  *     equals to JavaCore one
  * @test Verify that setting an option to workspace value does not remove it from project
  *     preferences
  * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=152578"
  */
 public void testBug152578() throws CoreException {
   Hashtable wkspOptions = JavaCore.getOptions();
   String wkspCompilerSource = (String) wkspOptions.get(JavaCore.COMPILER_SOURCE);
   String compilerSource =
       wkspCompilerSource.equals(JavaCore.VERSION_1_5)
           ? JavaCore.VERSION_1_6
           : JavaCore.VERSION_1_5;
   try {
     JavaProject project = (JavaProject) createJavaProject("P");
     project.setOption(JavaCore.COMPILER_SOURCE, wkspCompilerSource);
     String option = project.getOption(JavaCore.COMPILER_SOURCE, true);
     if (!option.equals(wkspCompilerSource)) {
       System.err.println(
           "Unexpected option value: " + option + " instead of: " + wkspCompilerSource);
     }
     Hashtable newOptions = JavaCore.getOptions();
     newOptions.put(JavaCore.COMPILER_SOURCE, compilerSource);
     JavaCore.setOptions(newOptions);
     option = project.getOption(JavaCore.COMPILER_SOURCE, false);
     assertNotNull("Project should still have the option set!", option);
   } finally {
     deleteProject("P");
     JavaCore.setOptions(wkspOptions);
   }
 }
 /**
  * @bug 152562: [prefs] IJavaProject.setOption(..., null) does not work
  * @test Verify that setting an option to null removes it from project preferences
  * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=152562"
  */
 public void testBug152562() throws CoreException {
   String wkspCompilerSource = JavaCore.getOption(JavaCore.COMPILER_SOURCE);
   String compilerSource =
       wkspCompilerSource.equals(JavaCore.VERSION_1_5)
           ? JavaCore.VERSION_1_6
           : JavaCore.VERSION_1_5;
   try {
     JavaProject project = (JavaProject) createJavaProject("P");
     project.setOption(JavaCore.COMPILER_SOURCE, compilerSource);
     String option = project.getOption(JavaCore.COMPILER_SOURCE, true);
     if (!option.equals(compilerSource)) {
       System.err.println("Unexpected option value: " + option + " instead of: " + compilerSource);
     }
     project.setOption(JavaCore.COMPILER_SOURCE, null);
     option = project.getOption(JavaCore.COMPILER_SOURCE, true);
     assertEquals(wkspCompilerSource, option);
   } finally {
     deleteProject("P");
   }
 }
 /**
  * @bug 125360: IJavaProject#setOption() doesn't work if same option as default
  * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=125360"
  */
 public void testBug125360() throws CoreException, BackingStoreException {
   try {
     JavaProject project =
         (JavaProject)
             createJavaProject(
                 "P",
                 new String[] {}, // source folders
                 new String[] {}, // lib folders
                 new String[] {}, // projects
                 "");
     project.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4);
     project.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
     String option = project.getOption(JavaCore.COMPILER_SOURCE, true);
     assertEquals(JavaCore.VERSION_1_3, option);
   } finally {
     deleteProject("P");
   }
 }
 /**
  * @bug 324987: [formatter] API compatibility problem with Annotation Newline options
  * @test Verify that a deprecated option is well preserved when a client use it through the
  *     IJavaProject.setOption(String, String) API
  * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324987"
  * @deprecated As using deprecated constants
  */
 public void testBug324987_Project01() throws CoreException {
   try {
     // Set the obsolete option using the IJavaProject API
     JavaProject project = (JavaProject) createJavaProject("P");
     final String obsoleteOption =
         DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER;
     project.setOption(obsoleteOption, JavaCore.DO_NOT_INSERT);
     // Verify that obsolete preference is not stored
     assertNull(
         "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
         project.getEclipsePreferences().get(obsoleteOption, null));
     // Verify that project obsolete option is well retrieved
     assertEquals(
         "Unexpected value for formatter deprecated option 'org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member'",
         JavaCore.DO_NOT_INSERT,
         project.getOption(obsoleteOption, true));
   } finally {
     deleteProject("P");
   }
 }