You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by mc...@apache.org on 2008/04/17 15:01:03 UTC
svn commit: r649079 - in /incubator/tuscany/java/sca/itest/oneway/src:
main/java/org/apache/tuscany/sca/itest/oneway/
main/java/org/apache/tuscany/sca/itest/oneway/impl/
test/java/org/apache/tuscany/sca/itest/oneway/
Author: mcombellack
Date: Thu Apr 17 06:00:54 2008
New Revision: 649079
URL: http://svn.apache.org/viewvc?rev=649079&view=rev
Log:
General code tidy up by adding JavaDoc, sorting code formatting, etc
Removed:
incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServer.java
Modified:
incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java
incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java
incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java
incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java
incubator/tuscany/java/sca/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java
Modified: incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java?rev=649079&r1=649078&r2=649079&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java (original)
+++ incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java Thu Apr 17 06:00:54 2008
@@ -18,17 +18,20 @@
*/
package org.apache.tuscany.sca.itest.oneway;
-
/**
- * The client for the oneway itest
+ * The client for the oneway itest.
*
* @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
*/
-
-
public interface OneWayClient {
-
- public int doSomething(int count);
+
+ /**
+ * 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.
Modified: incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java?rev=649079&r1=649078&r2=649079&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java (original)
+++ incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java Thu Apr 17 06:00:54 2008
@@ -24,15 +24,20 @@
/**
- * The service interface used when testing oneway interactions
+ * 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
- public void doSomething(int count);
+ void doSomething(int count);
/**
* This one way method will throw a NullPointerException.
Modified: incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java?rev=649079&r1=649078&r2=649079&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java (original)
+++ incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java Thu Apr 17 06:00:54 2008
@@ -25,32 +25,34 @@
/**
- * The client for the oneway itest
+ * 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;
-
- public static int callCount = 0;
+ /**
+ * Tracks the number of calls of the doSomething() method on the OneWayService.
+ */
+ public static int callCount = 0;
- public int doSomething(int count){
-
+ /**
+ * {@inheritDoc}
+ */
+ public void doSomething(int count) {
callCount = callCount + count;
-
- for (int loopCount = 0; loopCount < count; loopCount++){
+
+ for (int loopCount = 0; loopCount < count; loopCount++) {
//System.out.println("Client: doSomething " + loopCount);
//System.out.flush();
oneWayService.doSomething(loopCount);
}
-
- return count;
- }
+ }
/**
* {@inheritDoc}
Modified: incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java?rev=649079&r1=649078&r2=649079&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java (original)
+++ incubator/tuscany/java/sca/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java Thu Apr 17 06:00:54 2008
@@ -23,7 +23,7 @@
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
/**
- * The service for the oneway itest
+ * The service for the oneway itest.
*
* @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
*/
@@ -40,21 +40,22 @@
/**
* Counts the number of invocations to doSomething().
*/
- public static final AtomicInteger callCount = new AtomicInteger();
+ 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();
- public void doSomething(int count){
- callCount.incrementAndGet();
+ /**
+ * {@inheritDoc}
+ */
+ public void doSomething(int count) {
+ CALL_COUNT.incrementAndGet();
// System.out.println("Service: doSomething " + count + " callCount = " + callCount);
// System.out.flush();
-
-
- }
+ }
/**
* {@inheritDoc}
Modified: incubator/tuscany/java/sca/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java?rev=649079&r1=649078&r2=649079&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java (original)
+++ incubator/tuscany/java/sca/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java Thu Apr 17 06:00:54 2008
@@ -39,6 +39,11 @@
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
@@ -46,8 +51,16 @@
*/
private static final int MAX_SLEEP_TIME = 10000;
+ /**
+ * The SCADomain that we are using for testing.
+ */
private SCADomain domain;
+ /**
+ * Initialise the SCADomain.
+ *
+ * @throws Exception Failed to initialise the SCADomain
+ */
@Before
public void setUp() throws Exception {
SCANode node = SCANodeFactory.newInstance().createSCANode(null, null);
@@ -58,6 +71,11 @@
domain = node.getDomain();
}
+ /**
+ * This method will ensure that the SCADomain is shutdown.
+ *
+ * @throws Exception Failed to shutdown the SCADomain
+ */
@After
public void tearDown() throws Exception {
if (domain != null) {
@@ -65,39 +83,39 @@
}
}
+ /**
+ * 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 =
domain.getService(OneWayClient.class, "OneWayClientComponent");
- try {
- int count = 100;
+ 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.callCount.get()
- && System.currentTimeMillis() - startSleep < MAX_SLEEP_TIME) {
- Thread.sleep(100);
- // System.out.println("" + OneWayClientImpl.callCount + "," + OneWayServiceImpl.callCount);
- }
+ 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.callCount);
+ System.out.println("Finished callCount = " + OneWayServiceImpl.CALL_COUNT);
- Assert.assertEquals(OneWayClientImpl.callCount, OneWayServiceImpl.callCount.get());
- }
- } catch (Exception ex) {
- System.err.println("Exception: " + ex.toString());
- ex.printStackTrace();
- throw ex;
+ Assert.assertEquals(OneWayClientImpl.callCount, OneWayServiceImpl.CALL_COUNT.get());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org