/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.crypto.cipher;

import java.security.GeneralSecurityException;
import java.util.Properties;

import org.apache.commons.crypto.conf.ConfigurationKeys;

import org.junit.Assert;
import org.junit.Test;
import static junit.framework.Assert.fail;

public class CryptoCipherFactoryTest {
    @Test
    public void testDefaultCipher() throws GeneralSecurityException {
        CryptoCipher defaultCipher = CryptoCipherFactory
                .getInstance(CipherTransformation.AES_CBC_NOPADDING);
        Assert.assertEquals(OpensslCipher.class.getName(), defaultCipher
                .getClass().getName());
    }

    @Test
    public void testEmptyCipher() throws GeneralSecurityException {
        Properties properties = new Properties();
        properties.setProperty(
                ConfigurationKeys.COMMONS_CRYPTO_CIPHER_CLASSES_KEY, "");
        CryptoCipher defaultCipher = CryptoCipherFactory.getInstance(
                CipherTransformation.AES_CBC_NOPADDING, properties);
        Assert.assertEquals(OpensslCipher.class.getName(), defaultCipher
                .getClass().getName());
    }

    @Test
    public void testInvalidCipher() throws GeneralSecurityException {
        Properties properties = new Properties();
        properties.setProperty(ConfigurationKeys.COMMONS_CRYPTO_CIPHER_CLASSES_KEY,
                "InvalidCipherName");
        CryptoCipher defaultCipher = CryptoCipherFactory.getInstance(
                CipherTransformation.AES_CBC_NOPADDING, properties);
        Assert.assertEquals(JceCipher.class.getName(), defaultCipher.getClass()
                .getName());
    }

    @Test
    public void testDisableFallback() throws GeneralSecurityException {
        Properties properties = new Properties();
        properties.setProperty(
                ConfigurationKeys.COMMONS_CRYPTO_CIPHER_CLASSES_KEY,
                "InvalidCipherName");
        properties.setProperty(ConfigurationKeys
            .COMMONS_CRYPTO_ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "false");
        try {
            CryptoCipherFactory.getInstance(CipherTransformation.AES_CBC_NOPADDING, properties);
            fail("Should throw an exception when DisableFallback");
        } catch (Exception e) {
            ;
        }
    }
}

@@ -2437,32 +2437,75 @@
     %7D%0A%0A    @Test
+(expected = GeneralSecurityException.class)
 %0A    public void
@@ -2879,26 +2879,9 @@
 %22);%0A
-        try %7B%0A    
+%0A
     
@@ -2973,132 +2973,8 @@
 s);%0A
-            fail(%22Should throw an exception when DisableFallback%22);%0A        %7D catch (Exception e) %7B%0A            ;%0A        %7D%0A
     

Use JUnit annotation for testing for expected exception