From c8e3b161e1e10753e53fbf1800bcc6e066e3d3b8 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 2 Jul 2014 16:37:32 +0200 Subject: [PATCH] TLS unit test resources moved from src/main/resources to test/main/resources - TLS unit tests access resources via classpath (not relative path) Signed-off-by: Michal Polkorab --- .../core/PublishingChannelInitializerTest.java | 4 ++-- .../impl/core/SslContextFactoryTest.java | 4 ++-- .../protocol/impl/core/SslKeyStoreTest.java | 15 +++++++++++++-- .../src/{main => test}/resources/key.bin | Bin .../protocol/it/integration/IntegrationTest.java | 4 ++-- 5 files changed, 19 insertions(+), 8 deletions(-) rename openflow-protocol-impl/src/{main => test}/resources/key.bin (100%) diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java index 55b13552..6666da3d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java @@ -91,8 +91,8 @@ public class PublishingChannelInitializerTest { when(mockSwConnHandler.accept(eq(InetAddress.getLocalHost()))).thenReturn(true) ; when(mockSocketCh.pipeline()).thenReturn(mockChPipeline) ; - tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "src/main/resources/selfSignedSwitch", PathType.PATH, - KeystoreType.JKS, "src/main/resources/selfSignedController", PathType.PATH); + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH, + KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java index 2457fd33..2c45c0b0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java @@ -35,8 +35,8 @@ public class SslContextFactoryTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); - tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "src/main/resources/ctlTrustStore", - PathType.PATH, KeystoreType.JKS, "src/main/resources/ctlKeystore", PathType.PATH) ; + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/ctlTrustStore", + PathType.CLASSPATH, KeystoreType.JKS, "/ctlKeystore", PathType.CLASSPATH) ; sslContextFactory = new SslContextFactory(tlsConfiguration); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java index 7c871bbd..c75fdee9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java @@ -33,12 +33,23 @@ public class SslKeyStoreTest { } /** - * Test keystore file access + * Test keystore file access - via classpath * @throws Exception */ @Test public void testAsInputStream() throws Exception { - InputStream inputStream = SslKeyStore.asInputStream("src/main/resources/key.bin", PathType.PATH); + InputStream inputStream = SslKeyStore.asInputStream("/key.bin", PathType.CLASSPATH); + assertNotNull( inputStream ); + inputStream.close(); + } + + /** + * Test keystore file access - via relative path + * @throws Exception + */ + @Test + public void testAsInputStream2() throws Exception { + InputStream inputStream = SslKeyStore.asInputStream("src/test/resources/key.bin", PathType.PATH); assertNotNull( inputStream ); inputStream.close(); } diff --git a/openflow-protocol-impl/src/main/resources/key.bin b/openflow-protocol-impl/src/test/resources/key.bin similarity index 100% rename from openflow-protocol-impl/src/main/resources/key.bin rename to openflow-protocol-impl/src/test/resources/key.bin diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index 8a391dfa..597ac978 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -64,8 +64,8 @@ public class IntegrationTest { startupAddress = InetAddress.getLocalHost(); if (secured) { tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, - "../openflow-protocol-impl/src/main/resources/selfSignedSwitch", PathType.PATH, KeystoreType.JKS, - "../openflow-protocol-impl/src/main/resources/selfSignedController", PathType.PATH) ; + "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, + "/selfSignedController", PathType.CLASSPATH) ; connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); } else { connConfig = new ConnectionConfigurationImpl(startupAddress, 0, null, SWITCH_IDLE_TIMEOUT); -- 2.36.6