Author: dain
Date: Mon Mar 13 21:31:42 2006
New Revision: 385741
URL: http://svn.apache.org/viewcvs?rev=385741&view=rev
Log:
Added easier API for creating configurations (see ConfigTest and EARConfigBuilderTest for
examples)
Modified:
geronimo/branches/1.1/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java
geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java
Modified: geronimo/branches/1.1/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java?rev=385741&r1=385740&r2=385741&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
(original)
+++ geronimo/branches/1.1/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
Mon Mar 13 21:31:42 2006
@@ -50,6 +50,7 @@
import org.apache.geronimo.kernel.config.NoSuchConfigException;
import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.Environment;
import org.apache.geronimo.kernel.repository.ImportType;
@@ -248,33 +249,34 @@
Kernel kernel = KernelFactory.newInstance().createKernel("foo");
kernel.boot();
- GBeanData store = new GBeanData(Naming.createChildName(rootConfig, "ConfigStore",
"ConfigStore"), MockConfigStore.GBEAN_INFO);
- kernel.loadGBean(store, this.getClass().getClassLoader());
- kernel.startGBean(store.getAbstractName());
-
- GBeanData configurationManagerData = new GBeanData(Naming.createChildName(rootConfig,
"ConfigurationManager", "ConfigurationManager"), ConfigurationManagerImpl.GBEAN_INFO);
- configurationManagerData.setReferencePattern("Stores", new AbstractNameQuery(store.getAbstractName()));
- kernel.loadGBean(configurationManagerData, getClass().getClassLoader());
- kernel.startGBean(configurationManagerData.getAbstractName());
-
- EARConfigBuilder configBuilder = new EARConfigBuilder(defaultParentId,
- new AbstractNameQuery(transactionManagerObjectName),
- new AbstractNameQuery(connectionTrackerObjectName),
- new AbstractNameQuery(transactionalTimerObjectName),
- new AbstractNameQuery(nonTransactionalTimerObjectName),
- null,
- null,
- ejbConfigBuilder,
- ejbConfigBuilder,
- webConfigBuilder,
- connectorConfigBuilder,
- resourceReferenceBuilder,
- appClientConfigBuilder,
- serviceReferenceBuilder,
- kernel);
-
ConfigurationData configurationData = null;
try {
+ ConfigurationData testConfig = new ConfigurationData(new Artifact("test", "test",
"", "car"));
+ GBeanData storeData = new GBeanData(testConfig.getId(), "ConfigStore", MockConfigStore.GBEAN_INFO);
+ testConfig.addGBean(storeData);
+
+ GBeanData configurationManagerData = new GBeanData(testConfig.getId(), "ConfigurationManager",
ConfigurationManagerImpl.GBEAN_INFO);
+ configurationManagerData.setReferencePattern("Stores", new AbstractNameQuery(storeData.getAbstractName()));
+ testConfig.addGBean(configurationManagerData);
+
+ ConfigurationUtil.loadBootstrapConfiguration(kernel, testConfig, getClass().getClassLoader());
+
+ EARConfigBuilder configBuilder = new EARConfigBuilder(defaultParentId,
+ new AbstractNameQuery(transactionManagerObjectName),
+ new AbstractNameQuery(connectionTrackerObjectName),
+ new AbstractNameQuery(transactionalTimerObjectName),
+ new AbstractNameQuery(nonTransactionalTimerObjectName),
+ null,
+ null,
+ ejbConfigBuilder,
+ ejbConfigBuilder,
+ webConfigBuilder,
+ connectorConfigBuilder,
+ resourceReferenceBuilder,
+ appClientConfigBuilder,
+ serviceReferenceBuilder,
+ kernel);
+
Object plan = configBuilder.getDeploymentPlan(null, earFile);
configurationData = configBuilder.buildConfiguration(plan, earFile, configStore);
} finally {
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java?rev=385741&r1=385740&r2=385741&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java
Mon Mar 13 21:31:42 2006
@@ -28,8 +28,11 @@
import java.util.Map;
import java.util.Set;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.Naming;
+
/**
- * @version $Rev$ $Date$
+ * @version $Rev: 384686 $ $Date$
*/
public class GBeanData implements Externalizable {
private GBeanInfo gbeanInfo;
@@ -46,6 +49,14 @@
public GBeanData(GBeanInfo gbeanInfo) {
this();
+ this.gbeanInfo = gbeanInfo;
+ }
+
+ public GBeanData(Artifact artifact, String name, GBeanInfo gbeanInfo) {
+ this();
+ String j2eeType = gbeanInfo.getJ2eeType();
+ if (j2eeType == null) j2eeType = "GBean";
+ this.abstractName = Naming.createRootName(artifact, name, j2eeType);
this.gbeanInfo = gbeanInfo;
}
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java?rev=385741&r1=385740&r2=385741&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
Mon Mar 13 21:31:42 2006
@@ -19,6 +19,7 @@
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.gbean.GBeanData;
import java.util.ArrayList;
import java.util.Collections;
@@ -40,32 +41,48 @@
/**
* List of URIs in this configuration's classpath. These are for the classes directly
included in the configuration
*/
- private final LinkedHashSet classPath;
+ private final LinkedHashSet classPath = new LinkedHashSet();
/**
* GBeans contained in this configuration.
*/
- private final List gbeans;
+ private final List gbeans = new ArrayList();
/**
* Child configurations of this configuration
*/
- private final List childConfigurations;
+ private final List childConfigurations = new ArrayList();
private final Environment environment;
private final File configurationDir;
+ public ConfigurationData(Artifact configId) {
+ this(null, null, null, null, new Environment(configId), null);
+ }
+
+ public ConfigurationData(Environment environment) {
+ this(null, null, null, null, environment, null);
+ }
+
public ConfigurationData(ConfigurationModuleType moduleType, LinkedHashSet classPath,
List gbeans, List childConfigurations, Environment environment, File configurationDir) {
- this.moduleType = moduleType;
- if (classPath != null) {
- this.classPath = classPath;
+ if (moduleType != null) {
+ this.moduleType = moduleType;
} else {
- this.classPath = new LinkedHashSet();
+ this.moduleType = ConfigurationModuleType.CAR;
+ }
+ if (classPath != null) {
+ this.classPath.addAll(classPath);
+ }
+ if (gbeans != null){
+ this.gbeans.addAll(gbeans);
+ }
+ if (childConfigurations != null) {
+ this.childConfigurations.addAll(childConfigurations);
}
- if (gbeans == null) gbeans = Collections.EMPTY_LIST;
- this.gbeans = gbeans;
- this.childConfigurations = childConfigurations;
+
+ if (environment == null) throw new NullPointerException("environment is null");
+ if (environment.getConfigId() == null) throw new NullPointerException("environment.configId
is null");
this.environment = environment;
this.configurationDir = configurationDir;
}
@@ -84,6 +101,10 @@
public List getGBeans() {
return Collections.unmodifiableList(gbeans);
+ }
+
+ public void addGBean(GBeanData gbeanData) {
+ gbeans.add(gbeanData);
}
public List getChildConfigurations() {
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java?rev=385741&r1=385740&r2=385741&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java
Mon Mar 13 21:31:42 2006
@@ -47,7 +47,6 @@
public ConfigurationResolver(Artifact configurationId, File baseDir) {
if (configurationId == null) throw new NullPointerException("configurationId is
null");
- if (baseDir == null) throw new NullPointerException("baseDir is null");
this.configurationId = configurationId;
this.baseDir = baseDir;
@@ -59,7 +58,6 @@
public ConfigurationResolver(Artifact configurationId, File baseDir, Collection repositories)
{
if (configurationId == null) throw new NullPointerException("configurationId is
null");
if (repositories == null) repositories = Collections.EMPTY_SET;
- if (baseDir == null) throw new NullPointerException("baseDir is null");
this.configurationId = configurationId;
if (!repositories.isEmpty()) {
@@ -75,7 +73,6 @@
public ConfigurationResolver(Artifact configurationId, File baseDir, Collection repositories,
ArtifactResolver artifactResolver) {
if (configurationId == null) throw new NullPointerException("configurationId is
null");
if (repositories == null) repositories = Collections.EMPTY_SET;
- if (baseDir == null) throw new NullPointerException("baseDir is null");
this.configurationId = configurationId;
this.artifactResolver = artifactResolver;
@@ -110,8 +107,10 @@
public URL resolve(URI uri) throws MalformedURLException, NoSuchConfigException {
if (configurationStore != null) {
return configurationStore.resolve(configurationId, uri);
- } else {
+ } else if (baseDir != null) {
return new File(baseDir, uri.toString()).toURL();
+ } else {
+ throw new IllegalStateException("No configurationStore or baseDir supplied so
paths can not be resolved");
}
}
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java?rev=385741&r1=385740&r2=385741&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
Mon Mar 13 21:31:42 2006
@@ -55,6 +55,15 @@
ois.close();
}
+ return loadBootstrapConfiguration(kernel, configuration, classLoader);
+ }
+
+ public static AbstractName loadBootstrapConfiguration(Kernel kernel, ConfigurationData
configurationData, ClassLoader classLoader) throws Exception {
+ GBeanData configuration = toConfigurationGBeanData(configurationData, null, null,
null);
+ return loadBootstrapConfiguration(kernel, configuration, classLoader);
+ }
+
+ private static AbstractName loadBootstrapConfiguration(Kernel kernel, GBeanData configuration,
ClassLoader classLoader) throws Exception {
Environment environment = (Environment) configuration.getAttribute("environment");
Artifact configId = environment.getConfigId();
AbstractName configurationName = Configuration.getConfigurationAbstractName(configId);
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java?rev=385741&r1=385740&r2=385741&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java
Mon Mar 13 21:31:42 2006
@@ -52,6 +52,10 @@
public Environment() {
}
+ public Environment(Artifact configId) {
+ this.configId = configId;
+ }
+
public Environment(Environment environment) {
this.configId = environment.getConfigId();
this.dependencies.addAll(environment.dependencies);
Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java?rev=385741&r1=385740&r2=385741&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
Mon Mar 13 21:31:42 2006
@@ -17,38 +17,19 @@
package org.apache.geronimo.kernel;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import junit.framework.TestCase;
import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.ConfigurationData;
-import org.apache.geronimo.kernel.config.ConfigurationModuleType;
-import org.apache.geronimo.kernel.config.ConfigurationStore;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
import org.apache.geronimo.kernel.config.EditableConfigurationManager;
import org.apache.geronimo.kernel.config.EditableConfigurationManagerImpl;
-import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.NoSuchConfigException;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
-import org.apache.geronimo.kernel.repository.Environment;
/**
* @version $Rev: 384999 $ $Date$
@@ -59,7 +40,7 @@
private AbstractName gbeanName2;
private ConfigurationData configurationData;
private EditableConfigurationManager configurationManager;
- private final String BASE_NAME = "test:J2EEServer=geronimo";
+// private final String BASE_NAME = "test:J2EEServer=geronimo";
public void testConfigLifecycle() throws Exception {
@@ -170,7 +151,7 @@
Configuration configuration = configurationManager.loadConfiguration(configurationData);
assertNotNull(configuration.getConfigurationClassLoader());
- GBeanData mockBean3 = buildGBeanData(configuration.getId(), "MyMockGMBean3", "MockGBean",
MockGBean.getGBeanInfo());
+ GBeanData mockBean3 = new GBeanData(configuration.getId(), "MyMockGMBean3", MockGBean.getGBeanInfo());
try {
kernel.getGBeanState(mockBean3.getAbstractName());
fail("Gbean should not be found yet");
@@ -192,130 +173,46 @@
kernel = KernelFactory.newInstance().createKernel("test");
kernel.boot();
- Artifact baseArtifact = new Artifact("test", "base", "1", "car");
- GBeanData artifactManagerData = buildGBeanData(baseArtifact, "ArtifactManager", "ArtifactManager",
DefaultArtifactManager.GBEAN_INFO);
- kernel.loadGBean(artifactManagerData, getClass().getClassLoader());
- kernel.startGBean(artifactManagerData.getAbstractName());
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(artifactManagerData.getAbstractName()));
+ ConfigurationData bootstrap = new ConfigurationData(new Artifact("test", "test",
"", "car"));
+
+ GBeanData artifactManagerData = new GBeanData(bootstrap.getId(), "ArtifactManager",
DefaultArtifactManager.GBEAN_INFO);
+ bootstrap.addGBean(artifactManagerData);
- GBeanData artifactResolverData = buildGBeanData(baseArtifact, "ArtifactResolver",
"ArtifactResolver", DefaultArtifactResolver.GBEAN_INFO);
+ GBeanData artifactResolverData = new GBeanData(bootstrap.getId(), "ArtifactResolver",
DefaultArtifactResolver.GBEAN_INFO);
artifactResolverData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
- kernel.loadGBean(artifactResolverData, getClass().getClassLoader());
- kernel.startGBean(artifactResolverData.getAbstractName());
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(artifactResolverData.getAbstractName()));
+ bootstrap.addGBean(artifactResolverData);
- GBeanData configurationManagerData = buildGBeanData(baseArtifact, "ConfigurationManager",
"ConfigurationManager", EditableConfigurationManagerImpl.GBEAN_INFO);
+ GBeanData configurationManagerData = new GBeanData(bootstrap.getId(), "ConfigurationManager",
EditableConfigurationManagerImpl.GBEAN_INFO);
configurationManagerData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
configurationManagerData.setReferencePattern("ArtifactResolver", artifactResolverData.getAbstractName());
+ bootstrap.addGBean(configurationManagerData);
+
+ ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap, getClass().getClassLoader());
- kernel.loadGBean(configurationManagerData, getClass().getClassLoader());
- kernel.startGBean(configurationManagerData.getAbstractName());
configurationManager = ConfigurationUtil.getEditableConfigurationManager(kernel);
- Environment environment = new Environment();
- environment.setConfigId(new Artifact("geronimo", "test", "1", "car"));
- Map properties = new HashMap();
- properties.put(Configuration.JSR77_BASE_NAME_PROPERTY, BASE_NAME);
- environment.setProperties(properties);
- ArrayList gbeans = new ArrayList();
+ configurationData = new ConfigurationData(new Artifact("geronimo", "test", "1", "car"));
- GBeanData mockBean1 = buildGBeanData(environment.getConfigId(),"MyMockGMBean1", "MockGBean",
MockGBean.getGBeanInfo());
+ GBeanData mockBean1 = new GBeanData(configurationData.getId(),"MyMockGMBean1", MockGBean.getGBeanInfo());
gbeanName1 = mockBean1.getAbstractName();
mockBean1.setAttribute("value", "1234");
mockBean1.setAttribute("name", "child");
mockBean1.setAttribute("finalInt", new Integer(1));
- gbeans.add(mockBean1);
+ configurationData.addGBean(mockBean1);
- GBeanData mockBean2 = buildGBeanData(environment.getConfigId(), "MyMockGMBean2",
"MockGBean", MockGBean.getGBeanInfo());
+ GBeanData mockBean2 = new GBeanData(configurationData.getId(), "MyMockGMBean2", MockGBean.getGBeanInfo());
gbeanName2 = mockBean2.getAbstractName();
mockBean2.setAttribute("value", "5678");
mockBean2.setAttribute("name", "Parent");
mockBean2.setAttribute("finalInt", new Integer(3));
mockBean2.setReferencePattern("MockEndpoint", gbeanName1);
mockBean2.setReferencePattern("EndpointCollection", new AbstractNameQuery(gbeanName1));
- gbeans.add(mockBean2);
-
-
- configurationData = new ConfigurationData(ConfigurationModuleType.CAR, null, gbeans,
null, environment, new File("."));
+ configurationData.addGBean(mockBean2);
}
- private GBeanData buildGBeanData(Artifact artifact, String name, String type, GBeanInfo
info) {
- AbstractName abstractName = Naming.createRootName(artifact, name, type);
- return new GBeanData(abstractName, info);
- }
-
protected void tearDown() throws Exception {
kernel.shutdown();
super.tearDown();
- }
-
- public static class MockConfigStore implements ConfigurationStore {
-
- URL baseURL;
-
- public MockConfigStore() {
- }
-
- public MockConfigStore(URL baseURL) {
- this.baseURL = baseURL;
- }
-
- public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException
{
- }
-
- public void uninstall(Artifact configID) throws NoSuchConfigException, IOException
{
- }
-
- public GBeanData loadConfiguration(Artifact configId) throws NoSuchConfigException,
IOException, InvalidConfigException {
- AbstractName configurationName = Configuration.getConfigurationAbstractName(configId);
- GBeanData configData = new GBeanData(configurationName, Configuration.GBEAN_INFO);
- Environment environment = new Environment();
- environment.setConfigId(configId);
- environment.getProperties().put("foo", "geronimo.test:J2EEServer=geronimo");
- configData.setAttribute("environment", environment);
- configData.setAttribute("gBeanState", NO_OBJECTS_OS);
- configData.setAttribute("configurationStore", this);
- return configData;
- }
-
- public boolean containsConfiguration(Artifact configID) {
- return true;
- }
-
- public String getObjectName() {
- return null;
- }
-
- public List listConfigurations() {
- return null;
- }
-
- public File createNewConfigurationDir(Artifact configId) {
- return null;
- }
-
- public URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, MalformedURLException
{
- return baseURL;
- }
-
- public final static GBeanInfo GBEAN_INFO;
-
- private static final byte[] NO_OBJECTS_OS;
-
- static {
- GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(MockConfigStore.class,
"ConfigurationStore");
- infoBuilder.addInterface(ConfigurationStore.class);
- GBEAN_INFO = infoBuilder.getBeanInfo();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.flush();
- NO_OBJECTS_OS = baos.toByteArray();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
}
}
Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java?rev=385741&r1=385740&r2=385741&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java
Mon Mar 13 21:31:42 2006
@@ -17,18 +17,32 @@
package org.apache.geronimo.kernel.repository;
import junit.framework.TestCase;
-import org.apache.geronimo.kernel.ConfigTest;
import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.geronimo.kernel.config.ConfigurationResolver;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
import java.io.File;
+import java.io.IOException;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
+import java.util.List;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.net.URI;
/**
* @version $Rev$ $Date$
@@ -89,7 +103,7 @@
// create parent which uses version1 explicitly
ConfigurationResolver configurationResolver = new ConfigurationResolver(loader,
- new ConfigTest.MockConfigStore(new File("foo").toURL()),
+ new MockConfigStore(new File("foo").toURL()),
Collections.singleton(mockRepository),
artifactResolver);
@@ -134,6 +148,75 @@
public LinkedHashSet getDependencies(Artifact artifact) {
return new LinkedHashSet();
+ }
+ }
+
+ public static class MockConfigStore implements ConfigurationStore {
+
+ URL baseURL;
+
+ public MockConfigStore() {
+ }
+
+ public MockConfigStore(URL baseURL) {
+ this.baseURL = baseURL;
+ }
+
+ public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException
{
+ }
+
+ public void uninstall(Artifact configID) throws NoSuchConfigException, IOException
{
+ }
+
+ public GBeanData loadConfiguration(Artifact configId) throws NoSuchConfigException,
IOException, InvalidConfigException {
+ AbstractName configurationName = Configuration.getConfigurationAbstractName(configId);
+ GBeanData configData = new GBeanData(configurationName, Configuration.GBEAN_INFO);
+ Environment environment = new Environment();
+ environment.setConfigId(configId);
+ environment.getProperties().put("foo", "geronimo.test:J2EEServer=geronimo");
+ configData.setAttribute("environment", environment);
+ configData.setAttribute("gBeanState", NO_OBJECTS_OS);
+ configData.setAttribute("configurationStore", this);
+ return configData;
+ }
+
+ public boolean containsConfiguration(Artifact configID) {
+ return true;
+ }
+
+ public String getObjectName() {
+ return null;
+ }
+
+ public List listConfigurations() {
+ return null;
+ }
+
+ public File createNewConfigurationDir(Artifact configId) {
+ return null;
+ }
+
+ public URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, MalformedURLException
{
+ return baseURL;
+ }
+
+ public final static GBeanInfo GBEAN_INFO;
+
+ private static final byte[] NO_OBJECTS_OS;
+
+ static {
+ GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(MockConfigStore.class,
"ConfigurationStore");
+ infoBuilder.addInterface(ConfigurationStore.class);
+ GBEAN_INFO = infoBuilder.getBeanInfo();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.flush();
+ NO_OBJECTS_OS = baos.toByteArray();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
}
}
|