You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2014/10/01 06:06:02 UTC

[1/3] git commit: Adding Mockito dependency to CC.

Repository: stratos
Updated Branches:
  refs/heads/cc-unit-tests [created] 46d085e30


Adding Mockito dependency to CC.


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/7e9399a4
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/7e9399a4
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/7e9399a4

Branch: refs/heads/cc-unit-tests
Commit: 7e9399a4da8d0daa2e729cd340261609dc46f78e
Parents: 4ed3cda
Author: Nirmal Fernando <ni...@gmail.com>
Authored: Wed Oct 1 09:00:42 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Wed Oct 1 09:00:42 2014 +0530

----------------------------------------------------------------------
 components/org.apache.stratos.cloud.controller/pom.xml | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/7e9399a4/components/org.apache.stratos.cloud.controller/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/pom.xml b/components/org.apache.stratos.cloud.controller/pom.xml
index 59eaa46..feae163 100644
--- a/components/org.apache.stratos.cloud.controller/pom.xml
+++ b/components/org.apache.stratos.cloud.controller/pom.xml
@@ -304,6 +304,12 @@
             <artifactId>org.wso2.carbon.ntask.core</artifactId>
             <version>4.2.0</version>
         </dependency>
+        <dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-all</artifactId>
+			<version>1.9.5</version>
+			<scope>test</scope>
+		</dependency>
     </dependencies>
     <properties>
         <gson2.version>2.2</gson2.version>


[3/3] git commit: Initial version of CC unit tests using Mockito - testDeployCartridgeDefinition#exceptions

Posted by ni...@apache.org.
Initial version of CC unit tests using Mockito - testDeployCartridgeDefinition#exceptions


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/46d085e3
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/46d085e3
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/46d085e3

Branch: refs/heads/cc-unit-tests
Commit: 46d085e30db89aae3dd8a218298b34c7e8145697
Parents: 517f35c
Author: Nirmal Fernando <ni...@gmail.com>
Authored: Wed Oct 1 09:03:42 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Wed Oct 1 09:03:42 2014 +0530

----------------------------------------------------------------------
 .../impl/CloudControllerServiceImplTest.java    | 72 ++++++++++++++++++++
 1 file changed, 72 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/46d085e3/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImplTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImplTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImplTest.java
new file mode 100644
index 0000000..36c82c9
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImplTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.stratos.cloud.controller.impl;
+
+import org.apache.stratos.cloud.controller.exception.InvalidCartridgeDefinitionException;
+import org.apache.stratos.cloud.controller.pojo.CartridgeConfig;
+import org.apache.stratos.cloud.controller.registry.RegistryManager;
+import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
+import org.apache.stratos.cloud.controller.util.ServiceReferenceHolder;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.wso2.carbon.registry.core.session.UserRegistry;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+/**
+ * Testing operations provided by Cloud Controller.
+ */
+public class CloudControllerServiceImplTest {
+	private static RegistryManager registry;
+	private static FasterLookUpDataHolder data ;
+	private static ServiceReferenceHolder serviceRefHolder =
+			ServiceReferenceHolder.getInstance();
+	private static CloudControllerServiceImpl service;
+
+	@BeforeClass
+	public static void setUp(){
+		UserRegistry userReg = mock(UserRegistry.class);
+		serviceRefHolder = mock(ServiceReferenceHolder.class);
+		
+		when(serviceRefHolder.getRegistry()).thenReturn(userReg);
+		
+		registry = mock(RegistryManager.class);
+		when(registry.retrieve()).thenReturn(null);
+		
+		data = mock(FasterLookUpDataHolder.class);
+		
+		service = new CloudControllerServiceImpl(true);
+		
+	}
+	
+	@Test
+	public void testDeployCartridgeDefinition() throws Exception {
+		CartridgeConfig cartridgeConfig = new CartridgeConfig();
+		cartridgeConfig.setType("php");
+		cartridgeConfig.setBaseDir("/tmp");
+		try {
+			service.deployCartridgeDefinition(cartridgeConfig);
+		} catch(Exception e) {
+			assertEquals(InvalidCartridgeDefinitionException.class, e.getClass());
+			assertEquals("Invalid Cartridge Definition: Cartridge Type: php. "
+					+ "Cause: Iaases of this Cartridge is null or empty.", e.getMessage());
+		}
+	}
+}


[2/3] git commit: Adding a constructor to instantiate CC without data acquiring.

Posted by ni...@apache.org.
Adding a constructor to instantiate CC without data acquiring.


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/517f35c0
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/517f35c0
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/517f35c0

Branch: refs/heads/cc-unit-tests
Commit: 517f35c0d8a50f974645560627158c882b1f46c1
Parents: 7e9399a
Author: Nirmal Fernando <ni...@gmail.com>
Authored: Wed Oct 1 09:01:53 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Wed Oct 1 09:01:53 2014 +0530

----------------------------------------------------------------------
 .../cloud/controller/impl/CloudControllerServiceImpl.java   | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/517f35c0/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index 7abc6b7..819d024 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -74,11 +74,18 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 			.getLog(CloudControllerServiceImpl.class);
 	private FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder
 			.getInstance();
-
+	
 	public CloudControllerServiceImpl() {
 		// acquire serialized data from registry
 		acquireData();
 	}
+	
+	/**
+	 * Used for testing.
+	 * @param test set to true
+	 */
+	public CloudControllerServiceImpl(boolean test) {
+	}
 
 	private void acquireData() {