ContextLoadingMappingStrategy implements EndpointAdapterMappingStrategy { @Override public EndpointAdapter getEndpointAdapter(String mappingKey) { Assert.notNull(contextConfigLocation, "Spring bean application context location must be set properly"); ApplicationContext ctx; if (loadOnce) { if (applicationContext == null) { applicationContext = createApplicationContext(); } ctx = applicationContext; } else { ctx = createApplicationContext(); } try { return ctx.getBean(mappingKey, EndpointAdapter.class); } catch (NoSuchBeanDefinitionException e) { throw new CitrusRuntimeException("Unable to find matching endpoint adapter with bean name '" + mappingKey + "' in Spring bean application context", e); } }  @Override EndpointAdapter getEndpointAdapter(String mappingKey); void setContextConfigLocation(String contextConfigLocation);  }
@Test public void testGetEndpointAdapter() throws Exception { ContextLoadingMappingStrategy mappingStrategy = new ContextLoadingMappingStrategy(); mappingStrategy.setContextConfigLocation("classpath:com/consol/citrus/endpoint/adapter-mapping-context.xml"); Assert.assertNotNull(mappingStrategy.getEndpointAdapter("emptyResponseEndpointAdapter")); Assert.assertNotNull(mappingStrategy.getEndpointAdapter("staticResponseEndpointAdapter")); try { mappingStrategy.getEndpointAdapter("Unknown"); Assert.fail("Missing exception due to unknown mapping key"); } catch (CitrusRuntimeException e) { Assert.assertTrue(e.getCause() instanceof NoSuchBeanDefinitionException); } }