use of org.apache.camel.impl.DefaultClassResolver in project camel by apache.
the class NettySharedHttpServerTest method createRegistry.
@Override
protected JndiRegistry createRegistry() throws Exception {
nettySharedHttpServer = new DefaultNettySharedHttpServer();
nettySharedHttpServer.setClassResolver(new DefaultClassResolver(context));
NettySharedHttpServerBootstrapConfiguration configuration = new NettySharedHttpServerBootstrapConfiguration();
configuration.setPort(getPort());
configuration.setHost("localhost");
configuration.setBacklog(20);
configuration.setKeepAlive(true);
configuration.setCompression(true);
nettySharedHttpServer.setNettyServerBootstrapConfiguration(configuration);
nettySharedHttpServer.start();
JndiRegistry jndi = super.createRegistry();
jndi.bind("myNettyServer", nettySharedHttpServer);
return jndi;
}
use of org.apache.camel.impl.DefaultClassResolver in project camel by apache.
the class RestSwaggerEndpointTest method shouldComplainForUnknownOperations.
@Test(expected = IllegalArgumentException.class)
public void shouldComplainForUnknownOperations() throws Exception {
final CamelContext camelContext = mock(CamelContext.class);
when(camelContext.getClassResolver()).thenReturn(new DefaultClassResolver());
final RestSwaggerComponent component = new RestSwaggerComponent(camelContext);
final RestSwaggerEndpoint endpoint = new RestSwaggerEndpoint("rest-swagger:unknown", "unknown", component);
endpoint.createProducer();
}
use of org.apache.camel.impl.DefaultClassResolver in project camel by apache.
the class RestSwaggerEndpointTest method shouldCreateProducers.
@Test
public void shouldCreateProducers() throws Exception {
final CamelContext camelContext = mock(CamelContext.class);
when(camelContext.getClassResolver()).thenReturn(new DefaultClassResolver());
final Endpoint endpointDelegate = mock(Endpoint.class);
when(camelContext.getEndpoint("rest:GET:/v2:/pet/{petId}")).thenReturn(endpointDelegate);
final Producer delegateProducer = mock(Producer.class);
when(endpointDelegate.createProducer()).thenReturn(delegateProducer);
final RestSwaggerComponent component = new RestSwaggerComponent(camelContext);
component.setHost("http://petstore.swagger.io");
final RestSwaggerEndpoint endpoint = new RestSwaggerEndpoint("rest-swagger:getPetById", "getPetById", component);
final Producer producer = endpoint.createProducer();
assertThat(producer).isSameAs(delegateProducer);
}
use of org.apache.camel.impl.DefaultClassResolver in project camel by apache.
the class RestSwaggerEndpointTest method shouldLoadSwaggerSpecifications.
@Test
public void shouldLoadSwaggerSpecifications() throws IOException {
final CamelContext camelContext = mock(CamelContext.class);
when(camelContext.getClassResolver()).thenReturn(new DefaultClassResolver());
assertThat(RestSwaggerEndpoint.loadSpecificationFrom(camelContext, RestSwaggerComponent.DEFAULT_SPECIFICATION_URI)).isNotNull();
}
use of org.apache.camel.impl.DefaultClassResolver in project camel by apache.
the class RestSwaggerReaderApiDocsOverrideTest method testReaderRead.
@Test
public void testReaderRead() throws Exception {
BeanConfig config = new BeanConfig();
config.setHost("localhost:8080");
config.setSchemes(new String[] { "http" });
config.setBasePath("/api");
RestSwaggerReader reader = new RestSwaggerReader();
Swagger swagger = reader.read(context.getRestDefinitions(), null, config, context.getName(), new DefaultClassResolver());
assertNotNull(swagger);
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(swagger);
log.info(json);
assertFalse(json.contains("\"/hello/bye\""));
assertFalse(json.contains("\"summary\" : \"To update the greeting message\""));
assertTrue(json.contains("\"/hello/bye/{name}\""));
assertFalse(json.contains("\"/hello/hi/{name}\""));
context.stop();
}
Aggregations