Skip to content

Commit 2cf9529

Browse files
Add property test (#368)
* Added a test for fethcing properties from a properties file * Used Hamcrest matchers instead * Move properties file and use classpath * Remove unused variable
1 parent 0b59546 commit 2cf9529

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
Copyright 2017 Ericsson AB.
3+
For a full list of individual contributors, please see the commit history.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
package com.ericsson.ei.handlers.test;
18+
19+
import static org.hamcrest.CoreMatchers.equalTo;
20+
import static org.hamcrest.CoreMatchers.is;
21+
import static org.junit.Assert.assertThat;
22+
23+
import org.junit.Test;
24+
import org.junit.runner.RunWith;
25+
import org.springframework.beans.factory.annotation.Autowired;
26+
import org.springframework.test.context.ContextConfiguration;
27+
import org.springframework.test.context.TestPropertySource;
28+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
29+
30+
import com.ericsson.ei.handlers.RMQProperties;
31+
32+
33+
@ContextConfiguration(classes = RMQProperties.class)
34+
@TestPropertySource(locations = "classpath:RmqHandlerTestValues.properties")
35+
@RunWith(SpringJUnit4ClassRunner.class)
36+
37+
public class RmqPropertiesTest {
38+
39+
private Boolean queueDurable = true;
40+
private String host = "127.0.0.1";
41+
private String exchangeName = "ei-poc-4";
42+
private Integer port = 5672;
43+
private String domainId = "EN1";
44+
private String componentName = "eiffelintelligence";
45+
private String bindingKey = "#";
46+
private String consumerName = "messageConsumer";
47+
private String queueName = "EN1.eiffelintelligence.messageConsumer.durable";
48+
private String waitlistQueueName = "EN1.eiffelintelligence.messageConsumer.durable.waitlist";
49+
50+
@Autowired
51+
private RMQProperties rmqProperties;
52+
53+
@Test
54+
public void getQueueDurableTest() {
55+
assertThat(rmqProperties.getQueueDurable(), is(equalTo(queueDurable)));
56+
}
57+
58+
@Test
59+
public void getHostTest() {
60+
assertThat(rmqProperties.getHost(), is(equalTo(host)));
61+
}
62+
63+
@Test
64+
public void getExchangeNameTest() {
65+
assertThat(rmqProperties.getExchangeName(), is(equalTo(exchangeName)));
66+
}
67+
68+
@Test
69+
public void getPortTest() {
70+
assertThat(rmqProperties.getPort(), is(equalTo(port)));
71+
}
72+
73+
@Test
74+
public void getDomainIdTest() {
75+
assertThat(rmqProperties.getDomainId(), is(equalTo(domainId)));
76+
}
77+
78+
@Test
79+
public void getComponentNameTest() {
80+
assertThat(rmqProperties.getComponentName(), is(equalTo(componentName)));
81+
}
82+
83+
@Test
84+
public void getRoutingKeyTest() {
85+
assertThat(rmqProperties.getBindingKey(), is(equalTo(bindingKey)));
86+
}
87+
88+
@Test
89+
public void getConsumerNameTest() {
90+
assertThat(rmqProperties.getConsumerName(), is(equalTo(consumerName)));
91+
}
92+
93+
@Test
94+
public void getQueueNameTest() {
95+
assertThat(rmqProperties.getQueueName(), is(equalTo(queueName)));
96+
}
97+
98+
@Test
99+
public void getWaitlistQueueNameTest() {
100+
assertThat(rmqProperties.getWaitlistQueueName(), is(equalTo(waitlistQueueName)));
101+
}
102+
103+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
rabbitmq.exchange.name: RmqHandlerTest-exchange
2+
rabbitmq.consumerName: RmqHandlerTest
3+
4+
5+
rabbitmq.exchange.name: ei-poc-4
6+
rabbitmq.domainId: EN1
7+
rabbitmq.componentName: eiffelintelligence
8+
rabbitmq.consumerName: messageConsumer
9+
rabbitmq.queue.durable:true
10+
rabbitmq.host: 127.0.0.1
11+
rabbitmq.port: 5672
12+
rabbitmq.binding.key:#
13+
rabbitmq.waitlist.queue.suffix:waitlist

0 commit comments

Comments
 (0)