Author: richard.opalka(a)jboss.com
Date: 2008-09-30 05:17:46 -0400 (Tue, 30 Sep 2008)
New Revision: 8297
Removed:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/XOPTestSupport.java
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/swaref/BareEndpointImpl.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/swaref/RpcLitEndpointImpl.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/swaref/WrappedEndpointImpl.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMEndpointBean.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/WrappedEndpointImpl.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPBase.java
Log:
[JBWS-2322] refactoring + ensure cleanup
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/swaref/BareEndpointImpl.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/swaref/BareEndpointImpl.java 2008-09-30
09:16:27 UTC (rev 8296)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/swaref/BareEndpointImpl.java 2008-09-30
09:17:46 UTC (rev 8297)
@@ -32,7 +32,7 @@
import javax.xml.ws.WebServiceException;
import java.io.IOException;
-import java.rmi.RemoteException;
+import java.io.InputStream;
@Stateless
@WebService(name="BareEndpoint", serviceName="BareEndpointService")
@@ -45,7 +45,12 @@
{
try
{
- System.out.println("Got '" + payload.getData().getContent()
+"'");
+ Object dataContent = payload.getData().getContent();
+ System.out.println("Got '" + dataContent +"'");
+ if (dataContent instanceof InputStream)
+ {
+ ((InputStream)dataContent).close();
+ }
return new DocumentPayload( new DataHandler("Server data",
"text/plain"));
}
catch (IOException e)
@@ -61,9 +66,13 @@
try
{
if(null == payload) throw new WebServiceException("Payload was
null");
- System.out.println("Got " + payload.getData().getContent());
- DataHandler dataHandler = new DataHandler("Server data",
"text/plain");
- return new DocumentPayloadWithoutRef(dataHandler);
+ Object dataContent = payload.getData().getContent();
+ System.out.println("Got " + dataContent);
+ if (dataContent instanceof InputStream)
+ {
+ ((InputStream)dataContent).close();
+ }
+ return new DocumentPayloadWithoutRef(new DataHandler("Server data",
"text/plain"));
}
catch (IOException e)
{
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/swaref/RpcLitEndpointImpl.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/swaref/RpcLitEndpointImpl.java 2008-09-30
09:16:27 UTC (rev 8296)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/swaref/RpcLitEndpointImpl.java 2008-09-30
09:17:46 UTC (rev 8297)
@@ -32,6 +32,7 @@
import javax.activation.DataHandler;
import java.rmi.RemoteException;
import java.io.IOException;
+import java.io.InputStream;
@Stateless
@WebService(name="RpcLitEndpoint",
serviceName="RpcLitEndpointService")
@@ -45,7 +46,12 @@
{
try
{
- System.out.println("Got " + data.getContent() );
+ Object dataContent = data.getContent();
+ System.out.println("Got " + dataContent);
+ if (dataContent instanceof InputStream)
+ {
+ ((InputStream)dataContent).close();
+ }
return new DataHandler("Server data", "text/plain");
}
catch (IOException e)
@@ -60,9 +66,13 @@
{
try
{
- System.out.println("Got " + payload.getData().getContent() );
- DataHandler data = new DataHandler("Server data",
"text/plain");
- return new DocumentPayload(data);
+ Object dataContent = payload.getData().getContent();
+ System.out.println("Got " + dataContent);
+ if (dataContent instanceof InputStream)
+ {
+ ((InputStream)dataContent).close();
+ }
+ return new DocumentPayload(new DataHandler("Server data",
"text/plain"));
}
catch (IOException e)
{
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/swaref/WrappedEndpointImpl.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/swaref/WrappedEndpointImpl.java 2008-09-30
09:16:27 UTC (rev 8296)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/swaref/WrappedEndpointImpl.java 2008-09-30
09:17:46 UTC (rev 8297)
@@ -34,7 +34,6 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
-import java.rmi.RemoteException;
@Stateless
@WebService(name = "WrappedEndpoint", serviceName =
"WrappedEndpointService")
@@ -83,7 +82,12 @@
{
try
{
- System.out.println("Got " + data.getContent());
+ Object dataContent = data.getContent();
+ System.out.println("Got " + dataContent);
+ if (dataContent instanceof InputStream)
+ {
+ ((InputStream)dataContent).close();
+ }
return new DataHandler("Server data", "text/plain");
}
catch (IOException e)
@@ -96,24 +100,25 @@
{
InputStream is = in_dh.getInputStream();
if (is != null) {
-
System.out.println("[TestServiceImpl] ---> in_dh START : ");
- System.out.println("[TestServiceImpl] ---> in_dh START : ");
- System.out.println("[TestServiceImpl] ---> in_dh START : ");
-
// récupère le contenu du fichier
- BufferedReader in = new BufferedReader(new InputStreamReader(is));
- String ligne="";
- ligne = in.readLine();
- while (ligne != null)
+ BufferedReader in = null;
+ try
{
- System.out.println(ligne);
+ in = new BufferedReader(new InputStreamReader(is));
+ String ligne="";
ligne = in.readLine();
+ while (ligne != null)
+ {
+ System.out.println(ligne);
+ ligne = in.readLine();
+ }
}
- in.close();
+ finally
+ {
+ if (in != null) in.close();
+ }
System.out.println("[TestServiceImpl] ---> END.");
- System.out.println("[TestServiceImpl] ---> END.");
- System.out.println("[TestServiceImpl] ---> END.");
}
else
{
Deleted:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/XOPTestSupport.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/XOPTestSupport.java 2008-09-30
09:16:27 UTC (rev 8296)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/XOPTestSupport.java 2008-09-30
09:17:46 UTC (rev 8297)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.test.ws.jaxws.samples.xop;
-
-import java.awt.Image;
-import java.awt.Toolkit;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import javax.activation.DataHandler;
-import javax.xml.transform.stream.StreamSource;
-
-/**
- * @author Heiko Braun <heiko.braun(a)jboss.com>
- * @since 22-Sep-2006
- */
-public class XOPTestSupport
-{
-
- public static byte[] getBytesFromFile(File file) throws IOException
- {
- InputStream is = new FileInputStream(file);
-
- long length = file.length();
- byte[] bytes = new byte[(int)length];
-
- int offset = 0;
- int numRead = 0;
- while (offset < bytes.length && (numRead = is.read(bytes, offset,
bytes.length - offset)) >= 0)
- {
- offset += numRead;
- }
-
- is.close();
- return bytes;
- }
-
- public static Image createTestImage(File imgFile)
- {
- Image image = null;
- try
- {
- URL url = imgFile.toURL();
-
- image = null;
- try
- {
- image = Toolkit.getDefaultToolkit().createImage(url);
- }
- catch (Throwable th)
- {
- //log.warn("Cannot create Image: " + th);
- }
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException(e);
- }
-
- return image;
- }
-
- public static StreamSource createTestSource()
- {
- return new StreamSource(new
ByteArrayInputStream("<some><nestedXml/></some>".getBytes()));
- }
-
- public static DataHandler createDataHandler(File imgFile)
- {
- try
- {
- URL url = imgFile.toURL();
- return new DataHandler(url);
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException(e);
- }
- }
-}
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMEndpointBean.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMEndpointBean.java 2008-09-30
09:16:27 UTC (rev 8296)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMEndpointBean.java 2008-09-30
09:17:46 UTC (rev 8297)
@@ -47,11 +47,11 @@
try
{
log.info("Recv " + dataHandler.getContentType());
- Object dataHandlerContent = dataHandler.getContent();
- log.info("Content is " + dataHandlerContent);
- if ( dataHandlerContent instanceof InputStream )
+ Object dataContent = dataHandler.getContent();
+ log.info("Content is " + dataContent);
+ if ( dataContent instanceof InputStream )
{
- ((InputStream)dataHandlerContent).close();
+ ((InputStream)dataContent).close();
}
}
catch (IOException e)
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/WrappedEndpointImpl.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/WrappedEndpointImpl.java 2008-09-30
09:16:27 UTC (rev 8296)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/WrappedEndpointImpl.java 2008-09-30
09:17:46 UTC (rev 8297)
@@ -45,11 +45,11 @@
try
{
System.out.println("Recv " + data.getContentType());
- Object dataHandlerContent = data.getContent();
- System.out.println("Got " + dataHandlerContent);
- if ( dataHandlerContent instanceof InputStream )
+ Object dataContent = data.getContent();
+ System.out.println("Got " + dataContent);
+ if ( dataContent instanceof InputStream )
{
- ((InputStream)dataHandlerContent).close();
+ ((InputStream)dataContent).close();
}
return new DataHandler("Server data", "text/plain");
}
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPBase.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPBase.java 2008-09-30
09:16:27 UTC (rev 8296)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPBase.java 2008-09-30
09:17:46 UTC (rev 8297)
@@ -32,7 +32,7 @@
import javax.xml.transform.Source;
import javax.xml.ws.soap.SOAPBinding;
-import org.jboss.test.ws.jaxws.samples.xop.XOPTestSupport;
+import org.jboss.wsf.test.XOPTestSupport;
import org.jboss.wsf.test.JBossWSTest;
/**
@@ -163,8 +163,15 @@
// Metro returns an ByteArrayInputStream
if (content instanceof InputStream)
{
- BufferedReader br = new BufferedReader(new
InputStreamReader((InputStream)content));
- content = br.readLine();
+ try
+ {
+ BufferedReader br = new BufferedReader(new
InputStreamReader((InputStream)content));
+ content = br.readLine();
+ }
+ finally
+ {
+ ((InputStream)content).close();
+ }
}
return content;
}