Repository: ambari
Updated Branches:
  refs/heads/trunk 133381bac -> aebd5c0b3


AMBARI-8418.  Stack service version is now inherited by child service


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

Branch: refs/heads/trunk
Commit: aebd5c0b3ff005435e2fbd404c338e31fb118f26
Parents: 133381b
Author: Jayush Luniya <[email protected]>
Authored: Wed Nov 26 16:23:02 2014 -0500
Committer: John Speidel <[email protected]>
Committed: Wed Nov 26 16:27:26 2014 -0500

----------------------------------------------------------------------
 .../ambari/server/stack/ServiceModule.java      |  3 +++
 .../ambari/server/stack/ServiceModuleTest.java  | 27 ++++++++++++++++++++
 2 files changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aebd5c0b/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java 
b/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
index 279361b..e95e767 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
@@ -101,6 +101,9 @@ public class ServiceModule extends 
BaseModule<ServiceModule, ServiceInfo> {
     if (serviceInfo.getDisplayName() == null) {
       serviceInfo.setDisplayName(parent.getDisplayName());
     }
+    if (serviceInfo.getVersion() == null) {
+      serviceInfo.setVersion(parent.getVersion());
+    }
 
     if (serviceInfo.getRequiredServices() == null) {
       serviceInfo.setRequiredServices(parent.getRequiredServices() != null ?

http://git-wip-us.apache.org/repos/asf/ambari/blob/aebd5c0b/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
index 225213f..529def5 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
@@ -104,6 +104,33 @@ public class ServiceModuleTest {
   }
 
   @Test
+  public void testResolve_Version() throws Exception {
+    String version = "1.1";
+
+    // specified in child only
+    ServiceInfo info = new ServiceInfo();
+    ServiceInfo parentInfo = new ServiceInfo();
+    info.setVersion(version);
+
+    ServiceModule service = resolveService(info, parentInfo);
+    assertEquals(version, service.getModuleInfo().getVersion());
+
+    // specified in parent only
+    info.setVersion(null);
+    parentInfo.setVersion(version);
+
+    service = resolveService(info, parentInfo);
+    assertEquals(version, service.getModuleInfo().getVersion());
+
+    // specified in both
+    info.setVersion(version);
+    parentInfo.setVersion("1.0");
+
+    service = resolveService(info, parentInfo);
+    assertEquals(version, service.getModuleInfo().getVersion());
+  }
+
+  @Test
   public void testResolve_RequiredServices() throws Exception {
     List<String> requiredServices = new ArrayList<String>();
     requiredServices.add("foo");

Reply via email to