/** Check what happens when the portal page is not created by the store.. */ @Test public void testCreateException() { deletegateStore.create(searchRequest1); mockController.setThrowable(new RuntimeException("testCreateException")); deletegateStore.getSearchRequest(searchRequest1.getId()); mockController.setReturnValue(searchRequest1); mockController.replay(); try { cachingStore.create(searchRequest1); fail("Expecting an exception to be thrown by the store."); } catch (RuntimeException expected) { } // this should not be cached. assertEqualsNotSame(searchRequest1, cachingStore.getSearchRequest(searchRequest1.getId())); // this should now be cached. assertEqualsNotSame(searchRequest1, cachingStore.getSearchRequest(searchRequest1.getId())); assertEqualsNotSame(searchRequest1, cachingStore.getSearchRequest(searchRequest1.getId())); mockController.verify(); }
/** Does a created portal page get cached. */ @Test public void testCreate() { deletegateStore.create(searchRequest1); mockController.setReturnValue(searchRequest3); mockController.replay(); // add the search request. Should now be in the cache. assertEqualsNotSame(searchRequest3, cachingStore.create(searchRequest1)); // all of these calls should be cached. assertEqualsNotSame(searchRequest3, cachingStore.getSearchRequest(searchRequest3.getId())); assertEqualsNotSame(searchRequest3, cachingStore.getSearchRequest(searchRequest3.getId())); assertEqualsNotSame(searchRequest3, cachingStore.getSearchRequest(searchRequest3.getId())); mockController.verify(); }
/** Check what happens when the portal page is not created by the store.. */ @Test public void testCreateNullReturn() { deletegateStore.create(searchRequest1); mockController.setReturnValue(null); deletegateStore.getSearchRequest(searchRequest1.getId()); mockController.setReturnValue(searchRequest1); mockController.replay(); // add the search request. Should not be in he cache because of failure. assertNull(cachingStore.create(searchRequest1)); // this call goes to the cache. assertEqualsNotSame(searchRequest1, cachingStore.getSearchRequest(searchRequest1.getId())); // these should be cached. assertEqualsNotSame(searchRequest1, cachingStore.getSearchRequest(searchRequest1.getId())); assertEqualsNotSame(searchRequest1, cachingStore.getSearchRequest(searchRequest1.getId())); mockController.verify(); }