You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2013/08/30 22:41:33 UTC

svn commit: r1519082 - in /cxf/branches/2.7.x-fixes: ./ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreStorage.java systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java

Author: sergeyb
Date: Fri Aug 30 20:41:33 2013
New Revision: 1519082

URL: http://svn.apache.org/r1519082
Log:
Merged revisions 1519079 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1519079 | sergeyb | 2013-08-30 21:34:57 +0100 (Fri, 30 Aug 2013) | 1 line
  
  [CXF-5245] Updating the test to check that postConstruct was called only once
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreStorage.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1519079

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreStorage.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreStorage.java?rev=1519082&r1=1519081&r2=1519082&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreStorage.java (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreStorage.java Fri Aug 30 20:41:33 2013
@@ -30,17 +30,26 @@ import javax.ws.rs.Path;
 public abstract class BookStoreStorage implements LifecycleInterface {
     protected Map<Long, Book> books = new HashMap<Long, Book>();
     protected long bookId = 123;
-    protected boolean postConstructCalled;
+    protected int postConstructCalls;
+    protected int preDestroyCalls;
     
     @PostConstruct
     public void postConstruct() {
-        if (postConstructCalled) {
+        if (postConstructCalls++ == 1) {
             throw new RuntimeException();
         }
-        postConstructCalled = true;
     }
+    
     @PreDestroy
     public void preDestroy() {
-        // System.out.println("PreDestroy called");
+        if (preDestroyCalls++ == 1) {
+            throw new RuntimeException();
+        }
+    }
+    
+    protected void checkPostConstruct() {
+        if (postConstructCalls != 1) {
+            throw new RuntimeException();
+        }
     }
 }

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java?rev=1519082&r1=1519081&r2=1519082&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java Fri Aug 30 20:41:33 2013
@@ -52,9 +52,7 @@ public class BookStoreWithInterface exte
     }
     
     public Book getThatBook(Long id, String s) throws BookNotFoundFault {
-        if (!postConstructCalled) {
-            throw new RuntimeException();
-        }
+        checkPostConstruct();
         if (!id.toString().equals(s)) {
             throw new RuntimeException();
         }
@@ -62,9 +60,7 @@ public class BookStoreWithInterface exte
     }
     
     public Book getThatBook(Long id) throws BookNotFoundFault {
-        if (!postConstructCalled) {
-            throw new RuntimeException();
-        }
+        checkPostConstruct();
         return doGetBook(id);
     }