NullIV.java revision 2362
906N/A/*
906N/A * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
906N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
906N/A *
906N/A * This code is free software; you can redistribute it and/or modify it
906N/A * under the terms of the GNU General Public License version 2 only, as
906N/A * published by the Free Software Foundation.
906N/A *
906N/A * This code is distributed in the hope that it will be useful, but WITHOUT
906N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
906N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
906N/A * version 2 for more details (a copy is included in the LICENSE file that
906N/A * accompanied this code).
906N/A *
906N/A * You should have received a copy of the GNU General Public License version
906N/A * 2 along with this work; if not, write to the Free Software Foundation,
906N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
906N/A *
906N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
906N/A * or visit www.oracle.com if you need additional information or have any
906N/A * questions.
3806N/A */
906N/A
906N/A/**
906N/A * @test
906N/A * @bug 4960776
906N/A * @summary IvParameterSpec constructors should throw exception
3806N/A * if the iv parameter is null.
1887N/A * @author Sean Mullan
1887N/A */
906N/Aimport javax.crypto.spec.IvParameterSpec;
906N/A
3806N/Apublic class NullIV {
1887N/A
1887N/A public static void main(String[] args) throws Exception {
906N/A
3806N/A try {
3661N/A IvParameterSpec ivParams = new IvParameterSpec(null);
3806N/A throw new Exception("expected NullPointerException");
3806N/A } catch (NullPointerException npe) {}
1887N/A
1887N/A try {
2473N/A IvParameterSpec ivParams = new IvParameterSpec(null, 0, 0);
906N/A throw new Exception("expected IllegalArgumentException");
3985N/A } catch (IllegalArgumentException iae) {}
3985N/A
3985N/A }
3985N/A}
3806N/A