Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import static org.mockito.Mockito.when;

@MockitoSettings(strictness = Strictness.LENIENT)
public class SpringLdapProducerTest extends CamelTestSupport {
class SpringLdapProducerTest extends CamelTestSupport {

@Mock
private SpringLdapEndpoint ldapEndpoint;
Expand All @@ -60,7 +60,7 @@ public class SpringLdapProducerTest extends CamelTestSupport {
private SpringLdapProducer ldapProducer;

@Override
public void doPostSetup() {
protected void doPostSetup() {
when(ldapEndpoint.getLdapTemplate()).thenReturn(ldapTemplate);
ldapProducer = new SpringLdapProducer(ldapEndpoint);
}
Expand Down Expand Up @@ -95,16 +95,20 @@ public void testNoDN() throws Exception {
}

@Test
public void testNoDNForFunctionDrivenOperation() throws Exception {
void testNoDNForFunctionDrivenOperation() throws Exception {
Exchange exchange = new DefaultExchange(context);
Message in = new DefaultMessage(context);

@SuppressWarnings("unchecked")
BiFunction<LdapOperations, Object, ?> function = mock(BiFunction.class);

Map<String, Object> body = new HashMap<>();
body.put(SpringLdapProducer.FUNCTION, mock(BiFunction.class));
body.put(SpringLdapProducer.FUNCTION, function);

when(ldapEndpoint.getOperation()).thenReturn(LdapOperation.FUNCTION_DRIVEN);

processBody(exchange, in, body);
verify(function).apply(eq(ldapTemplate), isNull());
}

private void processBody(Exchange exchange, Message message, Map<String, Object> body) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@
*/
package org.apache.camel.component.springrabbit.integration;

import org.apache.camel.Exchange;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.junit.jupiter.api.Test;

public class RabbitMQProducerSimpleIT extends RabbitMQITSupport {
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;

class RabbitMQProducerSimpleIT extends RabbitMQITSupport {

@Test
public void testProducer() throws Exception {
template.sendBody("direct:start", "Hello World");
void testProducer() {
Exchange result = template.send("direct:start", e -> e.getMessage().setBody("Hello World"));
assertFalse(result.isFailed(), "Exchange should complete without error");
assertNull(result.getException(), "Exchange should have no exception");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.apache.camel.attachment.AttachmentMessage;
import org.apache.camel.component.spring.ws.SpringWebserviceConstants;
import org.apache.camel.test.junit6.ExchangeTestSupport;
import org.assertj.core.api.Assertions;
import org.assertj.core.util.Streams;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -32,7 +31,10 @@
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;

public class BasicMessageFilterTest extends ExchangeTestSupport {
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;

class BasicMessageFilterTest extends ExchangeTestSupport {

private BasicMessageFilter filter;
private SoapMessage message;
Expand All @@ -46,23 +48,36 @@ public void before() {
}

@Test
public void testNulls() throws Exception {
filter.filterConsumer(null, null);
filter.filterProducer(null, null);
void testNulls() {
// Verify null-safety: each method should handle null arguments gracefully
assertThatCode(() -> filter.filterConsumer(null, null)).doesNotThrowAnyException();
assertThatCode(() -> filter.filterProducer(null, null)).doesNotThrowAnyException();
}

@Test
public void testNullsWithExchange() throws Exception {
void testNullsWithExchange() {
// capture exchange state before filtering with null message
int headerCountBefore = exchange.getIn().getHeaders().size();
Object bodyBefore = exchange.getIn().getBody();

filter.filterConsumer(exchange, null);
filter.filterProducer(exchange, null);

// verify the exchange was not modified when message is null
assertThat(exchange.getIn().getHeaders()).hasSize(headerCountBefore);
assertThat(exchange.getIn().getBody()).isEqualTo(bodyBefore);
}

@Test
public void nonSoapMessageShouldBeSkipped() throws Exception {
void nonSoapMessageShouldBeSkipped() {
DomPoxMessage domPoxMessage = new DomPoxMessageFactory().createWebServiceMessage();

filter.filterConsumer(exchange, domPoxMessage);
filter.filterProducer(exchange, domPoxMessage);

// verify the exchange headers were not modified for non-SOAP messages
assertThat(exchange.getIn().getHeader("foo")).isEqualTo("abc");
assertThat(exchange.getIn().getHeader("bar")).isEqualTo(123);
}

@Test
Expand All @@ -80,10 +95,10 @@ public void withoutHeader() throws Exception {
filter.filterProducer(exchange, message);
filter.filterConsumer(exchange, message);

Assertions.assertThat(message.getAttachments()).isExhausted();
Assertions.assertThat(message.getSoapHeader().examineAllHeaderElements()).isExhausted();
assertThat(message.getAttachments()).isExhausted();
assertThat(message.getSoapHeader().examineAllHeaderElements()).isExhausted();

Assertions.assertThat(message.getSoapHeader().getAllAttributes()).isExhausted();
assertThat(message.getSoapHeader().getAllAttributes()).isExhausted();
}

@Test
Expand All @@ -102,10 +117,10 @@ public void removeCamelInternalHeaderAttributes() throws Exception {

filter.filterConsumer(exchange, message);

Assertions.assertThat(message.getAttachments()).isExhausted();
Assertions.assertThat(message.getSoapHeader().examineAllHeaderElements()).isExhausted();
assertThat(message.getAttachments()).isExhausted();
assertThat(message.getSoapHeader().examineAllHeaderElements()).isExhausted();

Assertions.assertThat(message.getSoapHeader().getAllAttributes()).isExhausted();
assertThat(message.getSoapHeader().getAllAttributes()).isExhausted();
}

@Test
Expand All @@ -114,12 +129,12 @@ public void consumerWithHeader() throws Exception {
exchange.getOut().getHeaders().put("headerAttributeElement", new QName("http://shouldBeInHeader", "myElement"));
filter.filterConsumer(exchange, message);

Assertions.assertThat(message.getAttachments()).isExhausted();
assertThat(message.getAttachments()).isExhausted();

Assertions.assertThat(Streams.stream(message.getSoapHeader().examineAllHeaderElements()).toList()).isNotEmpty()
assertThat(Streams.stream(message.getSoapHeader().examineAllHeaderElements()).toList()).isNotEmpty()
.hasSize(1);

Assertions.assertThat(Streams.stream(message.getSoapHeader().getAllAttributes()).toList()).isNotEmpty().hasSize(1);
assertThat(Streams.stream(message.getSoapHeader().getAllAttributes()).toList()).isNotEmpty().hasSize(1);

}

Expand All @@ -131,12 +146,12 @@ public void producerWithHeader() throws Exception {

filter.filterProducer(exchange, message);

Assertions.assertThat(message.getAttachments()).isExhausted();
assertThat(message.getAttachments()).isExhausted();

Assertions.assertThat(Streams.stream(message.getSoapHeader().examineAllHeaderElements()).toList()).isNotEmpty()
assertThat(Streams.stream(message.getSoapHeader().examineAllHeaderElements()).toList()).isNotEmpty()
.hasSize(1);

Assertions.assertThat(Streams.stream(message.getSoapHeader().getAllAttributes()).toList()).isNotEmpty().hasSize(2);
assertThat(Streams.stream(message.getSoapHeader().getAllAttributes()).toList()).isNotEmpty().hasSize(2);

}

Expand All @@ -145,7 +160,7 @@ public void withoutAttachment() throws Exception {
filter.filterConsumer(exchange, message);
filter.filterProducer(exchange, message);

Assertions.assertThat(message.getAttachments()).isExhausted();
assertThat(message.getAttachments()).isExhausted();
}

@Test
Expand All @@ -155,8 +170,8 @@ public void producerWithAttachment() throws Exception {

filter.filterProducer(exchange, message);

Assertions.assertThat(Streams.stream(message.getAttachments()).toList()).isNotEmpty();
Assertions.assertThat(message.getAttachment("testAttachment")).isNotNull();
assertThat(Streams.stream(message.getAttachments()).toList()).isNotEmpty();
assertThat(message.getAttachment("testAttachment")).isNotNull();
}

@Test
Expand All @@ -166,7 +181,7 @@ public void consumerWithAttachment() throws Exception {

filter.filterConsumer(exchange, message);

Assertions.assertThat(Streams.stream(message.getAttachments()).toList()).isNotEmpty();
Assertions.assertThat(message.getAttachment("testAttachment")).isNotNull();
assertThat(Streams.stream(message.getAttachments()).toList()).isNotEmpty();
assertThat(message.getAttachment("testAttachment")).isNotNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@
package org.apache.camel.language;

import org.apache.camel.CamelContext;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;

/**
*
*/
public class SpringTokenXMLPairNamespaceSplitTest extends TokenXMLPairNamespaceSplitTest {
class SpringTokenXMLPairNamespaceSplitTest extends TokenXMLPairNamespaceSplitTest {

@Override
protected CamelContext createCamelContext() throws Exception {
return createSpringCamelContext(this, "org/apache/camel/language/SpringTokenXMLPairNamespaceSplitTest.xml");
}

@Disabled("Not applicable for Spring XML variant")
@Override
@Test
public void testTokenXMLPair2() throws Exception {
public void testTokenXMLPair2() {
// noop
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
package org.apache.camel.spring;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import static org.junit.jupiter.api.Assertions.assertNotNull;

public class InjectedBeanTest extends SpringTestSupport {
class InjectedBeanTest extends SpringTestSupport {
protected InjectedBean bean;

@Test
Expand Down Expand Up @@ -56,8 +57,9 @@ public void testInjectionPoints() throws Exception {
"No PollingConsumer injected for getPropertyInjectedPollingConsumer()");
}

@Disabled("Empty test stub — no send/receive logic implemented")
@Test
public void testSendAndReceive() throws Exception {
void testSendAndReceive() {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,12 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class ErrorHandlerCamelContextRefNotFoundTest extends SpringTestSupport {
class ErrorHandlerCamelContextRefNotFoundTest extends SpringTestSupport {

@Override
@BeforeEach
public void setUp() throws Exception {
Exception e = assertThrows(Exception.class, () -> {
super.setUp();
});
FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e);
NoSuchBeanException nsbe = assertIsInstanceOf(NoSuchBeanException.class, cause.getCause());
assertEquals(
"No bean could be found in the registry for: foo of type: org.apache.camel.ErrorHandlerFactory",
nsbe.getMessage());
// Do NOT call super.setUp() — this test validates that context creation fails
}

@Override
Expand All @@ -48,7 +41,14 @@ protected AbstractXmlApplicationContext createApplicationContext() {
}

@Test
public void testDummy() {
// noop
void testErrorHandlerCamelContextRefNotFound() throws Exception {
Exception e = assertThrows(Exception.class, () -> {
super.setUp();
});
FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e);
NoSuchBeanException nsbe = assertIsInstanceOf(NoSuchBeanException.class, cause.getCause());
assertEquals(
"No bean could be found in the registry for: foo of type: org.apache.camel.ErrorHandlerFactory",
nsbe.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,12 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class ErrorHandlerRouteContextRefNotFoundTest extends SpringTestSupport {
class ErrorHandlerRouteContextRefNotFoundTest extends SpringTestSupport {

@Override
@BeforeEach
public void setUp() throws Exception {
Exception e = assertThrows(Exception.class, () -> {
super.setUp();
});
FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e);
NoSuchBeanException nsbe = assertIsInstanceOf(NoSuchBeanException.class, cause.getCause());
assertEquals(
"No bean could be found in the registry for: bar of type: org.apache.camel.ErrorHandlerFactory",
nsbe.getMessage());
// Do NOT call super.setUp() — this test validates that context creation fails
}

@Override
Expand All @@ -48,7 +41,14 @@ protected AbstractXmlApplicationContext createApplicationContext() {
}

@Test
public void testDummy() {
// noop
void testErrorHandlerRouteContextRefNotFound() throws Exception {
Exception e = assertThrows(Exception.class, () -> {
super.setUp();
});
FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e);
NoSuchBeanException nsbe = assertIsInstanceOf(NoSuchBeanException.class, cause.getCause());
assertEquals(
"No bean could be found in the registry for: bar of type: org.apache.camel.ErrorHandlerFactory",
nsbe.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@

import static org.junit.jupiter.api.Assertions.assertThrows;

public class OnExceptionNoExceptionConfiguredTest extends SpringTestSupport {
class OnExceptionNoExceptionConfiguredTest extends SpringTestSupport {

@Override
@BeforeEach
public void setUp() throws Exception {
assertThrows(Exception.class, () -> {
super.setUp();
});
// Do NOT call super.setUp() — this test validates that context creation fails
}

@Override
Expand All @@ -40,7 +38,9 @@ protected AbstractXmlApplicationContext createApplicationContext() {
}

@Test
public void testDummy() {
// noop
void testOnExceptionNoExceptionConfigured() throws Exception {
assertThrows(Exception.class, () -> {
super.setUp();
});
Comment thread
gnodet marked this conversation as resolved.
}
}
Loading