@Test public void testNoOperation() { ExecutionObserver observer = mock(ExecutionObserver.class); bev.execute(mockExecutionContext, mockOperationKey, args, observer, DefaultTimeConstraints.NO_CONSTRAINTS); ArgumentCaptor<ExecutionResult> executionResultArgumentCaptor = ArgumentCaptor.forClass(ExecutionResult.class); verify(observer).onResult(executionResultArgumentCaptor.capture()); assertNotNull(executionResultArgumentCaptor.getValue()); assertEquals(executionResultArgumentCaptor.getValue().getResultType(), ExecutionResult.ResultType.Fault); assertEquals(ServerFaultCode.NoSuchOperation, executionResultArgumentCaptor.getValue().getFault().getServerFaultCode()); }
@Override public void execute(final ExecutionContext ctx, final OperationKey key, final Object[] args, ExecutionObserver observer, TimeConstraints timeConstraints) { final DefinedExecutable de = registry.get(key); if (de == null) { LOGGER.debug("Not request logging request to URI: {} as no operation was found", key.toString()); observer.onResult(new ExecutionResult(new CougarFrameworkException(ServerFaultCode.NoSuchOperation, "Operation not found: "+key.toString()))); } else { long serverExpiryTime = de.maxExecutionTime == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + de.maxExecutionTime; long clientExpiryTime = timeConstraints.getExpiryTime() == null ? Long.MAX_VALUE : timeConstraints.getExpiryTime(); long expiryTime = Math.min(clientExpiryTime, serverExpiryTime); if (expiryTime == Long.MAX_VALUE) { expiryTime = 0; } if (!(observer instanceof ExpiringObserver)) { final ExpiringObserver expiringObserver = new ExpiringObserver(observer, expiryTime); if (expiringObserver.expires()) { registerExpiringObserver(expiringObserver); } observer = expiringObserver; } observer = new ExecutionObserverWrapper(observer, de.recorder, key); try { ExecutionContext contextToUse = resolveIdentitiesIfRequired(ctx); de.exec.execute(contextToUse, key, args, observer, this, timeConstraints); } catch (CougarException e) { observer.onResult(new ExecutionResult(e)); } catch (Exception e) { observer.onResult(new ExecutionResult( new CougarFrameworkException(ServerFaultCode.ServiceRuntimeException, "Exception thrown by service method", e))); } } if (observer instanceof ExpiringObserver) { deregisterExpiringObserver((ExpiringObserver) observer); } }
BaseExecutionVenue implements ExecutionVenue { @Override public void execute(final ExecutionContext ctx, final OperationKey key, final Object[] args, ExecutionObserver observer, TimeConstraints timeConstraints) { final DefinedExecutable de = registry.get(key); if (de == null) { LOGGER.debug("Not request logging request to URI: {} as no operation was found", key.toString()); observer.onResult(new ExecutionResult(new CougarFrameworkException(ServerFaultCode.NoSuchOperation, "Operation not found: "+key.toString()))); } else { long serverExpiryTime = de.maxExecutionTime == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + de.maxExecutionTime; long clientExpiryTime = timeConstraints.getExpiryTime() == null ? Long.MAX_VALUE : timeConstraints.getExpiryTime(); long expiryTime = Math.min(clientExpiryTime, serverExpiryTime); if (expiryTime == Long.MAX_VALUE) { expiryTime = 0; } if (!(observer instanceof ExpiringObserver)) { final ExpiringObserver expiringObserver = new ExpiringObserver(observer, expiryTime); if (expiringObserver.expires()) { registerExpiringObserver(expiringObserver); } observer = expiringObserver; } observer = new ExecutionObserverWrapper(observer, de.recorder, key); try { ExecutionContext contextToUse = resolveIdentitiesIfRequired(ctx); de.exec.execute(contextToUse, key, args, observer, this, timeConstraints); } catch (CougarException e) { observer.onResult(new ExecutionResult(e)); } catch (Exception e) { observer.onResult(new ExecutionResult( new CougarFrameworkException(ServerFaultCode.ServiceRuntimeException, "Exception thrown by service method", e))); } } if (observer instanceof ExpiringObserver) { deregisterExpiringObserver((ExpiringObserver) observer); } } }
BaseExecutionVenue implements ExecutionVenue { @Override public void execute(final ExecutionContext ctx, final OperationKey key, final Object[] args, ExecutionObserver observer, TimeConstraints timeConstraints) { final DefinedExecutable de = registry.get(key); if (de == null) { LOGGER.debug("Not request logging request to URI: {} as no operation was found", key.toString()); observer.onResult(new ExecutionResult(new CougarFrameworkException(ServerFaultCode.NoSuchOperation, "Operation not found: "+key.toString()))); } else { long serverExpiryTime = de.maxExecutionTime == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + de.maxExecutionTime; long clientExpiryTime = timeConstraints.getExpiryTime() == null ? Long.MAX_VALUE : timeConstraints.getExpiryTime(); long expiryTime = Math.min(clientExpiryTime, serverExpiryTime); if (expiryTime == Long.MAX_VALUE) { expiryTime = 0; } if (!(observer instanceof ExpiringObserver)) { final ExpiringObserver expiringObserver = new ExpiringObserver(observer, expiryTime); if (expiringObserver.expires()) { registerExpiringObserver(expiringObserver); } observer = expiringObserver; } observer = new ExecutionObserverWrapper(observer, de.recorder, key); try { ExecutionContext contextToUse = resolveIdentitiesIfRequired(ctx); de.exec.execute(contextToUse, key, args, observer, this, timeConstraints); } catch (CougarException e) { observer.onResult(new ExecutionResult(e)); } catch (Exception e) { observer.onResult(new ExecutionResult( new CougarFrameworkException(ServerFaultCode.ServiceRuntimeException, "Exception thrown by service method", e))); } } if (observer instanceof ExpiringObserver) { deregisterExpiringObserver((ExpiringObserver) observer); } }  }
BaseExecutionVenue implements ExecutionVenue { @Override public void execute(final ExecutionContext ctx, final OperationKey key, final Object[] args, ExecutionObserver observer, TimeConstraints timeConstraints) { final DefinedExecutable de = registry.get(key); if (de == null) { LOGGER.debug("Not request logging request to URI: {} as no operation was found", key.toString()); observer.onResult(new ExecutionResult(new CougarFrameworkException(ServerFaultCode.NoSuchOperation, "Operation not found: "+key.toString()))); } else { long serverExpiryTime = de.maxExecutionTime == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + de.maxExecutionTime; long clientExpiryTime = timeConstraints.getExpiryTime() == null ? Long.MAX_VALUE : timeConstraints.getExpiryTime(); long expiryTime = Math.min(clientExpiryTime, serverExpiryTime); if (expiryTime == Long.MAX_VALUE) { expiryTime = 0; } if (!(observer instanceof ExpiringObserver)) { final ExpiringObserver expiringObserver = new ExpiringObserver(observer, expiryTime); if (expiringObserver.expires()) { registerExpiringObserver(expiringObserver); } observer = expiringObserver; } observer = new ExecutionObserverWrapper(observer, de.recorder, key); try { ExecutionContext contextToUse = resolveIdentitiesIfRequired(ctx); de.exec.execute(contextToUse, key, args, observer, this, timeConstraints); } catch (CougarException e) { observer.onResult(new ExecutionResult(e)); } catch (Exception e) { observer.onResult(new ExecutionResult( new CougarFrameworkException(ServerFaultCode.ServiceRuntimeException, "Exception thrown by service method", e))); } } if (observer instanceof ExpiringObserver) { deregisterExpiringObserver((ExpiringObserver) observer); } }  @Override void registerOperation(String namespace, OperationDefinition def, Executable executable, ExecutionTimingRecorder recorder, long maxExecutionTime); @Override OperationDefinition getOperationDefinition(OperationKey key); @Override @ManagedAttribute Set<OperationKey> getOperationKeys(); @Override void execute(final ExecutionContext ctx, final OperationKey key, final Object[] args, ExecutionObserver observer, TimeConstraints timeConstraints); @Override void execute(final ExecutionContext ctx, final OperationKey key, final Object[] args, final ExecutionObserver observer, final Executor executor, final TimeConstraints timeConstraints); @Override void setPreProcessors(List<ExecutionPreProcessor> preProcessorList); @Override void setPostProcessors(List<ExecutionPostProcessor> postProcessorList); void setIdentityResolver(IdentityResolver identityResolver); }
BaseExecutionVenue implements ExecutionVenue { @Override public void execute(final ExecutionContext ctx, final OperationKey key, final Object[] args, ExecutionObserver observer, TimeConstraints timeConstraints) { final DefinedExecutable de = registry.get(key); if (de == null) { LOGGER.debug("Not request logging request to URI: {} as no operation was found", key.toString()); observer.onResult(new ExecutionResult(new CougarFrameworkException(ServerFaultCode.NoSuchOperation, "Operation not found: "+key.toString()))); } else { long serverExpiryTime = de.maxExecutionTime == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + de.maxExecutionTime; long clientExpiryTime = timeConstraints.getExpiryTime() == null ? Long.MAX_VALUE : timeConstraints.getExpiryTime(); long expiryTime = Math.min(clientExpiryTime, serverExpiryTime); if (expiryTime == Long.MAX_VALUE) { expiryTime = 0; } if (!(observer instanceof ExpiringObserver)) { final ExpiringObserver expiringObserver = new ExpiringObserver(observer, expiryTime); if (expiringObserver.expires()) { registerExpiringObserver(expiringObserver); } observer = expiringObserver; } observer = new ExecutionObserverWrapper(observer, de.recorder, key); try { ExecutionContext contextToUse = resolveIdentitiesIfRequired(ctx); de.exec.execute(contextToUse, key, args, observer, this, timeConstraints); } catch (CougarException e) { observer.onResult(new ExecutionResult(e)); } catch (Exception e) { observer.onResult(new ExecutionResult( new CougarFrameworkException(ServerFaultCode.ServiceRuntimeException, "Exception thrown by service method", e))); } } if (observer instanceof ExpiringObserver) { deregisterExpiringObserver((ExpiringObserver) observer); } }  @Override void registerOperation(String namespace, OperationDefinition def, Executable executable, ExecutionTimingRecorder recorder, long maxExecutionTime); @Override OperationDefinition getOperationDefinition(OperationKey key); @Override @ManagedAttribute Set<OperationKey> getOperationKeys(); @Override void execute(final ExecutionContext ctx, final OperationKey key, final Object[] args, ExecutionObserver observer, TimeConstraints timeConstraints); @Override void execute(final ExecutionContext ctx, final OperationKey key, final Object[] args, final ExecutionObserver observer, final Executor executor, final TimeConstraints timeConstraints); @Override void setPreProcessors(List<ExecutionPreProcessor> preProcessorList); @Override void setPostProcessors(List<ExecutionPostProcessor> postProcessorList); void setIdentityResolver(IdentityResolver identityResolver);  }