Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jboss.wsf.test;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.WeakHashMap;
import javax.management.MBeanServerConnection;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import jakarta.xml.ws.Service;
import jakarta.xml.ws.Service.Mode;
import jakarta.xml.ws.soap.SOAPBinding;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.apache.commons.validator.routines.InetAddressValidator;
/**
* A JBossWS test helper that deals with test deployment/undeployment, etc.
*
* @author [email protected]
* @author [email protected]
* @author [email protected]
*/
public class JBossWSTestHelper
{
private static final String SYSPROP_JBOSSWS_INTEGRATION_TARGET = "jbossws.integration.target";
private static final String SYSPROP_JBOSS_BIND_ADDRESS = "jboss.bind.address";
private static final String SYSPROP_JBOSS_REMOTING_PROTOCOL = "jboss.remoting.protocol";
private static final String SYSPROP_INITIAL_CONTEXT_FACTORY = "jboss.initial.context.factory";
private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
private static final String SYSPROP_DEFAULT_CONTAINER_QUALIFIER = "default.container.qualifier";
private static final String SYSPROP_DEFAULT_CONTAINER_GROUP_QUALIFIER = "default.container.group.qualifier";
private static final String SYSPROP_CONTAINER_PORT_OFFSET_PREFIX = "port-offset.";
private static final String SYSPROP_AS_SERVER_CONN_RETRIEVAL_ATTEMPTS = "test.as.server.connection.retrieval.attempts";
private static final String TEST_USERNAME = "test.username";
private static final String TEST_PASSWORD = "test.password";
private static final int AS_SERVER_CONN_RETRIEVAL_ATTEMPTS = Integer.getInteger(SYSPROP_AS_SERVER_CONN_RETRIEVAL_ATTEMPTS, 5);
private static final String testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY);
private static final String testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY);
//TODO: Look at remove this completely
private static final String integrationTarget = "wildfly";
private static final String implInfo;
private static final String serverHost = System.getProperty(SYSPROP_JBOSS_BIND_ADDRESS, "localhost");
private static final String remotingProtocol = System.getProperty(SYSPROP_JBOSS_REMOTING_PROTOCOL);
private static final String initialContextFactory = System.getProperty(SYSPROP_INITIAL_CONTEXT_FACTORY);
private static WeakHashMap> containerEnvs = new WeakHashMap>();
static {
Object obj = getImplementationObject();
implInfo = obj.getClass().getPackage().getName();
}
/** Deploy the given archive to the appclient.
* Archive name is always in form archive.ear#appclient.jar
*/
public static Process deployAppclient(final String archive, final OutputStream appclientOS, final String... appclientArgs) throws Exception
{
return AppclientHelper.deployAppclient(archive, appclientOS, appclientArgs);
}
/** Undeploy the given archive from the appclient
* Archive name is always in form archive.ear#appclient.jar
*/
public static void undeployAppclient(final String archive, boolean awaitShutdown) throws Exception
{
AppclientHelper.undeployAppclient(archive, awaitShutdown);
}
public static boolean isIntegrationCXF()
{
String vendor = getImplementationInfo();
return vendor.toLowerCase().indexOf("apache") != -1;
}
private static String getImplementationInfo()
{
return implInfo;
}
private static Object getImplementationObject()
{
Service service = Service.create(new QName("dummyService"));
Object obj = service.getHandlerResolver();
if (obj == null)
{
service.addPort(new QName("dummyPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://dummy-address");
obj = service.createDispatch(new QName("dummyPort"), Source.class, Mode.PAYLOAD);
}
return obj;
}
public static String getRemotingProtocol()
{
return remotingProtocol;
}
public static String getInitialContextFactory()
{
return initialContextFactory;
}
/**
* Get the JBoss server host from system property "jboss.bind.address"
* This defaults to "localhost"
*/
public static String getServerHost()
{
return toIPv6URLFormat(serverHost);
}
public static int getServerPort()
{
return getServerPort(null, null);
}
public static int getServerPort(String groupQualifier, String containerQualifier)
{
return 8080 + getContainerPortOffset(groupQualifier, containerQualifier);
}
public static int getSecureServerPort(String groupQualifier, String containerQualifier)
{
return 8443 + getContainerPortOffset(groupQualifier, containerQualifier);
}
protected static int getContainerPortOffset(String groupQualifier, String containerQualifier)
{
Hashtable env = getContainerEnvironment();
if (groupQualifier == null) {
groupQualifier = env.get(SYSPROP_DEFAULT_CONTAINER_GROUP_QUALIFIER);
}
if (containerQualifier == null) {
containerQualifier = env.get(SYSPROP_DEFAULT_CONTAINER_QUALIFIER);
}
String offset = env.get(SYSPROP_CONTAINER_PORT_OFFSET_PREFIX + groupQualifier + "." + containerQualifier);
return offset != null ? Integer.valueOf(offset) : 0;
}
private static Hashtable getContainerEnvironment() {
Hashtable env;
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
synchronized (containerEnvs)
{
env = containerEnvs.get(tccl);
if (env == null) {
env = new Hashtable();
final InputStream is = tccl.getResourceAsStream("container.properties");
try {
if (is != null) {
final Properties props = new Properties();
props.load(is);
Entry