1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17
18/**
19 * @author Vera Y. Petrashkova
20 * @version $Revision$
21 */
22
23package org.apache.harmony.crypto.tests.javax.crypto;
24
25import java.security.InvalidKeyException;
26import java.security.spec.InvalidKeySpecException;
27import java.security.spec.KeySpec;
28import javax.crypto.SecretKeyFactorySpi;
29import javax.crypto.SecretKey;
30import org.apache.harmony.crypto.tests.support.MySecretKeyFactorySpi;
31
32import junit.framework.TestCase;
33
34/**
35 * Tests for <code>SecretKeyFactorySpi</code> class constructors and methods.
36 */
37public class SecretKeyFactorySpiTest extends TestCase {
38    class Mock_SecretKeyFactorySpi extends MySecretKeyFactorySpi {
39
40        @Override
41        protected SecretKey engineGenerateSecret(KeySpec keySpec) throws InvalidKeySpecException {
42            return super.engineGenerateSecret(keySpec);
43        }
44
45        @Override
46        protected KeySpec engineGetKeySpec(SecretKey key, Class keySpec)
47                throws InvalidKeySpecException {
48            return super.engineGetKeySpec(key, keySpec);
49        }
50
51        @Override
52        protected SecretKey engineTranslateKey(SecretKey key) throws InvalidKeyException {
53            return super.engineTranslateKey(key);
54        }
55
56    }
57
58    /**
59     * Test for <code>SecretKeyFactorySpi</code> constructor Assertion:
60     * constructs SecretKeyFactorySpi
61     */
62    public void testSecretKeyFactorySpi01() throws InvalidKeyException, InvalidKeySpecException {
63        Mock_SecretKeyFactorySpi skfSpi = new Mock_SecretKeyFactorySpi();
64        SecretKey sk = null;
65        assertNull("Not null result", skfSpi.engineTranslateKey(sk));
66
67        KeySpec kspec = null;
68        assertNull("Not null result", skfSpi.engineGenerateSecret(kspec));
69
70        assertNull("Not null result", skfSpi.engineGetKeySpec(sk, null));
71    }
72}
73