@Test(expected=PanicInTheCougar.class) public void testBindOperation() { OperationDefinition op = Mockito.mock(OperationDefinition.class); when(op.getParameters()).thenReturn(new Parameter[0]); ExecutionVenue ev = Mockito.mock(ExecutionVenue.class); OperationKey key = Mockito.mock(OperationKey.class); when(ev.getOperationDefinition(key)).thenReturn(op); HttpServiceBindingDescriptor serviceDescriptor = new HttpServiceBindingDescriptor() { private ServiceVersion serviceVersion = new ServiceVersion("v42.1"); @Override public String getServiceContextPath() { return "/I/v1.0"; } @Override public OperationBindingDescriptor[] getOperationBindings() { return new OperationBindingDescriptor[0]; } @Override public Protocol getServiceProtocol() { return null; } @Override public String getServiceName() { return "AnotherServiceName"; } @Override public ServiceVersion getServiceVersion() { return serviceVersion; } }; RescriptOperationBindingDescriptor op1 = new RescriptOperationBindingDescriptor(key, "url1", "GET", Collections.<RescriptParamBindingDescriptor>emptyList(), null); RescriptOperationBindingDescriptor op2 = new RescriptOperationBindingDescriptor(key, "url2", "POST", Collections.<RescriptParamBindingDescriptor>emptyList(), null); RescriptTransportCommandProcessor sut = new RescriptTransportCommandProcessor(contextResolution, "X-RequestTimeout"); sut.setExecutionVenue(ev); sut.bindOperation(serviceDescriptor, op1); sut.bindOperation(serviceDescriptor, op2); sut.bindOperation(serviceDescriptor, op1); fail("Duplicate url binding forbidden, an exception should have been thrown"); }
public void bindOperation(ServiceBindingDescriptor serviceBindingDescriptor, OperationBindingDescriptor bindingDescriptor) { OperationDefinition operationDefinition = getOperationDefinition(bindingDescriptor.getOperationKey()); if (operationDefinition!=null) { RescriptOperationBindingDescriptor rescriptOperationBindingDescriptor = (RescriptOperationBindingDescriptor) bindingDescriptor; HttpServiceBindingDescriptor httpServiceBindingDescriptor = (HttpServiceBindingDescriptor) serviceBindingDescriptor; String uri = stripMinorVersionFromUri(httpServiceBindingDescriptor.getServiceContextPath() + httpServiceBindingDescriptor.getServiceVersion()); if (uri == null) uri = ""; uri += rescriptOperationBindingDescriptor.getURI(); if (bindings.containsKey(uri)) { throw new PanicInTheCougar("More than one operation is bound to the path [" + uri + "] edit your operation paths so that this is unique, existing = "+bindings.get(uri)+", new = "+bindingDescriptor); } bindings.put(uri, new RescriptOperationBinding(rescriptOperationBindingDescriptor, operationDefinition, hardFailEnumDeserialisation)); } }
RescriptTransportCommandProcessor extends AbstractTerminateableHttpCommandProcessor<Void> { public void bindOperation(ServiceBindingDescriptor serviceBindingDescriptor, OperationBindingDescriptor bindingDescriptor) { OperationDefinition operationDefinition = getOperationDefinition(bindingDescriptor.getOperationKey()); if (operationDefinition!=null) { RescriptOperationBindingDescriptor rescriptOperationBindingDescriptor = (RescriptOperationBindingDescriptor) bindingDescriptor; HttpServiceBindingDescriptor httpServiceBindingDescriptor = (HttpServiceBindingDescriptor) serviceBindingDescriptor; String uri = stripMinorVersionFromUri(httpServiceBindingDescriptor.getServiceContextPath() + httpServiceBindingDescriptor.getServiceVersion()); if (uri == null) uri = ""; uri += rescriptOperationBindingDescriptor.getURI(); if (bindings.containsKey(uri)) { throw new PanicInTheCougar("More than one operation is bound to the path [" + uri + "] edit your operation paths so that this is unique, existing = "+bindings.get(uri)+", new = "+bindingDescriptor); } bindings.put(uri, new RescriptOperationBinding(rescriptOperationBindingDescriptor, operationDefinition, hardFailEnumDeserialisation)); } } }
RescriptTransportCommandProcessor extends AbstractTerminateableHttpCommandProcessor<Void> { public void bindOperation(ServiceBindingDescriptor serviceBindingDescriptor, OperationBindingDescriptor bindingDescriptor) { OperationDefinition operationDefinition = getOperationDefinition(bindingDescriptor.getOperationKey()); if (operationDefinition!=null) { RescriptOperationBindingDescriptor rescriptOperationBindingDescriptor = (RescriptOperationBindingDescriptor) bindingDescriptor; HttpServiceBindingDescriptor httpServiceBindingDescriptor = (HttpServiceBindingDescriptor) serviceBindingDescriptor; String uri = stripMinorVersionFromUri(httpServiceBindingDescriptor.getServiceContextPath() + httpServiceBindingDescriptor.getServiceVersion()); if (uri == null) uri = ""; uri += rescriptOperationBindingDescriptor.getURI(); if (bindings.containsKey(uri)) { throw new PanicInTheCougar("More than one operation is bound to the path [" + uri + "] edit your operation paths so that this is unique, existing = "+bindings.get(uri)+", new = "+bindingDescriptor); } bindings.put(uri, new RescriptOperationBinding(rescriptOperationBindingDescriptor, operationDefinition, hardFailEnumDeserialisation)); } } RescriptTransportCommandProcessor(DehydratedExecutionContextResolution contextResolution, String requestTimeoutHeader); }
RescriptTransportCommandProcessor extends AbstractTerminateableHttpCommandProcessor<Void> { public void bindOperation(ServiceBindingDescriptor serviceBindingDescriptor, OperationBindingDescriptor bindingDescriptor) { OperationDefinition operationDefinition = getOperationDefinition(bindingDescriptor.getOperationKey()); if (operationDefinition!=null) { RescriptOperationBindingDescriptor rescriptOperationBindingDescriptor = (RescriptOperationBindingDescriptor) bindingDescriptor; HttpServiceBindingDescriptor httpServiceBindingDescriptor = (HttpServiceBindingDescriptor) serviceBindingDescriptor; String uri = stripMinorVersionFromUri(httpServiceBindingDescriptor.getServiceContextPath() + httpServiceBindingDescriptor.getServiceVersion()); if (uri == null) uri = ""; uri += rescriptOperationBindingDescriptor.getURI(); if (bindings.containsKey(uri)) { throw new PanicInTheCougar("More than one operation is bound to the path [" + uri + "] edit your operation paths so that this is unique, existing = "+bindings.get(uri)+", new = "+bindingDescriptor); } bindings.put(uri, new RescriptOperationBinding(rescriptOperationBindingDescriptor, operationDefinition, hardFailEnumDeserialisation)); } } RescriptTransportCommandProcessor(DehydratedExecutionContextResolution contextResolution, String requestTimeoutHeader); @Override void onCougarStart(); void bindOperation(ServiceBindingDescriptor serviceBindingDescriptor, OperationBindingDescriptor bindingDescriptor); }
RescriptTransportCommandProcessor extends AbstractTerminateableHttpCommandProcessor<Void> { public void bindOperation(ServiceBindingDescriptor serviceBindingDescriptor, OperationBindingDescriptor bindingDescriptor) { OperationDefinition operationDefinition = getOperationDefinition(bindingDescriptor.getOperationKey()); if (operationDefinition!=null) { RescriptOperationBindingDescriptor rescriptOperationBindingDescriptor = (RescriptOperationBindingDescriptor) bindingDescriptor; HttpServiceBindingDescriptor httpServiceBindingDescriptor = (HttpServiceBindingDescriptor) serviceBindingDescriptor; String uri = stripMinorVersionFromUri(httpServiceBindingDescriptor.getServiceContextPath() + httpServiceBindingDescriptor.getServiceVersion()); if (uri == null) uri = ""; uri += rescriptOperationBindingDescriptor.getURI(); if (bindings.containsKey(uri)) { throw new PanicInTheCougar("More than one operation is bound to the path [" + uri + "] edit your operation paths so that this is unique, existing = "+bindings.get(uri)+", new = "+bindingDescriptor); } bindings.put(uri, new RescriptOperationBinding(rescriptOperationBindingDescriptor, operationDefinition, hardFailEnumDeserialisation)); } } RescriptTransportCommandProcessor(DehydratedExecutionContextResolution contextResolution, String requestTimeoutHeader); @Override void onCougarStart(); void bindOperation(ServiceBindingDescriptor serviceBindingDescriptor, OperationBindingDescriptor bindingDescriptor);  }