use of org.apache.camel.NoSuchHeaderException in project camel by apache.
the class CMISProducerTest method namePropertyIsAlwaysRequired.
@Test
public void namePropertyIsAlwaysRequired() {
Exchange exchange = createExchangeWithInBody("Some content that will fail to be stored");
exchange.getIn().getHeaders().put(PropertyIds.CONTENT_STREAM_MIME_TYPE, "text/plain; charset=UTF-8");
template.send(exchange);
Exception exception = exchange.getException();
Object body = exchange.getOut().getBody();
assertNull(body);
assertTrue(exception instanceof NoSuchHeaderException);
}
use of org.apache.camel.NoSuchHeaderException in project camel by apache.
the class EhcacheProducer method process.
@Override
public void process(Exchange exchange) throws Exception {
final Message message = exchange.getIn();
final String action = exchange.getIn().getHeader(EhcacheConstants.ACTION, configuration.getAction(), String.class);
if (action == null) {
throw new NoSuchHeaderException(exchange, EhcacheConstants.ACTION, String.class);
}
switch(action) {
case EhcacheConstants.ACTION_CLEAR:
onClear(message);
break;
case EhcacheConstants.ACTION_PUT:
onPut(message);
break;
case EhcacheConstants.ACTION_PUT_ALL:
onPutAll(message);
break;
case EhcacheConstants.ACTION_PUT_IF_ABSENT:
onPutIfAbsent(message);
break;
case EhcacheConstants.ACTION_GET:
onGet(message);
break;
case EhcacheConstants.ACTION_GET_ALL:
onGetAll(message);
break;
case EhcacheConstants.ACTION_REMOVE:
onRemove(message);
break;
case EhcacheConstants.ACTION_REMOVE_ALL:
onRemoveAll(message);
break;
case EhcacheConstants.ACTION_REPLACE:
onReplace(message);
break;
default:
throw new IllegalStateException("Unsupported operation " + action);
}
}
Aggregations