cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1519079 - in /cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs: BookStoreStorage.java BookStoreWithInterface.java
Date Fri, 30 Aug 2013 20:34:58 GMT
Author: sergeyb
Date: Fri Aug 30 20:34:57 2013
New Revision: 1519079

URL: http://svn.apache.org/r1519079
Log:
[CXF-5245] Updating the test to check that postConstruct was called only once

Modified:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreStorage.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreStorage.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreStorage.java?rev=1519079&r1=1519078&r2=1519079&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreStorage.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreStorage.java
Fri Aug 30 20:34:57 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/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java?rev=1519079&r1=1519078&r2=1519079&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java
Fri Aug 30 20:34:57 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);
     }
     



Mime
View raw message