mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-1252 : Add tests for the JMS/ActiveMQ/Camel configuration in *alfresco-community-repo* (#356)
- fix messaging context for tests by adding missing mocked beans and properties - add tests for amqp, jms, activemq protocols - add travis job to run messaging tests
This commit is contained in:
@@ -177,6 +177,11 @@ jobs:
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - Messaging tests"
|
||||
before_script:
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=CamelRoutesTest,CamelComponentsTest
|
||||
|
||||
- name: "Remote-api - AppContext01TestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
|
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2018 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.messaging.camel;
|
||||
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.Produce;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests Camel components defined in the application's Spring context
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/test-messaging-context.xml")
|
||||
public class CamelComponentsTest {
|
||||
@Autowired
|
||||
protected CamelContext camelContext;
|
||||
|
||||
@Produce("activemq:queue:alfresco.test")
|
||||
protected ProducerTemplate activemqTemplate;
|
||||
|
||||
@Produce("amqp:queue:alfresco.test")
|
||||
protected ProducerTemplate amqpTemplate;
|
||||
|
||||
@Produce("jms:queue:alfresco.test")
|
||||
protected ProducerTemplate jmsTemplate;
|
||||
|
||||
|
||||
@Test
|
||||
public void testActivemqComponent()
|
||||
{
|
||||
final String msg = "ping <activemq>";
|
||||
|
||||
activemqTemplate.sendBody(msg);
|
||||
|
||||
final Object reply = camelContext
|
||||
.createConsumerTemplate()
|
||||
.receiveBody("activemq:queue:alfresco.test", 2000);
|
||||
|
||||
assertEquals(msg, reply);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAmqpComponent()
|
||||
{
|
||||
final String msg = "ping <amqp>";
|
||||
|
||||
amqpTemplate.sendBody(msg);
|
||||
|
||||
final Object reply = camelContext
|
||||
.createConsumerTemplate()
|
||||
.receiveBody("amqp:queue:alfresco.test", 2000);
|
||||
|
||||
assertEquals(msg, reply);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJmsComponent()
|
||||
{
|
||||
final String msg = "ping <jms>";
|
||||
|
||||
jmsTemplate.sendBody(msg);
|
||||
|
||||
final Object reply = camelContext
|
||||
.createConsumerTemplate()
|
||||
.receiveBody("jms:queue:alfresco.test", 2000);
|
||||
|
||||
assertEquals(msg, reply);
|
||||
}
|
||||
}
|
@@ -25,4 +25,19 @@
|
||||
<property name="routeContextId" value="customRoutes" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactionAwareEventProducer" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.alfresco.repo.rawevents.TransactionAwareEventProducer" />
|
||||
</bean>
|
||||
|
||||
<bean id="policyComponent" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.alfresco.repo.policy.PolicyComponentImpl"/>
|
||||
</bean>
|
||||
|
||||
<bean id="renditionEventProcessor" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.alfresco.repo.rendition2.RenditionEventProcessor"/>
|
||||
</bean>
|
||||
|
||||
<bean id="transformRequestProcessor" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.alfresco.repo.rendition2.TransformRequestProcessor" />
|
||||
</bean>
|
||||
</beans>
|
@@ -1,6 +1,9 @@
|
||||
messaging.broker.url=vm://localhost?broker.persistent=false
|
||||
messaging.broker.url=nio://localhost:61616
|
||||
messaging.broker.ssl=false
|
||||
messaging.broker.connections.max=8
|
||||
messaging.transacted=true
|
||||
messaging.broker.username=
|
||||
messaging.broker.password=
|
||||
|
||||
acs.repo.rendition.events.endpoint=jms:acs-repo-rendition-events-test?jmsMessageType=Text
|
||||
acs.repo.transform.request.endpoint=jms:acs-repo-transform-request-test?jmsMessageType=Text
|
Reference in New Issue
Block a user