Repository: commons-crypto Updated Branches: refs/heads/master b2953218f -> 170e51c89
Use standard naming convention Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/170e51c8 Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/170e51c8 Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/170e51c8 Branch: refs/heads/master Commit: 170e51c89beae2a4c8db9b1f572217b26f776ca7 Parents: b295321 Author: Sebb <[email protected]> Authored: Tue Jun 28 10:20:53 2016 +0100 Committer: Sebb <[email protected]> Committed: Tue Jun 28 10:20:53 2016 +0100 ---------------------------------------------------------------------- .../commons/crypto/random/CryptoRandomTest.java | 131 +++++++++++++++++++ .../crypto/random/JavaCryptoRandomTest.java | 42 ++++++ .../crypto/random/OpensslCryptoRandomTest.java | 42 ++++++ .../crypto/random/OsCryptoRandomTest.java | 42 ++++++ .../commons/crypto/random/TestCryptoRandom.java | 131 ------------------- .../crypto/random/TestJavaCryptoRandom.java | 42 ------ .../crypto/random/TestOpensslCryptoRandom.java | 42 ------ .../crypto/random/TestOsCryptoRandom.java | 42 ------ 8 files changed, 257 insertions(+), 257 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/170e51c8/src/test/java/org/apache/commons/crypto/random/CryptoRandomTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/random/CryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/CryptoRandomTest.java new file mode 100644 index 0000000..9f451a7 --- /dev/null +++ b/src/test/java/org/apache/commons/crypto/random/CryptoRandomTest.java @@ -0,0 +1,131 @@ +/** + * 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.random; + +import static org.junit.Assert.assertTrue; + +import java.util.Properties; + +import org.apache.commons.crypto.conf.ConfigurationKeys; +import org.junit.Test; + +public class CryptoRandomTest { + + @Test(expected=NullPointerException.class) + public void testNull() throws Exception { + CryptoRandomFactory.getCryptoRandom(null); + } + + @Test + public void testEmpty() throws Exception { + final Properties props = new Properties(); + props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, ""); + CryptoRandomFactory.getCryptoRandom(props); + } + + @Test + public void testEmptyFallback() throws Exception { + final Properties props = new Properties(); + props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, ""); + props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, ""); + CryptoRandomFactory.getCryptoRandom(props); + } + + @Test + public void testTrueFallback() throws Exception { + final Properties props = new Properties(); + props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, ""); + props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "true"); + CryptoRandomFactory.getCryptoRandom(props); + } + + @Test(expected=IllegalArgumentException.class) + public void testFalseFallbackEmpty() throws Exception { + final Properties props = new Properties(); + props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, ""); + props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "notTrue"); + CryptoRandomFactory.getCryptoRandom(props); + } + + @Test(expected=IllegalArgumentException.class) + public void testFalseFallbackNoNames() throws Exception { + final Properties props = new Properties(); + props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, ",,,,"); + props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "notTrue"); + CryptoRandomFactory.getCryptoRandom(props); + } + + @Test + public void testNoSuchClass() throws Exception { + final Properties props = new Properties(); + props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, "noSuchClass"); + props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "notTrue"); + try { + CryptoRandomFactory.getCryptoRandom(props); + } catch (Exception e) { + final String message = e.getMessage(); + assertTrue(message, message.contains("not found")); + assertTrue(message, message.contains("noSuchClass")); + } + } + + @Test + public void testWrongClass() throws Exception { + final Properties props = new Properties(); + props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, "java.util.Properties"); // Use a class that accepts a Properties object + props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "notTrue"); + try { + CryptoRandomFactory.getCryptoRandom(props); + } catch (Exception e) { + final String message = e.getMessage(); + assertTrue(message, message.contains("java.util.Properties")); + assertTrue(message, message.contains("not a CryptoRandom")); + } + } + + @Test + public void testWrongClassBadCtor() throws Exception { + final Properties props = new Properties(); + final String canonicalName = DummyRandom.class.getCanonicalName(); + props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, canonicalName); + props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "notTrue"); + try { + CryptoRandomFactory.getCryptoRandom(props); + } catch (Exception e) { + final String message = e.getMessage(); + assertTrue(message, message.contains(canonicalName)); + assertTrue(message, message.contains("NoSuchMethodException")); + } + } + + @Test + public void testAbstractClass() throws Exception { + final Properties props = new Properties(); + final String canonicalName = AbstractRandom.class.getCanonicalName(); + props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, canonicalName); + props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "notTrue"); + try { + CryptoRandomFactory.getCryptoRandom(props); + } catch (Exception e) { + final String message = e.getMessage(); + assertTrue(message, message.contains(canonicalName)); + assertTrue(message, message.contains("NoSuchMethodException")); + } + } + +} http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/170e51c8/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java new file mode 100644 index 0000000..972a66a --- /dev/null +++ b/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java @@ -0,0 +1,42 @@ +/** + * 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.random; + +import java.security.GeneralSecurityException; +import java.util.Properties; + +import org.apache.commons.crypto.conf.ConfigurationKeys; +import static org.junit.Assert.fail; + +public class JavaCryptoRandomTest extends AbstractRandomTest { + + @Override + public CryptoRandom getCryptoRandom() throws GeneralSecurityException { + Properties props = new Properties(); + props.setProperty( + ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, + JavaCryptoRandom.class.getName()); + CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props); + if (!(random instanceof JavaCryptoRandom)) { + fail("The CryptoRandom should be: " + + JavaCryptoRandom.class.getName()); + } + return random; + } + +} http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/170e51c8/src/test/java/org/apache/commons/crypto/random/OpensslCryptoRandomTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/random/OpensslCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/OpensslCryptoRandomTest.java new file mode 100644 index 0000000..973da72 --- /dev/null +++ b/src/test/java/org/apache/commons/crypto/random/OpensslCryptoRandomTest.java @@ -0,0 +1,42 @@ +/** + * 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.random; + +import java.security.GeneralSecurityException; +import java.util.Properties; + +import org.apache.commons.crypto.conf.ConfigurationKeys; +import static org.junit.Assert.fail; + +public class OpensslCryptoRandomTest extends AbstractRandomTest { + + @Override + public CryptoRandom getCryptoRandom() throws GeneralSecurityException { + Properties props = new Properties(); + props.setProperty( + ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, + OpensslCryptoRandom.class.getName()); + CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props); + if (!(random instanceof OpensslCryptoRandom)) { + fail("The CryptoRandom should be: " + + OpensslCryptoRandom.class.getName()); + } + return random; + } + +} http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/170e51c8/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java new file mode 100644 index 0000000..a284825 --- /dev/null +++ b/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java @@ -0,0 +1,42 @@ +/** + * 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.random; + +import static org.junit.Assert.fail; + +import java.security.GeneralSecurityException; +import java.util.Properties; + +import org.apache.commons.crypto.conf.ConfigurationKeys; + +public class OsCryptoRandomTest extends AbstractRandomTest { + + @Override + public CryptoRandom getCryptoRandom() throws GeneralSecurityException { + Properties props = new Properties(); + props.setProperty( + ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, + OsCryptoRandom.class.getName()); + CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props); + if (!(random instanceof OsCryptoRandom)) { + fail("The CryptoRandom should be: " + + OsCryptoRandom.class.getName()); + } + return random; + } +} http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/170e51c8/src/test/java/org/apache/commons/crypto/random/TestCryptoRandom.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/random/TestCryptoRandom.java b/src/test/java/org/apache/commons/crypto/random/TestCryptoRandom.java deleted file mode 100644 index d2b1c4c..0000000 --- a/src/test/java/org/apache/commons/crypto/random/TestCryptoRandom.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * 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.random; - -import static org.junit.Assert.assertTrue; - -import java.util.Properties; - -import org.apache.commons.crypto.conf.ConfigurationKeys; -import org.junit.Test; - -public class TestCryptoRandom { - - @Test(expected=NullPointerException.class) - public void testNull() throws Exception { - CryptoRandomFactory.getCryptoRandom(null); - } - - @Test - public void testEmpty() throws Exception { - final Properties props = new Properties(); - props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, ""); - CryptoRandomFactory.getCryptoRandom(props); - } - - @Test - public void testEmptyFallback() throws Exception { - final Properties props = new Properties(); - props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, ""); - props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, ""); - CryptoRandomFactory.getCryptoRandom(props); - } - - @Test - public void testTrueFallback() throws Exception { - final Properties props = new Properties(); - props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, ""); - props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "true"); - CryptoRandomFactory.getCryptoRandom(props); - } - - @Test(expected=IllegalArgumentException.class) - public void testFalseFallbackEmpty() throws Exception { - final Properties props = new Properties(); - props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, ""); - props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "notTrue"); - CryptoRandomFactory.getCryptoRandom(props); - } - - @Test(expected=IllegalArgumentException.class) - public void testFalseFallbackNoNames() throws Exception { - final Properties props = new Properties(); - props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, ",,,,"); - props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "notTrue"); - CryptoRandomFactory.getCryptoRandom(props); - } - - @Test - public void testNoSuchClass() throws Exception { - final Properties props = new Properties(); - props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, "noSuchClass"); - props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "notTrue"); - try { - CryptoRandomFactory.getCryptoRandom(props); - } catch (Exception e) { - final String message = e.getMessage(); - assertTrue(message, message.contains("not found")); - assertTrue(message, message.contains("noSuchClass")); - } - } - - @Test - public void testWrongClass() throws Exception { - final Properties props = new Properties(); - props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, "java.util.Properties"); // Use a class that accepts a Properties object - props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "notTrue"); - try { - CryptoRandomFactory.getCryptoRandom(props); - } catch (Exception e) { - final String message = e.getMessage(); - assertTrue(message, message.contains("java.util.Properties")); - assertTrue(message, message.contains("not a CryptoRandom")); - } - } - - @Test - public void testWrongClassBadCtor() throws Exception { - final Properties props = new Properties(); - final String canonicalName = DummyRandom.class.getCanonicalName(); - props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, canonicalName); - props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "notTrue"); - try { - CryptoRandomFactory.getCryptoRandom(props); - } catch (Exception e) { - final String message = e.getMessage(); - assertTrue(message, message.contains(canonicalName)); - assertTrue(message, message.contains("NoSuchMethodException")); - } - } - - @Test - public void testAbstractClass() throws Exception { - final Properties props = new Properties(); - final String canonicalName = AbstractRandom.class.getCanonicalName(); - props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, canonicalName); - props.setProperty(ConfigurationKeys.ENABLE_FALLBACK_ON_NATIVE_FAILED_KEY, "notTrue"); - try { - CryptoRandomFactory.getCryptoRandom(props); - } catch (Exception e) { - final String message = e.getMessage(); - assertTrue(message, message.contains(canonicalName)); - assertTrue(message, message.contains("NoSuchMethodException")); - } - } - -} http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/170e51c8/src/test/java/org/apache/commons/crypto/random/TestJavaCryptoRandom.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/random/TestJavaCryptoRandom.java b/src/test/java/org/apache/commons/crypto/random/TestJavaCryptoRandom.java deleted file mode 100644 index ba2681f..0000000 --- a/src/test/java/org/apache/commons/crypto/random/TestJavaCryptoRandom.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * 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.random; - -import java.security.GeneralSecurityException; -import java.util.Properties; - -import org.apache.commons.crypto.conf.ConfigurationKeys; -import static org.junit.Assert.fail; - -public class TestJavaCryptoRandom extends AbstractRandomTest { - - @Override - public CryptoRandom getCryptoRandom() throws GeneralSecurityException { - Properties props = new Properties(); - props.setProperty( - ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, - JavaCryptoRandom.class.getName()); - CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props); - if (!(random instanceof JavaCryptoRandom)) { - fail("The CryptoRandom should be: " - + JavaCryptoRandom.class.getName()); - } - return random; - } - -} http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/170e51c8/src/test/java/org/apache/commons/crypto/random/TestOpensslCryptoRandom.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/random/TestOpensslCryptoRandom.java b/src/test/java/org/apache/commons/crypto/random/TestOpensslCryptoRandom.java deleted file mode 100644 index f6d587d..0000000 --- a/src/test/java/org/apache/commons/crypto/random/TestOpensslCryptoRandom.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * 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.random; - -import java.security.GeneralSecurityException; -import java.util.Properties; - -import org.apache.commons.crypto.conf.ConfigurationKeys; -import static org.junit.Assert.fail; - -public class TestOpensslCryptoRandom extends AbstractRandomTest { - - @Override - public CryptoRandom getCryptoRandom() throws GeneralSecurityException { - Properties props = new Properties(); - props.setProperty( - ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, - OpensslCryptoRandom.class.getName()); - CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props); - if (!(random instanceof OpensslCryptoRandom)) { - fail("The CryptoRandom should be: " - + OpensslCryptoRandom.class.getName()); - } - return random; - } - -} http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/170e51c8/src/test/java/org/apache/commons/crypto/random/TestOsCryptoRandom.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/random/TestOsCryptoRandom.java b/src/test/java/org/apache/commons/crypto/random/TestOsCryptoRandom.java deleted file mode 100644 index fe04203..0000000 --- a/src/test/java/org/apache/commons/crypto/random/TestOsCryptoRandom.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * 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.random; - -import static org.junit.Assert.fail; - -import java.security.GeneralSecurityException; -import java.util.Properties; - -import org.apache.commons.crypto.conf.ConfigurationKeys; - -public class TestOsCryptoRandom extends AbstractRandomTest { - - @Override - public CryptoRandom getCryptoRandom() throws GeneralSecurityException { - Properties props = new Properties(); - props.setProperty( - ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, - OsCryptoRandom.class.getName()); - CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props); - if (!(random instanceof OsCryptoRandom)) { - fail("The CryptoRandom should be: " - + OsCryptoRandom.class.getName()); - } - return random; - } -}
