test/java/util/prefs/RemoveNullKeyCheck.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 7160242 7165118
  26  * @summary Check if NullPointerException is thrown if the key passed
  27  *          to remove() is null.

  28  */
  29 
  30 import java.util.prefs.Preferences;
  31 import java.util.prefs.AbstractPreferences;
  32 import java.util.prefs.BackingStoreException;
  33 
  34 public class RemoveNullKeyCheck {
  35 
  36     private static boolean failed = false;
  37 
  38     public static void main(String[] args) throws Exception {
  39         checkPreferencesRemove();
  40         checkAbstractPreferencesRemove();
  41         if (failed) {
  42             throw new RuntimeException("Expected NullPointerException " +
  43                                        "not thrown");
  44         }
  45     }
  46 
  47     public static void checkPreferencesRemove() {




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 7160242 7165118
  26  * @summary Check if NullPointerException is thrown if the key passed
  27  *          to remove() is null.
  28  * @run main/othervm -Djava.util.prefs.userRoot=. RemoveNullKeyCheck
  29  */
  30 
  31 import java.util.prefs.Preferences;
  32 import java.util.prefs.AbstractPreferences;
  33 import java.util.prefs.BackingStoreException;
  34 
  35 public class RemoveNullKeyCheck {
  36 
  37     private static boolean failed = false;
  38 
  39     public static void main(String[] args) throws Exception {
  40         checkPreferencesRemove();
  41         checkAbstractPreferencesRemove();
  42         if (failed) {
  43             throw new RuntimeException("Expected NullPointerException " +
  44                                        "not thrown");
  45         }
  46     }
  47 
  48     public static void checkPreferencesRemove() {