Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…@6236 4ca5cf0f-1a52-0410-96e1-5992aa8baeaf
  • Loading branch information
badqiu committed Jan 5, 2011
1 parent be14c42 commit 02410c2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ public void say() {
}

public void exception(){
try {
throwException();
}catch(RuntimeException e) {
throw new UnsupportedOperationException("unsupported",e);
}
}

private void throwException() {
throw new RuntimeException("server error");
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package cn.org.rapid_framework.hessian.HessianTest;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.math.RandomUtils;
import org.junit.Test;

import cn.org.rapid_framework.distributed.threadlocal.DistributedThreadLocal;
import cn.org.rapid_framework.distributed.threadlocal.hessian.DistributedThreadLocalHessianConnectionFactory;

import com.caucho.hessian.client.HessianConnection;
import com.caucho.hessian.client.HessianProxyFactory;
import com.caucho.hessian.io.Hessian2Input;
import com.caucho.hessian.io.Hessian2Output;
import com.caucho.hessian.io.SerializerFactory;

public class HessianTest {

Expand All @@ -28,10 +26,31 @@ public void test() throws Exception {
HessianProxyFactory factory = new HessianProxyFactory();
factory.setConnectionFactory(new DistributedThreadLocalHessianConnectionFactory(
factory.getConnectionFactory()));

factory.setSerializerFactory(new SerializerFactory(){
});
Hello hello = (Hello) factory.create(Hello.class, url);
hello.say();
// hello.exception();
try {
hello.exception();
}catch(UnsupportedOperationException e) {
System.out.println("error:"+e);
e.printStackTrace();

ByteArrayOutputStream bos = new ByteArrayOutputStream();
Hessian2Output out = new Hessian2Output(bos);
out.startMessage();
out.writeObject(e);
out.completeMessage();
out.close();

Hessian2Input in = new Hessian2Input(new ByteArrayInputStream(bos.toByteArray()));
in.startMessage();
Exception fromInput = (Exception)in.readObject();
in.completeMessage();
in.close();

fromInput.printStackTrace();
}
// JettyServer.stop();
}

Expand Down

0 comments on commit 02410c2

Please sign in to comment.