001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.j2ee.deployment;
017:
018: import junit.framework.Assert;
019: import org.apache.geronimo.common.DeploymentException;
020: import org.apache.geronimo.kernel.repository.Environment;
021: import org.apache.geronimo.kernel.repository.Artifact;
022: import org.apache.geronimo.kernel.Naming;
023: import org.apache.geronimo.kernel.config.ConfigurationStore;
024: import org.apache.geronimo.gbean.AbstractName;
025: import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
026: import org.apache.geronimo.deployment.ModuleIDBuilder;
027:
028: import java.io.File;
029: import java.net.URL;
030: import java.util.Map;
031: import java.util.Collection;
032: import java.util.jar.JarFile;
033:
034: /**
035: * @version $Rev:386276 $ $Date: 2007-03-14 20:06:17 -0700 (Wed, 14 Mar 2007) $
036: */
037: public class MockWARConfigBuilder extends Assert implements
038: ModuleBuilder {
039: private EARContext earContext;
040: private ClassLoader cl;
041: private Map portMap = null;
042: private String namespace = "foo";
043: public WebModule webModule;
044: public String contextRoot;
045:
046: public Module createModule(File plan, JarFile moduleFile,
047: Naming naming, ModuleIDBuilder idBuilder)
048: throws DeploymentException {
049: AbstractName earName = naming.createRootName(new Artifact(
050: "test", "test-war", "", "war"), NameFactory.NULL,
051: NameFactory.J2EE_APPLICATION);
052: AbstractName moduleName = naming.createChildName(earName,
053: "war", NameFactory.WEB_MODULE);
054: return new WebModule(true, moduleName, null, moduleFile, "war",
055: null, null, null, contextRoot, namespace, null);
056: }
057:
058: public Module createModule(Object plan, JarFile moduleFile,
059: String targetPath, URL specDDUrl, Environment environment,
060: Object moduleContextInfo, AbstractName earName,
061: Naming naming, ModuleIDBuilder idBuilder)
062: throws DeploymentException {
063: AbstractName moduleName = naming.createChildName(earName,
064: "war", NameFactory.WEB_MODULE);
065: return new WebModule(false, moduleName, null, moduleFile,
066: targetPath, null, null, null, contextRoot, namespace,
067: null);
068: }
069:
070: public void installModule(JarFile earFile, EARContext earContext,
071: Module webModule, Collection configurationStores,
072: ConfigurationStore targetConfigurationStore,
073: Collection repository) throws DeploymentException {
074: assertNotNull(earFile);
075: assertNotNull(earContext);
076: this .earContext = earContext;
077: // assertEquals(this.webModule, webModule);
078: // if ( null != this.webModule.getAltSpecDD() ) {
079: // assertEquals(this.webModule.getAltSpecDD(), webModule.getAltSpecDD());
080: // }
081: // if ( null != this.webModule.getAltVendorDD() ) {
082: // assertEquals(this.webModule.getAltVendorDD(), webModule.getAltVendorDD());
083: // }
084: }
085:
086: public void initContext(EARContext earContext, Module webModule,
087: ClassLoader cl) {
088: assertEquals(this .earContext, earContext);
089: // assertEquals(this.webModule, webModule);
090: assertNotNull(cl);
091: this .cl = cl;
092: }
093:
094: public void addGBeans(EARContext earContext, Module webModule,
095: ClassLoader cl, Collection repository)
096: throws DeploymentException {
097: assertEquals(this .earContext, earContext);
098: // assertEquals(this.webModule, webModule);
099: assertEquals(this .cl, cl);
100: assertNotNull(contextRoot);
101: this .contextRoot = ((WebModule) webModule).getContextRoot();
102: }
103:
104: public String getSchemaNamespace() {
105: return null;
106: }
107:
108: }
|