Author: kwall Date: Wed Jan 14 19:46:08 2015 New Revision: 1651787 URL: http://svn.apache.org/r1651787 Log: QPID-6304: [Java Broker] Remove now redundant FileKeyStoreCreationTest/FileTrustStoreCreationTest
* These test cases seemed to be testing features of the core model rather than anything specific to keystores/truststore. The core model is tested by the AbstractConfiguredObject tests. Removed: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileKeyStoreCreationTest.java qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/FileTrustStoreCreationTest.java Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/FileKeyStoreTest.java qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/FileTrustStoreTest.java Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/FileKeyStoreTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/FileKeyStoreTest.java?rev=1651787&r1=1651786&r2=1651787&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/FileKeyStoreTest.java (original) +++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/FileKeyStoreTest.java Wed Jan 14 19:46:08 2015 @@ -32,10 +32,14 @@ import javax.net.ssl.KeyManager; import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor; +import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.BrokerModel; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectFactory; import org.apache.qpid.server.model.IntegrityViolationException; +import org.apache.qpid.server.model.KeyStore; +import org.apache.qpid.server.model.Model; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.security.access.Operation; import org.apache.qpid.test.utils.QpidTestCase; @@ -46,17 +50,18 @@ import org.apache.qpid.util.FileUtils; public class FileKeyStoreTest extends QpidTestCase { private final Broker<?> _broker = mock(Broker.class); - private final CurrentThreadTaskExecutor _taskExecutor = new CurrentThreadTaskExecutor(); + private final TaskExecutor _taskExecutor = CurrentThreadTaskExecutor.newStartedInstance(); private final SecurityManager _securityManager = mock(SecurityManager.class); + private final Model _model = BrokerModel.getInstance(); + private final ConfiguredObjectFactory _factory = _model.getObjectFactory(); + public void setUp() throws Exception { super.setUp(); - _taskExecutor.start(); when(_broker.getTaskExecutor()).thenReturn(_taskExecutor); - when(_broker.getModel()).thenReturn(BrokerModel.getInstance()); - + when(_broker.getModel()).thenReturn(_model); when(_broker.getSecurityManager()).thenReturn(_securityManager); } @@ -67,9 +72,7 @@ public class FileKeyStoreTest extends Qp attributes.put(FileKeyStore.PATH, TestSSLConstants.BROKER_KEYSTORE); attributes.put(FileKeyStore.PASSWORD, TestSSLConstants.BROKER_KEYSTORE_PASSWORD); - FileKeyStoreImpl fileKeyStore = new FileKeyStoreImpl(attributes, _broker); - - fileKeyStore.create(); + FileKeyStoreImpl fileKeyStore = (FileKeyStoreImpl) _factory.create(KeyStore.class, attributes, _broker); KeyManager[] keyManager = fileKeyStore.getKeyManagers(); assertNotNull(keyManager); @@ -85,9 +88,7 @@ public class FileKeyStoreTest extends Qp attributes.put(FileKeyStore.PASSWORD, TestSSLConstants.BROKER_KEYSTORE_PASSWORD); attributes.put(FileKeyStore.CERTIFICATE_ALIAS, TestSSLConstants.BROKER_KEYSTORE_ALIAS); - FileKeyStoreImpl fileKeyStore = new FileKeyStoreImpl(attributes, _broker); - - fileKeyStore.create(); + FileKeyStoreImpl fileKeyStore = (FileKeyStoreImpl) _factory.create(KeyStore.class, attributes, _broker); KeyManager[] keyManager = fileKeyStore.getKeyManagers(); assertNotNull(keyManager); @@ -102,11 +103,9 @@ public class FileKeyStoreTest extends Qp attributes.put(FileKeyStore.PATH, TestSSLConstants.BROKER_KEYSTORE); attributes.put(FileKeyStore.PASSWORD, "wrong"); - FileKeyStoreImpl fileKeyStore = new FileKeyStoreImpl(attributes, _broker); - try { - fileKeyStore.create(); + _factory.create(KeyStore.class, attributes, _broker); fail("Exception not thrown"); } catch (IllegalConfigurationException ice) @@ -124,11 +123,9 @@ public class FileKeyStoreTest extends Qp attributes.put(FileKeyStore.PASSWORD, TestSSLConstants.KEYSTORE_PASSWORD); attributes.put(FileKeyStore.CERTIFICATE_ALIAS, "notknown"); - FileKeyStoreImpl fileKeyStore = new FileKeyStoreImpl(attributes, _broker); - try { - fileKeyStore.create(); + _factory.create(KeyStore.class, attributes, _broker); fail("Exception not thrown"); } catch (IllegalConfigurationException ice) @@ -147,9 +144,7 @@ public class FileKeyStoreTest extends Qp attributes.put(FileKeyStore.PATH, trustStoreAsDataUrl); attributes.put(FileKeyStore.PASSWORD, TestSSLConstants.BROKER_KEYSTORE_PASSWORD); - FileKeyStoreImpl fileKeyStore = new FileKeyStoreImpl(attributes, _broker); - - fileKeyStore.create(); + FileKeyStoreImpl fileKeyStore = (FileKeyStoreImpl) _factory.create(KeyStore.class, attributes, _broker); KeyManager[] keyManagers = fileKeyStore.getKeyManagers(); assertNotNull(keyManagers); @@ -167,9 +162,7 @@ public class FileKeyStoreTest extends Qp attributes.put(FileKeyStore.PASSWORD, TestSSLConstants.BROKER_KEYSTORE_PASSWORD); attributes.put(FileKeyStore.CERTIFICATE_ALIAS, TestSSLConstants.BROKER_KEYSTORE_ALIAS); - FileKeyStoreImpl fileKeyStore = new FileKeyStoreImpl(attributes, _broker); - - fileKeyStore.create(); + FileKeyStoreImpl fileKeyStore = (FileKeyStoreImpl) _factory.create(KeyStore.class, attributes, _broker); KeyManager[] keyManagers = fileKeyStore.getKeyManagers(); assertNotNull(keyManagers); @@ -186,12 +179,9 @@ public class FileKeyStoreTest extends Qp attributes.put(FileKeyStore.PASSWORD, "wrong"); attributes.put(FileKeyStore.PATH, keyStoreAsDataUrl); - FileKeyStoreImpl fileKeyStore = new FileKeyStoreImpl(attributes, _broker); - try { - - fileKeyStore.create(); + _factory.create(KeyStore.class, attributes, _broker); fail("Exception not thrown"); } catch (IllegalConfigurationException ice) @@ -210,11 +200,9 @@ public class FileKeyStoreTest extends Qp attributes.put(FileKeyStore.PASSWORD, TestSSLConstants.BROKER_KEYSTORE_PASSWORD); attributes.put(FileKeyStore.PATH, keyStoreAsDataUrl); - FileKeyStoreImpl fileKeyStore = new FileKeyStoreImpl(attributes, _broker); - try { - fileKeyStore.create(); + _factory.create(KeyStore.class, attributes, _broker); fail("Exception not thrown"); } catch (IllegalConfigurationException ice) @@ -235,11 +223,9 @@ public class FileKeyStoreTest extends Qp attributes.put(FileKeyStore.PATH, keyStoreAsDataUrl); attributes.put(FileKeyStore.CERTIFICATE_ALIAS, "notknown"); - FileKeyStoreImpl fileKeyStore = new FileKeyStoreImpl(attributes, _broker); - try { - fileKeyStore.create(); + _factory.create(KeyStore.class, attributes, _broker); fail("Exception not thrown"); } catch (IllegalConfigurationException ice) @@ -259,9 +245,7 @@ public class FileKeyStoreTest extends Qp attributes.put(FileKeyStore.PATH, TestSSLConstants.BROKER_KEYSTORE); attributes.put(FileKeyStore.PASSWORD, TestSSLConstants.BROKER_KEYSTORE_PASSWORD); - FileKeyStoreImpl fileKeyStore = new FileKeyStoreImpl(attributes, _broker); - - fileKeyStore.create(); + FileKeyStoreImpl fileKeyStore = (FileKeyStoreImpl) _factory.create(KeyStore.class, attributes, _broker); assertNull("Unexpected alias value before change", fileKeyStore.getCertificateAlias()); @@ -302,9 +286,8 @@ public class FileKeyStoreTest extends Qp attributes.put(FileKeyStore.PATH, TestSSLConstants.BROKER_KEYSTORE); attributes.put(FileKeyStore.PASSWORD, TestSSLConstants.BROKER_KEYSTORE_PASSWORD); - FileKeyStoreImpl fileKeyStore = new FileKeyStoreImpl(attributes, _broker); + FileKeyStoreImpl fileKeyStore = (FileKeyStoreImpl) _factory.create(KeyStore.class, attributes, _broker); - fileKeyStore.create(); fileKeyStore.delete(); } @@ -319,9 +302,7 @@ public class FileKeyStoreTest extends Qp attributes.put(FileKeyStore.PATH, TestSSLConstants.BROKER_KEYSTORE); attributes.put(FileKeyStore.PASSWORD, TestSSLConstants.BROKER_KEYSTORE_PASSWORD); - FileKeyStoreImpl fileKeyStore = new FileKeyStoreImpl(attributes, _broker); - - fileKeyStore.create(); + FileKeyStoreImpl fileKeyStore = (FileKeyStoreImpl) _factory.create(KeyStore.class, attributes, _broker); Port<?> port = mock(Port.class); when(port.getKeyStore()).thenReturn(fileKeyStore); Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/FileTrustStoreTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/FileTrustStoreTest.java?rev=1651787&r1=1651786&r2=1651787&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/FileTrustStoreTest.java (original) +++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/FileTrustStoreTest.java Wed Jan 14 19:46:08 2015 @@ -33,11 +33,14 @@ import javax.net.ssl.TrustManager; import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor; +import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.model.AuthenticationProvider; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.BrokerModel; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectFactory; import org.apache.qpid.server.model.IntegrityViolationException; +import org.apache.qpid.server.model.Model; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.TrustStore; import org.apache.qpid.server.security.access.Operation; @@ -51,18 +54,19 @@ import org.apache.qpid.util.FileUtils; public class FileTrustStoreTest extends QpidTestCase { private final Broker<?> _broker = mock(Broker.class); - private final CurrentThreadTaskExecutor _taskExecutor = new CurrentThreadTaskExecutor(); + private final TaskExecutor _taskExecutor = CurrentThreadTaskExecutor.newStartedInstance(); private final SecurityManager _securityManager = mock(SecurityManager.class); + private final Model _model = BrokerModel.getInstance(); + private final ConfiguredObjectFactory _factory = _model.getObjectFactory(); public void setUp() throws Exception { super.setUp(); - _taskExecutor.start(); when(_broker.getTaskExecutor()).thenReturn(_taskExecutor); - when(_broker.getModel()).thenReturn(BrokerModel.getInstance()); - + when(_broker.getModel()).thenReturn(_model); when(_broker.getSecurityManager()).thenReturn(_securityManager); + } public void testCreateTrustStoreFromFile_Success() throws Exception @@ -72,9 +76,8 @@ public class FileTrustStoreTest extends attributes.put(FileTrustStore.PATH, TestSSLConstants.TRUSTSTORE); attributes.put(FileTrustStore.PASSWORD, TestSSLConstants.TRUSTSTORE_PASSWORD); - FileTrustStoreImpl fileTrustStore = new FileTrustStoreImpl(attributes, _broker); - - fileTrustStore.create(); + FileTrustStoreImpl fileTrustStore = + (FileTrustStoreImpl) _factory.create(TrustStore.class, attributes, _broker); TrustManager[] trustManagers = fileTrustStore.getTrustManagers(); assertNotNull(trustManagers); @@ -89,11 +92,9 @@ public class FileTrustStoreTest extends attributes.put(FileTrustStore.PATH, TestSSLConstants.TRUSTSTORE); attributes.put(FileTrustStore.PASSWORD, "wrong"); - FileTrustStoreImpl fileTrustStore = new FileTrustStoreImpl(attributes, _broker); - try { - fileTrustStore.create(); + _factory.create(TrustStore.class, attributes, _broker); fail("Exception not thrown"); } catch (IllegalConfigurationException ice) @@ -111,9 +112,8 @@ public class FileTrustStoreTest extends attributes.put(FileTrustStore.PASSWORD, TestSSLConstants.BROKER_PEERSTORE_PASSWORD); attributes.put(FileTrustStore.PEERS_ONLY, true); - FileTrustStoreImpl fileTrustStore = new FileTrustStoreImpl(attributes, _broker); - - fileTrustStore.create(); + FileTrustStoreImpl fileTrustStore = + (FileTrustStoreImpl) _factory.create(TrustStore.class, attributes, _broker); TrustManager[] trustManagers = fileTrustStore.getTrustManagers(); assertNotNull(trustManagers); @@ -132,9 +132,8 @@ public class FileTrustStoreTest extends attributes.put(FileTrustStore.PATH, trustStoreAsDataUrl); attributes.put(FileTrustStore.PASSWORD, TestSSLConstants.TRUSTSTORE_PASSWORD); - FileTrustStoreImpl fileTrustStore = new FileTrustStoreImpl(attributes, _broker); - - fileTrustStore.create(); + FileTrustStoreImpl fileTrustStore = + (FileTrustStoreImpl) _factory.create(TrustStore.class, attributes, _broker); TrustManager[] trustManagers = fileTrustStore.getTrustManagers(); assertNotNull(trustManagers); @@ -151,12 +150,9 @@ public class FileTrustStoreTest extends attributes.put(FileTrustStore.PASSWORD, "wrong"); attributes.put(FileTrustStore.PATH, trustStoreAsDataUrl); - FileTrustStoreImpl fileTrustStore = new FileTrustStoreImpl(attributes, _broker); - try { - - fileTrustStore.create(); + _factory.create(TrustStore.class, attributes, _broker); fail("Exception not thrown"); } catch (IllegalConfigurationException ice) @@ -175,11 +171,9 @@ public class FileTrustStoreTest extends attributes.put(FileTrustStore.PASSWORD, TestSSLConstants.TRUSTSTORE_PASSWORD); attributes.put(FileTrustStore.PATH, trustStoreAsDataUrl); - FileTrustStoreImpl fileTrustStore = new FileTrustStoreImpl(attributes, _broker); - try { - fileTrustStore.create(); + _factory.create(TrustStore.class, attributes, _broker); fail("Exception not thrown"); } catch (IllegalConfigurationException ice) @@ -200,9 +194,8 @@ public class FileTrustStoreTest extends attributes.put(FileTrustStore.PATH, TestSSLConstants.TRUSTSTORE); attributes.put(FileTrustStore.PASSWORD, TestSSLConstants.TRUSTSTORE_PASSWORD); - FileTrustStoreImpl fileTrustStore = new FileTrustStoreImpl(attributes, _broker); - - fileTrustStore.create(); + FileTrustStoreImpl fileTrustStore = + (FileTrustStoreImpl) _factory.create(TrustStore.class, attributes, _broker); assertEquals("Unexpected path value before change", TestSSLConstants.TRUSTSTORE, fileTrustStore.getPath()); @@ -243,9 +236,9 @@ public class FileTrustStoreTest extends attributes.put(FileTrustStore.PATH, TestSSLConstants.TRUSTSTORE); attributes.put(FileTrustStore.PASSWORD, TestSSLConstants.TRUSTSTORE_PASSWORD); - FileTrustStoreImpl fileTrustStore = new FileTrustStoreImpl(attributes, _broker); + FileTrustStoreImpl fileTrustStore = + (FileTrustStoreImpl) _factory.create(TrustStore.class, attributes, _broker); - fileTrustStore.create(); fileTrustStore.delete(); } @@ -260,9 +253,8 @@ public class FileTrustStoreTest extends attributes.put(FileTrustStore.PATH, TestSSLConstants.TRUSTSTORE); attributes.put(FileTrustStore.PASSWORD, TestSSLConstants.TRUSTSTORE_PASSWORD); - FileTrustStoreImpl fileTrustStore = new FileTrustStoreImpl(attributes, _broker); - - fileTrustStore.create(); + FileTrustStoreImpl fileTrustStore = + (FileTrustStoreImpl) _factory.create(TrustStore.class, attributes, _broker); SimpleLDAPAuthenticationManager ldap = mock(SimpleLDAPAuthenticationManager.class); when(ldap.getTrustStore()).thenReturn(fileTrustStore); @@ -292,9 +284,8 @@ public class FileTrustStoreTest extends attributes.put(FileTrustStore.PATH, TestSSLConstants.TRUSTSTORE); attributes.put(FileTrustStore.PASSWORD, TestSSLConstants.TRUSTSTORE_PASSWORD); - FileTrustStoreImpl fileTrustStore = new FileTrustStoreImpl(attributes, _broker); - - fileTrustStore.create(); + FileTrustStoreImpl fileTrustStore = + (FileTrustStoreImpl) _factory.create(TrustStore.class, attributes, _broker); Port<?> port = mock(Port.class); when(port.getTrustStores()).thenReturn(Collections.<TrustStore>singletonList(fileTrustStore)); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org