@Test public void providedButNotRequired() { PolicyUtil.provide(exchange, new FooPolicy()); exchange.setPhase(ExchangePhase.IN); try { handler.handleMessage(exchange); } catch (HandlerException handlerEx) { Assert.fail("Exception not expected when policy is provided but not required: " + handlerEx); } }
@Override public void handleMessage(Exchange exchange) throws HandlerException { if (ExchangePhase.IN.equals(exchange.getPhase())) { Set<Policy> required = PolicyUtil.getRequired(exchange); Iterator<Policy> reqIt = required.iterator(); while (reqIt.hasNext()) { if (PolicyUtil.isProvided(exchange, reqIt.next())) { reqIt.remove(); } } if (!required.isEmpty()) { Iterator<Policy> missing = required.iterator(); StringBuilder requires = new StringBuilder(missing.next().getQName().toString()); while (missing.hasNext()) { requires.append(" " + missing.next().getQName().toString()); } throw RuntimeMessages.MESSAGES.requiredPolicesNeeded(requires.toString()); } } }
PolicyHandler extends BaseHandler { @Override public void handleMessage(Exchange exchange) throws HandlerException { if (ExchangePhase.IN.equals(exchange.getPhase())) { Set<Policy> required = PolicyUtil.getRequired(exchange); Iterator<Policy> reqIt = required.iterator(); while (reqIt.hasNext()) { if (PolicyUtil.isProvided(exchange, reqIt.next())) { reqIt.remove(); } } if (!required.isEmpty()) { Iterator<Policy> missing = required.iterator(); StringBuilder requires = new StringBuilder(missing.next().getQName().toString()); while (missing.hasNext()) { requires.append(" " + missing.next().getQName().toString()); } throw RuntimeMessages.MESSAGES.requiredPolicesNeeded(requires.toString()); } } } }
PolicyHandler extends BaseHandler { @Override public void handleMessage(Exchange exchange) throws HandlerException { if (ExchangePhase.IN.equals(exchange.getPhase())) { Set<Policy> required = PolicyUtil.getRequired(exchange); Iterator<Policy> reqIt = required.iterator(); while (reqIt.hasNext()) { if (PolicyUtil.isProvided(exchange, reqIt.next())) { reqIt.remove(); } } if (!required.isEmpty()) { Iterator<Policy> missing = required.iterator(); StringBuilder requires = new StringBuilder(missing.next().getQName().toString()); while (missing.hasNext()) { requires.append(" " + missing.next().getQName().toString()); } throw RuntimeMessages.MESSAGES.requiredPolicesNeeded(requires.toString()); } } } PolicyHandler(); }
PolicyHandler extends BaseHandler { @Override public void handleMessage(Exchange exchange) throws HandlerException { if (ExchangePhase.IN.equals(exchange.getPhase())) { Set<Policy> required = PolicyUtil.getRequired(exchange); Iterator<Policy> reqIt = required.iterator(); while (reqIt.hasNext()) { if (PolicyUtil.isProvided(exchange, reqIt.next())) { reqIt.remove(); } } if (!required.isEmpty()) { Iterator<Policy> missing = required.iterator(); StringBuilder requires = new StringBuilder(missing.next().getQName().toString()); while (missing.hasNext()) { requires.append(" " + missing.next().getQName().toString()); } throw RuntimeMessages.MESSAGES.requiredPolicesNeeded(requires.toString()); } } } PolicyHandler(); @Override void handleMessage(Exchange exchange); }
PolicyHandler extends BaseHandler { @Override public void handleMessage(Exchange exchange) throws HandlerException { if (ExchangePhase.IN.equals(exchange.getPhase())) { Set<Policy> required = PolicyUtil.getRequired(exchange); Iterator<Policy> reqIt = required.iterator(); while (reqIt.hasNext()) { if (PolicyUtil.isProvided(exchange, reqIt.next())) { reqIt.remove(); } } if (!required.isEmpty()) { Iterator<Policy> missing = required.iterator(); StringBuilder requires = new StringBuilder(missing.next().getQName().toString()); while (missing.hasNext()) { requires.append(" " + missing.next().getQName().toString()); } throw RuntimeMessages.MESSAGES.requiredPolicesNeeded(requires.toString()); } } } PolicyHandler(); @Override void handleMessage(Exchange exchange);  }