You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/08/20 17:13:00 UTC
svn commit: r806207 - in
/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime:
TestAll.java TestChild.java TestParams.java TestSemaphore.java
TestSharedMemory.java
Author: mturk
Date: Thu Aug 20 15:13:00 2009
New Revision: 806207
URL: http://svn.apache.org/viewvc?rev=806207&view=rev
Log:
Add Test helper singleton instance class for determinig weather we are master or slave task
Added:
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestParams.java (with props)
Modified:
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestChild.java
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSharedMemory.java
Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java?rev=806207&r1=806206&r2=806207&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java Thu Aug 20 15:13:00 2009
@@ -51,8 +51,10 @@
public static void main(String args[])
{
+ TestParams.initInstance(false);
String[] testCaseName = { TestAll.class.getName() };
junit.textui.TestRunner.main(testCaseName);
}
}
+
Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestChild.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestChild.java?rev=806207&r1=806206&r2=806207&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestChild.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestChild.java Thu Aug 20 15:13:00 2009
@@ -35,11 +35,13 @@
suite.addTest(TestChildMain.suite());
suite.addTest(TestOS.suite());
suite.addTest(TestSemaphore.suite());
+ suite.addTest(TestSharedMemory.suite());
return suite;
}
public static void main(String args[])
{
+ TestParams.initInstance(true);
String[] testCaseName = { TestChild.class.getName() };
junit.textui.TestRunner.main(testCaseName);
}
Added: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestParams.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestParams.java?rev=806207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestParams.java (added)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestParams.java Thu Aug 20 15:13:00 2009
@@ -0,0 +1,63 @@
+/* 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.commons.runtime;
+
+/**
+ * Global test parametersd.
+ *
+ */
+class TestParams
+{
+
+ private boolean child = false;
+ private Semaphore sync = null;
+
+ private TestParams(boolean child)
+ {
+ this.child = child;
+ }
+
+ private static TestParams singleton = null;
+
+ public static void initInstance(boolean child)
+ {
+ if (singleton == null)
+ singleton = new TestParams(child);
+ }
+
+ public static TestParams getInstance()
+ {
+ return singleton;
+ }
+
+ public boolean isChild()
+ {
+ return child;
+ }
+
+ public void setSemaphore(Semaphore sync)
+ {
+ this.sync = sync;
+ }
+
+ public Semaphore getSemaphore()
+ {
+ return sync;
+ }
+
+}
+
Propchange: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestParams.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java?rev=806207&r1=806206&r2=806207&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java Thu Aug 20 15:13:00 2009
@@ -47,32 +47,29 @@
public void testTestSemaphoreCreate()
throws Throwable
{
- boolean owner = false;
+ boolean owner = TestParams.getInstance().isChild();
int s = -1;
System.out.println();
- try {
- s = test002(0);
- } catch (Throwable t) {
- // Ignore
- }
- if (s < 0) {
+
+ if (owner) {
try {
s = test001(0);
} catch (Throwable t) {
// Ignore
}
- if (s > 0) {
- owner = true;
+ }
+ else {
+ try {
+ s = test002(0);
+ } catch (Throwable t) {
+ // Ignore
}
}
- if (s < 0) {
+ if (s < 0 && owner) {
// Neither Create or Attach were sussesful
// Remove and try Create again
test006(0);
s = test001(0);
- if (s > 0) {
- owner = true;
- }
}
assertTrue("Invalid Semaphore", s > 0);
if (owner) {
Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSharedMemory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSharedMemory.java?rev=806207&r1=806206&r2=806207&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSharedMemory.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSharedMemory.java Thu Aug 20 15:13:00 2009
@@ -42,7 +42,10 @@
public void testSharedMemoryCreate()
throws Throwable
{
-
+ if (TestParams.getInstance().isChild()) {
+ // Ship the test
+ return;
+ }
try {
SharedMemory.remove(new File("ACRSharedMemory"));
System.out.println("Removed previous instance of ACRSharedMemory");
@@ -62,6 +65,10 @@
public void testSharedMemoryDetach()
throws Throwable
{
+ if (TestParams.getInstance().isChild()) {
+ // Ship the test
+ return;
+ }
SharedMemory shm;
shm = SharedMemory.create(new File("ACRSharedMemory"), 1024);