Author: bsnyder
Date: Fri Feb 23 21:47:34 2007
New Revision: 511219
URL: http://svn.apache.org/viewvc?view=rev&rev=511219
Log:
Cleanup to remove unused code for SM-856.
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SerializedMarshaler.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/SerializedMarshalerTest.java
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SerializedMarshaler.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SerializedMarshaler.java?view=diff&rev=511219&r1=511218&r2=511219
==============================================================================
---
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SerializedMarshaler.java
(original)
+++
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SerializedMarshaler.java
Fri Feb 23 21:47:34 2007
@@ -1,17 +1,12 @@
package org.apache.servicemix.http.endpoints;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.ObjectInputStream;
-import java.io.OutputStreamWriter;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
import java.io.StringWriter;
import java.io.Writer;
-import java.io.OutputStream;
-import java.io.ObjectOutputStream;
-import java.net.URI;
import javax.jbi.component.ComponentContext;
import javax.jbi.messaging.MessageExchange;
@@ -21,9 +16,8 @@
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
-import org.apache.servicemix.jbi.jaxp.StringSource;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
-import org.apache.servicemix.jbi.messaging.MessageExchangeSupport;
+import org.apache.servicemix.jbi.jaxp.StringSource;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
@@ -38,10 +32,7 @@
public MessageExchange createExchange(HttpServletRequest request,
ComponentContext context) throws Exception {
MessageExchange me =
context.getDeliveryChannel().createExchangeFactory().createExchange(getDefaultMep());
- NormalizedMessage in = me.createMessage();
-
-// InputStream copy = copyInputStream(request.getInputStream());
-
+ NormalizedMessage in = me.createMessage();
in.setContent(marshal(request.getInputStream()));
me.setMessage(in, "in");
return me;
@@ -52,29 +43,6 @@
unmarshal(response.getOutputStream(), outMsg.getContent());
}
}
-
-// /**
-// * Copy the input stream in an attempt to get around 'stream is closed
error'.
-// *
-// * @param in
-// * @return
-// * @throws IOException
-// */
-// private InputStream copyInputStream(InputStream in) throws IOException {
-// InputStreamReader input = new InputStreamReader(in);
-// ByteArrayOutputStream baos = new ByteArrayOutputStream();
-// OutputStreamWriter output = new OutputStreamWriter(baos);
-//
-// char[] buffer1 = new char[1024*2];
-// int i = 0;
-// while (-1 != (i = input.read(buffer1))) {
-// output.write(buffer1, 0, i);
-// }
-// output.flush();
-//
-// InputStream newIn = new ByteArrayInputStream(baos.toByteArray());
-// return newIn;
-// }
/**
* Marshal the byte content of the input stream to an xml source
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/SerializedMarshalerTest.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/SerializedMarshalerTest.java?view=diff&rev=511219&r1=511218&r2=511219
==============================================================================
---
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/SerializedMarshalerTest.java
(original)
+++
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/SerializedMarshalerTest.java
Fri Feb 23 21:47:34 2007
@@ -18,9 +18,10 @@
import org.apache.servicemix.jbi.messaging.MessageExchangeSupport;
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;
import
org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor;
-import org.springframework.remoting.support.RemoteInvocationResult;
import org.springframework.remoting.support.DefaultRemoteInvocationExecutor;
import org.springframework.remoting.support.RemoteInvocation;
+import org.springframework.remoting.support.RemoteInvocationResult;
+
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
@@ -42,160 +43,6 @@
container.shutDown();
}
}
-
- /**
- * Test the SerializedMarshaler using only SMX. I don't think this is going
- * to work.
- */
-// public void testCreateExchange() throws Exception{
-// HttpConsumerEndpoint ep = new HttpConsumerEndpoint();
-// ep.setService(new QName("urn:httpconsumer", "HttpConsumer"));
-// ep.setEndpoint("HttpConsumer");
-// ep.setLocationURI("http://localhost:8192/service");
-// ep.setTargetService(new
QName("http://http.servicemix.org/Test", "ConsumerInOut"));
-//
-// SerializedMarshaler marshaler = new SerializedMarshaler();
-// ep.setMarshaler(marshaler);
-//
-// HttpComponent component = new HttpComponent();
-// component.setEndpoints(new HttpEndpointType[] { ep });
-// container.activateComponent(component, "HttpConsumer");
-//
-// EchoComponent echo = new EchoComponent();
-// ActivationSpec asReceiver = new ActivationSpec("echo", echo);
-// asReceiver.setService(new QName("http://http.servicemix.org/Test",
"ConsumerInOut"));
-// container.activateComponent(asReceiver);
-//
-// container.start();
-//
-// DefaultServiceMixClient client = new
DefaultServiceMixClient(container);
-// InOut inout = client.createInOutExchange();
-// inout.setService(new QName("urn:httpconsumer", "HttpConsumer"));
-// DocumentFragment epr =
URIResolver.createWSAEPR("http://localhost:8192/service");
-// ServiceEndpoint se =
client.getContext().resolveEndpointReference(epr);
-// inout.setEndpoint(se);
-// inout.getInMessage().setContent(
-// new StreamSource(new
ByteArrayInputStream(createRequestMessage())));
-//
-// long t0 = System.currentTimeMillis();
-// client.sendSync(inout);
-// long t1 = System.currentTimeMillis();
-// System.out.println("%%%%%%%%%%%%%%% Exchange: " + inout);
-// System.out.println("Fault: " + inout.getFault());
-// assertTrue(inout.getStatus() == ExchangeStatus.ACTIVE);
-//
-// System.err.println("Executed in " + (t1 - t0) + "ms");
-//
-// assertNotNull(inout.getOutMessage());
-// assertNotNull(inout.getOutMessage().getContent());
-//
-// SourceTransformer sourceTransformer = new SourceTransformer();
-// String reply =
sourceTransformer.toString(inout.getOutMessage().getContent());
-//
-// String inputMesage = sourceTransformer.toString(new StreamSource(
-// new ByteArrayInputStream(createBytesRequestMessage())));
-//
-//
System.err.println("##################################################");
-// System.err.println("Msg Sent [" + inputMesage + "]");
-// System.err.println("Msg Recieved [" + reply + "]");
-//
System.err.println("##################################################");
-// }
-
-// /**
-// * Test the SerializedMarshaler using the Spring
HttpInvokerProxyFactoryBean
-// * to initiate the request.
-// */
-// public void testUsingSpringHttpRemoting() throws Exception {
-// HttpConsumerEndpoint ep = new HttpConsumerEndpoint();
-// ep.setService(new QName("urn:httpconsumer", "HttpConsumer"));
-// ep.setEndpoint("HttpConsumer");
-// ep.setLocationURI("http://localhost:8192/service");
-// ep.setTargetService(new
QName("http://http.servicemix.org/Test", "ConsumerInOut"));
-//
-// SerializedMarshaler marshaler = new SerializedMarshaler();
-// ep.setMarshaler(marshaler);
-//
-// HttpComponent component = new HttpComponent();
-// component.setEndpoints(new HttpEndpointType[] { ep });
-// container.activateComponent(component, "HttpConsumer");
-//
-// EchoComponent echo = new EchoComponent();
-// ActivationSpec asReceiver = new ActivationSpec("echo", echo);
-// asReceiver.setService(new QName("http://http.servicemix.org/Test",
"ConsumerInOut"));
-// container.activateComponent(asReceiver);
-//
-// container.start();
-//
-// HttpInvokerProxyFactoryBean pfb = new
HttpInvokerProxyFactoryBean();
-// pfb.setServiceInterface(Person.class);
-// pfb.setServiceUrl("http://localhost:8192/service");
-//
-// // Not sure what to do about this mess
-// pfb.setHttpInvokerRequestExecutor(new
AbstractHttpInvokerRequestExecutor() {
-// protected RemoteInvocationResult doExecuteRequest(
-// HttpInvokerClientConfiguration config,
ByteArrayOutputStream baos) throws Exception {
-// assertEquals("http://localhost:8192/service",
config.getServiceUrl());
-//// MockHttpServletRequest request = new
MockHttpServletRequest();
-//// MockHttpServletResponse response = new
MockHttpServletResponse();
-//// request.setContent(baos.toByteArray());
-//// exporter.handleRequest(request, response);
-//// return readRemoteInvocationResult(
-//// new
ByteArrayInputStream(response.getContentAsByteArray()),
config.getCodebaseUrl());
-// HttpURLConnection con = openConnection(config);
-// prepareConnection(con, baos.size());
-// writeRequestBody(config, con, baos);
-//
-// return new RemoteInvocationResult(new Object());
-// }
-// });
-//
-// pfb.afterPropertiesSet();
-// }
-//
-// private HttpURLConnection openConnection(HttpInvokerClientConfiguration
config) throws IOException {
-// URLConnection con = new
URL(config.getServiceUrl()).openConnection();
-// if (!(con instanceof HttpURLConnection)) {
-// throw new IOException("Service URL [" +
config.getServiceUrl() + "] is not an HTTP URL");
-// }
-// return (HttpURLConnection) con;
-// }
-//
-// private void prepareConnection(HttpURLConnection con, int
contentLength) throws IOException {
-// con.setDoOutput(true);
-// con.setRequestMethod("POST");
-// con.setRequestProperty("Content-Type",
"application/x-java-serialized-object");
-// con.setRequestProperty("Content-Length",
Integer.toString(contentLength));
-// }
-//
-// private void writeRequestBody(HttpInvokerClientConfiguration config,
-// HttpURLConnection con, ByteArrayOutputStream baos) throws
IOException {
-// baos.writeTo(con.getOutputStream());
-// }
-//
-// private byte[] createBytesRequestMessage() {
-// Person p = new PersonImpl("Hunter", "Thompson", 67);
-// return p.toString().getBytes();
-// }
-//
-// private OutputStream createSerializedRequestMessage() {
-// Person p = new PersonImpl("Hunter", "Thompson", 67);
-// return serializeData(p.toString());
-// }
-//
-// private OutputStream serializeData(String str) {
-// ByteArrayOutputStream baos = new ByteArrayOutputStream();
-// ObjectOutputStream stream = null;
-//
-// try {
-// stream = new ObjectOutputStream(baos);
-// stream.writeUTF(str);
-// } catch (IOException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-//
-// return stream;
-// }
public void testUsingSpringHttpRemoting() throws Exception {
final Person person = new PersonImpl("Hunter", "Thompson", 67);