@Test public void testExecute() throws Exception { context.checking(new Expectations() { { one(reindexerMock).reindex(); } }); ReindexEntitiesExecution strategy = new ReindexEntitiesExecution(reindexerMock); strategy.execute(null); context.assertIsSatisfied(); }
@Override public Serializable execute(final ActionContext inActionContext) throws ExecutionException { if (indexInProgress) { log.error("User attempted to kick off a reindexing of the search engine while it's already in progress."); throw new ExecutionException("Cannot perform a reindexing right now - it's already in progress."); } synchronized (indexInProgress) { if (indexInProgress) { log.error("User attempted to kick off a reindexing of the search engine while it's " + "already in progress. The other thread started while this one waited for the lock"); throw new ExecutionException("Cannot perform a reindexing right now - " + "it's already in progress, kicked off while we waited for the lock."); } indexInProgress = true; } try { log.info("Search index reindex performed"); reindexer.reindex(); return "true"; } finally { log.info("Indexing stopping..."); indexInProgress = false; } }
ReindexEntitiesExecution implements ExecutionStrategy<ActionContext> { @Override public Serializable execute(final ActionContext inActionContext) throws ExecutionException { if (indexInProgress) { log.error("User attempted to kick off a reindexing of the search engine while it's already in progress."); throw new ExecutionException("Cannot perform a reindexing right now - it's already in progress."); } synchronized (indexInProgress) { if (indexInProgress) { log.error("User attempted to kick off a reindexing of the search engine while it's " + "already in progress. The other thread started while this one waited for the lock"); throw new ExecutionException("Cannot perform a reindexing right now - " + "it's already in progress, kicked off while we waited for the lock."); } indexInProgress = true; } try { log.info("Search index reindex performed"); reindexer.reindex(); return "true"; } finally { log.info("Indexing stopping..."); indexInProgress = false; } } }
ReindexEntitiesExecution implements ExecutionStrategy<ActionContext> { @Override public Serializable execute(final ActionContext inActionContext) throws ExecutionException { if (indexInProgress) { log.error("User attempted to kick off a reindexing of the search engine while it's already in progress."); throw new ExecutionException("Cannot perform a reindexing right now - it's already in progress."); } synchronized (indexInProgress) { if (indexInProgress) { log.error("User attempted to kick off a reindexing of the search engine while it's " + "already in progress. The other thread started while this one waited for the lock"); throw new ExecutionException("Cannot perform a reindexing right now - " + "it's already in progress, kicked off while we waited for the lock."); } indexInProgress = true; } try { log.info("Search index reindex performed"); reindexer.reindex(); return "true"; } finally { log.info("Indexing stopping..."); indexInProgress = false; } } ReindexEntitiesExecution(final EntityReindexer inReindexer); }
ReindexEntitiesExecution implements ExecutionStrategy<ActionContext> { @Override public Serializable execute(final ActionContext inActionContext) throws ExecutionException { if (indexInProgress) { log.error("User attempted to kick off a reindexing of the search engine while it's already in progress."); throw new ExecutionException("Cannot perform a reindexing right now - it's already in progress."); } synchronized (indexInProgress) { if (indexInProgress) { log.error("User attempted to kick off a reindexing of the search engine while it's " + "already in progress. The other thread started while this one waited for the lock"); throw new ExecutionException("Cannot perform a reindexing right now - " + "it's already in progress, kicked off while we waited for the lock."); } indexInProgress = true; } try { log.info("Search index reindex performed"); reindexer.reindex(); return "true"; } finally { log.info("Indexing stopping..."); indexInProgress = false; } } ReindexEntitiesExecution(final EntityReindexer inReindexer); @Override Serializable execute(final ActionContext inActionContext); }
ReindexEntitiesExecution implements ExecutionStrategy<ActionContext> { @Override public Serializable execute(final ActionContext inActionContext) throws ExecutionException { if (indexInProgress) { log.error("User attempted to kick off a reindexing of the search engine while it's already in progress."); throw new ExecutionException("Cannot perform a reindexing right now - it's already in progress."); } synchronized (indexInProgress) { if (indexInProgress) { log.error("User attempted to kick off a reindexing of the search engine while it's " + "already in progress. The other thread started while this one waited for the lock"); throw new ExecutionException("Cannot perform a reindexing right now - " + "it's already in progress, kicked off while we waited for the lock."); } indexInProgress = true; } try { log.info("Search index reindex performed"); reindexer.reindex(); return "true"; } finally { log.info("Indexing stopping..."); indexInProgress = false; } } ReindexEntitiesExecution(final EntityReindexer inReindexer); @Override Serializable execute(final ActionContext inActionContext);  }