diff --git a/pom.xml b/pom.xml index 32aea75..4124838 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ edu.stanford.protege webprotege-ipc - 1.0.2 + 1.0.3 webprotege-ipc Inter Process Communication framework diff --git a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqProperties.java b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqProperties.java new file mode 100644 index 0000000..063ef9f --- /dev/null +++ b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqProperties.java @@ -0,0 +1,54 @@ +package edu.stanford.protege.webprotege.ipc.impl; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * Matthew Horridge + * Stanford Center for Biomedical Informatics Research + * 2024-05-11 + */ +@Component +@ConfigurationProperties(prefix = "webprotege.rabbitmq") +public class RabbitMqProperties { + + private boolean commandsSubscribe; + + private String requestqueue; + + private String responsequeue; + + private long timeout; + + public boolean getCommandsSubscribe() { + return commandsSubscribe; + } + + public void setCommandsSubscribe(boolean commandsSubscribe) { + this.commandsSubscribe = commandsSubscribe; + } + + public String getRequestqueue() { + return requestqueue; + } + + public void setRequestqueue(String requestqueue) { + this.requestqueue = requestqueue; + } + + public String getResponsequeue() { + return responsequeue; + } + + public void setResponsequeue(String responsequeue) { + this.responsequeue = responsequeue; + } + + public long getTimeout() { + return timeout; + } + + public void setTimeout(long timeout) { + this.timeout = timeout; + } +} diff --git a/src/test/java/edu/stanford/protege/webprotege/ipc/RabbitMqPropertiesTest.java b/src/test/java/edu/stanford/protege/webprotege/ipc/RabbitMqPropertiesTest.java new file mode 100644 index 0000000..a5bf66d --- /dev/null +++ b/src/test/java/edu/stanford/protege/webprotege/ipc/RabbitMqPropertiesTest.java @@ -0,0 +1,45 @@ +package edu.stanford.protege.webprotege.ipc; + +import edu.stanford.protege.webprotege.ipc.impl.RabbitMqProperties; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Matthew Horridge + * Stanford Center for Biomedical Informatics Research + * 2024-05-11 + */ +@SpringBootTest(properties = { + "webprotege.rabbitmq.timeout=12345", + "webprotege.rabbitmq.commands-subscribe=false", + "webprotege.rabbitmq.requestqueue=abc", + "webprotege.rabbitmq.responsequeue=def" +}) +public class RabbitMqPropertiesTest { + + @Autowired + private RabbitMqProperties properties; + + @Test + void shouldReadTimeout() { + assertThat(properties.getTimeout()).isEqualTo(12345); + } + + @Test + void shouldReadCommandsSubscribe() { + assertThat(properties.getCommandsSubscribe()).isEqualTo(false); + } + + @Test + void shouldReadRequestQueue() { + assertThat(properties.getRequestqueue()).isEqualTo("abc"); + } + + @Test + void shouldReadResponseQueue() { + assertThat(properties.getResponsequeue()).isEqualTo("def"); + } +}