Removed Camel support (#387)

until https://issues.apache.org/jira/browse/CAMEL-11430 gets fixed

fixes #386
This commit is contained in:
Marcin Grzejszczak
2017-09-05 15:14:31 +02:00
committed by GitHub
parent d06af6544f
commit f4ec52d4ac
46 changed files with 17 additions and 1812 deletions

View File

@@ -1,88 +0,0 @@
/*
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.messaging.camel;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.camel.CamelContext;
import org.apache.camel.ConsumerTemplate;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.impl.DefaultExchange;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.contract.verifier.messaging.MessageVerifier;
import org.springframework.stereotype.Component;
/**
* @author Marcin Grzejszczak
*/
@Component
public class CamelStubMessages implements MessageVerifier<Message> {
private static final Logger log = LoggerFactory.getLogger(
CamelStubMessages.class);
private final CamelContext context;
private final ContractVerifierCamelMessageBuilder builder = new ContractVerifierCamelMessageBuilder();
@Autowired
public CamelStubMessages(CamelContext context) {
this.context = context;
}
@Override
public void send(Message message, String destination) {
try {
ProducerTemplate producerTemplate = this.context.createProducerTemplate();
Exchange exchange = new DefaultExchange(this.context);
exchange.setIn(message);
producerTemplate.send(destination, exchange);
} catch (Exception e) {
log.error("Exception occurred while trying to send a message [" + message + "] " +
"to a channel with name [" + destination + "]", e);
throw e;
}
}
@Override
public <T> void send(T payload, Map<String, Object> headers, String destination) {
send(this.builder.create(payload, headers), destination);
}
@Override
public Message receive(String destination, long timeout, TimeUnit timeUnit) {
try {
ConsumerTemplate consumerTemplate = this.context.createConsumerTemplate();
Exchange exchange = consumerTemplate.receive(destination, timeUnit.toMillis(timeout));
return exchange.getIn();
} catch (Exception e) {
log.error("Exception occurred while trying to read a message from " +
" a channel with name [" + destination + "]", e);
throw new IllegalStateException(e);
}
}
@Override
public Message receive(String destination) {
return receive(destination, 5, TimeUnit.SECONDS);
}
}

View File

@@ -1,65 +0,0 @@
/*
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.messaging.camel;
import org.apache.camel.CamelContext;
import org.apache.camel.Message;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.contract.verifier.messaging.MessageVerifier;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging;
import org.springframework.cloud.contract.verifier.messaging.noop.NoOpContractVerifierAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author Marcin Grzejszczak
*/
@Configuration
@ConditionalOnClass(Message.class)
@AutoConfigureBefore(NoOpContractVerifierAutoConfiguration.class)
public class ContractVerifierCamelConfiguration {
@Bean
@ConditionalOnMissingBean
MessageVerifier<Message> contractVerifierMessageExchange(
CamelContext context) {
return new CamelStubMessages(context);
}
@Bean
@ConditionalOnMissingBean
public ContractVerifierMessaging<Message> contractVerifierMessaging(
MessageVerifier<Message> exchange) {
return new ContractVerifierCamelHelper(exchange);
}
}
class ContractVerifierCamelHelper extends ContractVerifierMessaging<Message> {
public ContractVerifierCamelHelper(
MessageVerifier<Message> exchange) {
super(exchange);
}
@Override
protected ContractVerifierMessage convert(Message receive) {
return new ContractVerifierMessage(receive.getBody(), receive.getHeaders());
}
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.messaging.camel;
import java.util.Map;
import org.apache.camel.Message;
import org.apache.camel.impl.DefaultMessage;
/**
* @author Marcin Grzejszczak
*/
class ContractVerifierCamelMessageBuilder {
public <T> Message create(T payload, Map<String, Object> headers) {
DefaultMessage message = new DefaultMessage();
message.setBody(payload);
message.setHeaders(headers);
return message;
}
}

View File

@@ -4,5 +4,4 @@ org.springframework.cloud.contract.verifier.messaging.stream.ContractVerifierStr
org.springframework.cloud.contract.verifier.messaging.integration.ContractVerifierIntegrationConfiguration,\
org.springframework.cloud.contract.verifier.messaging.amqp.ContractVerifierAmqpAutoConfiguration,\
org.springframework.cloud.contract.verifier.messaging.amqp.RabbitMockConnectionFactoryAutoConfiguration,\
org.springframework.cloud.contract.verifier.messaging.camel.ContractVerifierCamelConfiguration,\
org.springframework.cloud.contract.verifier.messaging.noop.NoOpContractVerifierAutoConfiguration