From 0cc8ed2208c9d04057bcb00859490290e3aa948c Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:08:11 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835129 13f79535-47bb-0310-9956-ffa450edef68 --- branches/sca-java-1.3.2/itest/oneway/build.xml | 127 ----------- branches/sca-java-1.3.2/itest/oneway/pom.xml | 59 ------ .../tuscany/sca/itest/oneway/OneWayClient.java | 40 ---- .../tuscany/sca/itest/oneway/OneWayService.java | 47 ----- .../sca/itest/oneway/impl/OneWayClientImpl.java | 64 ------ .../sca/itest/oneway/impl/OneWayServiceImpl.java | 68 ------ .../META-INF/sca-deployables/oneWay.composite | 58 ----- .../tuscany/sca/itest/oneway/OneWayTestCase.java | 233 --------------------- 8 files changed, 696 deletions(-) delete mode 100644 branches/sca-java-1.3.2/itest/oneway/build.xml delete mode 100644 branches/sca-java-1.3.2/itest/oneway/pom.xml delete mode 100644 branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java delete mode 100644 branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java delete mode 100644 branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java delete mode 100644 branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java delete mode 100644 branches/sca-java-1.3.2/itest/oneway/src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite delete mode 100644 branches/sca-java-1.3.2/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java (limited to 'branches/sca-java-1.3.2/itest/oneway') diff --git a/branches/sca-java-1.3.2/itest/oneway/build.xml b/branches/sca-java-1.3.2/itest/oneway/build.xml deleted file mode 100644 index b1c97afb0f..0000000000 --- a/branches/sca-java-1.3.2/itest/oneway/build.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/sca-java-1.3.2/itest/oneway/pom.xml b/branches/sca-java-1.3.2/itest/oneway/pom.xml deleted file mode 100644 index 4f12dc0476..0000000000 --- a/branches/sca-java-1.3.2/itest/oneway/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - 4.0.0 - - org.apache.tuscany.sca - tuscany-itest - 1.3.2-SNAPSHOT - ../pom.xml - - itest-oneway - Apache Tuscany SCA OneWay Integration Tests - - - - - org.apache.tuscany.sca - tuscany-binding-ws-axis2 - 1.3.2-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-host-jetty - 1.3.2-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-node2-impl - 1.3.2-SNAPSHOT - runtime - - - - org.apache.tuscany.sca - tuscany-implementation-java-runtime - 1.3.2-SNAPSHOT - runtime - - - diff --git a/branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java b/branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java deleted file mode 100644 index 04c6069dfe..0000000000 --- a/branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java +++ /dev/null @@ -1,40 +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.itest.oneway; - -/** - * The client for the oneway itest. - * - * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ - */ -public interface OneWayClient { - - /** - * This method will invoke the doSomething() @OneWay method on the OneWayService - * the specified number of times. - * - * @param count The number of times to invoke doSomething() on the OneWayService - */ - void doSomething(int count); - - /** - * This method will invoke a @OneWay method that throws an exception. - */ - void doSomethingWhichThrowsException(); -} diff --git a/branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java b/branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java deleted file mode 100644 index b3cec51b1f..0000000000 --- a/branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java +++ /dev/null @@ -1,47 +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.itest.oneway; - - -import org.osoa.sca.annotations.OneWay; -import org.osoa.sca.annotations.Remotable; - - -/** - * The service interface used when testing @OneWay interactions. - * - * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ - */ -@Remotable -public interface OneWayService { - - /** - * This OneWay method will increment the callCount by 1. - * - * @param count Not used - */ - @OneWay - void doSomething(int count); - - /** - * This one way method will throw a NullPointerException. - */ - @OneWay - void doSomethingWhichThrowsException(); -} diff --git a/branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java b/branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java deleted file mode 100644 index 8013c5c0e8..0000000000 --- a/branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java +++ /dev/null @@ -1,64 +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.itest.oneway.impl; - -import org.apache.tuscany.sca.itest.oneway.OneWayClient; -import org.apache.tuscany.sca.itest.oneway.OneWayService; -import org.junit.Assert; -import org.osoa.sca.annotations.Reference; - - -/** - * The client for the oneway itest. - * - * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ - */ -public class OneWayClientImpl implements OneWayClient { - /** - * Injected reference to the OneWayService. - */ - @Reference - protected OneWayService oneWayService; - - /** - * Tracks the number of calls of the doSomething() method on the OneWayService. - */ - public static int callCount = 0; - - /** - * {@inheritDoc} - */ - public void doSomething(int count) { - callCount = callCount + count; - - for (int loopCount = 0; loopCount < count; loopCount++) { - //System.out.println("Client: doSomething " + loopCount); - //System.out.flush(); - oneWayService.doSomething(loopCount); - } - } - - /** - * {@inheritDoc} - */ - public void doSomethingWhichThrowsException() { - Assert.assertNotNull(oneWayService); - oneWayService.doSomethingWhichThrowsException(); - } -} diff --git a/branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java b/branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java deleted file mode 100644 index 01f956cb67..0000000000 --- a/branches/sca-java-1.3.2/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java +++ /dev/null @@ -1,68 +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.itest.oneway.impl; - -import org.apache.tuscany.sca.itest.oneway.OneWayService; - -import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger; - -/** - * The service for the oneway itest. - * - * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ - */ - - -public class OneWayServiceImpl implements OneWayService { - - /** - * This is the error message that will be in the Exception thrown by - * the doSomethingWhichThrowsException() method. - */ - public static final String EXCEPTION_MESSAGE = "Sample RuntimeException from a @OneWay method"; - - /** - * Counts the number of invocations to doSomething(). - */ - public static final AtomicInteger CALL_COUNT = new AtomicInteger(); - - /** - * Counts the number of invocations of the doSomethingWhichThrowsException() method. - */ - public static final AtomicInteger CALL_COUNT_FOR_THROWS_EXCEPTION_METHOD = new AtomicInteger(); - - /** - * {@inheritDoc} - */ - public void doSomething(int count) { - CALL_COUNT.incrementAndGet(); - - // System.out.println("Service: doSomething " + count + " callCount = " + callCount); - // System.out.flush(); - } - - /** - * {@inheritDoc} - */ - public void doSomethingWhichThrowsException() { - System.out.println("OneWay invoked. About to throw an Exception"); - CALL_COUNT_FOR_THROWS_EXCEPTION_METHOD.incrementAndGet(); - throw new NullPointerException(EXCEPTION_MESSAGE); - } -} diff --git a/branches/sca-java-1.3.2/itest/oneway/src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite b/branches/sca-java-1.3.2/itest/oneway/src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite deleted file mode 100644 index d053a6278c..0000000000 --- a/branches/sca-java-1.3.2/itest/oneway/src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/sca-java-1.3.2/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java b/branches/sca-java-1.3.2/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java deleted file mode 100644 index b21042c06b..0000000000 --- a/branches/sca-java-1.3.2/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java +++ /dev/null @@ -1,233 +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.itest.oneway; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -import junit.framework.Assert; - -import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor; -import org.apache.tuscany.sca.itest.oneway.impl.OneWayClientImpl; -import org.apache.tuscany.sca.itest.oneway.impl.OneWayServiceImpl; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCANode2; -import org.apache.tuscany.sca.node.SCANode2Factory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * This test case will test invoking @OneWay operations. - * - * @version $Date$ $Revision$ - */ -public class OneWayTestCase { - /** - * Maximum period of time that we are prepared to wait for all the @OneWay - * method calls to complete in milliseconds. - */ - private static final int MAX_SLEEP_TIME = 10000; - - private SCANode2 node; - - /** - * Initialise the SCADomain. - * - * @throws Exception Failed to initialise the SCADomain - */ - @Before - public void setUp() throws Exception { - - SCANode2Factory nodeFactory = SCANode2Factory.newInstance(); - node = nodeFactory.createSCANodeFromClassLoader("OneWayContribution/META-INF/sca-deployables/oneWay.composite", null); - node.start(); - - } - - /** - * This method will ensure that the SCADomain is shutdown. - * - * @throws Exception Failed to shutdown the SCADomain - */ - @After - public void tearDown() throws Exception { - node.stop(); - } - - /** - * This test will test repeatedly calling a @OneWay operation and ensure that the correct - * number of @OneWay operations are run. - * - * @throws Exception Test failed - */ - @Test - public void testOneWay() throws Exception { - OneWayClient client = - ((SCAClient)node).getService(OneWayClient.class, "OneWayClientComponent"); - - int count = 100; - - for (int i = 0; i < 10; i++) { - // System.out.println("Test: doSomething " + count); - // System.out.flush(); - client.doSomething(count); - - // TUSCANY-2192 - We need to sleep to allow the @OneWay method calls to complete. - // Note: This can take different periods depending on the speed and load - // on the computer where the test is being run. - // This loop will wait for the required number of @OneWay method calls to - // have taken place or MAX_SLEEP_TIME to have passed. - long startSleep = System.currentTimeMillis(); - while (OneWayClientImpl.callCount != OneWayServiceImpl.CALL_COUNT.get() - && System.currentTimeMillis() - startSleep < MAX_SLEEP_TIME) { - Thread.sleep(100); - // System.out.println("" + OneWayClientImpl.callCount + "," + OneWayServiceImpl.callCount); - } - - System.out.println("Finished callCount = " + OneWayServiceImpl.CALL_COUNT); - - Assert.assertEquals(OneWayClientImpl.callCount, OneWayServiceImpl.CALL_COUNT.get()); - } - } - - /** - * This method will invoke a @OneWay method that throws an exception - * when invoked over a SCA Binding which uses the NonBlockingInterceptor and - * ensure that the Exception is logged. - * See TUSCANY-2225 - */ - @Test - public void testOneWayUsingNonBlockingInterceptorThrowsAnException() { - OneWayClient client = - ((SCAClient)node).getService(OneWayClient.class, "OneWayClientComponentSCABinding"); - - // We need to modify the JDK Logger for the NonBlockingInterceptor so we - // can check that it logs a message for the @OneWay invocation that throws - // an Exception - Logger nbiLogger = Logger.getLogger(NonBlockingInterceptor.class.getName()); - DummyJDKHandler handler = new DummyJDKHandler(); - nbiLogger.addHandler(handler); - - // Add a message on the console to explain the stack dump that is going to be - // displayed and state that this is not a problem but expected behaviour - System.out.println(); - System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); - System.out.println("IMPORTANT: The error message that appears on the console"); - System.out.println("below is an expected error if it is a NullPointerException"); - System.out.println(" with the message of:"); - System.out.println(" \"" + OneWayServiceImpl.EXCEPTION_MESSAGE + "\""); - System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); - System.out.println(); - System.out.flush(); - - // Invoke the @OneWay method that throws an exception - client.doSomethingWhichThrowsException(); - - // The logging is done asynchronously so we will need to wait a bit before - // the log message appears. - long start = System.currentTimeMillis(); - boolean logged = false; - while (System.currentTimeMillis() - start < MAX_SLEEP_TIME && !logged) { - // Has the log message been logged? - if (handler.exceptionLogged.get()) { - logged = true; - } else { - try { - Thread.sleep(25); - } catch (InterruptedException ex) { - Assert.fail("Unexpected exception " + ex); - } - } - } - - // Add a message explaining that errors beyond this point should be reported - System.out.println(); - System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); - System.out.println("End of expected exceptions. Any errors beyond this point are errors!"); - System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); - System.out.println(); - System.out.flush(); - - // Remove the handler - nbiLogger.removeHandler(handler); - - // Make sure that the exception was logged - Assert.assertTrue(handler.exceptionLogged.get()); - } - - /** - * A handler that is added to the JDK Logging system to examine the log messages - * generated to ensure that a @OneWay method that throws an Exception will - * generate a log message. - */ - private class DummyJDKHandler extends Handler { - - /** - * Used to track whether the exception has been logged. - */ - private AtomicBoolean exceptionLogged = new AtomicBoolean(false); - - /** - * Constructor. - */ - private DummyJDKHandler() { - super.setLevel(Level.ALL); - } - - /** - * {@inheritDoc} - */ - @Override - public void close() throws SecurityException { - // Nothing to do - } - - /** - * {@inheritDoc} - */ - @Override - public void flush() { - // Nothing to do - } - - /** - * Examines the LogRecord and checks whether it matches the one we are looking for. - * If it matches, it will set exceptionLogged to True. - * - * @param record The Log Record that is being published - */ - @Override - public void publish(LogRecord record) { - // The log message we are looking for is Severe - if (record.getLevel() == Level.SEVERE) { - if (record.getThrown() != null - && record.getThrown().toString().indexOf( - OneWayServiceImpl.EXCEPTION_MESSAGE) != -1) { - // We have found our Exception. - exceptionLogged.set(true); - } - } - } - } -} -- cgit v1.2.3