/*
* JBoss, Home of Professional Open Source
* Copyright 2006, JBoss Inc., and others contributors as indicated
* by the @authors tag. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* (C) 2005-2006, JBoss Inc.
*/
package org.jboss.soa.esb.actions.soap;
import junit.framework.TestCase;
import org.jboss.wsf.container.jboss42.WebMetaDataAdapter;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentContext;
import org.jboss.wsf.spi.deployment.Service;
import org.jboss.wsf.spi.metadata.j2ee.UnifiedWebMetaData;
import org.jboss.metadata.WebMetaData;
import org.jboss.deployment.DeploymentInfo;
import org.jboss.deployment.DeploymentException;
import org.jboss.deployment.J2eeApplicationMetaData;
import org.jboss.ws.integration.UnifiedVirtualFile;
import javax.management.MBeanServer;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.Set;
/**
* @author tom.fennelly@jboss.com
*/
public class WebMetaDataAdapterTest extends TestCase {
public void test_NPE() throws DeploymentException, MalformedURLException {
WebMetaDataAdapter adapter = new WebMetaDataAdapter();
WebMetaData metaData = new WebMetaData();
DeploymentInfo parent = new DeploymentInfo(new URL("file:/jboss"), null, null);
DeploymentInfo di = new DeploymentInfo(new URL("file:/jboss"), parent, null);
di.metaData = metaData;
try {
adapter.buildUnifiedWebMetaData(new MyDeployment(), null, di);
fail("Expected NullPointerException.");
} catch (NullPointerException e) {
// Expected, because WebMetaDataAdapter.buildUnifiedWebMetaData doesn't
// check is there a J2eeApplicationMetaData instance set on the DeploymentInfo
// parent. See line 64 of revision 3771.
// This is an issue for JBossESB since there's no J2eeApplicationMetaData.
// We worked around it for now by overridding WebMetaDataAdapter, patching the
// instance with a J2eeApplicationMetaData and delegating to super.
}
// Set an instance of J2eeApplicationMetaData on the DeploymentInfo parent...
di.parent.metaData = new J2eeApplicationMetaData();
UnifiedWebMetaData unifiedMetaData = adapter.buildUnifiedWebMetaData(new MyDeployment(), null, di);
assertNotNull(unifiedMetaData);
// Shouldn't have been an exceptions!!
}
public class MyDeployment implements Deployment {
public UnifiedVirtualFile getRootFile() {
return null;
}
public void setRootFile(UnifiedVirtualFile unifiedVirtualFile) {
}
public ClassLoader getClassLoader() {
return null;
}
public void setClassLoader(ClassLoader classLoader) {
}
public DeploymentContext getContext() {
return new DeploymentContext() {
public T addAttachment(Class aClass, Object object) {
return null;
}
public T getAttachment(Class aClass) {
return null;
}
public T removeAttachment(Class aClass) {
return null;
}
public Object getProperty(String targetProfile) {
return null;
}
public void setProperty(String targetProfile, Object object) {
}
public void removeProperty(String targetProfile) {
}
public Set getProperties() {
return null;
}
};
}
public void setContext(DeploymentContext deploymentContext) {
}
public DeploymentType getType() {
return null;
}
public void setType(DeploymentType deploymentType) {
}
public DeploymentState getState() {
return null;
}
public void setState(DeploymentState deploymentState) {
}
public Service getService() {
return null;
}
public void setService(Service service) {
}
}
}