wise SVN: r435 - core/trunk/core/src/main/java/org/jboss/wise/core/utils.
by wise-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2012-06-24 13:20:49 -0400 (Sun, 24 Jun 2012)
New Revision: 435
Modified:
core/trunk/core/src/main/java/org/jboss/wise/core/utils/IOUtils.java
Log:
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/utils/IOUtils.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/utils/IOUtils.java 2012-06-24 17:20:25 UTC (rev 434)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/utils/IOUtils.java 2012-06-24 17:20:49 UTC (rev 435)
@@ -22,27 +22,19 @@
package org.jboss.wise.core.utils;
-// $Id: IOUtils.java 4018 2007-07-27 06:31:03Z thomas.diesler(a)jboss.com $
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+
import org.jboss.wise.core.exception.WiseRuntimeException;
/**
* IO utilities
*
- * @author stefano.maestri(a)javalinux.it class imported from JBossWS. Kept methods useful for Wise
+ * @author stefano.maestri(a)javalinux.it
*/
public final class IOUtils {
- // Hide the constructor
- private IOUtils() {
- }
-
- public static IOUtils newInstance() {
- return new IOUtils();
- }
-
+
/**
* True if the given type name is the source notation of a primitive or array of which.
*
@@ -50,7 +42,7 @@
* @param ins
* @throws WiseRuntimeException
*/
- public void copyStreamAndClose( OutputStream outs,
+ public static void copyStreamAndClose( OutputStream outs,
InputStream ins ) throws WiseRuntimeException {
try {
byte[] bytes = new byte[1024];
@@ -79,5 +71,4 @@
}
}
-
}
12 years, 7 months
wise SVN: r434 - in core/trunk: core/src/main/java/org/jboss/wise/core/consumer/impl/jbossws and 5 other directories.
by wise-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2012-06-24 13:20:25 -0400 (Sun, 24 Jun 2012)
New Revision: 434
Added:
core/trunk/core/src/main/java/org/jboss/wise/core/utils/LoggingOutputStream.java
Modified:
core/trunk/core-cxf/src/test/java/org/jboss/wise/core/client/jaxrs/ClientServerJaxrsTest.java
core/trunk/core-cxf/src/test/java/org/jboss/wise/core/consumer/impl/WSConsumerTest.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/builder/ReflectionBasedWSDynamicClientBuilder.java
core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/jbossws/DefaultWSImportImpl.java
core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/smooks/WiseIntegrationSmooksTest.java
core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/WSDLResolverIntegrationTest.java
Log:
[WISE-178] default to log4j for consumer output unless verbose is on + fixing some client/test logging
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/builder/ReflectionBasedWSDynamicClientBuilder.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/builder/ReflectionBasedWSDynamicClientBuilder.java 2012-06-24 15:31:23 UTC (rev 433)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/builder/ReflectionBasedWSDynamicClientBuilder.java 2012-06-24 17:20:25 UTC (rev 434)
@@ -37,6 +37,7 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jboss.wise.core.client.WSDynamicClient;
import org.jboss.wise.core.client.builder.WSDynamicClientBuilder;
@@ -45,6 +46,7 @@
import org.jboss.wise.core.client.impl.wsdlResolver.WSDLResolver;
import org.jboss.wise.core.exception.WiseRuntimeException;
import org.jboss.wise.core.utils.IDGenerator;
+import org.jboss.wise.core.utils.LoggingOutputStream;
/**
* @author stefano.maestri(a)javalinux.it
@@ -54,6 +56,7 @@
public class ReflectionBasedWSDynamicClientBuilder implements WSDynamicClientBuilder {
private static Logger logger = Logger.getLogger(ReflectionBasedWSDynamicClientBuilder.class);
+ private static PrintStream ps = new PrintStream(new LoggingOutputStream(logger, Level.INFO), true);
@GuardedBy("this")
private String wsdlURL;
@@ -95,7 +98,7 @@
private String clientSpecificTmpDir;
@GuardedBy("this")
- private PrintStream messageStream = System.out;
+ private PrintStream messageStream = ps;
@GuardedBy("this")
private int maxThreadPoolSize = MAX_THREAD_POOL_SIZE.getIntValue();
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/jbossws/DefaultWSImportImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/jbossws/DefaultWSImportImpl.java 2012-06-24 15:31:23 UTC (rev 433)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/jbossws/DefaultWSImportImpl.java 2012-06-24 17:20:25 UTC (rev 434)
@@ -70,13 +70,15 @@
wsImporter.setGenerateSource(this.isKeepSource());
wsImporter.setOutputDirectory(outputDir);
wsImporter.setSourceDirectory(sourceDir);
+
+ if (this.isVerbose()) {
+ wsImporter.setMessageStream(System.out);
+ }
+
if (messageStream != null) {
wsImporter.setMessageStream(messageStream);
}
- if (this.isVerbose()) {
- wsImporter.setMessageStream(System.out);
- }
wsImporter.setAdditionalCompilerClassPath(defineAdditionalCompilerClassPath());
if (bindingFiles != null && bindingFiles.size() > 0) {
Added: core/trunk/core/src/main/java/org/jboss/wise/core/utils/LoggingOutputStream.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/utils/LoggingOutputStream.java (rev 0)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/utils/LoggingOutputStream.java 2012-06-24 17:20:25 UTC (rev 434)
@@ -0,0 +1,91 @@
+package org.jboss.wise.core.utils;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+/**
+ * An OutputStream that flushes out to a Logger
+ */
+public class LoggingOutputStream extends OutputStream {
+
+ public static final int DEFAULT_BUFFER_LENGTH = 2048;
+
+ protected boolean hasBeenClosed = false;
+ protected byte[] buf;
+ protected int count;
+ private int bufLength;
+ protected Logger logger;
+ protected Level level;
+
+ public LoggingOutputStream(Logger log, Level level) throws IllegalArgumentException {
+ if (log == null) {
+ throw new IllegalArgumentException("Null category!");
+ }
+ if (level == null) {
+ throw new IllegalArgumentException("Null priority!");
+ }
+ this.level = level;
+ logger = log;
+ bufLength = DEFAULT_BUFFER_LENGTH;
+ buf = new byte[DEFAULT_BUFFER_LENGTH];
+ count = 0;
+ }
+
+ public void close() {
+ flush();
+ hasBeenClosed = true;
+ }
+
+ public void write(final int b) throws IOException {
+ if (hasBeenClosed) {
+ throw new IOException("The stream has been closed.");
+ }
+ // would this be writing past the buffer?
+ if (count == bufLength) {
+ // grow the buffer
+ final int newBufLength = bufLength + DEFAULT_BUFFER_LENGTH;
+ final byte[] newBuf = new byte[newBufLength];
+ System.arraycopy(buf, 0, newBuf, 0, bufLength);
+ buf = newBuf;
+ bufLength = newBufLength;
+ }
+ buf[count] = (byte) b;
+ count++;
+ }
+
+ public void flush() {
+ if (count == 0) {
+ return;
+ }
+ // don't print out blank lines; flushing from PrintStream puts
+ // out these
+ // For linux system
+ if (count == 1 && ((char) buf[0]) == '\n') {
+ reset();
+ return;
+ }
+ // For mac system
+ if (count == 1 && ((char) buf[0]) == '\r') {
+ reset();
+ return;
+ }
+ // On windows system
+ if (count == 2 && (char) buf[0] == '\r' && (char) buf[1] == '\n') {
+ reset();
+ return;
+ }
+ final byte[] theBytes = new byte[count];
+ System.arraycopy(buf, 0, theBytes, 0, count);
+ logger.log(level, new String(theBytes));
+ reset();
+ }
+
+ private void reset() {
+ // not resetting the buffer -- assuming that if it grew then it
+ // will likely grow similarly again
+ count = 0;
+ }
+}
Modified: core/trunk/core-cxf/src/test/java/org/jboss/wise/core/client/jaxrs/ClientServerJaxrsTest.java
===================================================================
--- core/trunk/core-cxf/src/test/java/org/jboss/wise/core/client/jaxrs/ClientServerJaxrsTest.java 2012-06-24 15:31:23 UTC (rev 433)
+++ core/trunk/core-cxf/src/test/java/org/jboss/wise/core/client/jaxrs/ClientServerJaxrsTest.java 2012-06-24 17:20:25 UTC (rev 434)
@@ -1,9 +1,11 @@
package org.jboss.wise.core.client.jaxrs;
import java.io.InputStream;
+
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.io.CachedOutputStream;
import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
+import org.apache.log4j.Logger;
import org.jboss.wise.core.client.InvocationResult;
import org.jboss.wise.core.client.factories.WSDynamicClientFactory;
import org.junit.BeforeClass;
@@ -11,6 +13,8 @@
public class ClientServerJaxrsTest extends AbstractClientServerTestBase {
+ private Logger logger = Logger.getLogger(ClientServerJaxrsTest.class);
+
@BeforeClass
public static void startServers() throws Exception {
assertTrue("server did not launch correctly", launchServer(JaxrsServer.class));
@@ -41,7 +45,7 @@
InvocationResult result = client.invoke(request, null);
String response = (String)result.getResult().get(InvocationResult.RESPONSE);
- System.out.println("-------------" + response);
+ logger.debug("-------------" + response);
String expected = getStringFromInputStream(getClass().getResourceAsStream("/jaxrs/expected_add_book.txt"));
Modified: core/trunk/core-cxf/src/test/java/org/jboss/wise/core/consumer/impl/WSConsumerTest.java
===================================================================
--- core/trunk/core-cxf/src/test/java/org/jboss/wise/core/consumer/impl/WSConsumerTest.java 2012-06-24 15:31:23 UTC (rev 433)
+++ core/trunk/core-cxf/src/test/java/org/jboss/wise/core/consumer/impl/WSConsumerTest.java 2012-06-24 17:20:25 UTC (rev 434)
@@ -27,12 +27,16 @@
import static org.junit.matchers.JUnitMatchers.hasItem;
import java.io.File;
+import java.io.PrintStream;
import java.net.URL;
import java.util.List;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
import org.jboss.wise.core.client.SpiLoader;
import org.jboss.wise.core.consumer.WSConsumer;
import org.jboss.wise.core.exception.WiseRuntimeException;
+import org.jboss.wise.core.utils.LoggingOutputStream;
import org.junit.Test;
/**
@@ -40,6 +44,8 @@
* @author alessio.soldano(a)jboss.com
*/
public class WSConsumerTest {
+
+ private PrintStream testPrintStream = new PrintStream(new LoggingOutputStream(Logger.getLogger(this.getClass()), Level.INFO), true);
@Test
public void parseHelloGreetingWSDLShouldWorkWithoutPackage() throws Exception {
@@ -47,7 +53,7 @@
File outputDir = new File(url.getFile());
URL wsdURL = Thread.currentThread().getContextClassLoader().getResource("./hello_world.wsdl");
WSConsumer importer = newConsumer();
- importer.importObjectFromWsdl(wsdURL.toExternalForm(), outputDir, outputDir, null, null, System.out, null);
+ importer.importObjectFromWsdl(wsdURL.toExternalForm(), outputDir, outputDir, null, null, testPrintStream, null);
}
@Test()
@@ -60,7 +66,7 @@
List<File> bindings = new java.util.ArrayList<File>();
bindings.add(bindFile);
WSConsumer importer = newConsumer();
- importer.importObjectFromWsdl(wsdURL.toExternalForm(), outputDir, outputDir, null, bindings, System.out, null);
+ importer.importObjectFromWsdl(wsdURL.toExternalForm(), outputDir, outputDir, null, bindings, testPrintStream, null);
File generatedClass = new File(url.getFile(), "org/mytest");
assertTrue(generatedClass.exists());
}
@@ -71,7 +77,7 @@
File outputDir = new File(url.getFile());
URL wsdURL = Thread.currentThread().getContextClassLoader().getResource("./hello_world.wsdl");
WSConsumer importer = newConsumer();
- importer.importObjectFromWsdl(wsdURL.toExternalForm(), outputDir, outputDir, "org.jboss.wise", null, System.out, null);
+ importer.importObjectFromWsdl(wsdURL.toExternalForm(), outputDir, outputDir, "org.jboss.wise", null, testPrintStream, null);
}
@Test()
Modified: core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/smooks/WiseIntegrationSmooksTest.java
===================================================================
--- core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/smooks/WiseIntegrationSmooksTest.java 2012-06-24 15:31:23 UTC (rev 433)
+++ core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/smooks/WiseIntegrationSmooksTest.java 2012-06-24 17:20:25 UTC (rev 434)
@@ -30,6 +30,8 @@
import java.util.Date;
import java.util.Map;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
import org.jboss.wise.core.client.InvocationResult;
import org.jboss.wise.core.client.WSDynamicClient;
import org.jboss.wise.core.client.WSMethod;
@@ -64,7 +66,7 @@
.toString()).build();
WSMethod method = client.getWSMethod("ComplexWSService", "ComplexWSPort", "ping");
- method.getEndpoint().addHandler(new LoggingHandler());
+ method.getEndpoint().addHandler(new LoggingHandler(Logger.getLogger(this.getClass()), Level.DEBUG));
InternalObject internal = new InternalObject();
internal.setNumber(new Integer(1));
internal.setText("aa");
Modified: core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/WSDLResolverIntegrationTest.java
===================================================================
--- core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/WSDLResolverIntegrationTest.java 2012-06-24 15:31:23 UTC (rev 433)
+++ core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/WSDLResolverIntegrationTest.java 2012-06-24 17:20:25 UTC (rev 434)
@@ -29,6 +29,7 @@
import net.jcip.annotations.Immutable;
+import org.apache.log4j.Logger;
import org.jboss.wise.core.client.impl.wsdlResolver.Connection;
import org.jboss.wise.core.client.impl.wsdlResolver.WSDLResolver;
import org.jboss.wise.core.test.WiseTest;
@@ -110,7 +111,7 @@
@Before
public void createTmpDir() throws IOException
{
- System.out.println("Creating tmp dir: " + tmpDir.getPath());
+ Logger.getLogger(this.getClass()).debug("Creating tmp dir: " + tmpDir.getPath());
if (tmpDir.exists()) {
tmpDir.delete();
}
12 years, 7 months
wise SVN: r433 - core/trunk/distribution.
by wise-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2012-06-24 11:31:23 -0400 (Sun, 24 Jun 2012)
New Revision: 433
Modified:
core/trunk/distribution/pom.xml
Log:
[WSIE-174] Minor updates to Maven 3 in distribution module
Modified: core/trunk/distribution/pom.xml
===================================================================
--- core/trunk/distribution/pom.xml 2012-06-24 15:20:20 UTC (rev 432)
+++ core/trunk/distribution/pom.xml 2012-06-24 15:31:23 UTC (rev 433)
@@ -19,12 +19,12 @@
<dependency>
<groupId>org.jboss.wise</groupId>
<artifactId>wise-core</artifactId>
- <version>${version}</version>
+ <version>${project.version}</version>
</dependency>
</dependencies>
<properties>
- <wise.version>${pom.version}</wise.version>
+ <wise.version>${project.version}</wise.version>
</properties>
<build>
@@ -43,10 +43,10 @@
<outputDirectory>${project.build.directory}/javadoc</outputDirectory>
<artifactItems>
<artifactItem>
- <groupId>${pom.groupId}</groupId>
+ <groupId>${project.groupId}</groupId>
<artifactId>wise-core</artifactId>
<classifier>javadoc</classifier>
- <version>${pom.version}</version>
+ <version>${project.version}</version>
</artifactItem>
</artifactItems>
</configuration>
12 years, 7 months
wise SVN: r432 - core/trunk/integration-testsuite/common.
by wise-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2012-06-24 11:20:20 -0400 (Sun, 24 Jun 2012)
New Revision: 432
Modified:
core/trunk/integration-testsuite/common/pom.xml
Log:
[WISE-174] Cleanup test war contents with recent maven-war-plugin (no lib jars are needed in the wars)
Modified: core/trunk/integration-testsuite/common/pom.xml
===================================================================
--- core/trunk/integration-testsuite/common/pom.xml 2012-06-17 22:59:09 UTC (rev 431)
+++ core/trunk/integration-testsuite/common/pom.xml 2012-06-24 15:20:20 UTC (rev 432)
@@ -70,6 +70,7 @@
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
<webappDirectory>${project.build.directory}/basic</webappDirectory>
<warSourceExcludes>**/lib/**</warSourceExcludes>
+ <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
<webResources>
<webResource>
<targetPath>WEB-INF/classes</targetPath>
@@ -96,6 +97,7 @@
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
<webappDirectory>${project.build.directory}/wsdlResolver</webappDirectory>
<warSourceExcludes>**/lib/**</warSourceExcludes>
+ <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
<webResources>
<webResource>
<targetPath>WEB-INF/classes</targetPath>
@@ -129,6 +131,7 @@
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
<webappDirectory>${project.build.directory}/smooks</webappDirectory>
<warSourceExcludes>**/lib/**</warSourceExcludes>
+ <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
<webResources>
<webResource>
<targetPath>WEB-INF/classes</targetPath>
12 years, 7 months
wise SVN: r431 - in core/trunk: core/src/main/java/org/jboss/wise/core/client and 18 other directories.
by wise-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2012-06-17 18:59:09 -0400 (Sun, 17 Jun 2012)
New Revision: 431
Added:
core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/SecurityActions.java
Modified:
core/trunk/core/src/main/java/org/jboss/wise/core/client/SpiLoader.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/WSEndpoint.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/WSService.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/WebParameter.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/factories/WSDynamicClientFactory.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/EndpointMethodCaller.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/InvocationResultImpl.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImpl.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSEndpointImpl.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSMethodImpl.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSServiceImpl.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/builder/ReflectionBasedWSDynamicClientBuilder.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/wsdlResolver/Connection.java
core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/wsdlResolver/WSDLResolver.java
core/trunk/core/src/main/java/org/jboss/wise/core/consumer/WSConsumer.java
core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/jbossws/DefaultWSImportImpl.java
core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/metro/LocalFirstClassLoader.java
core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/metro/MetroWSConsumer.java
core/trunk/core/src/main/java/org/jboss/wise/core/exception/InvocationException.java
core/trunk/core/src/main/java/org/jboss/wise/core/exception/MappingException.java
core/trunk/core/src/main/java/org/jboss/wise/core/handlers/LoggingHandler.java
core/trunk/core/src/main/java/org/jboss/wise/core/handlers/SmooksHandler.java
core/trunk/core/src/main/java/org/jboss/wise/core/mapper/SmooksMapper.java
core/trunk/core/src/main/java/org/jboss/wise/core/test/WiseTest.java
core/trunk/core/src/main/java/org/jboss/wise/core/utils/DefaultConfig.java
core/trunk/core/src/main/java/org/jboss/wise/core/utils/IDGenerator.java
core/trunk/core/src/main/java/org/jboss/wise/core/utils/IOUtils.java
core/trunk/core/src/main/java/org/jboss/wise/core/utils/JavaUtils.java
core/trunk/core/src/main/java/org/jboss/wise/core/utils/ReflectionUtils.java
core/trunk/core/src/main/java/org/jboss/wise/core/wsextensions/impl/MTOMEnabler.java
core/trunk/core/src/main/java/org/jboss/wise/core/wsextensions/impl/WSAddressingEnabler.java
core/trunk/core/src/main/java/org/jboss/wise/core/wsextensions/impl/WSRMEnabler.java
core/trunk/core/src/main/java/org/jboss/wise/smooks/decoders/DurationDecoder.java
core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/reflection/InvocationResultImplTest.java
core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImplTest.java
core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/wsdlResolver/ConnectionTest.java
core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/wsdlResolver/WSDLResolverTest.java
core/trunk/core/src/test/java/org/jboss/wise/core/mapper/SmooksMapperTest.java
core/trunk/core/src/test/java/org/jboss/wise/smooks/decoders/JAXBElementDecoderTest.java
core/trunk/pom.xml
Log:
[WISE-177] Cleanup of core module
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/SpiLoader.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/SpiLoader.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/SpiLoader.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -22,14 +22,10 @@
package org.jboss.wise.core.client;
import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.Properties;
/**
* @author stefano.maestri(a)javalinux.it
@@ -83,7 +79,7 @@
public static Object loadFromServices(String propertyName) {
Object factory = null;
String factoryName = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = getContextClassLoader();
// Use the Services API (as detailed in the JAR specification), if
// available, to determine the classname.
@@ -95,7 +91,7 @@
factoryName = br.readLine();
br.close();
if (factoryName != null) {
- Class factoryClass = loader.loadClass(factoryName);
+ Class<?> factoryClass = loader.loadClass(factoryName);
factory = factoryClass.newInstance();
}
} catch (Throwable t) {
@@ -114,15 +110,12 @@
*/
public static Object loadFromSystemProperty(String propertyName) {
Object factory = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = getContextClassLoader();
- PrivilegedAction action = new PropertyAccessAction(propertyName);
- String factoryName = (String) AccessController.doPrivileged(action);
+ String factoryName = AccessController.doPrivileged(new PropertyAccessAction(propertyName));
if (factoryName != null) {
try {
- // if(log.isDebugEnabled())
- // log.debug("Load from system property: " + factoryName);
- Class factoryClass = loader.loadClass(factoryName);
+ Class<?> factoryClass = loader.loadClass(factoryName);
factory = factoryClass.newInstance();
} catch (Throwable t) {
throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
@@ -134,14 +127,12 @@
private static Object loadDefault(String defaultFactory) {
Object factory = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = getContextClassLoader();
// Use the default factory implementation class.
if (defaultFactory != null) {
try {
- // if(log.isDebugEnabled()) log.debug("Load from default: " +
- // factoryName);
- Class factoryClass = loader.loadClass(defaultFactory);
+ Class<?> factoryClass = loader.loadClass(defaultFactory);
factory = factoryClass.newInstance();
} catch (Throwable t) {
throw new IllegalStateException("Failed to load: " + defaultFactory, t);
@@ -151,7 +142,7 @@
return factory;
}
- private static class PropertyAccessAction implements PrivilegedAction {
+ private static class PropertyAccessAction implements PrivilegedAction<String> {
private final String name;
@@ -159,29 +150,26 @@
this.name = name;
}
- public Object run() {
+ public String run() {
return System.getProperty(name);
}
}
-
- private static class PropertyFileAccessAction implements PrivilegedAction {
-
- private final String filename;
-
- PropertyFileAccessAction(String filename) {
- this.filename = filename;
- }
-
- public Object run() {
- try {
- InputStream inStream = new FileInputStream(filename);
- Properties props = new Properties();
- props.load(inStream);
- return props;
- } catch (IOException ex) {
- throw new SecurityException("Cannot load properties: " + filename, ex);
- }
- }
+
+ private static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
}
-
}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/WSEndpoint.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/WSEndpoint.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/WSEndpoint.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -64,7 +64,7 @@
public void setPassword(String password);
@GuardedBy("this")
- public Class getUnderlyingObjectClass();
+ public Class<?> getUnderlyingObjectClass();
/**
*
@@ -81,7 +81,7 @@
* @param handler
*/
@GuardedBy("this")
- public void addHandler(Handler handler);
+ public void addHandler(Handler<?> handler);
/**
* Create the webmethods' map and it back. This maps would be used by
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/WSService.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/WSService.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/WSService.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -27,7 +27,7 @@
import net.jcip.annotations.ThreadSafe;
/**
- * It represents a sigle service. I can be used to retrieve endpoints (Ports) of this services.
+ * It represents a single service. I can be used to retrieve endpoints (Ports) of this services.
*
* @author Stefano Maestri, stefano.maestri(a)javalinux.it
*/
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/WebParameter.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/WebParameter.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/WebParameter.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -40,13 +40,13 @@
/**
*
* @return The name defined in the wsdl and {@link WebParam} annotation of
- * generated classses
+ * generated classes
*/
public String getName();
/**
*
- * @return The {@link Type} defined in generated classses
+ * @return The {@link Type} defined in generated classes
*/
public Type getType();
@@ -60,7 +60,7 @@
/**
*
* @return The {@link Mode} defined in the wsdl and {@link WebParam}
- * annotation of generated classses
+ * annotation of generated classes
*/
public Enum<WebParam.Mode> getMode();
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/factories/WSDynamicClientFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/factories/WSDynamicClientFactory.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/factories/WSDynamicClientFactory.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -48,7 +48,7 @@
synchronized (WSDynamicClientFactory.class) {
// If the logger has not been configured
if (Logger.getRootLogger().getAllAppenders() instanceof NullEnumeration) {
- // Use default log configuraiton to startup jbossmc
+ // Use default log configuration to startup jbossmc
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL url = cl.getResource("META-INF/" + WISE_LOG_CONFIG);
if (url != null) {
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/EndpointMethodCaller.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/EndpointMethodCaller.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/EndpointMethodCaller.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -22,11 +22,12 @@
package org.jboss.wise.core.client.impl.reflection;
import java.lang.reflect.Method;
-import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
+
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.Handler;
+
import org.jboss.wise.core.client.WSEndpoint;
import org.jboss.wise.core.wsextensions.WSExtensionEnabler;
@@ -83,7 +84,8 @@
if (epInstance.getHandlers() != null) {
for (Handler<?> handler : epInstance.getHandlers()) {
- List<Handler> handlerChain = ((BindingProvider)epUnderlyingObjectInstance.get()).getBinding().getHandlerChain();
+ @SuppressWarnings("rawtypes")
+ List<Handler> handlerChain = ((BindingProvider)epUnderlyingObjectInstance.get()).getBinding().getHandlerChain();
handlerChain.add(handler);
((BindingProvider)epUnderlyingObjectInstance.get()).getBinding().setHandlerChain(handlerChain);
}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/InvocationResultImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/InvocationResultImpl.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/InvocationResultImpl.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -53,7 +53,7 @@
this.originalObjects = new HashMap<String, Object>();
if (results == null) {
- results = Collections.EMPTY_MAP;
+ results = Collections.emptyMap();
}
this.originalObjects.putAll(results);
if (name != null && name.trim().length() != 0) {
Added: core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/SecurityActions.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/SecurityActions.java (rev 0)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/SecurityActions.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -0,0 +1,84 @@
+package org.jboss.wise.core.client.impl.reflection;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+public class SecurityActions {
+
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ /**
+ * Set context classloader.
+ *
+ * @param cl the classloader
+ * @return previous context classloader
+ * @throws Throwable for any error
+ */
+ static ClassLoader setContextClassLoader(final ClassLoader cl)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ else
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
+ public ClassLoader run() throws Exception
+ {
+ try
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException("ERROR_SETTING_CONTEXT_CLASSLOADER", e);
+ }
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new RuntimeException("ERROR_RUNNING_PRIVILEGED_ACTION", e.getCause());
+ }
+ }
+ }
+}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImpl.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImpl.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -113,8 +113,8 @@
wsExtensionEnablerDelegate = EnablerDelegateProvider.newEnablerDelegate(builder.getSecurityConfigFileURL(), builder
.getSecurityConfigName());
this.tmpDir = builder.getClientSpecificTmpDir();
- File outputDir = new File(tmpDir + "/classes/");
- File sourceDir = new File(tmpDir + "/src/");
+ final File outputDir = new File(new StringBuilder(tmpDir).append(File.separator).append("classes").append(File.separator).toString());
+ final File sourceDir = new File(new StringBuilder(tmpDir).append(File.separator).append("src").append(File.separator).toString());
try {
classNames.addAll(consumer.importObjectFromWsdl(builder.getNormalizedWsdlUrl(), outputDir, sourceDir, builder
@@ -135,19 +135,18 @@
private synchronized void initClassLoader(File outputDir) throws WiseRuntimeException {
try {
+ final ClassLoader oldLoader = SecurityActions.getContextClassLoader();
// we need a custom classloader pointing the temp dir
// in order to load the generated classes on the fly
- this.setClassLoader(new URLClassLoader(new URL[] { outputDir.toURI().toURL(), }, Thread.currentThread()
- .getContextClassLoader()));
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ this.setClassLoader(new URLClassLoader(new URL[] { outputDir.toURI().toURL(), }, oldLoader));
try {
- Thread.currentThread().setContextClassLoader(this.getClassLoader());
+ SecurityActions.setContextClassLoader(this.getClassLoader());
Class<?> clazz = JavaUtils.loadJavaType("javax.xml.ws.spi.Provider", this.getClassLoader());
clazz.getMethod("provider", new Class[]{}).invoke(null, new Object[]{});
} finally {
// restore the original classloader
- Thread.currentThread().setContextClassLoader(oldLoader);
+ SecurityActions.setContextClassLoader(oldLoader);
}
} catch (Exception e) {
throw new WiseRuntimeException(
@@ -161,10 +160,10 @@
* @see org.jboss.wise.core.client.WSDynamicClient#processServices()
*/
public synchronized Map<String, WSService> processServices() throws IllegalStateException {
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader oldLoader = SecurityActions.getContextClassLoader();
try {
- Thread.currentThread().setContextClassLoader(this.getClassLoader());
+ SecurityActions.setContextClassLoader(this.getClassLoader());
for (String className : classNames) {
try {
Class<?> clazz = JavaUtils.loadJavaType(className, this.getClassLoader());
@@ -183,7 +182,7 @@
}
} finally {
// restore the original classloader
- Thread.currentThread().setContextClassLoader(oldLoader);
+ SecurityActions.setContextClassLoader(oldLoader);
}
return servicesMap;
}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSEndpointImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSEndpointImpl.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSEndpointImpl.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -22,6 +22,8 @@
package org.jboss.wise.core.client.impl.reflection;
+import static org.jboss.wise.core.utils.DefaultConfig.MAX_THREAD_POOL_SIZE;
+
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.LinkedList;
@@ -30,14 +32,16 @@
import java.util.TreeMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+
import javax.jws.WebMethod;
import javax.xml.ws.handler.Handler;
+
import net.jcip.annotations.GuardedBy;
import net.jcip.annotations.ThreadSafe;
+
import org.jboss.wise.core.client.WSEndpoint;
import org.jboss.wise.core.client.WSMethod;
import org.jboss.wise.core.client.impl.reflection.WSServiceImpl.WSEndPointbuilder;
-import static org.jboss.wise.core.utils.DefaultConfig.MAX_THRED_POOL_SIZE;
import org.jboss.wise.core.wsextensions.WSExtensionEnabler;
/**
@@ -54,7 +58,7 @@
private String name;
@GuardedBy("this")
- private Class underlyingObjectClass;
+ private Class<?> underlyingObjectClass;
private final ExecutorService service;
@@ -84,7 +88,7 @@
if (maxThreadPoolSize >= 1) {
this.service = Executors.newFixedThreadPool(maxThreadPoolSize);
} else {
- this.service = Executors.newFixedThreadPool(MAX_THRED_POOL_SIZE.getIntValue());
+ this.service = Executors.newFixedThreadPool(MAX_THREAD_POOL_SIZE.getIntValue());
}
}
@@ -144,11 +148,11 @@
this.password = password;
}
- public synchronized Class getUnderlyingObjectClass() {
+ public synchronized Class<?> getUnderlyingObjectClass() {
return underlyingObjectClass;
}
- public synchronized void setUnderlyingObjectClass(Class clazz) {
+ public synchronized void setUnderlyingObjectClass(Class<?> clazz) {
this.underlyingObjectClass = clazz;
}
@@ -159,7 +163,7 @@
* @see #getWSMethods()
* @param handler
*/
- public void addHandler(Handler handler) {
+ public void addHandler(Handler<?> handler) {
handlers.add(handler);
}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSMethodImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSMethodImpl.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSMethodImpl.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -23,7 +23,6 @@
package org.jboss.wise.core.client.impl.reflection;
import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Arrays;
@@ -33,7 +32,6 @@
import java.util.concurrent.Future;
import javax.jws.Oneway;
import javax.jws.WebParam;
-import net.jcip.annotations.GuardedBy;
import net.jcip.annotations.Immutable;
import net.jcip.annotations.ThreadSafe;
import org.jboss.wise.core.client.InvocationResult;
@@ -71,7 +69,7 @@
/*
* Invokes this method with the provided arguments
*
- * @param args @return @throws WiseException If an unknowtn exception is
+ * @param args @return @throws WiseException If an unknown exception is
* received
*/
InvocationResultImpl invoke(Map<String, Object> args) throws InvocationException, IllegalArgumentException {
@@ -123,18 +121,18 @@
* @throws IllegalArgumentException
* @throws MappingException
*/
+ @SuppressWarnings("unchecked")
public InvocationResultImpl invoke(Object args, WiseMapper mapper) throws InvocationException, IllegalArgumentException, MappingException {
if (mapper == null) {
return this.invoke((Map<String, Object>) args);
}
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader oldLoader = SecurityActions.getContextClassLoader();
Map<String, Object> mappingResults;
try {
- Thread.currentThread().setContextClassLoader(this.getEndpoint().getClassLoader());
+ SecurityActions.setContextClassLoader(this.getEndpoint().getClassLoader());
mappingResults = mapper.applyMapping(args);
} finally {
- // restore the original classloader
- Thread.currentThread().setContextClassLoader(oldLoader);
+ SecurityActions.setContextClassLoader(oldLoader);
}
return this.invoke(mappingResults);
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSServiceImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSServiceImpl.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSServiceImpl.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -41,7 +41,7 @@
@Immutable
public class WSServiceImpl implements WSService {
- private final Class serviceClass;
+ private final Class<?> serviceClass;
private final URLClassLoader classLoader;
private final Object service;
private final String userName;
@@ -57,7 +57,7 @@
* @param password
* @param maxThreadPoolSize the max pool size for method execution of service attached endpoint.
*/
- public WSServiceImpl( Class serviceClass,
+ public WSServiceImpl( Class<?> serviceClass,
URLClassLoader classLoader,
Object service,
String userName,
@@ -110,10 +110,10 @@
private WSEndpoint getWiseEndpoint( Method method,
String name ) throws WiseRuntimeException {
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader oldLoader = SecurityActions.getContextClassLoader();
WSEndpointImpl ep = new WSEndpointImpl(this.maxThreadPoolSize);
try {
- Thread.currentThread().setContextClassLoader(this.getClassLoader());
+ SecurityActions.setContextClassLoader(this.getClassLoader());
ep.setClassLoader(this.getClassLoader());
// ep.setUnderlyingObjectInstance(this.getServiceClass().getMethod(method.getName(),
// method.getParameterTypes()).invoke(this.getService(),
@@ -129,13 +129,12 @@
} catch (Exception e) {
throw new WiseRuntimeException("Error while reading an endpoint!", e);
} finally {
- Thread.currentThread().setContextClassLoader(oldLoader);
+ SecurityActions.setContextClassLoader(oldLoader);
}
return ep;
}
- @SuppressWarnings( "unchecked" )
- private synchronized final Class getServiceClass() {
+ private synchronized final Class<?> getServiceClass() {
return serviceClass;
}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/builder/ReflectionBasedWSDynamicClientBuilder.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/builder/ReflectionBasedWSDynamicClientBuilder.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/builder/ReflectionBasedWSDynamicClientBuilder.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -22,12 +22,14 @@
package org.jboss.wise.core.client.impl.reflection.builder;
-import static org.jboss.wise.core.utils.DefaultConfig.MAX_THRED_POOL_SIZE;
+import static org.jboss.wise.core.utils.DefaultConfig.MAX_THREAD_POOL_SIZE;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.List;
import net.jcip.annotations.GuardedBy;
@@ -63,7 +65,7 @@
private String password;
@GuardedBy("this")
- private String tmpDir = System.getProperty("java.io.tmpdir");
+ private String tmpDir = AccessController.doPrivileged(new PropertyAccessAction("java.io.tmpdir"));
@GuardedBy("this")
private String targetPackage;
@@ -96,7 +98,7 @@
private PrintStream messageStream = System.out;
@GuardedBy("this")
- private int maxThreadPoolSize = MAX_THRED_POOL_SIZE.getIntValue();
+ private int maxThreadPoolSize = MAX_THREAD_POOL_SIZE.getIntValue();
public ReflectionBasedWSDynamicClientBuilder() {
super();
@@ -110,8 +112,7 @@
public synchronized WSDynamicClient build() throws IllegalStateException, WiseRuntimeException {
clientSpecificTmpDir = tmpDir;
if (clientSpecificTmpDir != null) {
- String id = IDGenerator.nextVal();
- clientSpecificTmpDir = tmpDir + "/Wise" + id;
+ clientSpecificTmpDir = new StringBuilder().append(tmpDir).append(File.separator).append("Wise").append(IDGenerator.nextVal()).toString();
File tmpDirFile = new File(clientSpecificTmpDir);
try {
FileUtils.forceMkdir(tmpDirFile);
@@ -413,5 +414,18 @@
this.maxThreadPoolSize = maxThreadPoolSize;
return this;
}
+
+ private static class PropertyAccessAction implements PrivilegedAction<String> {
+ private final String name;
+
+ PropertyAccessAction(String name) {
+ this.name = name;
+ }
+
+ public String run() {
+ return System.getProperty(name);
+ }
+ }
+
}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/wsdlResolver/Connection.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/wsdlResolver/Connection.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/wsdlResolver/Connection.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -27,12 +27,11 @@
import java.net.HttpURLConnection;
import java.net.URL;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.jboss.wise.core.exception.WiseRuntimeException;
import org.jboss.ws.common.utils.JarUrlConnection;
-import sun.misc.BASE64Encoder;
-
/**
*
* @author alessio.soldano(a)jboss.com
@@ -99,7 +98,7 @@
// BASIC AUTH
String usernamePassword = getUserNameAndPasswordForBasicAuthentication();
if (usernamePassword != null && usernamePassword.length() != 0) {
- conn.setRequestProperty("Authorization", "Basic " + (new BASE64Encoder()).encode(usernamePassword.getBytes()));
+ conn.setRequestProperty("Authorization", "Basic " + new String(Base64.encodeBase64(usernamePassword.getBytes())));
}
return conn;
} catch (Exception e) {
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/wsdlResolver/WSDLResolver.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/wsdlResolver/WSDLResolver.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/wsdlResolver/WSDLResolver.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -89,7 +89,7 @@
Definition def = getWsdlDefinition(wsdlURL);
- URL savedWsdlURL = wsdlFile.toURL();
+ URL savedWsdlURL = wsdlFile.toURI().toURL();
log.info("WSDL saved to: " + savedWsdlURL);
// Process the wsdl imports
@@ -98,7 +98,7 @@
// Publish XMLSchema imports
for (Element documentElement : getSchemaElements(def)) {
- saveSchemaImports(wsdlFile.toURL(), documentElement, saved, wsdlURL);
+ saveSchemaImports(wsdlFile.toURI().toURL(), documentElement, saved, wsdlURL);
}
// save modified file
@@ -141,7 +141,7 @@
Types types = definition.getTypes();
List<Element> result = new LinkedList<Element>();
if (types != null && types.getExtensibilityElements().size() > 0) {
- List extElements = types.getExtensibilityElements();
+ List<?> extElements = types.getExtensibilityElements();
int len = extElements.size();
for (int i = 0; i < len; i++) {
ExtensibilityElement extElement = (ExtensibilityElement) extElements.get(i);
@@ -172,7 +172,7 @@
private void saveWsdlImports(URL parentURL, Definition parentDefinition, Map<String, String> saved, URL wsdlURL) throws Exception {
String baseURI = parentURL.toExternalForm();
- Iterator it = parentDefinition.getImports().values().iterator();
+ Iterator<?> it = parentDefinition.getImports().values().iterator();
while (it.hasNext()) {
for (Import wsdlImport : (List<Import>) it.next()) {
String locationURI = wsdlImport.getLocationURI();
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/consumer/WSConsumer.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/consumer/WSConsumer.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/consumer/WSConsumer.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -93,13 +93,16 @@
return name.endsWith(".class");
}
};
- File scanDir = new File(outputDir.getAbsolutePath() + "/" + targetPackage.replaceAll("\\.", "/") + "/");
+ File scanDir = new File(new StringBuilder(outputDir.getAbsolutePath()).append(File.separator)
+ .append(targetPackage.replaceAll("\\.", File.separator)).append(File.separator).toString());
String[] children = scanDir.list(filter);
- for (int i = 0; children != null && i < children.length; i++) {
- classNames.add(targetPackage + "." + children[i].substring(0, children[i].length() - 6));
+ if (children != null) {
+ for (int i = 0; i < children.length; i++) {
+ classNames.add(targetPackage + "." + children[i].substring(0, children[i].length() - 6));
+ }
}
if (classNames.size() == 0) {
- throw new WiseRuntimeException("No classs foung in dir " + outputDir + "for targetPackage " + targetPackage);
+ throw new WiseRuntimeException("No classs found in dir " + outputDir + " for targetPackage " + targetPackage);
}
return classNames;
@@ -108,7 +111,7 @@
public List<String> getClassNames( File outputDir ) throws WiseRuntimeException {
List<String> classNames = this.getClassNames(outputDir, outputDir);
if (classNames.size() == 0) {
- throw new WiseRuntimeException("No classs foung in dir " + outputDir + "for targetPackage unspecified");
+ throw new WiseRuntimeException("No classs found in dir " + outputDir + " for unspecified targetPackage");
}
return classNames;
}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/jbossws/DefaultWSImportImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/jbossws/DefaultWSImportImpl.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/jbossws/DefaultWSImportImpl.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -24,6 +24,8 @@
import java.io.File;
import java.io.PrintStream;
import java.net.MalformedURLException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.LinkedList;
import java.util.List;
@@ -59,7 +61,7 @@
@Override
public synchronized List<String> importObjectFromWsdl(String wsdlURL, File outputDir, File sourceDir, String targetPackage, List<File> bindingFiles, PrintStream messageStream, File catelog) throws MalformedURLException, WiseRuntimeException {
- WSContractConsumer wsImporter = WSContractConsumer.newInstance(Thread.currentThread().getContextClassLoader());
+ WSContractConsumer wsImporter = WSContractConsumer.newInstance(getContextClassLoader());
if (targetPackage != null && targetPackage.trim().length() > 0) {
wsImporter.setTargetPackage(targetPackage);
@@ -102,12 +104,30 @@
List<String> cp = new LinkedList<String>();
for (String jar : neededClasses) {
try {
- cp.add(Thread.currentThread().getContextClassLoader().getResource(jar).getPath().split("!")[0]);
+ cp.add(getContextClassLoader().getResource(jar).getPath().split("!")[0]);
} catch (NullPointerException npe) {
- Logger.getLogger(this.getClass()).debug("Didnt't find jar needed by wsImport API:" + jar);
+ Logger.getLogger(this.getClass()).debug("Did not find jar needed by wsImport API:" + jar);
}
}
return cp;
}
+
+ private static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/metro/LocalFirstClassLoader.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/metro/LocalFirstClassLoader.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/metro/LocalFirstClassLoader.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -34,7 +34,7 @@
@Override
public synchronized Class<?> loadClass( String name,
boolean resolve ) throws ClassNotFoundException {
- Class claz = findLoadedClass(name);
+ Class<?> claz = findLoadedClass(name);
if (claz == null) {
try {
claz = findClass(name);
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/metro/MetroWSConsumer.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/metro/MetroWSConsumer.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/consumer/impl/metro/MetroWSConsumer.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -28,6 +28,8 @@
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.List;
import org.apache.log4j.Logger;
import org.jboss.wise.core.consumer.WSConsumer;
@@ -45,11 +47,11 @@
List<File> bindingFiles,
PrintStream messageStream,
File catelog) throws MalformedURLException, WiseRuntimeException {
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader oldClassLoader = getContextClassLoader();
LocalFirstClassLoader metroClassLoader = new LocalFirstClassLoader(getMertroJars(), oldClassLoader);
try {
- Class wsImportClaz = metroClassLoader.loadClass("com.sun.tools.ws.WsImport");
+ Class<?> wsImportClaz = metroClassLoader.loadClass("com.sun.tools.ws.WsImport");
Method mainMethod = wsImportClaz.getDeclaredMethod("doMain", new Class[] {String[].class});
List<String> args = new java.util.ArrayList<String>();
args.add("-keep");
@@ -118,7 +120,7 @@
for (String jar : jars) {
File jarFile = new File(metroLibPath + "/" + jar);
try {
- urls.add(jarFile.toURL());
+ urls.add(jarFile.toURI().toURL());
} catch (MalformedURLException e) {
log.error("Failed to getURL from the metro jar file ", e);
}
@@ -130,5 +132,22 @@
}
+ private static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/exception/InvocationException.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/exception/InvocationException.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/exception/InvocationException.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -29,6 +29,8 @@
*/
public class InvocationException extends Exception {
+ private static final long serialVersionUID = 5648725651299619979L;
+
public InvocationException(String message, Throwable cause) {
super(message, cause);
}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/exception/MappingException.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/exception/MappingException.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/exception/MappingException.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -29,6 +29,8 @@
*/
public class MappingException extends Exception {
+ private static final long serialVersionUID = 5830827412437161462L;
+
public MappingException( String message,
Throwable cause ) {
super(message, cause);
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/handlers/LoggingHandler.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/handlers/LoggingHandler.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/handlers/LoggingHandler.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -24,7 +24,6 @@
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
-import java.io.StringWriter;
import java.util.HashSet;
import java.util.Set;
import javax.xml.namespace.QName;
@@ -35,7 +34,6 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
import net.jcip.annotations.Immutable;
import net.jcip.annotations.ThreadSafe;
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/handlers/SmooksHandler.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/handlers/SmooksHandler.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/handlers/SmooksHandler.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -29,6 +29,7 @@
import java.util.Map;
import java.util.Set;
+import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.stream.StreamResult;
@@ -51,9 +52,7 @@
import org.milyn.cdr.XMLConfigDigester;
import org.milyn.container.ExecutionContext;
import org.milyn.event.report.HtmlReportGenerator;
-import org.milyn.javabean.BeanAccessor;
import org.milyn.javabean.repository.BeanRepository;
-import org.milyn.javabean.repository.BeanRepositoryManager;
import org.milyn.profile.DefaultProfileSet;
import org.milyn.profile.ProfileStore;
import org.milyn.profile.UnknownProfileMemberException;
@@ -73,7 +72,7 @@
@ThreadSafe
public class SmooksHandler implements SOAPHandler<SOAPMessageContext> {
- private final Map beansMap;
+ private final Map<String, Object> beansMap;
private final Smooks smooks;
@@ -95,7 +94,7 @@
* @param client
* @param smooksReport
*/
- public SmooksHandler(String smooksResource, Map beans, WSDynamicClient client, String smooksReport) {
+ public SmooksHandler(String smooksResource, Map<String, Object> beans, WSDynamicClient client, String smooksReport) {
assert smooksResource != null;
@@ -126,7 +125,7 @@
this.beansMap = beans;
}
- public Set getHeaders() {
+ public Set<QName> getHeaders() {
return null;
}
@@ -182,14 +181,14 @@
StringWriter transResult = new StringWriter();
BeanRepository.getInstance(executionContext).getBeanMap().putAll(this.beansMap);
- StringWriter buffer;
outStream = new ByteArrayOutputStream();
message.writeTo(outStream);
outStream.flush();
inStream = new ByteArrayInputStream(outStream.toByteArray());
- smooks.filter(new StreamSource(inStream), new StreamResult(transResult), executionContext);
+ smooks.filterSource(executionContext, new StreamSource(inStream), new StreamResult(transResult));
inStream.close();
inStream = new ByteArrayInputStream(transResult.toString().getBytes());
+ //TODO evaluate avoiding buinding up a new factory each time + check for soap 1.2
SOAPMessage message2 = MessageFactory.newInstance().createMessage(message.getMimeHeaders(), inStream);
return message2;
} finally {
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/mapper/SmooksMapper.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/mapper/SmooksMapper.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/mapper/SmooksMapper.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -23,7 +23,10 @@
package org.jboss.wise.core.mapper;
import java.io.IOException;
-import java.util.Arrays;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Map;
import javax.xml.transform.Source;
@@ -41,7 +44,6 @@
import org.milyn.cdr.SmooksResourceConfigurationList;
import org.milyn.cdr.XMLConfigDigester;
import org.milyn.container.ExecutionContext;
-import org.milyn.container.plugin.PayloadProcessor;
import org.milyn.event.report.HtmlReportGenerator;
import org.milyn.payload.JavaResult;
import org.milyn.payload.JavaSource;
@@ -70,10 +72,10 @@
}
public SmooksMapper(String smooksResource, String smooksReport, WSDynamicClient client) {
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader oldLoader = getContextClassLoader();
try {
- Thread.currentThread().setContextClassLoader(client.getClassLoader());
+ setContextClassLoader(client.getClassLoader());
smooks = client.getSmooksInstance();
try {
@@ -102,7 +104,7 @@
throw new WiseRuntimeException("failde to create SmooksMapper", e);
} finally {
// restore the original classloader
- Thread.currentThread().setContextClassLoader(oldLoader);
+ setContextClassLoader(oldLoader);
}
}
@@ -136,12 +138,13 @@
* wsdl/wsconsume generated classes
* @throws MappingException
*/
+ @SuppressWarnings("unchecked")
public Map<String, Object> applyMapping(Object originalObjects) throws MappingException {
ExecutionContext executionContext = initExecutionContext(smooksReport);
Source source = new JavaSource(originalObjects);
JavaResult result = new JavaResult();
- smooks.filter(source, result, executionContext);
+ smooks.filterSource(executionContext, source, result);
Map<String, Object> returnMap = result.getResultMap();
@@ -154,5 +157,68 @@
return returnMap;
}
+
+ private static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ private static ClassLoader setContextClassLoader(final ClassLoader cl)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ else
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
+ public ClassLoader run() throws Exception
+ {
+ try
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException("ERROR_SETTING_CONTEXT_CLASSLOADER", e);
+ }
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new RuntimeException("ERROR_RUNNING_PRIVILEGED_ACTION", e.getCause());
+ }
+ }
+ }
}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/test/WiseTest.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/test/WiseTest.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/test/WiseTest.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -90,8 +90,9 @@
*/
public URL getArchiveUrl( String archiveName ) {
URL warUrl = null;
- URL dirURL = this.getClass().getClassLoader().getResource(".");
- File file = new File(dirURL.getFile(), ".." + File.separator + TEST_WS_ARCHIVE_DIR + File.separator + archiveName);
+ final URL dirURL = this.getClass().getClassLoader().getResource(".");
+ final File parent = new File(dirURL.getFile()).getParentFile();
+ final File file = new File(parent, TEST_WS_ARCHIVE_DIR + File.separator + archiveName);
if (file.exists()) {
try {
warUrl = file.getAbsoluteFile().toURI().toURL();
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/utils/DefaultConfig.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/utils/DefaultConfig.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/utils/DefaultConfig.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -29,7 +29,7 @@
* @author Stefano Maestri stefano.maestri(a)javalinux.it
*/
public enum DefaultConfig {
- MAX_THRED_POOL_SIZE("100");
+ MAX_THREAD_POOL_SIZE("100");
Object value;
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/utils/IDGenerator.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/utils/IDGenerator.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/utils/IDGenerator.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -22,11 +22,8 @@
package org.jboss.wise.core.utils;
-import java.util.Random;
import java.util.UUID;
-import org.apache.commons.lang.math.RandomUtils;
-
/**
* Generates unique ID numbers, almost like a database sequence.
*
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/utils/IOUtils.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/utils/IOUtils.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/utils/IOUtils.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -30,7 +30,7 @@
import org.jboss.wise.core.exception.WiseRuntimeException;
/**
- * IO utilites
+ * IO utilities
*
* @author stefano.maestri(a)javalinux.it class imported from JBossWS. Kept methods useful for Wise
*/
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/utils/JavaUtils.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/utils/JavaUtils.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/utils/JavaUtils.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -23,32 +23,17 @@
package org.jboss.wise.core.utils;
import java.lang.reflect.Array;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
import java.util.HashMap;
-import java.util.HashSet;
-import org.jboss.logging.Logger;
/**
* Java utilities
*
* @author stefano.maestri(a)javalinux.it class imported from JBossWS.
*/
-// TODO: remove unused method
public class JavaUtils {
- // provide logging
- private static final Logger log = Logger.getLogger(JavaUtils.class);
- private static HashMap<String, Class> primitiveNames = new HashMap<String, Class>(8);
+ private static HashMap<String, Class<?>> primitiveNames = new HashMap<String, Class<?>>(8);
- private static HashMap<String, String> primitiveNameDescriptors = new HashMap<String, String>(8);
-
- private static HashSet<String> reservedKeywords = new HashSet<String>(50);
-
static {
primitiveNames.put("int", int.class);
primitiveNames.put("short", short.class);
@@ -58,94 +43,21 @@
primitiveNames.put("double", double.class);
primitiveNames.put("float", float.class);
primitiveNames.put("char", char.class);
-
- primitiveNameDescriptors.put("int", "I");
- primitiveNameDescriptors.put("short", "S");
- primitiveNameDescriptors.put("boolean", "Z");
- primitiveNameDescriptors.put("byte", "B");
- primitiveNameDescriptors.put("long", "J");
- primitiveNameDescriptors.put("double", "D");
- primitiveNameDescriptors.put("float", "F");
- primitiveNameDescriptors.put("char", "C");
-
- reservedKeywords.add("abstract");
- reservedKeywords.add("continue");
- reservedKeywords.add("for");
- reservedKeywords.add("new");
- reservedKeywords.add("switch");
- reservedKeywords.add("assert");
- reservedKeywords.add("default");
- reservedKeywords.add("if");
- reservedKeywords.add("package");
- reservedKeywords.add("synchronized");
- reservedKeywords.add("boolean");
- reservedKeywords.add("do");
- reservedKeywords.add("goto");
- reservedKeywords.add("private");
- reservedKeywords.add("this");
- reservedKeywords.add("break");
- reservedKeywords.add("double");
- reservedKeywords.add("implements");
- reservedKeywords.add("protected");
- reservedKeywords.add("throw");
- reservedKeywords.add("byte");
- reservedKeywords.add("else");
- reservedKeywords.add("import");
- reservedKeywords.add("public");
- reservedKeywords.add("throws");
- reservedKeywords.add("case");
- reservedKeywords.add("enum");
- reservedKeywords.add("instanceof");
- reservedKeywords.add("return");
- reservedKeywords.add("transient");
- reservedKeywords.add("catch");
- reservedKeywords.add("extends");
- reservedKeywords.add("int");
- reservedKeywords.add("short");
- reservedKeywords.add("try");
- reservedKeywords.add("char");
- reservedKeywords.add("final");
- reservedKeywords.add("interface");
- reservedKeywords.add("static");
- reservedKeywords.add("void");
- reservedKeywords.add("class");
- reservedKeywords.add("finally");
- reservedKeywords.add("long");
- reservedKeywords.add("strictfp");
- reservedKeywords.add("volatile");
- reservedKeywords.add("const");
- reservedKeywords.add("float");
- reservedKeywords.add("native");
- reservedKeywords.add("super");
- reservedKeywords.add("while");
}
/**
* Load a Java type from a given class loader.
*
* @param typeName
- * maybe the source notation of a primitve, class name, array of
- * both
- * @return Class
- * @throws ClassNotFoundException
- */
- public static Class loadJavaType(String typeName) throws ClassNotFoundException {
- return loadJavaType(typeName, null);
- }
-
- /**
- * Load a Java type from a given class loader.
- *
- * @param typeName
* @param classLoader
* @return Class
* @throws ClassNotFoundException
*/
- public static Class loadJavaType(String typeName, ClassLoader classLoader) throws ClassNotFoundException {
+ public static Class<?> loadJavaType(String typeName, ClassLoader classLoader) throws ClassNotFoundException {
if (classLoader == null)
classLoader = Thread.currentThread().getContextClassLoader();
- Class javaType = primitiveNames.get(typeName);
+ Class<?> javaType = primitiveNames.get(typeName);
if (javaType == null)
javaType = getArray(typeName, classLoader);
@@ -156,43 +68,17 @@
}
/**
- * True if the given type name is the source notation of a primitive or
- * array of which.
- *
- * @param javaType
- * @return boolean
- */
- public static boolean isPrimitive(String javaType) {
- return getPrimitiveType(javaType) != null;
- }
-
- /**
* True if the given class is a primitive or array of which.
*
* @param javaType
* boolean
* @return boolean
*/
- public static boolean isPrimitive(Class javaType) {
+ public static boolean isPrimitive(Class<?> javaType) {
return javaType.isPrimitive() || (javaType.isArray() && isPrimitive(javaType.getComponentType()));
}
- public static Class getPrimitiveType(String javaType) {
- Class type = primitiveNames.get(javaType);
- if (type != null)
- return type;
-
- try {
- // null loader = primitive only
- type = getArray(javaType, null);
- } catch (ClassNotFoundException e) {
- // This will actually never be thrown since is null
- }
-
- return type;
- }
-
- private static Class getArray(String javaType, ClassLoader loader) throws ClassNotFoundException {
+ private static Class<?> getArray(String javaType, ClassLoader loader) throws ClassNotFoundException {
if (javaType.charAt(0) == '[')
return getArrayFromJVMName(javaType, loader);
@@ -202,8 +88,8 @@
return null;
}
- private static Class getArrayFromJVMName(String javaType, ClassLoader loader) throws ClassNotFoundException {
- Class componentType;
+ private static Class<?> getArrayFromJVMName(String javaType, ClassLoader loader) throws ClassNotFoundException {
+ Class<?> componentType;
int componentStart = javaType.lastIndexOf('[') + 1;
switch (javaType.charAt(componentStart)) {
case 'I':
@@ -245,11 +131,11 @@
return Array.newInstance(componentType, new int[componentStart]).getClass();
}
- private static Class getArrayFromSourceName(String javaType, ClassLoader loader) throws ClassNotFoundException {
+ private static Class<?> getArrayFromSourceName(String javaType, ClassLoader loader) throws ClassNotFoundException {
int arrayStart = javaType.indexOf('[');
String componentName = javaType.substring(0, arrayStart);
- Class componentType = primitiveNames.get(componentName);
+ Class<?> componentType = primitiveNames.get(componentName);
if (componentType == null) {
if (loader == null)
return null;
@@ -264,87 +150,13 @@
}
/**
- * Get the corresponding primitive for a give wrapper type. Also handles
- * arrays of which.
- *
- * @param javaType
- * @return Class
- */
- public static Class getPrimitiveType(Class javaType) {
- if (javaType == Integer.class)
- return int.class;
- if (javaType == Short.class)
- return short.class;
- if (javaType == Boolean.class)
- return boolean.class;
- if (javaType == Byte.class)
- return byte.class;
- if (javaType == Long.class)
- return long.class;
- if (javaType == Double.class)
- return double.class;
- if (javaType == Float.class)
- return float.class;
- if (javaType == Character.class)
- return char.class;
-
- if (javaType == Integer[].class)
- return int[].class;
- if (javaType == Short[].class)
- return short[].class;
- if (javaType == Boolean[].class)
- return boolean[].class;
- if (javaType == Byte[].class)
- return byte[].class;
- if (javaType == Long[].class)
- return long[].class;
- if (javaType == Double[].class)
- return double[].class;
- if (javaType == Float[].class)
- return float[].class;
- if (javaType == Character[].class)
- return char[].class;
-
- if (javaType.isArray() && javaType.getComponentType().isArray()) {
- Class compType = getPrimitiveType(javaType.getComponentType());
- return Array.newInstance(compType, 0).getClass();
- }
-
- return javaType;
- }
-
- /**
- * Converts an n-dimensional array of wrapper types to primitive types
- *
- * @param value
- * @return Object
- */
- public static Object getPrimitiveValueArray(Object value) {
- if (value == null)
- return null;
-
- Class javaType = value.getClass();
- if (javaType.isArray()) {
- int length = Array.getLength(value);
- Object destArr = Array.newInstance(getPrimitiveType(javaType.getComponentType()), length);
- for (int i = 0; i < length; i++) {
- Object srcObj = Array.get(value, i);
- Array.set(destArr, i, getPrimitiveValueArray(srcObj));
- }
- return destArr;
- }
-
- return value;
- }
-
- /**
* Get the corresponding wrapper type for a give primitive. Also handles
* arrays of which.
*
* @param javaType
* @return Class
*/
- public static Class getWrapperType(Class javaType) {
+ public static Class<?> getWrapperType(Class<?> javaType) {
if (javaType == int.class)
return Integer.class;
if (javaType == short.class)
@@ -380,142 +192,13 @@
return Character[].class;
if (javaType.isArray() && javaType.getComponentType().isArray()) {
- Class compType = getWrapperType(javaType.getComponentType());
+ Class<?> compType = getWrapperType(javaType.getComponentType());
return Array.newInstance(compType, 0).getClass();
}
return javaType;
}
- /**
- * Converts an n-dimensional array of primitive types to wrapper types
- *
- * @param value
- * @return Object
- */
- public static Object getWrapperValueArray(Object value) {
- if (value == null)
- return null;
-
- Class javaType = value.getClass();
- if (javaType.isArray()) {
- int length = Array.getLength(value);
- Object destArr = Array.newInstance(getWrapperType(javaType.getComponentType()), length);
- for (int i = 0; i < length; i++) {
- Object srcObj = Array.get(value, i);
- Array.set(destArr, i, getWrapperValueArray(srcObj));
- }
- return destArr;
- }
-
- return value;
- }
-
- public static Object syncArray(Object array, Class target) {
- return (JavaUtils.isPrimitive(target)) ? JavaUtils.getPrimitiveValueArray(array) : JavaUtils.getWrapperValueArray(array);
- }
-
- /**
- * Return true if the dest class is assignable from the src. Also handles
- * arrays and primitives.
- *
- * @param dest
- * @param src
- * @return boolean
- */
- public static boolean isAssignableFrom(Class dest, Class src) {
- if (dest == null)
- throw new IllegalArgumentException("Destination class cannot be null");
- if (src == null)
- throw new IllegalArgumentException("Source class cannot be null");
-
- boolean isAssignable = dest.isAssignableFrom(src);
- if (isAssignable == false && dest.getName().equals(src.getName())) {
- ClassLoader destLoader = dest.getClassLoader();
- ClassLoader srcLoader = src.getClassLoader();
- if (log.isDebugEnabled())
- log
- .debug("Not assignable because of conflicting class loaders:\ndstLoader=" + destLoader + "\nsrcLoader=" + srcLoader);
- }
-
- if (isAssignable == false && isPrimitive(dest)) {
- dest = getWrapperType(dest);
- isAssignable = dest.isAssignableFrom(src);
- }
- if (isAssignable == false && isPrimitive(src)) {
- src = getWrapperType(src);
- isAssignable = dest.isAssignableFrom(src);
- }
- return isAssignable;
- }
-
- public static String convertJVMNameToSourceName(String typeName, ClassLoader loader) {
- // TODO Don't use a ClassLoader for this, we need to just convert it
- try {
- Class javaType = loadJavaType(typeName, loader);
- typeName = getSourceName(javaType);
- } catch (Exception e) {
- }
-
- return typeName;
- }
-
- /**
- * Converts a JVM external name to a JVM signature name. An external name is
- * that which is returned from {@link Class#getName()} A signature name is
- * the name in class file format.
- * <p>
- * For example:
- * <p>
- * [java.lang.Object
- * <p>
- * becomes:
- * <p>
- * [Ljava/lang/Object;
- *
- * @param externalName
- * @return Strimg
- */
- public static String toSignature(String externalName) {
- if (externalName == null)
- return null;
-
- String ret = primitiveNameDescriptors.get(externalName);
- if (ret != null)
- return ret;
-
- ret = externalName.replace('.', '/');
- return (ret.charAt(0) == '[') ? ret : "L" + ret + ";";
- }
-
- public static String printArray(Object[] val) {
- if (val == null)
- return "null";
-
- StringBuilder out = new StringBuilder("[");
- for (int i = 0; i < val.length; i++) {
- if (i > 0) {
- out.append(",");
- }
- out.append(val[i].getClass().isArray() ? printArray((Object[]) val[i]) : val[i]);
- }
- return out.append("]").toString();
- }
-
- public static String getSourceName(Class type) {
- if (!type.isArray())
- return type.getName();
-
- String arrayNotation = "";
- Class component = type;
- while (component.isArray()) {
- component = component.getComponentType();
- arrayNotation += "[]";
- }
-
- return component.getName() + arrayNotation;
- }
-
public static String capitalize(String source) {
if (source == null)
return null;
@@ -531,114 +214,4 @@
return c + source.substring(1);
}
- public static boolean isLoaded(String className, ClassLoader loader) {
- try {
- loadJavaType(className, loader);
- } catch (ClassNotFoundException e) {
- return false;
- }
-
- return true;
- }
-
- public static String getPackageName(Class<?> clazz) {
- String fullName = clazz.getName();
- return fullName.substring(0, fullName.lastIndexOf("."));
- }
-
- public static boolean isReservedKeyword(String keyword) {
- return reservedKeywords.contains(keyword);
- }
-
- /**
- * Erases a type according to the JLS type erasure rules
- *
- * @param type
- * @return erased type
- */
- public static Class erasure(Type type) {
- if (type instanceof ParameterizedType) {
- return erasure(((ParameterizedType) type).getRawType());
- }
- if (type instanceof TypeVariable) {
- return erasure(((TypeVariable) type).getBounds()[0]);
- }
- if (type instanceof WildcardType) {
- return erasure(((WildcardType) type).getUpperBounds()[0]);
- }
- if (type instanceof GenericArrayType) {
- return Array.newInstance(erasure(((GenericArrayType) type).getGenericComponentType()), 0).getClass();
- }
-
- // Only type left is class
- return (Class) type;
- }
-
- public static String[] getRawParameterTypeArguments(ParameterizedType type) {
- Type[] arguments = type.getActualTypeArguments();
- String[] ret = new String[arguments.length];
- for (int i = 0; i < arguments.length; i++) {
- Class raw = erasure(arguments[i]);
- ret[i] = raw.getName();
- }
-
- return ret;
- }
-
- /**
- * This method tests for retro translation by searching for a known problem
- * where Class does not implement Type. If this is true, then code must
- * never cast a Class to a Type.
- *
- * @return true if we are in retro
- */
- public static boolean isRetro14() {
- return !(String.class instanceof java.lang.reflect.Type);
- }
-
- /**
- * Tests if this class loader is a JBoss RepositoryClassLoader
- *
- * @param loader
- * @return boolean
- */
- public static boolean isJBossRepositoryClassLoader(ClassLoader loader) {
- Class clazz = loader.getClass();
- while (!clazz.getName().startsWith("java")) {
- if ("org.jboss.mx.loading.RepositoryClassLoader".equals(clazz.getName()))
- return true;
- clazz = clazz.getSuperclass();
- }
-
- return false;
- }
-
- /**
- * Clears black lists on a JBoss RepositoryClassLoader. This is somewhat of
- * a hack, and could be replaced with an integration module. This is needed
- * when the following order of events occur.
- * <ol>
- * <li>loadClass() returns not found</li>
- * <li>Some call to defineClass()</li>
- * <ol>
- * The CNFE triggers a black list addition, which cause the class never
- * again to be found.
- *
- * @param loader
- * the loader to clear black lists for
- */
- public static void clearBlacklists(ClassLoader loader) {
- if (isJBossRepositoryClassLoader(loader)) {
- for (Method m : loader.getClass().getMethods()) {
- if ("clearBlackLists".equalsIgnoreCase(m.getName())) {
- try {
- m.invoke(loader);
- } catch (Exception e) {
- if (log.isDebugEnabled())
- log.debug("Could not clear blacklists on " + loader);
- }
- }
- }
- }
- }
}
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/utils/ReflectionUtils.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/utils/ReflectionUtils.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/utils/ReflectionUtils.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -42,8 +42,7 @@
* @param cl the class to reflect to.
* @return all fields of the provided class
*/
- @SuppressWarnings( "unchecked" )
- public static List<Field> getAllFields( Class cl ) {
+ public static List<Field> getAllFields( Class<?> cl ) {
List<Field> list = new LinkedList<Field>();
for (Field field : cl.getDeclaredFields()) {
if (!"serialVersionUID".equals(field.getName())) {
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/wsextensions/impl/MTOMEnabler.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/wsextensions/impl/MTOMEnabler.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/wsextensions/impl/MTOMEnabler.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -24,7 +24,6 @@
import net.jcip.annotations.Immutable;
import net.jcip.annotations.ThreadSafe;
import org.jboss.wise.core.client.WSDynamicClient;
-import org.jboss.wise.core.client.WSEndpoint;
import org.jboss.wise.core.wsextensions.EnablerDelegate;
import org.jboss.wise.core.wsextensions.WSExtensionEnabler;
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/wsextensions/impl/WSAddressingEnabler.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/wsextensions/impl/WSAddressingEnabler.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/wsextensions/impl/WSAddressingEnabler.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -24,7 +24,6 @@
import net.jcip.annotations.Immutable;
import net.jcip.annotations.ThreadSafe;
import org.jboss.wise.core.client.WSDynamicClient;
-import org.jboss.wise.core.client.WSEndpoint;
import org.jboss.wise.core.wsextensions.EnablerDelegate;
import org.jboss.wise.core.wsextensions.WSExtensionEnabler;
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/wsextensions/impl/WSRMEnabler.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/wsextensions/impl/WSRMEnabler.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/wsextensions/impl/WSRMEnabler.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -23,8 +23,8 @@
import net.jcip.annotations.Immutable;
import net.jcip.annotations.ThreadSafe;
+
import org.jboss.wise.core.client.WSDynamicClient;
-import org.jboss.wise.core.client.WSEndpoint;
import org.jboss.wise.core.wsextensions.EnablerDelegate;
import org.jboss.wise.core.wsextensions.WSExtensionEnabler;
Modified: core/trunk/core/src/main/java/org/jboss/wise/smooks/decoders/DurationDecoder.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/smooks/decoders/DurationDecoder.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/main/java/org/jboss/wise/smooks/decoders/DurationDecoder.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -32,8 +32,8 @@
/**
* {@link javax.xml.datatype.Duration} data decoder.
* <p/>
- * Decodes the supplied string into a {@link javax.xml.datatype.Duration} String value is supposed to be millisecs representing
- * this Duaration
+ * Decodes the supplied string into a {@link javax.xml.datatype.Duration} String value is supposed to be milliseconds representing
+ * this Duration
*/
@DecodeType( Duration.class )
public class DurationDecoder extends DateDecoder implements DataDecoder {
Modified: core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/reflection/InvocationResultImplTest.java
===================================================================
--- core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/reflection/InvocationResultImplTest.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/reflection/InvocationResultImplTest.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -44,21 +44,21 @@
public void shoudReturnAnOriginaObjectsEmptyMapIfNameIsNull() throws Exception {
results = new InvocationResultImpl(null, new Long(1), null);
Map<String, Object> mappedResult = results.getMapRequestAndResult(null, null);
- assertThat(((Map)mappedResult.get("results")).isEmpty(), is(true));
+ assertThat(((Map<?,?>)mappedResult.get("results")).isEmpty(), is(true));
}
@Test
public void shoudReturnAnOriginaObjectsEmptyMapIfNameIsEmptyString() throws Exception {
results = new InvocationResultImpl(" ", new Long(1), null);
Map<String, Object> mappedResult = results.getMapRequestAndResult(null, null);
- assertThat(((Map)mappedResult.get("results")).isEmpty(), is(true));
+ assertThat(((Map<?,?>)mappedResult.get("results")).isEmpty(), is(true));
}
@Test
public void shouldReturnOriginalObjectIfMapperIsNull() throws Exception {
results = new InvocationResultImpl("result", new Long(1), null);
Map<String, Object> mappedResult = results.getMapRequestAndResult(null, null);
- assertThat((Long)((Map)mappedResult.get("results")).get("result"), equalTo(new Long(1)));
+ assertThat((Long)((Map<?,?>)mappedResult.get("results")).get("result"), equalTo(new Long(1)));
}
@@ -70,7 +70,7 @@
map.put("result", new Long(2));
when(mapper.applyMapping(anyObject())).thenReturn(map);
Map<String, Object> mappedResult = results.getMapRequestAndResult(mapper, null);
- assertThat((Long)((Map)mappedResult).get("result"), equalTo(new Long(2)));
+ assertThat((Long)((Map<?,?>)mappedResult).get("result"), equalTo(new Long(2)));
}
@@ -80,7 +80,7 @@
Map<String, Object> inputMap = new HashMap<String, Object>();
inputMap.put("origKey", "origValue");
Map<String, Object> mappedResult = results.getMapRequestAndResult(null, inputMap);
- assertThat((Long)((Map)mappedResult.get("results")).get("result"), equalTo(new Long(1)));
+ assertThat((Long)((Map<?,?>)mappedResult.get("results")).get("result"), equalTo(new Long(1)));
assertThat((String)mappedResult.get("origKey"), equalTo("origValue"));
}
@@ -95,7 +95,7 @@
Map<String, Object> inputMap = new HashMap<String, Object>();
inputMap.put("origKey", "origValue");
Map<String, Object> mappedResult = results.getMapRequestAndResult(null, inputMap);
- assertThat((Long)((Map)mappedResult.get("results")).get("result"), equalTo(new Long(1)));
+ assertThat((Long)((Map<?,?>)mappedResult.get("results")).get("result"), equalTo(new Long(1)));
assertThat((String)mappedResult.get("origKey"), equalTo("origValue"));
}
Modified: core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImplTest.java
===================================================================
--- core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImplTest.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImplTest.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -69,6 +69,7 @@
when(builder.getClientSpecificTmpDir()).thenReturn("target/temp/foo");
}
+ @SuppressWarnings("unchecked")
@Test
public void shouldInitClassLoader() throws Exception {
WSConsumer consumerMock = mock(WSConsumer.class);
@@ -77,15 +78,16 @@
(File)anyObject(),
(File)anyObject(),
anyString(),
- (List)anyObject(),
+ (List<File>)anyObject(),
(PrintStream)anyObject(),
(File)anyObject())).thenReturn(new LinkedList<String>());
WSDynamicClientImpl client = new WSDynamicClientImpl(builder, consumerMock);
File expectedOutPutDir = new File("target/temp/foo/classes");
assertThat(client.getClassLoader().getURLs().length, is(1));
- assertThat(client.getClassLoader().getURLs()[0], equalTo(expectedOutPutDir.toURL()));
+ assertThat(client.getClassLoader().getURLs()[0], equalTo(expectedOutPutDir.toURI().toURL()));
}
+ @SuppressWarnings("unchecked")
@Test
public void shouldProcessServices() throws Exception {
WSConsumer consumerMock = mock(WSConsumer.class);
@@ -95,7 +97,7 @@
(File)anyObject(),
(File)anyObject(),
anyString(),
- (List)anyObject(),
+ (List<File>)anyObject(),
(PrintStream)anyObject(),
(File)anyObject())).thenReturn(Arrays.asList(classes));
WSDynamicClientImpl client = new WSDynamicClientImpl(builder, consumerMock);
@@ -106,6 +108,7 @@
assertThat(services.keySet(), hasItem("ServiceName2"));
}
+ @SuppressWarnings("unchecked")
@Test
public void testGetMethod() throws Exception {
WSConsumer consumerMock = mock(WSConsumer.class);
@@ -115,7 +118,7 @@
(File)anyObject(),
(File)anyObject(),
anyString(),
- (List)anyObject(),
+ (List<File>)anyObject(),
(PrintStream)anyObject(),
(File)anyObject())).thenReturn(Arrays.asList(classes));
WSDynamicClientImpl client = new WSDynamicClientImpl(builder, consumerMock);
@@ -124,6 +127,7 @@
assertNotNull("Should get WsMethod through getWSMethod api", wsMethod);
}
+ @SuppressWarnings("unchecked")
@Test( expected = ResourceNotAvailableException.class )
public void missingOperationShouldCaseExceptionThrownOnGetWSMethod() throws Exception {
WSConsumer consumerMock = mock(WSConsumer.class);
@@ -133,13 +137,14 @@
(File)anyObject(),
(File)anyObject(),
anyString(),
- (List)anyObject(),
+ (List<File>)anyObject(),
(PrintStream)anyObject(),
(File)anyObject())).thenReturn(Arrays.asList(classes));
WSDynamicClientImpl client = new WSDynamicClientImpl(builder, consumerMock);
client.getWSMethod("ServiceName1", "Port1", "testWrongMethod");
}
+ @SuppressWarnings("unchecked")
@Test( expected = ResourceNotAvailableException.class )
public void missingPortShouldCaseExceptionThrownOnGetWSMethod() throws Exception {
WSConsumer consumerMock = mock(WSConsumer.class);
@@ -149,13 +154,14 @@
(File)anyObject(),
(File)anyObject(),
anyString(),
- (List)anyObject(),
+ (List<File>)anyObject(),
(PrintStream)anyObject(),
(File)anyObject())).thenReturn(Arrays.asList(classes));
WSDynamicClientImpl client = new WSDynamicClientImpl(builder, consumerMock);
client.getWSMethod("ServiceName1", "Port2", "testMethod");
}
+ @SuppressWarnings("unchecked")
@Test( expected = ResourceNotAvailableException.class )
public void missingServiceShouldCaseExceptionThrownOnGetWSMethod() throws Exception {
WSConsumer consumerMock = mock(WSConsumer.class);
@@ -165,7 +171,7 @@
(File)anyObject(),
(File)anyObject(),
anyString(),
- (List)anyObject(),
+ (List<File>)anyObject(),
(PrintStream)anyObject(),
(File)anyObject())).thenReturn(Arrays.asList(classes));
WSDynamicClientImpl client = new WSDynamicClientImpl(builder, consumerMock);
Modified: core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/wsdlResolver/ConnectionTest.java
===================================================================
--- core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/wsdlResolver/ConnectionTest.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/wsdlResolver/ConnectionTest.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -33,8 +33,7 @@
import java.net.HttpURLConnection;
import java.net.ProtocolException;
-import sun.misc.BASE64Encoder;
-import org.jboss.wise.core.client.impl.reflection.builder.ReflectionBasedWSDynamicClientBuilder;
+import org.apache.commons.codec.binary.Base64;
import org.jboss.wise.core.exception.WiseRuntimeException;
import org.junit.Test;
@@ -94,7 +93,7 @@
verify(conn).setRequestProperty("Accept",
"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
verify(conn).setRequestProperty("Connection", "close");
- verify(conn).setRequestProperty("Authorization", "Basic " + (new BASE64Encoder()).encode("username:password".getBytes()));
+ verify(conn).setRequestProperty("Authorization", "Basic " + new String(Base64.encodeBase64("username:password".getBytes())));
}
@Test
Modified: core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/wsdlResolver/WSDLResolverTest.java
===================================================================
--- core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/wsdlResolver/WSDLResolverTest.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/test/java/org/jboss/wise/core/client/impl/wsdlResolver/WSDLResolverTest.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -42,22 +42,22 @@
@Test
public void shouldSaveSimpleWsdl() throws Exception {
- performTest(tmpDir.getAbsolutePath() + File.separator + "SimpleWsdl", new File("./src/test/resources/testWsdls/Simple/SimpleWsdl.wsdl").toURL());
+ performTest(tmpDir.getAbsolutePath() + File.separator + "SimpleWsdl", new File("./src/test/resources/testWsdls/Simple/SimpleWsdl.wsdl").toURI().toURL());
}
@Test
public void shouldSaveWsdlWithWsdlImport() throws Exception {
- performTest(tmpDir.getAbsolutePath() + File.separator + "WsdlWsdl", new File("./src/test/resources/testWsdls/WsdlImport/WsdlWithWsdlImport.wsdl").toURL());
+ performTest(tmpDir.getAbsolutePath() + File.separator + "WsdlWsdl", new File("./src/test/resources/testWsdls/WsdlImport/WsdlWithWsdlImport.wsdl").toURI().toURL());
}
@Test
public void shouldSaveWsdlWithSchemaImport() throws Exception {
- performTest(tmpDir.getAbsolutePath() + File.separator + "SchemaWsdl", new File("./src/test/resources/testWsdls/SchemaImport/WsdlWithSchemaImport.wsdl").toURL());
+ performTest(tmpDir.getAbsolutePath() + File.separator + "SchemaWsdl", new File("./src/test/resources/testWsdls/SchemaImport/WsdlWithSchemaImport.wsdl").toURI().toURL());
}
@Test
public void shouldSaveWsdlWithSchemaAndWsdlImports() throws Exception {
- performTest(tmpDir.getAbsolutePath() + File.separator + "SchemaAndWsdlWsdl", new File("./src/test/resources/testWsdls/SchemaAndWsdlImport/WsdlWithSchemaAndWsdlImport.wsdl").toURL());
+ performTest(tmpDir.getAbsolutePath() + File.separator + "SchemaAndWsdlWsdl", new File("./src/test/resources/testWsdls/SchemaAndWsdlImport/WsdlWithSchemaAndWsdlImport.wsdl").toURI().toURL());
}
private void performTest(String testTempDir, URL wsdlURL) throws Exception {
@@ -70,7 +70,6 @@
@Before
public void createTmpDir() throws IOException
{
- System.out.println("Creating tmp dir: " + tmpDir.getPath());
if (tmpDir.exists()) {
tmpDir.delete();
}
Modified: core/trunk/core/src/test/java/org/jboss/wise/core/mapper/SmooksMapperTest.java
===================================================================
--- core/trunk/core/src/test/java/org/jboss/wise/core/mapper/SmooksMapperTest.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/test/java/org/jboss/wise/core/mapper/SmooksMapperTest.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -46,8 +46,6 @@
import org.milyn.Smooks;
import org.milyn.container.ExecutionContext;
-import com.sun.tools.corba.se.idl.constExpr.And;
-
/**
* @author stefano.maestri(a)javalinux.it
*/
@@ -71,10 +69,10 @@
originalObjects.put("external", external);
Map<String, Object> results;
results = mapper.applyMapping(originalObjects);
- Integer integerResult = (Integer) results.get("complexObject").getClass().getMethod("getNumberField", null)
- .invoke(results.get("complexObject"), null);
- String stringResult = (String) results.get("complexObject").getClass().getMethod("getTextField", null).invoke(results
- .get("complexObject"), null);
+ Integer integerResult = (Integer) results.get("complexObject").getClass().getMethod("getNumberField")
+ .invoke(results.get("complexObject"));
+ String stringResult = (String) results.get("complexObject").getClass().getMethod("getTextField").invoke(results
+ .get("complexObject"));
assertThat(integerResult, equalTo(internal.getNumber()));
assertThat(stringResult, equalTo("fooText"));
@@ -95,8 +93,8 @@
originalObjects.put("external", external);
Map<String, Object> results;
results = mapper.applyMapping(originalObjects);
- long returnedTime = ((XMLGregorianCalendar) results.get("complexObject").getClass().getMethod("getDateField", null)
- .invoke(results.get("complexObject"), null)).toGregorianCalendar().getTimeInMillis();
+ long returnedTime = ((XMLGregorianCalendar) results.get("complexObject").getClass().getMethod("getDateField")
+ .invoke(results.get("complexObject"))).toGregorianCalendar().getTimeInMillis();
assertThat(returnedTime, is(date.getTime()));
Modified: core/trunk/core/src/test/java/org/jboss/wise/smooks/decoders/JAXBElementDecoderTest.java
===================================================================
--- core/trunk/core/src/test/java/org/jboss/wise/smooks/decoders/JAXBElementDecoderTest.java 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/core/src/test/java/org/jboss/wise/smooks/decoders/JAXBElementDecoderTest.java 2012-06-17 22:59:09 UTC (rev 431)
@@ -28,6 +28,7 @@
decorator.setConfiguration(config);
}
+ @SuppressWarnings("unchecked")
@Test
public void shouldReturnJAXBElementAccordingConfig() {
JAXBElementDecoder decorator = new JAXBElementDecoder();
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2012-06-17 20:39:13 UTC (rev 430)
+++ core/trunk/pom.xml 2012-06-17 22:59:09 UTC (rev 431)
@@ -42,13 +42,14 @@
</issueManagement>
<properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<surefire.fork.mode>once</surefire.fork.mode>
<surefire.format>brief</surefire.format>
<surefire.usefile>false</surefire.usefile>
<compile.flags>-Xlint:unchecked,deprecation,fallthrough,finally</compile.flags>
<checkstyle.extension />
<cxf.version>2.4.6</cxf.version> <!-- This should stay in synch with the one used within the jbossws-cxf being pulled in wise-core-cxf -->
- <compiler.fork>false</compiler.fork>
+ <compiler.fork>false</compiler.fork>
</properties>
<!-- DistributionManagement -->
@@ -348,11 +349,12 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.6</source>
+ <target>1.6</target>
<maxmem>256M</maxmem>
<fork>${compiler.fork}</fork>
<debug>true</debug>
+ <showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
12 years, 7 months
wise SVN: r430 - core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection.
by wise-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2012-06-17 16:39:13 -0400 (Sun, 17 Jun 2012)
New Revision: 430
Modified:
core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImpl.java
Log:
[WISE-176] Pass verbose and keepSources flags from client builder to wsconsumer instance
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImpl.java 2012-06-17 20:26:11 UTC (rev 429)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/client/impl/reflection/WSDynamicClientImpl.java 2012-06-17 20:39:13 UTC (rev 430)
@@ -92,6 +92,8 @@
private static WSConsumer createConsumer(WSDynamicClientBuilder builder) {
WSConsumer consumer = (WSConsumer) SpiLoader
.loadService("org.jboss.wise.consumer.WSConsumer", "org.jboss.wise.core.consumer.impl.jbossws.DefaultWSImportImpl");
+ consumer.setVerbose(builder.isVerbose());
+ consumer.setKeepSource(builder.isKeepSource());
return consumer;
}
12 years, 7 months
wise SVN: r429 - core/trunk/integration-testsuite.
by wise-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2012-06-17 16:26:11 -0400 (Sun, 17 Jun 2012)
New Revision: 429
Modified:
core/trunk/integration-testsuite/pom.xml
Log:
[WISE-174] Fixing WiseIntegrationSmooksTest regression
Modified: core/trunk/integration-testsuite/pom.xml
===================================================================
--- core/trunk/integration-testsuite/pom.xml 2012-06-17 16:06:57 UTC (rev 428)
+++ core/trunk/integration-testsuite/pom.xml 2012-06-17 20:26:11 UTC (rev 429)
@@ -64,15 +64,6 @@
<build>
<testResources>
- <!-- copy handler definitions & property files -->
- <testResource>
- <targetPath>../test-classes</targetPath>
- <directory>src/test/java</directory>
- <includes>
- <include>**/*.xml</include>
- <include>**/*.properties</include>
- </includes>
- </testResource>
</testResources>
<plugins>
<plugin>
12 years, 7 months
wise SVN: r428 - in core/trunk: integration-testsuite and 4 other directories.
by wise-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2012-06-17 12:06:57 -0400 (Sun, 17 Jun 2012)
New Revision: 428
Added:
core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/jbossws-roles.properties
core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/jbossws-users.properties
Modified:
core/trunk/core/src/main/java/org/jboss/wise/core/test/WiseTest.java
core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/basic/WiseIntegrationBasicTest.java
core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/smooks/WiseIntegrationSmooksTest.java
core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/WSDLResolverIntegrationTest.java
core/trunk/integration-testsuite/cxf/src/test/java/org/jboss/wise/test/integration/wsaddressing/HelloImpl.java
core/trunk/integration-testsuite/pom.xml
Log:
[WISE-174] Adding support for security domain creation on AS7 + fixing a bunch of test failures
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/test/WiseTest.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/test/WiseTest.java 2012-06-17 14:49:11 UTC (rev 427)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/test/WiseTest.java 2012-06-17 16:06:57 UTC (rev 428)
@@ -28,6 +28,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
+import java.util.Map;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
@@ -63,7 +64,7 @@
* @param url url for webservice war
* @throws Exception if the deployment is failed
*/
- public void deployWS(URL url) throws Exception {
+ public static void deployWS(URL url) throws Exception {
getDeployer().deploy(url);
}
@@ -71,10 +72,18 @@
* @param url url of webservice war
* @throws Exception if undeployment is failed
*/
- public void undeployWS(URL url) throws Exception {
- getDeployer().undeploy(url);
+ public static void undeployWS(URL url) throws Exception {
+ getDeployer().undeploy(url);
}
+ public static void addSecurityDomain(String domainName, Map<String, String> authenticationOptions) throws Exception {
+ getDeployer().addSecurityDomain(domainName, authenticationOptions);
+ }
+
+ public static void removeSecurityDomain(String domainName) throws Exception {
+ getDeployer().removeSecurityDomain(domainName);
+ }
+
/**Get the URL path for a given webservice archive. It will find this war file under ${baseDir}/build/test-ws-archive
* @param archiveName the webservice archive name
* @return webservice war url
Modified: core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/basic/WiseIntegrationBasicTest.java
===================================================================
--- core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/basic/WiseIntegrationBasicTest.java 2012-06-17 14:49:11 UTC (rev 427)
+++ core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/basic/WiseIntegrationBasicTest.java 2012-06-17 16:06:57 UTC (rev 428)
@@ -24,25 +24,25 @@
import java.net.URL;
import java.util.Map;
+
import org.jboss.wise.core.client.InvocationResult;
import org.jboss.wise.core.client.WSDynamicClient;
import org.jboss.wise.core.client.WSMethod;
import org.jboss.wise.core.client.builder.WSDynamicClientBuilder;
import org.jboss.wise.core.client.factories.WSDynamicClientFactory;
import org.jboss.wise.core.test.WiseTest;
-import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Assert;
-import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
public class WiseIntegrationBasicTest extends WiseTest {
- private URL warUrl = null;
+ private static URL warUrl = null;
- @Before
- public void setUp() throws Exception {
- warUrl = this.getClass().getClassLoader().getResource("basic.war");
+ @BeforeClass
+ public static void setUp() throws Exception {
+ warUrl = WiseIntegrationBasicTest.class.getClassLoader().getResource("basic.war");
deployWS(warUrl);
-
}
@Test
@@ -63,8 +63,12 @@
Assert.assertEquals("from-wise-client", test.get("result"));
}
- @After
- public void tearDown() throws Exception {
- undeployWS(warUrl);
+ @AfterClass
+ public static void tearDown() throws Exception {
+ try {
+ undeployWS(warUrl);
+ } finally {
+ warUrl = null;
+ }
}
}
Modified: core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/smooks/WiseIntegrationSmooksTest.java
===================================================================
--- core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/smooks/WiseIntegrationSmooksTest.java 2012-06-17 14:49:11 UTC (rev 427)
+++ core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/smooks/WiseIntegrationSmooksTest.java 2012-06-17 16:06:57 UTC (rev 428)
@@ -40,17 +40,17 @@
import org.jboss.wise.core.test.WiseTest;
import org.jboss.wise.test.integration.smooks.pojo.clientside.ExternalObject;
import org.jboss.wise.test.integration.smooks.pojo.clientside.InternalObject;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
public class WiseIntegrationSmooksTest extends WiseTest {
- private URL warUrl = null;
+ private static URL warUrl = null;
- @Before
- public void setUp() throws Exception {
- warUrl = this.getClass().getClassLoader().getResource("smooks.war");
+ @BeforeClass
+ public static void setUp() throws Exception {
+ warUrl = WiseIntegrationSmooksTest.class.getClassLoader().getResource("smooks.war");
deployWS(warUrl);
}
@@ -82,8 +82,12 @@
assertThat(((ExternalObject) resultMap.get("ExternalObject")).getDate(), notNullValue());
}
- @After
- public void tearDown() throws Exception {
- undeployWS(warUrl);
+ @AfterClass
+ public static void tearDown() throws Exception {
+ try {
+ undeployWS(warUrl);
+ } finally {
+ warUrl = null;
+ }
}
}
Modified: core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/WSDLResolverIntegrationTest.java
===================================================================
--- core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/WSDLResolverIntegrationTest.java 2012-06-17 14:49:11 UTC (rev 427)
+++ core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/WSDLResolverIntegrationTest.java 2012-06-17 16:06:57 UTC (rev 428)
@@ -24,14 +24,17 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
import net.jcip.annotations.Immutable;
import org.jboss.wise.core.client.impl.wsdlResolver.Connection;
import org.jboss.wise.core.client.impl.wsdlResolver.WSDLResolver;
import org.jboss.wise.core.test.WiseTest;
-import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
@@ -43,7 +46,7 @@
public class WSDLResolverIntegrationTest extends WiseTest {
private static final File tmpDir = new File("target/temp/WSDLResolverTest");
- private URL warUrl = null;
+ private static URL warUrl = null;
@Test
public void shouldSaveRemoteSimpleWsdl() throws Exception {
@@ -92,11 +95,16 @@
assertTrue(wsdlFile.length() > 0);
}
- @Before
- public void setUp() throws Exception {
- warUrl = this.getClass().getClassLoader().getResource("wsdlResolver.war");
+ @BeforeClass
+ public static void setUp() throws Exception {
+ final ClassLoader classloader = WSDLResolverIntegrationTest.class.getClassLoader();
+ Map<String, String> authenticationOptions = new HashMap<String, String>();
+ authenticationOptions.put("usersProperties", classloader.getResource("org/jboss/wise/test/integration/wsdlResolver/jbossws-users.properties").toString());
+ authenticationOptions.put("rolesProperties", classloader.getResource("org/jboss/wise/test/integration/wsdlResolver/jbossws-roles.properties").toString());
+ authenticationOptions.put("unauthenticatedIdentity", "anonymous");
+ addSecurityDomain("JBossWS", authenticationOptions);
+ warUrl = classloader.getResource("wsdlResolver.war");
deployWS(warUrl);
-
}
@Before
@@ -109,9 +117,14 @@
tmpDir.mkdir();
}
- @After
- public void tearDown() throws Exception {
- undeployWS(warUrl);
+ @AfterClass
+ public static void tearDown() throws Exception {
+ try {
+ undeployWS(warUrl);
+ removeSecurityDomain("JBossWS");
+ } finally {
+ warUrl = null;
+ }
}
}
Added: core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/jbossws-roles.properties
===================================================================
--- core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/jbossws-roles.properties (rev 0)
+++ core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/jbossws-roles.properties 2012-06-17 16:06:57 UTC (rev 428)
@@ -0,0 +1,2 @@
+# A sample roles.properties file for use with the UsersRolesLoginModule
+kermit=friend
\ No newline at end of file
Added: core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/jbossws-users.properties
===================================================================
--- core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/jbossws-users.properties (rev 0)
+++ core/trunk/integration-testsuite/common/src/test/java/org/jboss/wise/test/integration/wsdlResolver/jbossws-users.properties 2012-06-17 16:06:57 UTC (rev 428)
@@ -0,0 +1,2 @@
+# A sample users.properties file for use with the UsersRolesLoginModule
+kermit=thefrog
Modified: core/trunk/integration-testsuite/cxf/src/test/java/org/jboss/wise/test/integration/wsaddressing/HelloImpl.java
===================================================================
--- core/trunk/integration-testsuite/cxf/src/test/java/org/jboss/wise/test/integration/wsaddressing/HelloImpl.java 2012-06-17 14:49:11 UTC (rev 427)
+++ core/trunk/integration-testsuite/cxf/src/test/java/org/jboss/wise/test/integration/wsaddressing/HelloImpl.java 2012-06-17 16:06:57 UTC (rev 428)
@@ -21,7 +21,6 @@
*/
package org.jboss.wise.test.integration.wsaddressing;
-import javax.ejb.Stateless;
import javax.jws.WebService;
import javax.xml.ws.soap.Addressing;
@@ -37,7 +36,6 @@
serviceName = "HelloService",
wsdlLocation = "WEB-INF/test.wsdl" ) //this is added to force the server on publishing a WSDL without policies; this way we're sure WS-Addressing
//on client side is controlled by features only, not by WS-Policy engine.
-@Stateless
@Addressing(enabled = true, required = false)
public class HelloImpl implements Hello {
Modified: core/trunk/integration-testsuite/pom.xml
===================================================================
--- core/trunk/integration-testsuite/pom.xml 2012-06-17 14:49:11 UTC (rev 427)
+++ core/trunk/integration-testsuite/pom.xml 2012-06-17 16:06:57 UTC (rev 428)
@@ -63,6 +63,17 @@
</dependencies>
<build>
+ <testResources>
+ <!-- copy handler definitions & property files -->
+ <testResource>
+ <targetPath>../test-classes</targetPath>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </testResource>
+ </testResources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
12 years, 7 months
wise SVN: r427 - in core/trunk: core/src/main/java/org/jboss/wise/core/test and 3 other directories.
by wise-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2012-06-17 10:49:11 -0400 (Sun, 17 Jun 2012)
New Revision: 427
Modified:
core/trunk/core/src/main/java/org/jboss/wise/core/test/WiseTest.java
core/trunk/integration-testsuite/common/src/test/resources/integration-test-log4j.xml
core/trunk/integration-testsuite/cxf/src/test/resources/integration-test-log4j.xml
core/trunk/integration-testsuite/pom.xml
core/trunk/pom.xml
Log:
[WISE-174] Initial changes for AS7.1.x support
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/test/WiseTest.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/test/WiseTest.java 2012-06-17 11:19:52 UTC (rev 426)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/test/WiseTest.java 2012-06-17 14:49:11 UTC (rev 427)
@@ -23,31 +23,48 @@
package org.jboss.wise.core.test;
import java.io.File;
+import java.net.Inet6Address;
+import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
-import javax.management.ObjectName;
-import org.apache.log4j.Logger;
+import java.net.UnknownHostException;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployer.Deployer;
+
/**
* Wise test base class. Subclass can use the methods in this class to
- * deploy and undeploy a web service war in JBossAS
+ * deploy and undeploy a web service war in JBossAS
+ *
* @author ema(a)redhat.com
+ * @author alessio.soldano(a)jboss.com
*
*/
public class WiseTest {
- private static final Logger logger = Logger.getLogger(WiseTest.class);
- private static final String MAIN_DEPLOYER = "jboss.system:service=MainDeployer";
- private static final String WS_SERVER_CONFIG = "jboss.ws:service=ServerConfig";
private static final String TEST_WS_ARCHIVE_DIR = "test-ws-archive";
+ private static final String SYSPROP_JBOSS_BIND_ADDRESS = "jboss.bind.address";
+ private static final String SYSPROP_JBOSS_HTTP_PORT = "jboss.http.port";
+ private static Deployer DEPLOYER;
+ private static synchronized Deployer getDeployer()
+ {
+ //lazy loading of deployer
+ if (DEPLOYER == null)
+ {
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ DEPLOYER = spiProvider.getSPI(Deployer.class);
+ }
+ return DEPLOYER;
+ }
+
/**
* Deploy the webservice war in JBoss server
* @param url url for webservice war
* @throws Exception if the deployment is failed
*/
public void deployWS(URL url) throws Exception {
- throw new Exception("TODO");
-// JBossWSTestHelper.getServer().invoke(new ObjectName(MAIN_DEPLOYER), "deploy", new Object[] { url }, new String[] { "java.net.URL" });
+ getDeployer().deploy(url);
}
/**Undeploy a webservice
@@ -55,8 +72,7 @@
* @throws Exception if undeployment is failed
*/
public void undeployWS(URL url) throws Exception {
- throw new Exception("TODO");
-// JBossWSTestHelper.getServer().invoke(new ObjectName(MAIN_DEPLOYER), "undeploy", new Object[] { url }, new String[] { "java.net.URL" });
+ getDeployer().undeploy(url);
}
/**Get the URL path for a given webservice archive. It will find this war file under ${baseDir}/build/test-ws-archive
@@ -69,7 +85,7 @@
File file = new File(dirURL.getFile(), ".." + File.separator + TEST_WS_ARCHIVE_DIR + File.separator + archiveName);
if (file.exists()) {
try {
- warUrl = file.getAbsoluteFile().toURL();
+ warUrl = file.getAbsoluteFile().toURI().toURL();
} catch (MalformedURLException e) {
return null;
}
@@ -78,28 +94,37 @@
}
- /**Get the jboss webservice server side hostname and port
+ /**
+ * Get the jboss webservice server side hostname and port
+ *
* @return http://server-hostname:port
*/
public String getServerHostAndPort() {
- Logger.getLogger(this.getClass()).warn("TODO!! implement getServerHostAndPort()");
- //return "http://" + JBossWSTestHelper.getServerHost() + ":" + getServerPort();
- return null;
+ final String host = System.getProperty(SYSPROP_JBOSS_BIND_ADDRESS, "localhost");
+ final String port = System.getProperty(SYSPROP_JBOSS_HTTP_PORT, "8080");
+ final StringBuilder sb = new StringBuilder("http://");
+ sb.append(toIPv6URLFormat(host)).append(":").append(port);
+ return sb.toString();
}
-
- /**Get the web service server port
- * @return webservice server configured port
- */
- public String getServerPort() {
- Logger.getLogger(this.getClass()).warn("TODO!! implement getServerPort()");
- try {
-// return JBossWSTestHelper.getServer().getAttribute(new ObjectName(WS_SERVER_CONFIG), "WebServicePort").toString();
- return "8080";
- } catch (Exception e) {
- logger.warn("WARNING: Failed to get server port; using default 8080");
- return "8080";
- }
+
+ private static String toIPv6URLFormat(final String host) {
+ try {
+ if (host.startsWith(":")) {
+ throw new IllegalArgumentException("JBossWS test suite requires IPv6 addresses to be wrapped with [] brackets. Expected format is: [" + host + "]");
+ }
+ if (host.startsWith("[")) {
+ if (System.getProperty("java.net.preferIPv4Stack") == null) {
+ throw new IllegalStateException("always provide java.net.preferIPv4Stack JVM property when using IPv6 address format");
+ }
+ if (System.getProperty("java.net.preferIPv6Addresses") == null) {
+ throw new IllegalStateException("always provide java.net.preferIPv6Addresses JVM property when using IPv6 address format");
+ }
+ }
+ final boolean isIPv6Address = InetAddress.getByName(host) instanceof Inet6Address;
+ final boolean isIPv6Formatted = isIPv6Address && host.startsWith("[");
+ return isIPv6Address && !isIPv6Formatted ? "[" + host + "]" : host;
+ } catch (final UnknownHostException e) {
+ throw new RuntimeException(e);
+ }
}
-
-
}
Modified: core/trunk/integration-testsuite/common/src/test/resources/integration-test-log4j.xml
===================================================================
--- core/trunk/integration-testsuite/common/src/test/resources/integration-test-log4j.xml 2012-06-17 11:19:52 UTC (rev 426)
+++ core/trunk/integration-testsuite/common/src/test/resources/integration-test-log4j.xml 2012-06-17 14:49:11 UTC (rev 427)
@@ -5,7 +5,7 @@
debug="false">
<appender name="FILE" class="org.apache.log4j.FileAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
<param name="File" value="target/integration-test.log"/>
<param name="Append" value="false"/>
Modified: core/trunk/integration-testsuite/cxf/src/test/resources/integration-test-log4j.xml
===================================================================
--- core/trunk/integration-testsuite/cxf/src/test/resources/integration-test-log4j.xml 2012-06-17 11:19:52 UTC (rev 426)
+++ core/trunk/integration-testsuite/cxf/src/test/resources/integration-test-log4j.xml 2012-06-17 14:49:11 UTC (rev 427)
@@ -5,7 +5,7 @@
debug="false">
<appender name="FILE" class="org.apache.log4j.FileAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
<param name="File" value="target/integration-test.log"/>
<param name="Append" value="false"/>
Modified: core/trunk/integration-testsuite/pom.xml
===================================================================
--- core/trunk/integration-testsuite/pom.xml 2012-06-17 11:19:52 UTC (rev 426)
+++ core/trunk/integration-testsuite/pom.xml 2012-06-17 14:49:11 UTC (rev 427)
@@ -133,90 +133,22 @@
</dependencies>
</profile>
<profile>
- <id>jboss5</id>
+ <id>jboss711</id>
<activation>
- <property>
- <name>!jboss6</name>
- </property>
+ <property>
+ <name>!no-jboss711.stack</name>
+ </property>
</activation>
<dependencies>
<dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-server</artifactId>
- <version>5.1.0.GA</version>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-webservices-tests-integration</artifactId>
+ <version>7.1.1.Final</version>
<scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>sun-jaxb</groupId>
- <artifactId>jaxb-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.jpa</groupId>
- <artifactId>jboss-jpa-deployers</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.metadata</groupId>
- <artifactId>jboss-metadata</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.javaee</groupId>
- <artifactId>jboss-ejb-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.ws.native</groupId>
- <artifactId>jbossws-native-saaj</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.ws.native</groupId>
- <artifactId>jbossws-native-jaxws</artifactId>
- </exclusion>
- </exclusions>
</dependency>
</dependencies>
</profile>
<profile>
- <id>jboss6</id>
- <activation>
- <property>
- <name>jboss6</name>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-server</artifactId>
- <version>6.0.0.20101110-CR1</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>sun-jaxb</groupId>
- <artifactId>jaxb-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.jpa</groupId>
- <artifactId>jboss-jpa-deployers</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.metadata</groupId>
- <artifactId>jboss-metadata</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.javaee</groupId>
- <artifactId>jboss-ejb-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.ws.native</groupId>
- <artifactId>jbossws-native-saaj</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.ws.native</groupId>
- <artifactId>jbossws-native-jaxws</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
- </profile>
- <profile>
<id>use.endorsed.dir</id>
<activation>
<property>
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2012-06-17 11:19:52 UTC (rev 426)
+++ core/trunk/pom.xml 2012-06-17 14:49:11 UTC (rev 427)
@@ -124,15 +124,10 @@
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
<version>2.2.17.GA</version>
+ <scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging</artifactId>
- <version>3.1.0.GA</version>
- </dependency>
-
- <dependency>
<groupId>org.jboss.ws</groupId>
<artifactId>jbossws-common</artifactId>
<version>2.0.2.GA</version>
12 years, 7 months
wise SVN: r426 - core/trunk.
by wise-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2012-06-17 07:19:52 -0400 (Sun, 17 Jun 2012)
New Revision: 426
Modified:
core/trunk/
Log:
Adding .classpath to svn:ignore
Property changes on: core/trunk
___________________________________________________________________
Modified: svn:ignore
- temp
test-output
build
classes
.settings
target
+ temp
test-output
build
classes
.settings
.classpath
target
12 years, 7 months