geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r748991 - in /geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src: main/java/org/apache/geronimo/farm/deployment/ test/java/org/apache/geronimo/farm/deployment/
Date Sun, 01 Mar 2009 10:10:15 GMT
Author: gdamour
Date: Sun Mar  1 10:10:15 2009
New Revision: 748991

URL: http://svn.apache.org/viewvc?rev=748991&view=rev
Log:
Do not rename the actual module being deployed to prevent issues with JNDI resource reference
resolutions which use the actual module name.

Name the master module, i.e. the module defining GBeans controlling the farmed module, X_G_MASTER
where X is the name artifact id of the farmed module.

This resolves GERONIMO-4556 - Farm deployment of configurations using JNDI resource references
does not work.

Added:
    geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java
  (contents, props changed)
      - copied, changed from r741976, geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicSlaveConfigurationNameBuilder.java
    geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java
  (contents, props changed)
      - copied, changed from r741976, geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/SlaveConfigurationNameBuilder.java
    geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilderTest.java
  (contents, props changed)
      - copied, changed from r741976, geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicMasterConfigurationNameBuilderTest.java
Removed:
    geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicSlaveConfigurationNameBuilder.java
    geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/SlaveConfigurationNameBuilder.java
    geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicMasterConfigurationNameBuilderTest.java
Modified:
    geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/MasterConfigurationStore.java
    geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/MasterConfigurationStoreTest.java

Copied: geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java
(from r741976, geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicSlaveConfigurationNameBuilder.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java?p2=geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java&p1=geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicSlaveConfigurationNameBuilder.java&r1=741976&r2=748991&rev=748991&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicSlaveConfigurationNameBuilder.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java
Sun Mar  1 10:10:15 2009
@@ -25,18 +25,27 @@
  *
  * @version $Rev:$ $Date:$
  */
-public class BasicSlaveConfigurationNameBuilder implements SlaveConfigurationNameBuilder
{
-    private static final String ARTIFACT_SUFFIX = "_G_SLAVE";
+public class BasicConfigurationNameBuilder implements ConfigurationNameBuilder {
+    private static final String ARTIFACT_SUFFIX = "_G_MASTER";
+
+    public Artifact buildMasterConfigurationName(Artifact configId) {
+        return newArtifact(configId, configId.getArtifactId() + ARTIFACT_SUFFIX);
+    }
 
     public Artifact buildSlaveConfigurationName(Artifact configId) {
-        return new Artifact(configId.getGroupId(),
-            configId.getArtifactId() + ARTIFACT_SUFFIX,
-            configId.getVersion(),
-            configId.getType());
+        if (!isMasterConfigurationName(configId)) {
+            throw new IllegalArgumentException("[" + configId + "] is not a master configuration
name");
+        }
+        String artifactId = configId.getArtifactId();
+        return newArtifact(configId, artifactId.substring(0, artifactId.length() - ARTIFACT_SUFFIX.length()));
     }
     
-    public boolean isSlaveConfigurationName(Artifact configId) {
+    public boolean isMasterConfigurationName(Artifact configId) {
         return configId.getArtifactId().endsWith(ARTIFACT_SUFFIX);
     }
     
+    protected Artifact newArtifact(Artifact configId, String artifactId) {
+        return new Artifact(configId.getGroupId(), artifactId, configId.getVersion(), configId.getType());
+    }
+    
 }

Propchange: geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java
(from r741976, geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/SlaveConfigurationNameBuilder.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java?p2=geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java&p1=geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/SlaveConfigurationNameBuilder.java&r1=741976&r2=748991&rev=748991&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/SlaveConfigurationNameBuilder.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java
Sun Mar  1 10:10:15 2009
@@ -25,8 +25,10 @@
  *
  * @version $Rev:$ $Date:$
  */
-public interface SlaveConfigurationNameBuilder {
+public interface ConfigurationNameBuilder {
+    Artifact buildMasterConfigurationName(Artifact configId);
+
     Artifact buildSlaveConfigurationName(Artifact configId);
 
-    boolean isSlaveConfigurationName(Artifact configId);
+    boolean isMasterConfigurationName(Artifact configId);
 }

Propchange: geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/MasterConfigurationStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/MasterConfigurationStore.java?rev=748991&r1=748990&r2=748991&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/MasterConfigurationStore.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/MasterConfigurationStore.java
Sun Mar  1 10:10:15 2009
@@ -30,8 +30,6 @@
 import java.util.List;
 import java.util.Set;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.geronimo.farm.config.ClusterInfo;
 import org.apache.geronimo.farm.config.NodeInfo;
 import org.apache.geronimo.gbean.AbstractName;
@@ -53,6 +51,8 @@
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.WritableListableRepository;
 import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  *
@@ -67,7 +67,7 @@
     private final ClusterInfo clusterInfo;
     private final AbstractName clusterInfoName;
     private final ClusterConfigurationStoreClient storeDelegate;
-    private final SlaveConfigurationNameBuilder slaveConfigNameBuilder;
+    private final ConfigurationNameBuilder configNameBuilder;
     
     
     public MasterConfigurationStore(@ParamSpecial(type=SpecialAttributeType.kernel) Kernel
kernel,
@@ -94,21 +94,20 @@
         this.clusterInfo = clusterInfo;
         this.storeDelegate = storeDelegate;
 
-        slaveConfigNameBuilder = newSlaveConfigurationNameBuilder();
+        configNameBuilder = newMasterConfigurationNameBuilder();
         clusterInfoName = kernel.getAbstractNameFor(clusterInfo);
         delegate = newConfigurationStore(kernel, objectName, abstractName, repository);
     }
 
     public boolean containsConfiguration(Artifact configId) {
-        if (slaveConfigNameBuilder.isSlaveConfigurationName(configId)) {
+        if (!configNameBuilder.isMasterConfigurationName(configId)) {
             return false;
         }
         return delegate.containsConfiguration(configId);
     }
 
     public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException
{
-        Artifact slaveConfigId = slaveConfigNameBuilder.buildSlaveConfigurationName(configId);
-        return delegate.createNewConfigurationDir(slaveConfigId);
+        return delegate.createNewConfigurationDir(configId);
     }
 
     public void exportConfiguration(Artifact configId, OutputStream output) throws IOException,
NoSuchConfigException {
@@ -125,16 +124,14 @@
     }
 
     public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException
{
-        Environment environment = configurationData.getEnvironment();
-        Artifact actualConfigId = environment.getConfigId();
-        Artifact slaveConfigId = slaveConfigNameBuilder.buildSlaveConfigurationName(actualConfigId);
-        environment.setConfigId(slaveConfigId);
-
         storeDelegate.install(clusterInfo, configurationData);
-        installSlaveConfiguration(configurationData);
 
-        environment.setConfigId(actualConfigId);
+        installSlaveConfiguration(configurationData);
 
+        Environment environment = configurationData.getEnvironment();
+        Artifact slaveConfigId = environment.getConfigId();
+        Artifact masterConfigId = configNameBuilder.buildMasterConfigurationName(slaveConfigId);
+        environment.setConfigId(masterConfigId);
         installMasterConfiguration(configurationData, slaveConfigId);
     }
 
@@ -148,7 +145,7 @@
         
         List<ConfigurationInfo> filteredConfigurationInfos = new ArrayList<ConfigurationInfo>();
         for (ConfigurationInfo configurationInfo : configurationInfos) {
-            if (!slaveConfigNameBuilder.isSlaveConfigurationName(configurationInfo.getConfigID()))
{
+            if (configNameBuilder.isMasterConfigurationName(configurationInfo.getConfigID()))
{
                 filteredConfigurationInfos.add(configurationInfo);
             }
         }
@@ -171,7 +168,7 @@
     public void uninstall(Artifact configId) throws NoSuchConfigException, IOException {
         ensureArtifactForMasterConfiguration(configId);
         
-        Artifact slaveConfigId = slaveConfigNameBuilder.buildSlaveConfigurationName(configId);
+        Artifact slaveConfigId = configNameBuilder.buildSlaveConfigurationName(configId);
         storeDelegate.uninstall(clusterInfo, slaveConfigId);
 
         try {
@@ -183,7 +180,7 @@
     }
 
     protected void ensureArtifactForMasterConfiguration(Artifact configId) throws NoSuchConfigException
{
-        if (slaveConfigNameBuilder.isSlaveConfigurationName(configId)) {
+        if (!configNameBuilder.isMasterConfigurationName(configId)) {
             throw new NoSuchConfigException(configId);
         }
     }
@@ -195,8 +192,8 @@
         return new RepositoryConfigurationStore(kernel, objectName, abstractName, repository);
     }
 
-    protected SlaveConfigurationNameBuilder newSlaveConfigurationNameBuilder() {
-        return new BasicSlaveConfigurationNameBuilder();
+    protected ConfigurationNameBuilder newMasterConfigurationNameBuilder() {
+        return new BasicConfigurationNameBuilder();
     }
 
     protected void installMasterConfiguration(ConfigurationData configurationData, Artifact
slaveConfigId)
@@ -288,8 +285,6 @@
     }
 
     public static final String GBEAN_J2EE_TYPE = "ConfigurationStore";
-    public static final String GBEAN_ATTR_KERNEL = "kernel";
-    public static final String GBEAN_ATTR_OBJECT_NAME = "objectName";
     public static final String GBEAN_ATTR_DEFAULT_ENV = "defaultEnvironment";
     public static final String GBEAN_REF_REPOSITORY = "Repository";
     public static final String GBEAN_REF_CLUSTER_INFO = "ClusterInfo";

Copied: geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilderTest.java
(from r741976, geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicMasterConfigurationNameBuilderTest.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilderTest.java?p2=geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilderTest.java&p1=geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicMasterConfigurationNameBuilderTest.java&r1=741976&r2=748991&rev=748991&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicMasterConfigurationNameBuilderTest.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilderTest.java
Sun Mar  1 10:10:15 2009
@@ -27,29 +27,39 @@
  *
  * @version $Rev:$ $Date:$
  */
-public class BasicMasterConfigurationNameBuilderTest extends TestCase {
+public class BasicConfigurationNameBuilderTest extends TestCase {
 
-    private BasicSlaveConfigurationNameBuilder builder;
+    private BasicConfigurationNameBuilder builder;
 
     @Override
     protected void setUp() throws Exception {
-        builder = new BasicSlaveConfigurationNameBuilder();
+        builder = new BasicConfigurationNameBuilder();
     }
     
-    public void testIsSlaveConfigurationName() throws Exception {
+    public void testIsMasterConfigurationName() throws Exception {
         Artifact artifact = new Artifact("groupId", "artifactId", "2.0", "car");
-        assertFalse(builder.isSlaveConfigurationName(artifact));
-        Artifact masterConfiguration = builder.buildSlaveConfigurationName(artifact);
-        assertTrue(builder.isSlaveConfigurationName(masterConfiguration));
+        assertFalse(builder.isMasterConfigurationName(artifact));
+        Artifact masterConfiguration = builder.buildMasterConfigurationName(artifact);
+        assertTrue(builder.isMasterConfigurationName(masterConfiguration));
     }
     
-    public void testBuildSlaveConfigurationName() throws Exception {
+    public void testBuildMasterConfigurationName() throws Exception {
         Artifact artifact = new Artifact("groupId", "artifactId", "2.0", "car");
-        Artifact masterConfiguration = builder.buildSlaveConfigurationName(artifact);
+        Artifact masterConfiguration = builder.buildMasterConfigurationName(artifact);
         assertEquals(artifact.getGroupId(), masterConfiguration.getGroupId());
-        assertEquals(artifact.getArtifactId() + "_G_SLAVE", masterConfiguration.getArtifactId());
+        assertEquals(artifact.getArtifactId() + "_G_MASTER", masterConfiguration.getArtifactId());
         assertEquals(artifact.getVersion(), masterConfiguration.getVersion());
         assertEquals(artifact.getType(), masterConfiguration.getType());
     }
     
+    public void testBuildSlaveConfigurationName() throws Exception {
+        String artifactId = "artifactId";
+        Artifact artifact = new Artifact("groupId", artifactId + "_G_MASTER", "2.0", "car");
+        Artifact slaveConfiguration = builder.buildSlaveConfigurationName(artifact);
+        assertEquals(artifact.getGroupId(), slaveConfiguration.getGroupId());
+        assertEquals(artifactId, slaveConfiguration.getArtifactId());
+        assertEquals(artifact.getVersion(), slaveConfiguration.getVersion());
+        assertEquals(artifact.getType(), slaveConfiguration.getType());
+    }
+    
 }

Propchange: geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilderTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/MasterConfigurationStoreTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/MasterConfigurationStoreTest.java?rev=748991&r1=748990&r2=748991&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/MasterConfigurationStoreTest.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/test/java/org/apache/geronimo/farm/deployment/MasterConfigurationStoreTest.java
Sun Mar  1 10:10:15 2009
@@ -62,7 +62,7 @@
     private ClusterConfigurationStoreClient storeClient;
     private AbstractName clusterInfoName;
     private ConfigurationStore delegate;
-    private SlaveConfigurationNameBuilder nameBuilder;
+    private ConfigurationNameBuilder nameBuilder;
     private Artifact configId;
 
     @Override
@@ -77,13 +77,13 @@
         modify().returnValue(clusterInfoName);
         
         delegate = (ConfigurationStore) mock(ConfigurationStore.class);
-        nameBuilder = (SlaveConfigurationNameBuilder) mock(SlaveConfigurationNameBuilder.class);
+        nameBuilder = (ConfigurationNameBuilder) mock(ConfigurationNameBuilder.class);
     }
 
     private MasterConfigurationStore newMasterConfigurationStore() {
         return new MasterConfigurationStore(kernel,
             "objectName",
-                null,
+            null,
             repository,
             new Environment(),
             clusterInfo,
@@ -96,15 +96,15 @@
                 return delegate;
             }
             @Override
-            protected SlaveConfigurationNameBuilder newSlaveConfigurationNameBuilder() {
+            protected ConfigurationNameBuilder newMasterConfigurationNameBuilder() {
                 return nameBuilder;
             }
         };
     }
     
     public void testContainsConfigurationOK() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(true);
 
         delegate.containsConfiguration(configId);
         modify().returnValue(true);
@@ -116,8 +116,8 @@
     }
     
     public void testContainsConfigurationFailsWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(false);
 
         startVerification();
         
@@ -126,11 +126,7 @@
     }
 
     public void testDelegateCreateNewConfigurationDir() throws Exception {
-        Artifact slaveId = new Artifact("groupId", "slaveId", "2.0", "car");
-        nameBuilder.buildSlaveConfigurationName(configId);
-        modify().returnValue(slaveId);
-        
-        delegate.createNewConfigurationDir(slaveId);
+        delegate.createNewConfigurationDir(configId);
         File expectedFile = new File("confDir");
         modify().returnValue(expectedFile);
         
@@ -141,8 +137,8 @@
     }
     
     public void testExportFailsWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(false);
 
         startVerification();
         
@@ -157,8 +153,8 @@
     public void testDelegateExport() throws Exception {
         OutputStream out = new ByteArrayOutputStream();
         
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(true);
         
         delegate.exportConfiguration(configId, out);
         
@@ -179,8 +175,8 @@
     }
     
     public void testDelegateGetObjectName() throws Exception {
-        delegate.getObjectName();
         String expectedName = "name";
+        delegate.getObjectName();
         modify().returnValue(expectedName);
         
         startVerification();
@@ -190,8 +186,8 @@
     }
     
     public void testIsInPlaceConfigurationWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(false);
 
         startVerification();
         
@@ -204,8 +200,8 @@
     }
 
     public void testIsInPlaceConfigurationReturnsFalse() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(true);
         
         startVerification();
         
@@ -226,12 +222,12 @@
         delegate.listConfigurations();
         modify().returnValue(configurationInfos);
         
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
-        
-        nameBuilder.isSlaveConfigurationName(configId2);
+        nameBuilder.isMasterConfigurationName(configId);
         modify().returnValue(true);
         
+        nameBuilder.isMasterConfigurationName(configId2);
+        modify().returnValue(false);
+        
         startVerification();
         
         MasterConfigurationStore store = newMasterConfigurationStore();
@@ -241,8 +237,8 @@
     }
 
     public void testLoadConfigurationWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(false);
 
         startVerification();
         
@@ -255,8 +251,8 @@
     }
 
     public void testDelegateLoadConfiguration() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(true);
         
         delegate.loadConfiguration(configId);
         
@@ -267,8 +263,8 @@
     }
 
     public void testResolveWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(false);
         
         startVerification();
         
@@ -281,8 +277,8 @@
     }
     
     public void testDelegateResolve() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(true);
         
         delegate.resolve(configId, null, null);
         
@@ -293,8 +289,8 @@
     }
     
     public void testUninstall() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(true);
         
         nameBuilder.buildSlaveConfigurationName(configId);
         Artifact slaveId = new Artifact("groupId", "slaveId", "2.0", "car");
@@ -312,8 +308,8 @@
     }
     
     public void testUninstallWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(false);
         
         startVerification();
         
@@ -326,7 +322,7 @@
     }
     
     public void testInstallOK() throws Exception {
-        ConfigurationData configurationData = new ConfigurationData(ConfigurationModuleType.CAR,
+        final ConfigurationData configurationData = new ConfigurationData(ConfigurationModuleType.CAR,
             new LinkedHashSet(),
             new ArrayList(),
             Collections.EMPTY_MAP,
@@ -335,33 +331,34 @@
             null,
             new Jsr77Naming());
         
-        final Artifact slaveId = new Artifact("groupId", "slaveId", "2.0", "car");
-        nameBuilder.buildSlaveConfigurationName(configId);
-        modify().returnValue(slaveId);
-        
-        storeClient.install(clusterInfo, configurationData);
-        modify().args(is.AS_RECORDED, new AbstractExpression() {
+        AbstractExpression assertConfigurationData = new AbstractExpression() {
             public void describeWith(ExpressionDescriber arg) throws IOException {
             }
-
+            
             public boolean passes(Object arg) {
-                ConfigurationData configurationData = (ConfigurationData) arg;
-                assertSame(slaveId, configurationData.getId());
+                assertSame(configurationData, arg);
                 return true;
             }
-        });
+        };
+
+        storeClient.install(clusterInfo, configurationData);
+        modify().args(is.AS_RECORDED, assertConfigurationData);
         
         delegate.install(configurationData);
-        modify().args(new AbstractExpression() {
-            public void describeWith(ExpressionDescriber arg) throws IOException {
-            }
+        modify().args(assertConfigurationData);
+        
+        recordInstallMasterConfiguration();
+        
+        startVerification();
 
-            public boolean passes(Object arg) {
-                ConfigurationData configurationData = (ConfigurationData) arg;
-                assertSame(slaveId, configurationData.getId());
-                return true;
-            }
-        });
+        MasterConfigurationStore store = newMasterConfigurationStore();
+        store.install(configurationData);
+    }
+
+    private void recordInstallMasterConfiguration() throws IOException, InvalidConfigException
{
+        final Artifact masterId = new Artifact("groupId", "masterId", "2.0", "car");
+        nameBuilder.buildMasterConfigurationName(configId);
+        modify().returnValue(masterId);
         
         NodeInfo nodeInfo = (NodeInfo) mock(NodeInfo.class);
         nodeInfo.getName();
@@ -370,7 +367,7 @@
         clusterInfo.getNodeInfos();
         modify().returnValue(Collections.singleton(nodeInfo));
         
-        delegate.createNewConfigurationDir(configId);
+        delegate.createNewConfigurationDir(masterId);
         final File masterDir = new File("masterDir");
         modify().returnValue(masterDir);
         
@@ -381,7 +378,7 @@
 
             public boolean passes(Object arg) {
                 ConfigurationData configurationData = (ConfigurationData) arg;
-                assertSame(configId, configurationData.getId());
+                assertSame(masterId, configurationData.getId());
                 assertSame(masterDir, configurationData.getConfigurationDir());
                 
                 List<GBeanData> gbeans;
@@ -393,16 +390,11 @@
                 assertEquals(1, gbeans.size());
                 GBeanData gbean = gbeans.get(0);
                 assertEquals(BasicClusterConfigurationController.class.getName(), gbean.getGBeanInfo().getClassName());
-                assertEquals(slaveId, gbean.getAttribute(BasicClusterConfigurationController.GBEAN_ATTR_ARTIFACT));
+                assertEquals(configId, gbean.getAttribute(BasicClusterConfigurationController.GBEAN_ATTR_ARTIFACT));
                 assertEquals(nodeName, gbean.getAttribute(BasicClusterConfigurationController.GBEAN_ATTR_NODE_NAME));
                 return true;
             }
         });
-        
-        startVerification();
-
-        MasterConfigurationStore store = newMasterConfigurationStore();
-        store.install(configurationData);
     }
     
     private ConfigurationInfo newConfigurationInfo(Artifact configId) {



Mime
View raw message