Author: davsclaus
Date: Thu Aug 27 07:50:01 2009
New Revision: 808309

URL: http://svn.apache.org/viewvc?rev=808309&view=rev
Log:
CAMEL-1948: Fixed inccorect state of service support after a restart

Added:
    
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ServiceSupportTest.java
   (with props)
Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java?rev=808309&r1=808308&r2=808309&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java 
(original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java 
Thu Aug 27 07:50:01 2009
@@ -59,6 +59,8 @@
                     } else {
                         started.set(true);
                         starting.set(false);
+                        stopping.set(false);
+                        stopped.set(false);
                     }
                 }
             }
@@ -82,6 +84,8 @@
             } finally {
                 stopped.set(true);
                 stopping.set(false);
+                starting.set(false);
+                started.set(false);
             }
         }
     }

Added: 
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ServiceSupportTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ServiceSupportTest.java?rev=808309&view=auto
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ServiceSupportTest.java
 (added)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ServiceSupportTest.java
 Thu Aug 27 07:50:01 2009
@@ -0,0 +1,51 @@
+/**
+ * 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.camel.impl;
+
+import org.apache.camel.TestSupport;
+
+/**
+ * @version $Revision$
+ */
+public class ServiceSupportTest extends TestSupport {
+
+    private class MyService extends ServiceSupport {
+
+        protected void doStart() throws Exception {
+        }
+
+        protected void doStop() throws Exception {
+        }
+    }
+
+    public void testServiceSupport() throws Exception {
+        MyService service = new MyService();
+        service.start();
+
+        assertEquals(true, service.isStarted());
+        assertEquals(false, service.isStarting());
+        assertEquals(false, service.isStopped());
+        assertEquals(false, service.isStopping());
+
+        service.stop();
+
+        assertEquals(true, service.isStopped());
+        assertEquals(false, service.isStopping());
+        assertEquals(false, service.isStarted());
+        assertEquals(false, service.isStarting());
+    }
+}

Propchange: 
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ServiceSupportTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ServiceSupportTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date


Reply via email to