@Override public Exchange recover(CamelContext camelContext, String exchangeId) { LOG.trace("Recovering an Exchange with ID {}.", exchangeId); return useRecovery ? unmarshallExchange(camelContext, cache.get(exchangeId)) : null; }
@InvokeOnHeader("GET") @InvokeOnHeader(InfinispanConstants.GET) void onGet(Message message) { final BasicCache<Object, Object> cache = manager.getCache(message, this.cacheName); final Object key = message.getHeader(InfinispanConstants.KEY); final Object result = cache.get(key); setResult(message, result); }
@Test public void demonstrateCachePutOnCreateJsr107() { final Book bookToCreate = new Book("112-358-132", "Random Author", "Path to Infinispan Enlightenment"); this.log.infof("Creating book [%s] ...", bookToCreate); Book result = bookDao.createBook(bookToCreate); this.log.infof("Book [%s] created", bookToCreate); assert booksCache().get(result).equals(bookToCreate) : "createBook(" + bookToCreate + ") should have inserted created book into cache"; }
@Test public void demonstrateCachePutOnCreateJsr107() { final Book bookToCreate = new Book("112-358-132", "Random Author", "Path to Infinispan Enlightenment"); this.log.infof("Creating book [%s] ...", bookToCreate); Book result = bookDao.createBook(bookToCreate); this.log.infof("Book [%s] created", bookToCreate); assert booksCache().get(result).equals(bookToCreate) : "createBook(" + bookToCreate + ") should have inserted created book into cache"; }
@Test public void demonstrateCachingLoadedBooksJsr107() { final Integer bookToCacheId = Integer.valueOf(5); assert !booksCache().containsKey(bookToCacheId) : "Cache should not initially contain the book with id " + bookToCacheId; final Book cachedBook = this.bookDao.findBook(bookToCacheId); this.log.infof("Book [%s] cached", cachedBook); assert cachedBook.equals(booksCache().get(bookToCacheId)) : "findBook(" + bookToCacheId + ") should have cached book"; }
@Test public void testFindConditionMet() { final Integer bookToCacheId = Integer.valueOf(5); assert !booksCache().containsKey(bookToCacheId): "Cache should not initially contain the book with id " + bookToCacheId; final Book cachedBook = getBookService().findBookCondition(bookToCacheId); this.log.infof("Book [%s] cached", cachedBook); assert cachedBook.equals(booksCache().get(bookToCacheId)) : "findBook(" + bookToCacheId + ") should have cached book"; }
@Test public void testFindConditionMet() { final Integer bookToCacheId = Integer.valueOf(5); assert !booksCache().containsKey(bookToCacheId): "Cache should not initially contain the book with id " + bookToCacheId; final Book cachedBook = getBookService().findBookCondition(bookToCacheId); this.log.infof("Book [%s] cached", cachedBook); assert cachedBook.equals(booksCache().get(bookToCacheId)) : "findBook(" + bookToCacheId + ") should have cached book"; }
@Test public void testFindCustomCacheManager() { final Integer bookToCacheId = Integer.valueOf(5); assert !booksCache().containsKey(bookToCacheId): "Cache should not initially contain the book with id " + bookToCacheId; final Book cachedBook = getBookService().findBookCustomCacheManager(bookToCacheId); this.log.infof("Book [%s] cached", cachedBook); assert cachedBook.equals(booksCache().get(bookToCacheId)) : "findBook(" + bookToCacheId + ") should have cached book"; }
@Test public void testFindCustomKeyGenerator() { final Integer bookToCacheId = Integer.valueOf(5); assert !booksCache().containsKey(bookToCacheId): "Cache should not initially contain the book with id " + bookToCacheId; final Book cachedBook = getBookService().findBookCustomKeyGenerator(bookToCacheId); this.log.infof("Book [%s] cached", cachedBook); assert cachedBook.equals(booksCache().get(bookToCacheId)) : "findBook(" + bookToCacheId + ") should have cached book"; }
@Test public void testFindConditionMet() { final Integer bookToCacheId = Integer.valueOf(5); assert !booksCache().containsKey(bookToCacheId): "Cache should not initially contain the book with id " + bookToCacheId; final Book cachedBook = getBookService().findBookCondition(bookToCacheId); this.log.infof("Book [%s] cached", cachedBook); assert cachedBook.equals(booksCache().get(bookToCacheId)) : "findBook(" + bookToCacheId + ") should have cached book"; }
@Test public void testFindCustomCacheManager() { final Integer bookToCacheId = Integer.valueOf(5); assert !booksCache().containsKey(bookToCacheId): "Cache should not initially contain the book with id " + bookToCacheId; final Book cachedBook = getBookService().findBookCustomCacheManager(bookToCacheId); this.log.infof("Book [%s] cached", cachedBook); assert cachedBook.equals(booksCache().get(bookToCacheId)) : "findBook(" + bookToCacheId + ") should have cached book"; }
@Test public void testCachingCreate() { Book bookToCreate = new Book("112-358-132", "Random Author", "Path to Infinispan Enlightenment"); this.log.infof("Creating book [%s] ...", bookToCreate); getBookService().createBookCachingBackup(bookToCreate); this.log.infof("Book [%s] created", bookToCreate); assert bookToCreate.equals(booksCache().get(bookToCreate.getId())) : "createBook(" + bookToCreate + ") should have inserted created book into cache"; assert bookToCreate.equals(backupCache().get(bookToCreate.getId())) : "createBook(" + bookToCreate + ") should have inserted created book into cache"; }
@Test public void testCachingCreate() { Book bookToCreate = new Book("112-358-132", "Random Author", "Path to Infinispan Enlightenment"); this.log.infof("Creating book [%s] ...", bookToCreate); getBookService().createBookCachingBackup(bookToCreate); this.log.infof("Book [%s] created", bookToCreate); assert bookToCreate.equals(booksCache().get(bookToCreate.getId())) : "createBook(" + bookToCreate + ") should have inserted created book into cache"; assert bookToCreate.equals(backupCache().get(bookToCreate.getId())) : "createBook(" + bookToCreate + ") should have inserted created book into cache"; }
@Test public void testCachingFind() { final Integer bookToCacheId = Integer.valueOf(5); assert !booksCache().containsKey(bookToCacheId) : "Cache should not initially contain the book with id " + bookToCacheId; assert !backupCache().containsKey(bookToCacheId) : "Cache should not initially contain the book with id " + bookToCacheId; final Book cachedBook = getBookService().findBookCachingBackup(bookToCacheId); this.log.infof("Book [%s] cached", cachedBook); assert cachedBook.equals(booksCache().get(cachedBook.getId())) : "findBook(" + bookToCacheId + ") should have cached book"; assert cachedBook.equals(backupCache().get(cachedBook.getId())) : "findBook(" + bookToCacheId + ") should have cached book"; }
@Test public void testCachingFind() { final Integer bookToCacheId = Integer.valueOf(5); assert !booksCache().containsKey(bookToCacheId) : "Cache should not initially contain the book with id " + bookToCacheId; assert !backupCache().containsKey(bookToCacheId) : "Cache should not initially contain the book with id " + bookToCacheId; final Book cachedBook = getBookService().findBookCachingBackup(bookToCacheId); this.log.infof("Book [%s] cached", cachedBook); assert cachedBook.equals(booksCache().get(cachedBook.getId())) : "findBook(" + bookToCacheId + ") should have cached book"; assert cachedBook.equals(backupCache().get(cachedBook.getId())) : "findBook(" + bookToCacheId + ") should have cached book"; }
@Test public void testCreateCustomCacheResolver() { final Book bookToCreate = new Book("112-358-132", "Random Author", "Path to Infinispan Enlightenment"); this.log.infof("Creating book [%s] ...", bookToCreate); getBookService().createBookCustomCacheResolver(bookToCreate); this.log.infof("Book [%s] created", bookToCreate); assert bookToCreate.equals(getCache("custom").get(bookToCreate.getId())) : "createBook(" + bookToCreate + ") should have inserted created book into cache"; }
@Test public void testCreateCustomCacheResolver() { final Book bookToCreate = new Book("112-358-132", "Random Author", "Path to Infinispan Enlightenment"); this.log.infof("Creating book [%s] ...", bookToCreate); getBookService().createBookCustomCacheResolver(bookToCreate); this.log.infof("Book [%s] created", bookToCreate); assert bookToCreate.equals(getCache("custom").get(bookToCreate.getId())) : "createBook(" + bookToCreate + ") should have inserted created book into cache"; }
@Test public void testCreateCustomCacheResolver() { final Book bookToCreate = new Book("112-358-132", "Random Author", "Path to Infinispan Enlightenment"); this.log.infof("Creating book [%s] ...", bookToCreate); getBookService().createBookCustomCacheResolver(bookToCreate); this.log.infof("Book [%s] created", bookToCreate); assert bookToCreate.equals(getCache("custom").get(bookToCreate.getId())) : "createBook(" + bookToCreate + ") should have inserted created book into cache"; }
@Test public void testCreateConditionMet() { final Book bookToCreate = new Book("112-358-132", "Random Author", "Path to Infinispan Enlightenment"); this.log.infof("Creating book [%s] ...", bookToCreate); Book result = getBookService().createBookCondition(bookToCreate); this.log.infof("Book [%s] created", bookToCreate); assert bookToCreate.equals(booksCache().get(result.getId())) : "createBook(" + bookToCreate + ") should have inserted created book into cache"; }
@Test public void testCreateConditionMet() { final Book bookToCreate = new Book("112-358-132", "Random Author", "Path to Infinispan Enlightenment"); this.log.infof("Creating book [%s] ...", bookToCreate); Book result = getBookService().createBookCondition(bookToCreate); this.log.infof("Book [%s] created", bookToCreate); assert bookToCreate.equals(booksCache().get(result.getId())) : "createBook(" + bookToCreate + ") should have inserted created book into cache"; }