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 dalvik.annotation.TestTargetClass;
26import dalvik.annotation.TestTargets;
27import dalvik.annotation.TestLevel;
28import dalvik.annotation.TestTargetNew;
29
30import java.security.InvalidKeyException;
31import java.security.spec.InvalidKeySpecException;
32import java.security.spec.KeySpec;
33import javax.crypto.SecretKeyFactorySpi;
34import javax.crypto.SecretKey;
35import org.apache.harmony.crypto.tests.support.MySecretKeyFactorySpi;
36
37import junit.framework.TestCase;
38
39/**
40 * Tests for <code>SecretKeyFactorySpi</code> class constructors and methods.
41 */
42
43@TestTargetClass(SecretKeyFactorySpi.class)
44public class SecretKeyFactorySpiTest extends TestCase {
45    class Mock_SecretKeyFactorySpi extends MySecretKeyFactorySpi {
46
47        @Override
48        protected SecretKey engineGenerateSecret(KeySpec keySpec) throws InvalidKeySpecException {
49            return super.engineGenerateSecret(keySpec);
50        }
51
52        @Override
53        protected KeySpec engineGetKeySpec(SecretKey key, Class keySpec)
54                throws InvalidKeySpecException {
55            return super.engineGetKeySpec(key, keySpec);
56        }
57
58        @Override
59        protected SecretKey engineTranslateKey(SecretKey key) throws InvalidKeyException {
60            return super.engineTranslateKey(key);
61        }
62
63    }
64
65    /**
66     * Test for <code>SecretKeyFactorySpi</code> constructor Assertion:
67     * constructs SecretKeyFactorySpi
68     */
69    @TestTargetNew(level = TestLevel.COMPLETE, notes = "", method = "SecretKeyFactorySpi", args = {})
70    public void testSecretKeyFactorySpi01() throws InvalidKeyException, InvalidKeySpecException {
71        Mock_SecretKeyFactorySpi skfSpi = new Mock_SecretKeyFactorySpi();
72        SecretKey sk = null;
73        assertNull("Not null result", skfSpi.engineTranslateKey(sk));
74
75        KeySpec kspec = null;
76        assertNull("Not null result", skfSpi.engineGenerateSecret(kspec));
77
78        assertNull("Not null result", skfSpi.engineGetKeySpec(sk, null));
79    }
80}
81