cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ko...@apache.org
Subject [2/2] git commit: updated refs/heads/4.3 to 9f4c461
Date Wed, 13 Nov 2013 21:29:44 GMT
Add assumtion on OpenJDK for tests that build on JCE

This patch adds an assumption that OpenJDK is used in some of the tests.
OpenJDK detection utility also added. By specifying -Dcloudstack.jce.enabled=true in the test
parameters the OpenJDK detection can be overridden.

Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9f4c4612
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9f4c4612
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9f4c4612

Branch: refs/heads/4.3
Commit: 9f4c46126f5750af5e6cce883b8622e158fe6bf0
Parents: 9a3d32d
Author: Laszlo Hornyak <laszlo.hornyak@gmail.com>
Authored: Tue Nov 12 20:22:44 2013 +0100
Committer: Laszlo Hornyak <laszlo.hornyak@gmail.com>
Committed: Wed Nov 13 22:28:51 2013 +0100

----------------------------------------------------------------------
 .../cloudstack/network/lb/CertServiceTest.java  | 76 ++++++++++++++------
 1 file changed, 53 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f4c4612/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java b/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java
index 97c8b7b..a37e626 100644
--- a/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java
+++ b/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java
@@ -16,21 +16,13 @@
 // under the License.
 package org.apache.cloudstack.network.lb;
 
-import com.cloud.network.dao.*;
-import com.cloud.user.Account;
-import com.cloud.user.AccountManager;
-import com.cloud.user.AccountVO;
-import com.cloud.user.UserVO;
-import com.cloud.user.dao.AccountDao;
-import com.cloud.utils.db.EntityManager;
-import com.cloud.utils.db.TransactionLegacy;
-import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd;
-import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd;
-import org.apache.cloudstack.context.CallContext;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
+import static org.apache.commons.io.FileUtils.readFileToString;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.when;
 
 import java.io.File;
 import java.io.IOException;
@@ -40,11 +32,27 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
 
-import static org.apache.commons.io.FileUtils.readFileToString;
-import static org.mockito.Matchers.*;
-import static org.mockito.Mockito.when;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertTrue;
+import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd;
+import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd;
+import org.apache.cloudstack.context.CallContext;
+import org.junit.After;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.cloud.network.dao.LoadBalancerCertMapDao;
+import com.cloud.network.dao.LoadBalancerCertMapVO;
+import com.cloud.network.dao.LoadBalancerVO;
+import com.cloud.network.dao.SslCertDao;
+import com.cloud.network.dao.SslCertVO;
+import com.cloud.user.Account;
+import com.cloud.user.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.db.EntityManager;
+import com.cloud.utils.db.TransactionLegacy;
 
 public class CertServiceTest {
 
@@ -60,12 +68,30 @@ public class CertServiceTest {
         CallContext.unregister();
     }
 
+    /**
+     * JCE is known to be working fine without additional configuration in OpenJDK.
+     * This checks if the tests are running in OpenJDK;
+     * @return  true if openjdk environment
+     */
+    static boolean isOpenJdk() {
+        //TODO: find a better way for OpenJDK detection
+        return System.getProperty("java.home").toLowerCase().contains("openjdk");
+    }
+
+    /**
+     * One can run the tests on Oracle JDK after installing JCE by specifying -Dcloudstack.jce.enabled=true
+     * @return true if the jce enable property was set to true
+     */
+    static boolean isJCEInstalled() {
+        return Boolean.getBoolean("cloudstack.jce.enabled");
+    }
+    
     @Test
     /**
      * Given a certificate signed by a CA and a valid CA chain, upload should succeed
      */
     public void runUploadSslCertWithCAChain() throws Exception {
-        //To change body of created methods use File | Settings | File Templates.
+        Assume.assumeTrue(isOpenJdk() || isJCEInstalled());
 
         TransactionLegacy txn = TransactionLegacy.open("runUploadSslCertWithCAChain");
 
@@ -218,7 +244,8 @@ public class CertServiceTest {
 
     @Test
     public void runUploadSslCertBadChain()  throws IOException, IllegalAccessException, NoSuchFieldException
{
-        //To change body of created methods use File | Settings | File Templates.
+        Assume.assumeTrue(isOpenJdk() || isJCEInstalled());
+
         String certFile  = getClass().getResource("/certs/rsa_ca_signed.crt").getFile();
         String keyFile   = getClass().getResource("/certs/rsa_ca_signed.key").getFile();
         String chainFile = getClass().getResource("/certs/rsa_self_signed.crt").getFile();
@@ -271,7 +298,8 @@ public class CertServiceTest {
     @Test
     public void runUploadSslCertNoRootCert()  throws IOException, IllegalAccessException,
NoSuchFieldException {
 
-                //To change body of created methods use File | Settings | File Templates.
+        Assume.assumeTrue(isOpenJdk() || isJCEInstalled());
+
         String certFile  = getClass().getResource("/certs/rsa_ca_signed.crt").getFile();
         String keyFile   = getClass().getResource("/certs/rsa_ca_signed.key").getFile();
         String chainFile = getClass().getResource("/certs/rsa_ca_signed2.crt").getFile();
@@ -325,6 +353,8 @@ public class CertServiceTest {
     @Test
     public void runUploadSslCertNoChain() throws IOException, IllegalAccessException, NoSuchFieldException
{
 
+        Assume.assumeTrue(isOpenJdk() || isJCEInstalled());
+        
         String certFile = getClass().getResource("/certs/rsa_ca_signed.crt").getFile();
         String keyFile  = getClass().getResource("/certs/rsa_ca_signed.key").getFile();
         String password = "user";


Mime
View raw message