From 9425990f532b1152c2d73db96c0f07ef5216a3d1 Mon Sep 17 00:00:00 2001 From: lresende Date: Thu, 12 Nov 2009 00:43:48 +0000 Subject: Moving 2.x contribs git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835178 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/java/account/BankManagerFacade.java | 33 ----- .../src/test/java/account/Customer.java | 36 ----- .../src/test/java/account/CustomerImpl.java | 57 -------- .../src/test/java/calculator/AddService.java | 27 ---- .../src/test/java/calculator/AddServiceHome.java | 31 ----- .../samples/bank/ejb/BankManagerFacade.java | 44 ------ .../samples/bank/ejb/BankManagerFacadeHome.java | 44 ------ .../binding/ejb/tests/EJBReferenceTestCase.java | 73 ---------- .../tuscany/sca/binding/ejb/tests/MockServer.java | 151 --------------------- .../sca/binding/ejb/tests/SocketTracer.java | 138 ------------------- .../src/test/resources/account/account.composite | 35 ----- 11 files changed, 669 deletions(-) delete mode 100644 java/sca-contrib/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java delete mode 100644 java/sca-contrib/modules/binding-ejb-runtime/src/test/java/account/Customer.java delete mode 100644 java/sca-contrib/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java delete mode 100644 java/sca-contrib/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java delete mode 100644 java/sca-contrib/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java delete mode 100644 java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacade.java delete mode 100644 java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacadeHome.java delete mode 100644 java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java delete mode 100644 java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java delete mode 100644 java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java delete mode 100644 java/sca-contrib/modules/binding-ejb-runtime/src/test/resources/account/account.composite (limited to 'java/sca-contrib/modules/binding-ejb-runtime/src/test') diff --git a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java b/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java deleted file mode 100644 index 337bb004b5..0000000000 --- a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package account; - -import org.oasisopen.sca.annotation.Remotable; - -/** - * - * Compatible EJB interface - * - * @version $Rev$ $Date$ - */ -@Remotable -public interface BankManagerFacade { - Double getAccountBalance( String accountNo ); - void changeAccountBalance( String accountNo, Double balance ); -} diff --git a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/account/Customer.java b/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/account/Customer.java deleted file mode 100644 index 8585301868..0000000000 --- a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/account/Customer.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package account; - -import org.oasisopen.sca.annotation.Remotable; - -@Remotable -public interface Customer { - - /** - * This method deposits the amount. method accesses external EJB to get the - * current balance and add the amount to existing balance. - * - * @param accountNo The number of the account into which to deposit the money - * @param amount The amount to be deposited - * @return total amount in customer account after deposit - */ - Double depositAmount(java.lang.String accountNo, Double amount); - -} diff --git a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java b/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java deleted file mode 100644 index 7406b9bd37..0000000000 --- a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package account; - -import org.oasisopen.sca.ServiceRuntimeException; -import org.oasisopen.sca.annotation.Reference; -import org.oasisopen.sca.annotation.Service; - -import calculator.AddService; - -@Service(Customer.class) -public class CustomerImpl implements Customer { - - private AddService extEJBService = null; - - public AddService getExtEJBService() { - return extEJBService; - } - - @Reference - public void setExtEJBService(AddService extEJBService) { - this.extEJBService = extEJBService; - } - - // this method invokes external EJB through EJB reference binding - public Double depositAmount(java.lang.String accountNo, Double amount) { - - Double total = null; - - System.out.println("In component implementation. Invoking external EJB through EJB reference binding "); - - try { - Double balance = extEJBService.add(amount.doubleValue(), 1000); //invoke external ejb through ejb reference binding - total = balance + amount; - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - return total; - } - -} diff --git a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java b/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java deleted file mode 100644 index 7cefba530a..0000000000 --- a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package calculator; - -/** - * @version $Rev$ $Date$ - */ -public interface AddService { - double add(double n1, double n2); -} diff --git a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java b/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java deleted file mode 100644 index 799bcaa672..0000000000 --- a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package calculator; - -import java.rmi.RemoteException; - -import javax.ejb.CreateException; -import javax.ejb.EJBHome; - -public interface AddServiceHome extends EJBHome { - - AddService create() throws CreateException, RemoteException; - -} diff --git a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacade.java b/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacade.java deleted file mode 100644 index e480e648d9..0000000000 --- a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacade.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Generated by XDoclet - Do not edit! - */ -package org.apache.geronimo.samples.bank.ejb; - -// copied from the Geronimo Bank sample: http://cwiki.apache.org/GMOxDOC11/ejb-sample-application.html#EJBsampleapplication-overview - -/** - * Remote interface for BankManagerFacadeBean. - * @xdoclet-generated at ${TODAY} - * @copyright The XDoclet Team - * - * @version $Rev$ $Date$ - */ -public interface BankManagerFacade - extends javax.ejb.EJBObject -{ - - void changeAccountBalance( java.lang.String accountNo,java.lang.Double balance ) - throws java.rmi.RemoteException; - - java.lang.Double getAccountBalance( java.lang.String accountNo ) - throws java.rmi.RemoteException; - -} diff --git a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacadeHome.java b/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacadeHome.java deleted file mode 100644 index 0d02be3b95..0000000000 --- a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacadeHome.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Generated by XDoclet - Do not edit! - */ - -// copied from the Geronimo Bank sample: http://cwiki.apache.org/GMOxDOC11/ejb-sample-application.html#EJBsampleapplication-overview - -package org.apache.geronimo.samples.bank.ejb; - -/** - * Home interface for BankManagerFacadeBean. - * @xdoclet-generated at ${TODAY} - * @copyright The XDoclet Team - * - * @version $Rev$ $Date$ - */ -public interface BankManagerFacadeHome - extends javax.ejb.EJBHome -{ - String COMP_NAME="java:comp/env/ejb/BankManagerFacadeBean"; - String JNDI_NAME="org.apache.geronimo.samples.bank.ejb.BankManagerFacadeBean"; - - org.apache.geronimo.samples.bank.ejb.BankManagerFacade create() - throws javax.ejb.CreateException,java.rmi.RemoteException; - -} diff --git a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java b/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java deleted file mode 100644 index 87616330dc..0000000000 --- a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.binding.ejb.tests; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.node.Contribution; -import org.apache.tuscany.sca.node.ContributionLocationHelper; -import org.apache.tuscany.sca.node.Node; -import org.apache.tuscany.sca.node.NodeFactory; - -import account.Customer; - -/** - * Invokes the component which calls the reference using the EJB binding - * - * @version $Rev$ $Date$ - */ -public class EJBReferenceTestCase extends TestCase { - private static final int MOCK_PORT = 8085; - private Node node; - - @Override - protected void setUp() throws Exception { - System.setProperty("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory"); - System.setProperty("java.naming.provider.url", "ejbd://localhost:" + MOCK_PORT); - System.setProperty("managed", "false"); - - String contribution = ContributionLocationHelper.getContributionLocation(EJBReferenceTestCase.class); - node = NodeFactory.newInstance().createNode("account/account.composite", new Contribution("account", contribution)); - node.start(); - - // To capture the network traffic for the MockServer, uncomment the next line - // new Thread(new SocketTracer(MOCK_PORT, OPENEJB_PORT)).start(); - - // Start the mock server to simulate the remote EJB - new Thread(new MockServer(MOCK_PORT)).start(); - - // Wait enough for the server to be started - Thread.sleep(500); - } - - @Override - protected void tearDown() throws Exception { - node.stop(); - node.destroy(); - } - - public void testCalculator() throws Exception { - Customer customer = node.getService(Customer.class, "CustomerComponent"); - // This is one of the customer numbers in bank application running on Geronimo - String accountNo = "1234567890"; - Double balance = customer.depositAmount(accountNo, new Double(100)); - // System.out.println("Balance amount for account " + accountNo + " is $" + balance); - assertEquals(1200.0, balance); - } -} diff --git a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java b/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java deleted file mode 100644 index 48e87fb6d1..0000000000 --- a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.binding.ejb.tests; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.ServerSocket; -import java.net.Socket; - -public class MockServer implements Runnable { - - private int listen; - byte[][] seq = - { - {79, 69, 74, 80, 47, 51, 46, 48, 1, -84, -19, 0, 5, 119, 58, 1, 27, 0, 54, 47, 104, 101, 108, 108, 111, 45, - 97, 100, 100, 115, 101, 114, 118, 105, 99, 101, 47, 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 66, 101, - 97, 110, 47, 99, 97, 108, 99, 117, 108, 97, 116, 111, 114, 46, 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, - 112}, - - {79, 69, 74, 80, 47, 50, 46, 48, -84, -19, 0, 5, 119, 3, 1, 13, 1, 118, 114, 0, 25, 99, 97, 108, 99, 117, 108, - 97, 116, 111, 114, 46, 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 72, 111, 109, 101, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 120, 112, 118, 114, 0, 21, 99, 97, 108, 99, 117, 108, 97, 116, 111, 114, 46, 65, 100, 100, 83, - 101, 114, 118, 105, 99, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 112, 112, 112, 119, 38, 7, 0, 31, 104, - 101, 108, 108, 111, 45, 97, 100, 100, 115, 101, 114, 118, 105, 99, 101, 47, 65, 100, 100, 83, 101, 114, 118, - 105, 99, 101, 66, 101, 97, 110, -1, -1, 0, 0}, - - {79, 69, 74, 80, 47, 51, 46, 48, 0, -84, -19, 0, 5, 119, 1, 10, 116, 0, 31, 104, 101, 108, 108, 111, 45, 97, - 100, 100, 115, 101, 114, 118, 105, 99, 101, 47, 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 66, 101, 97, - 110, 119, 2, -1, -1, 112, 119, 1, 1, 112, 118, 114, 0, 25, 99, 97, 108, 99, 117, 108, 97, 116, 111, 114, 46, - 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 72, 111, 109, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 112, - 119, 9, 0, 6, 99, 114, 101, 97, 116, 101, 0}, - {79, 69, 74, 80, 47, 50, 46, 48, -84, -19, 0, 5, 119, 2, 1, 4, 112}, - - {79, 69, 74, 80, 47, 51, 46, 48, 0, -84, -19, 0, 5, 119, 1, 23, 116, 0, 31, 104, 101, 108, 108, 111, 45, 97, - 100, 100, 115, 101, 114, 118, 105, 99, 101, 47, 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 66, 101, 97, - 110, 119, 2, -1, -1, 112, 119, 1, 1, 112, 118, 114, 0, 21, 99, 97, 108, 99, 117, 108, 97, 116, 111, 114, 46, - 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 112, 119, 24, 0, 3, 97, - 100, 100, 2, 4, 64, 89, 0, 0, 0, 0, 0, 0, 4, 64, -113, 64, 0, 0, 0, 0, 0}, - {79, 69, 74, 80, 47, 50, 46, 48, -84, -19, 0, 5, 119, 2, 1, 4, 115, 114, 0, 16, 106, 97, 118, 97, 46, 108, 97, - 110, 103, 46, 68, 111, 117, 98, 108, 101, -128, -77, -62, 74, 41, 107, -5, 4, 2, 0, 1, 68, 0, 5, 118, 97, - 108, 117, 101, 120, 114, 0, 16, 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 78, 117, 109, 98, 101, 114, - -122, -84, -107, 29, 11, -108, -32, -117, 2, 0, 0, 120, 112, 64, -111, 48, 0, 0, 0, 0, 0} - - }; - - public MockServer(int listen) { - this.listen = listen; - } - - public void run() { - try { - ServerSocket ss = new ServerSocket(listen); - for (int i = 0; i < seq.length; i += 2) { - // System.out.println("Processing request[" + i/2 + "]"); - doExchange(ss.accept(), seq[i], seq[i + 1]); - } - - } catch (Exception e) { - e.printStackTrace(); - } - } - - private void doExchange(Socket socket, byte[] read, byte[] write) throws IOException, InterruptedException { - Thread t2 = readBytes(socket, read.length); - Thread t1 = writeBytes(socket, write); - t1.join(); - t2.join(); - socket.close(); - } - - private Thread readBytes(Socket socket, int x) throws IOException, InterruptedException { - byte[] buf = new byte[x]; - Thread t = new Reader(socket, buf); - t.start(); - return t; - } - - private Thread writeBytes(Socket socket, byte[] bs) throws IOException, InterruptedException { - Thread t = new Writer(socket, bs); - t.start(); - return t; - } - - private static class Reader extends Thread { - - private InputStream is; - private byte[] buf; - - Reader(Socket socket, byte[] buf) throws IOException { - this.is = socket.getInputStream(); - this.buf = buf; - } - - @Override - public void run() { - try { - int totalSize = buf.length; - int readSize = 0; - int offset = 0; - while (totalSize > 0 && (readSize = is.read(buf, offset, totalSize)) != -1) { - offset += readSize; - totalSize -= readSize; - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - } - - private static class Writer extends Thread { - - private OutputStream os; - private byte[] buf; - - Writer(Socket socket, byte[] buf) throws IOException { - this.os = socket.getOutputStream(); - this.buf = buf; - } - - @Override - public void run() { - try { - os.write(buf); - os.flush(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - } - -} diff --git a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java b/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java deleted file mode 100644 index 66b3feb458..0000000000 --- a/java/sca-contrib/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.binding.ejb.tests; - -import java.io.InputStream; -import java.io.OutputStream; -import java.net.ServerSocket; -import java.net.Socket; - -/** - * Displays the bytes flowing across a Socket connection. - * Used to get the read count and reply data for the MockServer - * - * @version $Rev$ $Date$ - */ -public class SocketTracer implements Runnable { - - private int listen; - private int send; - - SocketTracer(int listen, int send) { - this.listen = listen; - this.send = send; - } - - public void run() { - try { - ServerSocket ss = new ServerSocket(listen); - while (true) { - Socket sin = ss.accept(); - - Socket sout = new Socket("localhost", send); - - Thread st = new Thread(new Send(sin, sout)); - st.start(); - } - - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * @param buf - * @param count - */ - static synchronized void dump(String str, byte[] buf, int count) { - // System.out.println(Thread.currentThread()); - System.out.print(str+"{"); - for (int j = 0; j < count; j++) { - if (j == count - 1) { - System.out.println(buf[j] + "}, "); - } else { - System.out.print(buf[j] + ", "); - } - } - } -} - - -class Send implements Runnable { - - Socket sin; - Socket sout; - - Send(Socket sin, Socket sout) { - this.sin = sin; - this.sout = sout; - } - - public void run() { - try { - - Reply rr = new Reply(sout.getInputStream(), sin.getOutputStream()); - Thread rt = new Thread(rr); - rt.start(); - - OutputStream outout = sout.getOutputStream(); - InputStream is = sin.getInputStream(); - byte[] buf = new byte[4096]; - int i = 0; - int count = 0; - while ((i = is.read()) != -1) { - buf[count++] = (byte)i; - outout.write(i); - } - SocketTracer.dump("Req: ", buf, count); - - } catch (Exception e) { - e.printStackTrace(); - } - } - -} - -class Reply implements Runnable { - - InputStream is; - OutputStream outout; - - Reply(InputStream is, OutputStream outout) { - this.is = is; - this.outout = outout; - } - - public void run() { - try { - byte[] buf = new byte[4096]; - int i = 0; - int count = 0; - while ((i = is.read()) != -1) { - buf[count++] = (byte)i; - outout.write(i); - } - SocketTracer.dump("Res: ", buf, count); - } catch (Exception e) { - e.printStackTrace(); - } - } - -} diff --git a/java/sca-contrib/modules/binding-ejb-runtime/src/test/resources/account/account.composite b/java/sca-contrib/modules/binding-ejb-runtime/src/test/resources/account/account.composite deleted file mode 100644 index 14f77eed08..0000000000 --- a/java/sca-contrib/modules/binding-ejb-runtime/src/test/resources/account/account.composite +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - -- cgit v1.2.3