[hornetq-commits] JBoss hornetq SVN: r11588 - in trunk/hornetq-core/src: test/java/org/hornetq/core and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Oct 25 08:31:52 EDT 2011


Author: borges
Date: 2011-10-25 08:31:51 -0400 (Tue, 25 Oct 2011)
New Revision: 11588

Added:
   trunk/hornetq-core/src/test/java/org/hornetq/core/server/
   trunk/hornetq-core/src/test/java/org/hornetq/core/server/impl/
   trunk/hornetq-core/src/test/java/org/hornetq/core/server/impl/InVMNodeManager.java
Removed:
   trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/InVMNodeManager.java
Log:
Move test class into test sources

Deleted: trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/InVMNodeManager.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/InVMNodeManager.java	2011-10-25 12:31:33 UTC (rev 11587)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/InVMNodeManager.java	2011-10-25 12:31:51 UTC (rev 11588)
@@ -1,150 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- *  Red Hat 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.hornetq.core.server.impl;
-
-import static org.hornetq.core.server.impl.InVMNodeManager.State.FAILING_BACK;
-import static org.hornetq.core.server.impl.InVMNodeManager.State.LIVE;
-import static org.hornetq.core.server.impl.InVMNodeManager.State.NOT_STARTED;
-import static org.hornetq.core.server.impl.InVMNodeManager.State.PAUSED;
-
-import java.util.concurrent.Semaphore;
-
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.core.server.NodeManager;
-import org.hornetq.utils.UUIDGenerator;
-
-/**
- * This is a _mock_ NodeManager and is used only in tests.
- * <p>
- * It allows writing tests without the need to spawn a new JVM.
- * 
- * @author <a href="mailto:andy.taylor at jboss.com">Andy Taylor</a> Date: Oct 13, 2010 Time: 3:55:47
- *         PM
- */
-public class InVMNodeManager extends NodeManager
-{
-
-   private final Semaphore liveLock;
-
-   private final Semaphore backupLock;
-
-   public enum State {LIVE, PAUSED, FAILING_BACK, NOT_STARTED}
-
-   public State state = NOT_STARTED;
-
-   public InVMNodeManager()
-   {
-      liveLock = new Semaphore(1);
-      backupLock = new Semaphore(1);
-      uuid = UUIDGenerator.getInstance().generateUUID();
-      nodeID = new SimpleString(uuid.toString());
-   }
-
-   @Override
-   public void awaitLiveNode() throws Exception
-   {
-      do
-      {
-         while (state == NOT_STARTED)
-         {
-            Thread.sleep(2000);
-         }
-
-         liveLock.acquire();
-
-         if (state == PAUSED)
-         {
-            liveLock.release();
-            Thread.sleep(2000);
-         }
-         else if (state == FAILING_BACK)
-         {
-            liveLock.release();
-            Thread.sleep(2000);
-         }
-         else if (state == LIVE)
-         {
-            break;
-         }
-      }
-      while (true);
-   }
-
-   @Override
-   public void startBackup() throws Exception
-   {
-      backupLock.acquire();
-   }
-
-   @Override
-   public void startLiveNode() throws Exception
-   {
-      state = FAILING_BACK;
-      liveLock.acquire();
-      state = LIVE;
-   }
-
-   @Override
-   public void pauseLiveServer() throws Exception
-   {
-      state = PAUSED;
-      liveLock.release();
-   }
-
-   @Override
-   public void crashLiveServer() throws Exception
-   {
-      //overkill as already set to live
-      state = LIVE;
-      liveLock.release();
-   }
-
-   @Override
-   public void stopBackup() throws Exception
-   {
-      backupLock.release();
-   }
-
-   @Override
-   public void releaseBackup()
-   {
-      releaseBackupNode();
-   }
-
-   @Override
-   public boolean isAwaitingFailback() throws Exception
-   {
-      return state == FAILING_BACK;
-   }
-
-   @Override
-   public boolean isBackupLive() throws Exception
-   {
-      return liveLock.availablePermits() == 0;
-   }
-
-   @Override
-   public void interrupt()
-   {
-      //To change body of implemented methods use File | Settings | File Templates.
-   }
-
-   private void releaseBackupNode()
-   {
-      if(backupLock != null)
-      {
-         backupLock.release();
-      }
-   }
-}

Copied: trunk/hornetq-core/src/test/java/org/hornetq/core/server/impl/InVMNodeManager.java (from rev 11587, trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/InVMNodeManager.java)
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/core/server/impl/InVMNodeManager.java	                        (rev 0)
+++ trunk/hornetq-core/src/test/java/org/hornetq/core/server/impl/InVMNodeManager.java	2011-10-25 12:31:51 UTC (rev 11588)
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ *  Red Hat 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.hornetq.core.server.impl;
+
+import static org.hornetq.core.server.impl.InVMNodeManager.State.FAILING_BACK;
+import static org.hornetq.core.server.impl.InVMNodeManager.State.LIVE;
+import static org.hornetq.core.server.impl.InVMNodeManager.State.NOT_STARTED;
+import static org.hornetq.core.server.impl.InVMNodeManager.State.PAUSED;
+
+import java.util.concurrent.Semaphore;
+
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.server.NodeManager;
+import org.hornetq.utils.UUIDGenerator;
+
+/**
+ * This is a _mock_ NodeManager and is used only in tests.
+ * <p>
+ * It allows writing tests without the need to spawn a new JVM.
+ * 
+ * @author <a href="mailto:andy.taylor at jboss.com">Andy Taylor</a> Date: Oct 13, 2010 Time: 3:55:47
+ *         PM
+ */
+public class InVMNodeManager extends NodeManager
+{
+
+   private final Semaphore liveLock;
+
+   private final Semaphore backupLock;
+
+   public enum State {LIVE, PAUSED, FAILING_BACK, NOT_STARTED}
+
+   public State state = NOT_STARTED;
+
+   public InVMNodeManager()
+   {
+      liveLock = new Semaphore(1);
+      backupLock = new Semaphore(1);
+      uuid = UUIDGenerator.getInstance().generateUUID();
+      nodeID = new SimpleString(uuid.toString());
+   }
+
+   @Override
+   public void awaitLiveNode() throws Exception
+   {
+      do
+      {
+         while (state == NOT_STARTED)
+         {
+            Thread.sleep(2000);
+         }
+
+         liveLock.acquire();
+
+         if (state == PAUSED)
+         {
+            liveLock.release();
+            Thread.sleep(2000);
+         }
+         else if (state == FAILING_BACK)
+         {
+            liveLock.release();
+            Thread.sleep(2000);
+         }
+         else if (state == LIVE)
+         {
+            break;
+         }
+      }
+      while (true);
+   }
+
+   @Override
+   public void startBackup() throws Exception
+   {
+      backupLock.acquire();
+   }
+
+   @Override
+   public void startLiveNode() throws Exception
+   {
+      state = FAILING_BACK;
+      liveLock.acquire();
+      state = LIVE;
+   }
+
+   @Override
+   public void pauseLiveServer() throws Exception
+   {
+      state = PAUSED;
+      liveLock.release();
+   }
+
+   @Override
+   public void crashLiveServer() throws Exception
+   {
+      //overkill as already set to live
+      state = LIVE;
+      liveLock.release();
+   }
+
+   @Override
+   public void stopBackup() throws Exception
+   {
+      backupLock.release();
+   }
+
+   @Override
+   public void releaseBackup()
+   {
+      releaseBackupNode();
+   }
+
+   @Override
+   public boolean isAwaitingFailback() throws Exception
+   {
+      return state == FAILING_BACK;
+   }
+
+   @Override
+   public boolean isBackupLive() throws Exception
+   {
+      return liveLock.availablePermits() == 0;
+   }
+
+   @Override
+   public void interrupt()
+   {
+      //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   private void releaseBackupNode()
+   {
+      if(backupLock != null)
+      {
+         backupLock.release();
+      }
+   }
+}



More information about the hornetq-commits mailing list