configAttributes) {
19 | final EnableNatsServer enableNatsServer = AnnotatedElementUtils.findMergedAnnotation(testClass, EnableNatsServer.class);
20 | return new EnableNatsServerContextCustomizer(enableNatsServer);
21 | }
22 |
23 | }
--------------------------------------------------------------------------------
/src/test/java/berlin/yuna/natsserver/embedded/logic/NatsServerWithPortComponentTest.java:
--------------------------------------------------------------------------------
1 | package berlin.yuna.natsserver.embedded.logic;
2 |
3 | import berlin.yuna.natsserver.embedded.annotation.EnableNatsServer;
4 | import org.junit.jupiter.api.DisplayName;
5 | import org.junit.jupiter.api.Tag;
6 | import org.junit.jupiter.api.Test;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 |
10 | import java.io.IOException;
11 | import java.net.Socket;
12 |
13 | import static org.hamcrest.CoreMatchers.is;
14 | import static org.hamcrest.CoreMatchers.notNullValue;
15 | import static org.hamcrest.MatcherAssert.assertThat;
16 |
17 | @SpringBootTest
18 | @Tag("IntegrationTest")
19 | @EnableNatsServer(port = 4234)
20 | @DisplayName("NatsServer AutoConfig port test")
21 | class NatsServerWithPortComponentTest {
22 |
23 | @Autowired
24 | private NatsServer natsServer;
25 |
26 | @Test
27 | @DisplayName("Accept custom port")
28 | void natsServer_withCustomPort_shouldStartWithCustomPort() throws IOException {
29 | new Socket("localhost", 4234).close();
30 | assertThat(natsServer, is(notNullValue()));
31 | assertThat(natsServer.port(), is(4234));
32 | natsServer.close();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/berlin/yuna/natsserver/embedded/helper/VersionTextUpdaterTest.java:
--------------------------------------------------------------------------------
1 | package berlin.yuna.natsserver.embedded.helper;
2 |
3 | import com.vdurmont.semver4j.Semver;
4 | import org.junit.jupiter.api.Tag;
5 | import org.junit.jupiter.api.Test;
6 |
7 | import java.io.IOException;
8 | import java.nio.file.Files;
9 | import java.nio.file.Path;
10 | import java.nio.file.Paths;
11 |
12 | import static berlin.yuna.natsserver.config.NatsConfig.NATS_VERSION;
13 |
14 | @Tag("UnitTest")
15 | class VersionTextUpdaterTest {
16 |
17 | @Test
18 | void updateVersionTxtTest() throws IOException {
19 | final Path versionFile = Paths.get(System.getProperty("user.dir"), "version.txt");
20 | final Semver versionText = semverOf(readFile(versionFile).trim());
21 | final Semver natsVersion = semverOf(NATS_VERSION.defaultValueStr());
22 | if (natsVersion.compareTo(versionText) > 0) {
23 | Files.write(versionFile, natsVersion.getOriginalValue().getBytes());
24 | }
25 | }
26 |
27 | private static Semver semverOf(final String semver) {
28 | return new Semver(semver.startsWith("v") ? semver.substring(1) : semver);
29 | }
30 |
31 | private static String readFile(final Path versionFile) {
32 | try {
33 | return "v" + new String(Files.readAllBytes(versionFile));
34 | } catch (IOException e) {
35 | return "";
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/java/berlin/yuna/natsserver/embedded/logic/NatsServerOverwritePortComponentTest.java:
--------------------------------------------------------------------------------
1 | package berlin.yuna.natsserver.embedded.logic;
2 |
3 | import berlin.yuna.natsserver.embedded.annotation.EnableNatsServer;
4 | import berlin.yuna.natsserver.logic.NatsUtils;
5 | import org.junit.jupiter.api.DisplayName;
6 | import org.junit.jupiter.api.Tag;
7 | import org.junit.jupiter.api.Test;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.boot.test.context.SpringBootTest;
10 |
11 | import static org.hamcrest.CoreMatchers.is;
12 | import static org.hamcrest.CoreMatchers.notNullValue;
13 | import static org.hamcrest.MatcherAssert.assertThat;
14 | import static org.hamcrest.Matchers.greaterThan;
15 |
16 | @SpringBootTest
17 | @Tag("IntegrationTest")
18 | @EnableNatsServer(port = 4247, config = {"port", "4246"})
19 | @DisplayName("NatsServer overwrite AutoConfig port test")
20 | class NatsServerOverwritePortComponentTest {
21 |
22 | @Autowired
23 | private NatsServer natsServer;
24 |
25 | @Test
26 | @DisplayName("Custom port overwritten by map")
27 | void natsServer_customPorts_shouldOverwritePortMap() {
28 | NatsUtils.waitForPort(4246, 5000, false);
29 | assertThat(natsServer, is(notNullValue()));
30 | assertThat(natsServer.port(), is(4246));
31 | assertThat(natsServer.pid(), is(greaterThan(-1)));
32 | natsServer.close();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/berlin/yuna/natsserver/embedded/logic/NatsServerWithPortMapComponentTest.java:
--------------------------------------------------------------------------------
1 | package berlin.yuna.natsserver.embedded.logic;
2 |
3 | import berlin.yuna.natsserver.embedded.annotation.EnableNatsServer;
4 | import berlin.yuna.natsserver.logic.NatsUtils;
5 | import org.junit.jupiter.api.DisplayName;
6 | import org.junit.jupiter.api.Tag;
7 | import org.junit.jupiter.api.Test;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.boot.test.context.SpringBootTest;
10 |
11 | import static org.hamcrest.CoreMatchers.is;
12 | import static org.hamcrest.CoreMatchers.notNullValue;
13 | import static org.hamcrest.MatcherAssert.assertThat;
14 | import static org.hamcrest.Matchers.greaterThan;
15 |
16 | @SpringBootTest
17 | @Tag("IntegrationTest")
18 | @EnableNatsServer(port = 4227 ,config = {"port", "4235"})
19 | @DisplayName("NatsServer AutoConfig port from map test")
20 | class NatsServerWithPortMapComponentTest {
21 |
22 | @Autowired
23 | private NatsServer natsServer;
24 |
25 | @Test
26 | @DisplayName("Overwrite port on config map")
27 | void natsServer_withCustomPortInMap_shouldStartWithCustomPort() {
28 | NatsUtils.waitForPort(4235, 5000, false);
29 | assertThat(natsServer, is(notNullValue()));
30 | assertThat(natsServer.port(), is(4235));
31 | assertThat(natsServer.pid(), is(greaterThan(-1)));
32 | natsServer.close();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/berlin/yuna/natsserver/embedded/logic/NatsServerComponentRandomPortTest.java:
--------------------------------------------------------------------------------
1 | package berlin.yuna.natsserver.embedded.logic;
2 |
3 | import berlin.yuna.natsserver.embedded.annotation.EnableNatsServer;
4 | import org.junit.jupiter.api.DisplayName;
5 | import org.junit.jupiter.api.Tag;
6 | import org.junit.jupiter.api.Test;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 |
10 | import java.io.IOException;
11 | import java.nio.file.Files;
12 |
13 | import static berlin.yuna.natsserver.config.NatsConfig.PORT;
14 | import static org.hamcrest.CoreMatchers.is;
15 | import static org.hamcrest.CoreMatchers.notNullValue;
16 | import static org.hamcrest.MatcherAssert.assertThat;
17 | import static org.hamcrest.Matchers.greaterThan;
18 |
19 | @SpringBootTest
20 | @EnableNatsServer(port = -1, timeoutMs = 5000)
21 | @Tag("IntegrationTest")
22 | @DisplayName("NatsServerRandomPortComponentTestTest")
23 | class NatsServerComponentRandomPortTest {
24 |
25 | @Autowired
26 | private NatsServer natsServer;
27 |
28 | @Test
29 | @DisplayName("Download and start server")
30 | void natsServer_shouldDownloadUnzipAndStart() throws IOException {
31 | Files.deleteIfExists(natsServer.binary());
32 | assertThat(natsServer, is(notNullValue()));
33 | System.out.println("Port: " + natsServer.port());
34 | assertThat(natsServer.port(), is(greaterThan(((int) PORT.defaultValue()))));
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/java/berlin/yuna/natsserver/embedded/util/ConfigMetadataIntegrationTest.java:
--------------------------------------------------------------------------------
1 | package berlin.yuna.natsserver.embedded.util;
2 |
3 |
4 | import berlin.yuna.configmetadata.model.ConfigurationMetadata;
5 | import berlin.yuna.natsserver.config.NatsConfig;
6 | import org.junit.jupiter.api.DisplayName;
7 | import org.junit.jupiter.api.Tag;
8 | import org.junit.jupiter.api.Test;
9 |
10 | import java.io.IOException;
11 | import java.nio.file.Path;
12 |
13 | import static org.hamcrest.CoreMatchers.is;
14 | import static org.hamcrest.CoreMatchers.notNullValue;
15 | import static org.hamcrest.MatcherAssert.assertThat;
16 |
17 | @Tag("UnitTest")
18 | class ConfigMetadataIntegrationTest {
19 |
20 | @Test
21 | @DisplayName("Generate spring boot autocompletion")
22 | void generate() throws IOException {
23 | final ConfigurationMetadata metadata = new ConfigurationMetadata("nats.server", NatsConfig.class);
24 | for (NatsConfig config : NatsConfig.values()) {
25 | final String name = config.name().toLowerCase();
26 | final String desc = config.description();
27 | final Class> type = config.type();
28 | final Object defaultValue = config.defaultValue();
29 | metadata.newProperties().name(name).description(desc).type(type == NatsConfig.SilentBoolean.class ? Boolean.class : type).defaultValue(defaultValue);
30 | }
31 |
32 | final Path generated = metadata.generate();
33 | assertThat(generated, is(notNullValue()));
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/berlin/yuna/natsserver/embedded/annotation/EnableNatsServerContextCustomizerTest.java:
--------------------------------------------------------------------------------
1 | package berlin.yuna.natsserver.embedded.annotation;
2 |
3 | import berlin.yuna.natsserver.config.NatsConfig;
4 | import berlin.yuna.natsserver.embedded.logic.NatsServer;
5 | import org.junit.jupiter.api.DisplayName;
6 | import org.junit.jupiter.api.Tag;
7 | import org.junit.jupiter.api.Test;
8 | import org.springframework.beans.factory.NoSuchBeanDefinitionException;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.boot.test.context.SpringBootTest;
11 | import org.springframework.context.ConfigurableApplicationContext;
12 |
13 | import static org.junit.jupiter.api.Assertions.assertThrows;
14 | import static org.mockito.Mockito.mock;
15 | import static org.mockito.Mockito.when;
16 |
17 | @SpringBootTest
18 | @Tag("IntegrationTest")
19 | @DisplayName("ContextCustomizerTest")
20 | class EnableNatsServerContextCustomizerTest {
21 |
22 | @Autowired
23 | private ConfigurableApplicationContext context;
24 |
25 | @Test
26 | @DisplayName("with invalid port [FAIL]")
27 | void runCustomizer_withInvalidPort_shouldNotStartNatsServer() {
28 | final EnableNatsServer enableNatsServer = mock(EnableNatsServer.class);
29 | when(enableNatsServer.config()).thenReturn(new String[]{NatsConfig.PORT.name(), "invalidPortValue"});
30 | assertThrows(
31 | NoSuchBeanDefinitionException.class,
32 | () -> context.getBean(NatsServer.class),
33 | "No qualifying bean of type"
34 | );
35 | }
36 | }
--------------------------------------------------------------------------------
/src/main/java/berlin/yuna/natsserver/embedded/annotation/EnableNatsServer.java:
--------------------------------------------------------------------------------
1 | package berlin.yuna.natsserver.embedded.annotation;
2 |
3 | import berlin.yuna.natsserver.embedded.logic.NatsServer;
4 |
5 | import java.lang.annotation.Documented;
6 | import java.lang.annotation.Inherited;
7 | import java.lang.annotation.Retention;
8 | import java.lang.annotation.Target;
9 |
10 | import static java.lang.annotation.ElementType.TYPE;
11 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
12 |
13 | /**
14 | * Annotation that can be specified on a test class that runs Nats based tests.
15 | * Provides the following features over and above the regular Spring {@link org.springframework.test.context.TestContext}
16 | * Framework:
17 | *
18 | * - Registers a {@link NatsServer} bean with the {@link NatsServer} bean name.
19 | *
20 | *
21 | *
22 | * The typical usage of this annotation is like:
23 | *
24 | * @{@link org.springframework.boot.test.context.SpringBootTest}
25 | * @{@link EnableNatsServer}
26 | * public class MyNatsTests {
27 | *
28 | * @{@link org.springframework.beans.factory.annotation.Autowired}
29 | * private {@link NatsServer} natsServer;
30 | *
31 | * }
32 | *
33 | */
34 | @Retention(RUNTIME)
35 | @Target(TYPE)
36 | @Documented
37 | @Inherited
38 | public @interface EnableNatsServer {
39 |
40 | /**
41 | * Sets nats port
42 | * -1 means random port
43 | */
44 | int port() default 4222;
45 |
46 | /**
47 | * Defines the startup and teardown timeout
48 | */
49 | long timeoutMs() default 10000;
50 |
51 | /**
52 | * Config file
53 | */
54 | String configFile() default "";
55 |
56 | /**
57 | * Custom download URL
58 | */
59 | String downloadUrl() default "";
60 |
61 | /**
62 | * File to nats server binary so no download will be needed
63 | */
64 | String binaryFile() default "";
65 |
66 | /**
67 | * Passes the original parameters to {@link NatsServer#config(String...)} for startup
68 | * {@link berlin.yuna.natsserver.config.NatsConfig}
69 | */
70 | String[] config() default {};
71 |
72 | /**
73 | * Sets the version for the {@link NatsServer}
74 | */
75 | String version() default "";
76 | }
77 |
--------------------------------------------------------------------------------
/src/test/java/berlin/yuna/natsserver/embedded/annotation/NatsServerComponentRandomPortTest.java:
--------------------------------------------------------------------------------
1 | package berlin.yuna.natsserver.embedded.annotation;
2 |
3 | import berlin.yuna.natsserver.embedded.model.exception.NatsStartException;
4 | import org.junit.jupiter.api.BeforeEach;
5 | import org.junit.jupiter.api.DisplayName;
6 | import org.junit.jupiter.api.Tag;
7 | import org.junit.jupiter.api.Test;
8 | import org.springframework.context.annotation.AnnotationConfigApplicationContext;
9 | import org.springframework.core.env.MapPropertySource;
10 | import org.springframework.core.env.MutablePropertySources;
11 | import org.springframework.test.context.MergedContextConfiguration;
12 |
13 | import java.util.HashMap;
14 | import java.util.Map;
15 |
16 | import static berlin.yuna.natsserver.config.NatsConfig.PROFILE;
17 | import static org.junit.jupiter.api.Assertions.assertThrows;
18 | import static org.mockito.Mockito.mock;
19 | import static org.mockito.Mockito.when;
20 |
21 | @Tag("UnitTest")
22 | @DisplayName("Configuration unit test")
23 | class NatsServerComponentRandomPortTest {
24 |
25 | private EnableNatsServer annotation;
26 | private AnnotationConfigApplicationContext ctx;
27 | private MergedContextConfiguration mCtx;
28 | private EnableNatsServerContextCustomizer contextCustomizer;
29 |
30 |
31 | @BeforeEach
32 | void setUp() {
33 | ctx = new AnnotationConfigApplicationContext();
34 | mCtx = mock(MergedContextConfiguration.class);
35 | annotation = mock(EnableNatsServer.class);
36 | when(annotation.port()).thenReturn(4222);
37 | when(annotation.timeoutMs()).thenReturn(512L);
38 | contextCustomizer = new EnableNatsServerContextCustomizer(annotation);
39 | final MutablePropertySources propertySources = ctx.getEnvironment().getPropertySources();
40 | final Map map = new HashMap<>();
41 | map.put("nats.server.nats_log_name", "NatsTest");
42 | propertySources.addFirst(new MapPropertySource("nats.server.nats_log_name", map));
43 | }
44 |
45 | @Test
46 | @DisplayName("Configure with invalid config value [FAIL]")
47 | void natsServer_withInvalidConfigValue_shouldFailToStart() {
48 | when(annotation.config()).thenReturn(new String[]{PROFILE.name(), "invalid"});
49 | when(annotation.configFile()).thenReturn("invalid/path");
50 | assertThrows(NatsStartException.class, () -> contextCustomizer.customizeContext(ctx, mCtx));
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/java/berlin/yuna/natsserver/embedded/logic/NatsServerComponentTest.java:
--------------------------------------------------------------------------------
1 | package berlin.yuna.natsserver.embedded.logic;
2 |
3 | import berlin.yuna.natsserver.embedded.annotation.EnableNatsServer;
4 | import org.junit.jupiter.api.DisplayName;
5 | import org.junit.jupiter.api.Tag;
6 | import org.junit.jupiter.api.Test;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 |
10 | import java.io.IOException;
11 | import java.net.Socket;
12 | import java.nio.file.Files;
13 |
14 | import static berlin.yuna.natsserver.config.NatsOptions.natsBuilder;
15 | import static org.hamcrest.CoreMatchers.containsString;
16 | import static org.hamcrest.CoreMatchers.is;
17 | import static org.hamcrest.CoreMatchers.notNullValue;
18 | import static org.hamcrest.MatcherAssert.assertThat;
19 | import static org.hamcrest.Matchers.greaterThan;
20 | import static org.junit.jupiter.api.Assertions.assertThrows;
21 |
22 | @SpringBootTest
23 | @EnableNatsServer
24 | @Tag("IntegrationTest")
25 | @DisplayName("NatsServerComponentTest")
26 | class NatsServerComponentTest {
27 |
28 | @Autowired
29 | private NatsServer natsServer;
30 |
31 | @Test
32 | @DisplayName("Download and start server")
33 | void natsServer_shouldDownloadUnzipAndStart() throws IOException {
34 | Files.deleteIfExists(natsServer.binary());
35 | assertThat(natsServer, is(notNullValue()));
36 | assertThat(natsServer.port(), is(4222));
37 | assertThat(natsServer.pid(), is(greaterThan(-1)));
38 | }
39 |
40 | @Test
41 | @DisplayName("Port config with double dash")
42 | void secondNatsServer_withDoubleDotSeparatedProperty_shouldStartSuccessful() {
43 | assertNatsServerStart(4225, "--port", "4225");
44 | }
45 |
46 | @Test
47 | @DisplayName("Port config without dashes")
48 | void secondNatsServer_withOutMinusProperty_shouldStartSuccessful() {
49 | assertNatsServerStart(4226, "port", "4226");
50 | }
51 |
52 | @Test
53 | @DisplayName("Invalid config [FAIL]")
54 | void secondNatsServer_withInvalidProperty_shouldFailToStart() {
55 | assertThrows(
56 | IllegalArgumentException.class,
57 | () -> assertNatsServerStart(4228, "p", "4228"),
58 | "No enum constant"
59 | );
60 | }
61 |
62 | @Test
63 | @DisplayName("ToString")
64 | void toString_shouldPrintPortAndOs() {
65 | final String serverString = natsServer.toString();
66 | assertThat(serverString, containsString("4222"));
67 | }
68 |
69 | private void assertNatsServerStart(final int port, final String... config) {
70 | try (final NatsServer natsServer = new NatsServer(natsBuilder().timeoutMs(10000).config(config).build())) {
71 | new Socket("localhost", port).close();
72 | } catch (Exception e) {
73 | throw new IllegalArgumentException(e);
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # nats-server-embedded
4 |
5 | [](https://github.com/sponsors/YunaBraska)
6 |
7 | Nats Server for testing which contains the original [Nats server](https://github.com/nats-io/nats-server)
8 |
9 | [![Build][build_shield]][build_link]
10 | [![Maintainable][maintainable_shield]][maintainable_link]
11 | [![Coverage][coverage_shield]][coverage_link]
12 | [![Issues][issues_shield]][issues_link]
13 | [![Commit][commit_shield]][commit_link]
14 | [![Dependencies][dependency_shield]][dependency_link]
15 | [![License][license_shield]][license_link]
16 | [![Central][central_shield]][central_link]
17 | [![Tag][tag_shield]][tag_link]
18 | [![Javadoc][javadoc_shield]][javadoc_link]
19 | [![Size][size_shield]][size_shield]
20 | ![Label][label_shield]
21 | ![Label][spring_boot_3]
22 |
23 | [build_shield]: https://github.com/YunaBraska/nats-server-embedded/workflows/Daily/badge.svg
24 | [build_link]: https://github.com/YunaBraska/nats-server-embedded/actions?query=workflow%3ADaily
25 | [maintainable_shield]: https://img.shields.io/codeclimate/maintainability/YunaBraska/nats-server-embedded?style=flat-square
26 | [maintainable_link]: https://codeclimate.com/github/YunaBraska/nats-server-embedded/maintainability
27 | [coverage_shield]: https://img.shields.io/codeclimate/coverage/YunaBraska/nats-server-embedded?style=flat-square
28 | [coverage_link]: https://codeclimate.com/github/YunaBraska/nats-server-embedded/test_coverage
29 | [issues_shield]: https://img.shields.io/github/issues/YunaBraska/nats-server-embedded?style=flat-square
30 | [issues_link]: https://github.com/YunaBraska/nats-server-embedded/commits/main
31 | [commit_shield]: https://img.shields.io/github/last-commit/YunaBraska/nats-server-embedded?style=flat-square
32 | [commit_link]: https://github.com/YunaBraska/nats-server-embedded/issues
33 | [license_shield]: https://img.shields.io/github/license/YunaBraska/nats-server-embedded?style=flat-square
34 | [license_link]: https://github.com/YunaBraska/nats-server-embedded/blob/main/LICENSE
35 | [dependency_shield]: https://img.shields.io/librariesio/github/YunaBraska/nats-server-embedded?style=flat-square
36 | [dependency_link]: https://libraries.io/github/YunaBraska/nats-server-embedded
37 | [central_shield]: https://img.shields.io/maven-central/v/berlin.yuna/nats-server-embedded?style=flat-square
38 | [central_link]:https://search.maven.org/artifact/berlin.yuna/nats-server-embedded
39 | [tag_shield]: https://img.shields.io/github/v/tag/YunaBraska/nats-server-embedded?style=flat-square
40 | [tag_link]: https://github.com/YunaBraska/nats-server-embedded/releases
41 | [javadoc_shield]: https://javadoc.io/badge2/berlin.yuna/nats-server-embedded/javadoc.svg?style=flat-square
42 | [javadoc_link]: https://javadoc.io/doc/berlin.yuna/nats-server-embedded
43 | [size_shield]: https://img.shields.io/github/repo-size/YunaBraska/nats-server-embedded?style=flat-square
44 | [label_shield]: https://img.shields.io/badge/Yuna-QueenInside-blueviolet?style=flat-square
45 | [gitter_shield]: https://img.shields.io/gitter/room/YunaBraska/nats-server-embedded?style=flat-square
46 | [gitter_link]: https://gitter.im/nats-server-embedded/Lobby
47 | [spring_boot_3]: https://img.shields.io/badge/SpringBoot-2-blueviolet?style=flat-square
48 |
49 | For more, have a look to the [Documentation (GitHubPage)](https://yunabraska.github.io/nats-server/) *(You will find Examples, Configs, Spring, Junit, etc.)*
50 |
--------------------------------------------------------------------------------
/src/main/java/berlin/yuna/natsserver/embedded/annotation/EnableNatsServerContextCustomizer.java:
--------------------------------------------------------------------------------
1 | package berlin.yuna.natsserver.embedded.annotation;
2 |
3 | import berlin.yuna.natsserver.config.NatsConfig;
4 | import berlin.yuna.natsserver.config.NatsOptionsBuilder;
5 | import berlin.yuna.natsserver.embedded.logic.NatsServer;
6 | import berlin.yuna.natsserver.embedded.model.exception.NatsStartException;
7 | import org.slf4j.Logger;
8 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
9 | import org.springframework.beans.factory.support.DefaultSingletonBeanRegistry;
10 | import org.springframework.context.ConfigurableApplicationContext;
11 | import org.springframework.core.env.ConfigurableEnvironment;
12 | import org.springframework.test.context.ContextCustomizer;
13 | import org.springframework.test.context.MergedContextConfiguration;
14 | import org.springframework.util.Assert;
15 |
16 | import static berlin.yuna.natsserver.config.NatsConfig.NATS_BINARY_PATH;
17 | import static berlin.yuna.natsserver.config.NatsConfig.NATS_DOWNLOAD_URL;
18 | import static berlin.yuna.natsserver.config.NatsConfig.NATS_PROPERTY_FILE;
19 | import static berlin.yuna.natsserver.config.NatsConfig.PORT;
20 | import static berlin.yuna.natsserver.config.NatsOptions.natsBuilder;
21 | import static berlin.yuna.natsserver.embedded.logic.NatsServer.BEAN_NAME;
22 | import static berlin.yuna.natsserver.logic.NatsUtils.isNotEmpty;
23 | import static java.util.Optional.ofNullable;
24 | import static org.slf4j.LoggerFactory.getLogger;
25 | import static org.springframework.util.StringUtils.hasText;
26 |
27 | class EnableNatsServerContextCustomizer implements ContextCustomizer {
28 |
29 | private final EnableNatsServer enableNatsServer;
30 | private static final Logger LOG = getLogger(EnableNatsServerContextCustomizer.class);
31 |
32 | /**
33 | * Sets the source with parameter {@link EnableNatsServer} {@link EnableNatsServerContextCustomizer#customizeContext(ConfigurableApplicationContext, MergedContextConfiguration)}
34 | *
35 | * @param enableNatsServer {@link EnableNatsServer} annotation class
36 | */
37 | EnableNatsServerContextCustomizer(final EnableNatsServer enableNatsServer) {
38 | this.enableNatsServer = enableNatsServer;
39 | }
40 |
41 | /**
42 | * customizeContext will start register {@link NatsServer} with bean name {@link NatsServer#BEAN_NAME} to the spring test context
43 | *
44 | * @param context {@link ConfigurableApplicationContext}
45 | * @param mergedConfig {@link MergedContextConfiguration} is not in use
46 | */
47 | @Override
48 | public void customizeContext(final ConfigurableApplicationContext context, final MergedContextConfiguration mergedConfig) {
49 | final ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
50 | Assert.isInstanceOf(DefaultSingletonBeanRegistry.class, beanFactory);
51 | final ConfigurableEnvironment environment = context.getEnvironment();
52 |
53 | if (enableNatsServer == null) {
54 | LOG.debug("Skipping [{}] cause its not defined", EnableNatsServer.class.getSimpleName());
55 | return;
56 | }
57 |
58 | NatsServer natsServer = null;
59 | final NatsOptionsBuilder options = natsBuilder().timeoutMs(enableNatsServer.timeoutMs());
60 | setEnvConfig(options, environment);
61 | if (enableNatsServer.port() != (Integer) PORT.defaultValue()) {
62 | options.port(enableNatsServer.port());
63 | }
64 | options.config(enableNatsServer.config()).version(isNotEmpty(enableNatsServer.version()) ? enableNatsServer.version() : options.version());
65 | configure(options, NATS_PROPERTY_FILE, enableNatsServer.configFile());
66 | configure(options, NATS_BINARY_PATH, enableNatsServer.binaryFile());
67 | configure(options, NATS_DOWNLOAD_URL, enableNatsServer.downloadUrl());
68 |
69 | try {
70 | natsServer = new NatsServer(options.build());
71 | } catch (Exception e) {
72 | ofNullable(natsServer).ifPresent(NatsServer::close);
73 | throw new NatsStartException(
74 | "Failed to initialise"
75 | + " name [" + EnableNatsServer.class.getSimpleName() + "]"
76 | + " port [" + options.port() + "]"
77 | + " timeoutMs [" + options.timeoutMs() + "]"
78 | + " logLevel [" + options.logLevel() + "]"
79 | + " jetStream [" + options.jetStream() + "]"
80 | + " autostart [" + options.autostart() + "]"
81 | + " configFile [" + options.configFile() + "]"
82 | + " downloadUrl [" + options.configMap().get(NATS_DOWNLOAD_URL) + "]"
83 | , e
84 | );
85 | }
86 |
87 | beanFactory.initializeBean(natsServer, BEAN_NAME);
88 | beanFactory.registerSingleton(BEAN_NAME, natsServer);
89 | ((DefaultSingletonBeanRegistry) beanFactory).registerDisposableBean(BEAN_NAME, natsServer);
90 |
91 | }
92 |
93 | private void configure(final NatsOptionsBuilder options, final NatsConfig key, final String value) {
94 | if (hasText(value)) {
95 | options.config(key, value);
96 | }
97 | }
98 |
99 | private void setEnvConfig(final NatsOptionsBuilder options, final ConfigurableEnvironment environment) {
100 | for (NatsConfig natsConfig : NatsConfig.values()) {
101 | final String key = "nats.server." + natsConfig.name().toLowerCase();
102 | final String value = environment.getProperty(key);
103 | if (hasText(value)) {
104 | options.config(natsConfig, value);
105 | }
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/mvnw.cmd:
--------------------------------------------------------------------------------
1 | <# : batch portion
2 | @REM ----------------------------------------------------------------------------
3 | @REM Licensed to the Apache Software Foundation (ASF) under one
4 | @REM or more contributor license agreements. See the NOTICE file
5 | @REM distributed with this work for additional information
6 | @REM regarding copyright ownership. The ASF licenses this file
7 | @REM to you under the Apache License, Version 2.0 (the
8 | @REM "License"); you may not use this file except in compliance
9 | @REM with the License. You may obtain a copy of the License at
10 | @REM
11 | @REM http://www.apache.org/licenses/LICENSE-2.0
12 | @REM
13 | @REM Unless required by applicable law or agreed to in writing,
14 | @REM software distributed under the License is distributed on an
15 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | @REM KIND, either express or implied. See the License for the
17 | @REM specific language governing permissions and limitations
18 | @REM under the License.
19 | @REM ----------------------------------------------------------------------------
20 |
21 | @REM ----------------------------------------------------------------------------
22 | @REM Apache Maven Wrapper startup batch script, version 3.3.4
23 | @REM
24 | @REM Optional ENV vars
25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution
26 | @REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
27 | @REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
28 | @REM ----------------------------------------------------------------------------
29 |
30 | @IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
31 | @SET __MVNW_CMD__=
32 | @SET __MVNW_ERROR__=
33 | @SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
34 | @SET PSModulePath=
35 | @FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
36 | IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
37 | )
38 | @SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
39 | @SET __MVNW_PSMODULEP_SAVE=
40 | @SET __MVNW_ARG0_NAME__=
41 | @SET MVNW_USERNAME=
42 | @SET MVNW_PASSWORD=
43 | @IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
44 | @echo Cannot start maven from wrapper >&2 && exit /b 1
45 | @GOTO :EOF
46 | : end batch / begin powershell #>
47 |
48 | $ErrorActionPreference = "Stop"
49 | if ($env:MVNW_VERBOSE -eq "true") {
50 | $VerbosePreference = "Continue"
51 | }
52 |
53 | # calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
54 | $distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
55 | if (!$distributionUrl) {
56 | Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
57 | }
58 |
59 | switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
60 | "maven-mvnd-*" {
61 | $USE_MVND = $true
62 | $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
63 | $MVN_CMD = "mvnd.cmd"
64 | break
65 | }
66 | default {
67 | $USE_MVND = $false
68 | $MVN_CMD = $script -replace '^mvnw','mvn'
69 | break
70 | }
71 | }
72 |
73 | # apply MVNW_REPOURL and calculate MAVEN_HOME
74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/
75 | if ($env:MVNW_REPOURL) {
76 | $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
78 | }
79 | $distributionUrlName = $distributionUrl -replace '^.*/',''
80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
81 |
82 | $MAVEN_M2_PATH = "$HOME/.m2"
83 | if ($env:MAVEN_USER_HOME) {
84 | $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
85 | }
86 |
87 | if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
88 | New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
89 | }
90 |
91 | $MAVEN_WRAPPER_DISTS = $null
92 | if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
93 | $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
94 | } else {
95 | $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
96 | }
97 |
98 | $MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
99 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
100 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
101 |
102 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
103 | Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
104 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
105 | exit $?
106 | }
107 |
108 | if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
109 | Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
110 | }
111 |
112 | # prepare tmp dir
113 | $TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
114 | $TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
115 | $TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
116 | trap {
117 | if ($TMP_DOWNLOAD_DIR.Exists) {
118 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
119 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
120 | }
121 | }
122 |
123 | New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
124 |
125 | # Download and Install Apache Maven
126 | Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
127 | Write-Verbose "Downloading from: $distributionUrl"
128 | Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
129 |
130 | $webclient = New-Object System.Net.WebClient
131 | if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
132 | $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
133 | }
134 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
135 | $webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
136 |
137 | # If specified, validate the SHA-256 sum of the Maven distribution zip file
138 | $distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
139 | if ($distributionSha256Sum) {
140 | if ($USE_MVND) {
141 | Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
142 | }
143 | Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
144 | if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
145 | Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
146 | }
147 | }
148 |
149 | # unzip and move
150 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
151 |
152 | # Find the actual extracted directory name (handles snapshots where filename != directory name)
153 | $actualDistributionDir = ""
154 |
155 | # First try the expected directory name (for regular distributions)
156 | $expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
157 | $expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
158 | if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
159 | $actualDistributionDir = $distributionUrlNameMain
160 | }
161 |
162 | # If not found, search for any directory with the Maven executable (for snapshots)
163 | if (!$actualDistributionDir) {
164 | Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
165 | $testPath = Join-Path $_.FullName "bin/$MVN_CMD"
166 | if (Test-Path -Path $testPath -PathType Leaf) {
167 | $actualDistributionDir = $_.Name
168 | }
169 | }
170 | }
171 |
172 | if (!$actualDistributionDir) {
173 | Write-Error "Could not find Maven distribution directory in extracted archive"
174 | }
175 |
176 | Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
177 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
178 | try {
179 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
180 | } catch {
181 | if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
182 | Write-Error "fail to move MAVEN_HOME"
183 | }
184 | } finally {
185 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
186 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
187 | }
188 |
189 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
190 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Apache Maven Wrapper startup batch script, version 3.3.4
23 | #
24 | # Optional ENV vars
25 | # -----------------
26 | # JAVA_HOME - location of a JDK home dir, required when download maven via java source
27 | # MVNW_REPOURL - repo url base for downloading maven distribution
28 | # MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
29 | # MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
30 | # ----------------------------------------------------------------------------
31 |
32 | set -euf
33 | [ "${MVNW_VERBOSE-}" != debug ] || set -x
34 |
35 | # OS specific support.
36 | native_path() { printf %s\\n "$1"; }
37 | case "$(uname)" in
38 | CYGWIN* | MINGW*)
39 | [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
40 | native_path() { cygpath --path --windows "$1"; }
41 | ;;
42 | esac
43 |
44 | # set JAVACMD and JAVACCMD
45 | set_java_home() {
46 | # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
47 | if [ -n "${JAVA_HOME-}" ]; then
48 | if [ -x "$JAVA_HOME/jre/sh/java" ]; then
49 | # IBM's JDK on AIX uses strange locations for the executables
50 | JAVACMD="$JAVA_HOME/jre/sh/java"
51 | JAVACCMD="$JAVA_HOME/jre/sh/javac"
52 | else
53 | JAVACMD="$JAVA_HOME/bin/java"
54 | JAVACCMD="$JAVA_HOME/bin/javac"
55 |
56 | if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
57 | echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
58 | echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
59 | return 1
60 | fi
61 | fi
62 | else
63 | JAVACMD="$(
64 | 'set' +e
65 | 'unset' -f command 2>/dev/null
66 | 'command' -v java
67 | )" || :
68 | JAVACCMD="$(
69 | 'set' +e
70 | 'unset' -f command 2>/dev/null
71 | 'command' -v javac
72 | )" || :
73 |
74 | if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
75 | echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
76 | return 1
77 | fi
78 | fi
79 | }
80 |
81 | # hash string like Java String::hashCode
82 | hash_string() {
83 | str="${1:-}" h=0
84 | while [ -n "$str" ]; do
85 | char="${str%"${str#?}"}"
86 | h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
87 | str="${str#?}"
88 | done
89 | printf %x\\n $h
90 | }
91 |
92 | verbose() { :; }
93 | [ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
94 |
95 | die() {
96 | printf %s\\n "$1" >&2
97 | exit 1
98 | }
99 |
100 | trim() {
101 | # MWRAPPER-139:
102 | # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
103 | # Needed for removing poorly interpreted newline sequences when running in more
104 | # exotic environments such as mingw bash on Windows.
105 | printf "%s" "${1}" | tr -d '[:space:]'
106 | }
107 |
108 | scriptDir="$(dirname "$0")"
109 | scriptName="$(basename "$0")"
110 |
111 | # parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
112 | while IFS="=" read -r key value; do
113 | case "${key-}" in
114 | distributionUrl) distributionUrl=$(trim "${value-}") ;;
115 | distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
116 | esac
117 | done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
118 | [ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
119 |
120 | case "${distributionUrl##*/}" in
121 | maven-mvnd-*bin.*)
122 | MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
123 | case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
124 | *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
125 | :Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
126 | :Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
127 | :Linux*x86_64*) distributionPlatform=linux-amd64 ;;
128 | *)
129 | echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
130 | distributionPlatform=linux-amd64
131 | ;;
132 | esac
133 | distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
134 | ;;
135 | maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
136 | *) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
137 | esac
138 |
139 | # apply MVNW_REPOURL and calculate MAVEN_HOME
140 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/
141 | [ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
142 | distributionUrlName="${distributionUrl##*/}"
143 | distributionUrlNameMain="${distributionUrlName%.*}"
144 | distributionUrlNameMain="${distributionUrlNameMain%-bin}"
145 | MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
146 | MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
147 |
148 | exec_maven() {
149 | unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
150 | exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
151 | }
152 |
153 | if [ -d "$MAVEN_HOME" ]; then
154 | verbose "found existing MAVEN_HOME at $MAVEN_HOME"
155 | exec_maven "$@"
156 | fi
157 |
158 | case "${distributionUrl-}" in
159 | *?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
160 | *) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
161 | esac
162 |
163 | # prepare tmp dir
164 | if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
165 | clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
166 | trap clean HUP INT TERM EXIT
167 | else
168 | die "cannot create temp dir"
169 | fi
170 |
171 | mkdir -p -- "${MAVEN_HOME%/*}"
172 |
173 | # Download and Install Apache Maven
174 | verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
175 | verbose "Downloading from: $distributionUrl"
176 | verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
177 |
178 | # select .zip or .tar.gz
179 | if ! command -v unzip >/dev/null; then
180 | distributionUrl="${distributionUrl%.zip}.tar.gz"
181 | distributionUrlName="${distributionUrl##*/}"
182 | fi
183 |
184 | # verbose opt
185 | __MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
186 | [ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
187 |
188 | # normalize http auth
189 | case "${MVNW_PASSWORD:+has-password}" in
190 | '') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
191 | has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
192 | esac
193 |
194 | if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
195 | verbose "Found wget ... using wget"
196 | wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
197 | elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
198 | verbose "Found curl ... using curl"
199 | curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
200 | elif set_java_home; then
201 | verbose "Falling back to use Java to download"
202 | javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
203 | targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
204 | cat >"$javaSource" <<-END
205 | public class Downloader extends java.net.Authenticator
206 | {
207 | protected java.net.PasswordAuthentication getPasswordAuthentication()
208 | {
209 | return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
210 | }
211 | public static void main( String[] args ) throws Exception
212 | {
213 | setDefault( new Downloader() );
214 | java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
215 | }
216 | }
217 | END
218 | # For Cygwin/MinGW, switch paths to Windows format before running javac and java
219 | verbose " - Compiling Downloader.java ..."
220 | "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
221 | verbose " - Running Downloader.java ..."
222 | "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
223 | fi
224 |
225 | # If specified, validate the SHA-256 sum of the Maven distribution zip file
226 | if [ -n "${distributionSha256Sum-}" ]; then
227 | distributionSha256Result=false
228 | if [ "$MVN_CMD" = mvnd.sh ]; then
229 | echo "Checksum validation is not supported for maven-mvnd." >&2
230 | echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
231 | exit 1
232 | elif command -v sha256sum >/dev/null; then
233 | if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
234 | distributionSha256Result=true
235 | fi
236 | elif command -v shasum >/dev/null; then
237 | if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
238 | distributionSha256Result=true
239 | fi
240 | else
241 | echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
242 | echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
243 | exit 1
244 | fi
245 | if [ $distributionSha256Result = false ]; then
246 | echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
247 | echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
248 | exit 1
249 | fi
250 | fi
251 |
252 | # unzip and move
253 | if command -v unzip >/dev/null; then
254 | unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
255 | else
256 | tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
257 | fi
258 |
259 | # Find the actual extracted directory name (handles snapshots where filename != directory name)
260 | actualDistributionDir=""
261 |
262 | # First try the expected directory name (for regular distributions)
263 | if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
264 | if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
265 | actualDistributionDir="$distributionUrlNameMain"
266 | fi
267 | fi
268 |
269 | # If not found, search for any directory with the Maven executable (for snapshots)
270 | if [ -z "$actualDistributionDir" ]; then
271 | # enable globbing to iterate over items
272 | set +f
273 | for dir in "$TMP_DOWNLOAD_DIR"/*; do
274 | if [ -d "$dir" ]; then
275 | if [ -f "$dir/bin/$MVN_CMD" ]; then
276 | actualDistributionDir="$(basename "$dir")"
277 | break
278 | fi
279 | fi
280 | done
281 | set -f
282 | fi
283 |
284 | if [ -z "$actualDistributionDir" ]; then
285 | verbose "Contents of $TMP_DOWNLOAD_DIR:"
286 | verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
287 | die "Could not find Maven distribution directory in extracted archive"
288 | fi
289 |
290 | verbose "Found extracted Maven distribution directory: $actualDistributionDir"
291 | printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
292 | mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
293 |
294 | clean || :
295 | exec_maven "$@"
296 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/spring-configuration-metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "hints" : [ ],
3 | "groups" : [ {
4 | "name" : "nats.server",
5 | "type" : "berlin.yuna.natsserver.config.NatsConfig",
6 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
7 | } ],
8 | "properties" : [ {
9 | "name" : "nats.server.net",
10 | "type" : "java.lang.String",
11 | "description" : "Bind to host address (default: 0.0.0.0)",
12 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
13 | "defaultValue" : "0.0.0.0"
14 | }, {
15 | "name" : "nats.server.port",
16 | "type" : "java.lang.Integer",
17 | "description" : "Use port for clients (default: 4222)",
18 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
19 | "defaultValue" : 4222
20 | }, {
21 | "name" : "nats.server.server_name",
22 | "type" : "java.lang.String",
23 | "description" : "Server name (default: auto)",
24 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
25 | }, {
26 | "name" : "nats.server.pid",
27 | "type" : "java.nio.file.Path",
28 | "description" : "File to store PID",
29 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
30 | }, {
31 | "name" : "nats.server.http_port",
32 | "type" : "java.lang.Integer",
33 | "description" : "Use port for http monitoring",
34 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
35 | }, {
36 | "name" : "nats.server.https_port",
37 | "type" : "java.lang.Integer",
38 | "description" : "Use port for https monitoring",
39 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
40 | }, {
41 | "name" : "nats.server.config",
42 | "type" : "java.nio.file.Path",
43 | "description" : "Configuration file",
44 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
45 | }, {
46 | "name" : "nats.server.test_config",
47 | "type" : "java.lang.Boolean",
48 | "description" : "Test configuration and exit\n(default: false)",
49 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
50 | "defaultValue" : false
51 | }, {
52 | "name" : "nats.server.signal",
53 | "type" : "java.lang.String",
54 | "description" : "Send signal to nats-server process (ldm, stop, quit, term, reopen, reload)\n can be either a PID (e.g. 1) or the path to a PID file\n (e.g. /var/run/nats-server.pid) e.g. stop=pid",
55 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
56 | }, {
57 | "name" : "nats.server.client_advertise",
58 | "type" : "java.lang.String",
59 | "description" : "Client URL to advertise to other servers",
60 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
61 | }, {
62 | "name" : "nats.server.ports_file_dir",
63 | "type" : "java.nio.file.Path",
64 | "description" : "Creates a ports file in the specified directory (_.ports).",
65 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
66 | }, {
67 | "name" : "nats.server.log",
68 | "type" : "java.nio.file.Path",
69 | "description" : "File to redirect log output",
70 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
71 | }, {
72 | "name" : "nats.server.log_timelog_time",
73 | "type" : "java.lang.Boolean",
74 | "description" : "Timestamp log entries (default: true)",
75 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
76 | }, {
77 | "name" : "nats.server.syslog",
78 | "type" : "java.lang.Boolean",
79 | "description" : "Log to syslog or windows event log\n(default: false)",
80 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
81 | "defaultValue" : false
82 | }, {
83 | "name" : "nats.server.remote_syslog",
84 | "type" : "java.lang.String",
85 | "description" : "Syslog server addr (udp://localhost:514)",
86 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
87 | }, {
88 | "name" : "nats.server.debug",
89 | "type" : "java.lang.Boolean",
90 | "description" : "Enable debugging output\n(default: false)",
91 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
92 | "defaultValue" : false
93 | }, {
94 | "name" : "nats.server.trace",
95 | "type" : "java.lang.Boolean",
96 | "description" : "Trace the raw protocol\n(default: false)",
97 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
98 | "defaultValue" : false
99 | }, {
100 | "name" : "nats.server.vv",
101 | "type" : "java.lang.Boolean",
102 | "description" : "Verbose trace (traces system account as well)\n(default: false)",
103 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
104 | "defaultValue" : false
105 | }, {
106 | "name" : "nats.server.dv",
107 | "type" : "java.lang.Boolean",
108 | "description" : "Debug and trace\n(default: false)",
109 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
110 | "defaultValue" : false
111 | }, {
112 | "name" : "nats.server.dvv",
113 | "type" : "java.lang.Boolean",
114 | "description" : "Debug and verbose trace (traces system account as well)\n(default: false)",
115 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
116 | "defaultValue" : false
117 | }, {
118 | "name" : "nats.server.log_size_limit",
119 | "type" : "java.lang.Integer",
120 | "description" : "Logfile size limit (default: auto)",
121 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
122 | }, {
123 | "name" : "nats.server.max_traced_msg_len",
124 | "type" : "java.lang.Integer",
125 | "description" : "Maximum printable length for traced messages (default: unlimited)",
126 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
127 | }, {
128 | "name" : "nats.server.jetstream",
129 | "type" : "java.lang.Boolean",
130 | "description" : "Enable JetStream functionality\n(default: false)",
131 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
132 | "defaultValue" : false
133 | }, {
134 | "name" : "nats.server.store_dir",
135 | "type" : "java.nio.file.Path",
136 | "description" : "Set the storage directory",
137 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
138 | }, {
139 | "name" : "nats.server.user",
140 | "type" : "java.lang.String",
141 | "description" : "User required for connections",
142 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
143 | }, {
144 | "name" : "nats.server.pass",
145 | "type" : "java.lang.String",
146 | "description" : "Password required for connections",
147 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
148 | }, {
149 | "name" : "nats.server.auth",
150 | "type" : "java.lang.String",
151 | "description" : "Authorization token required for connections",
152 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
153 | }, {
154 | "name" : "nats.server.tls",
155 | "type" : "java.lang.Boolean",
156 | "description" : "Enable TLS, do not verify clients (default: false)",
157 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
158 | "defaultValue" : false
159 | }, {
160 | "name" : "nats.server.tls_cert",
161 | "type" : "java.nio.file.Path",
162 | "description" : "Server certificate file",
163 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
164 | }, {
165 | "name" : "nats.server.tls_key",
166 | "type" : "java.nio.file.Path",
167 | "description" : "Private key for server certificate",
168 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
169 | }, {
170 | "name" : "nats.server.tls_verify",
171 | "type" : "java.lang.Boolean",
172 | "description" : "Enable TLS, verify client certificates\n(default: false)",
173 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
174 | "defaultValue" : false
175 | }, {
176 | "name" : "nats.server.tls_ca_cert",
177 | "type" : "java.nio.file.Path",
178 | "description" : "Client certificate CA for verification",
179 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
180 | }, {
181 | "name" : "nats.server.routes",
182 | "type" : "java.lang.String",
183 | "description" : "Routes to solicit and connect\ne.g. rurl-1, rurl-2",
184 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
185 | }, {
186 | "name" : "nats.server.cluster",
187 | "type" : "java.net.URL",
188 | "description" : "Cluster URL for solicited routes",
189 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
190 | }, {
191 | "name" : "nats.server.cluster_name",
192 | "type" : "java.lang.String",
193 | "description" : "Cluster Name, if not set one will be dynamically generated",
194 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
195 | }, {
196 | "name" : "nats.server.no_advertise",
197 | "type" : "java.lang.Boolean",
198 | "description" : "Do not advertise known cluster information to clients\n(default: false)",
199 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
200 | }, {
201 | "name" : "nats.server.luster_advertise",
202 | "type" : "java.lang.String",
203 | "description" : "Cluster URL to advertise to other servers",
204 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
205 | }, {
206 | "name" : "nats.server.connect_retries",
207 | "type" : "java.lang.Integer",
208 | "description" : "For implicit routes, number of connect retries",
209 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
210 | }, {
211 | "name" : "nats.server.cluster_listen",
212 | "type" : "java.net.URL",
213 | "description" : "Cluster url from which members can solicit routes",
214 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
215 | }, {
216 | "name" : "nats.server.profile",
217 | "type" : "java.lang.Integer",
218 | "description" : "Profiling HTTP port",
219 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
220 | }, {
221 | "name" : "nats.server.help",
222 | "type" : "java.lang.Boolean",
223 | "description" : "Show this message\n(default: false)",
224 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
225 | "defaultValue" : false
226 | }, {
227 | "name" : "nats.server.help_tls",
228 | "type" : "java.lang.Boolean",
229 | "description" : "TLS help\n(default: false)",
230 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
231 | "defaultValue" : false
232 | }, {
233 | "name" : "nats.server.nats_autostart",
234 | "type" : "java.lang.Boolean",
235 | "description" : "[true] == auto closable, [false] == manual use `.start()` method (default: true)",
236 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
237 | "defaultValue" : true
238 | }, {
239 | "name" : "nats.server.nats_shutdown_hook",
240 | "type" : "java.lang.Boolean",
241 | "description" : "[true] == registers a shutdown hook, [false] == manual use `.stop()` method (default: true)",
242 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
243 | "defaultValue" : true
244 | }, {
245 | "name" : "nats.server.nats_log_level",
246 | "type" : "java.lang.String",
247 | "description" : "java log level e.g. [OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL]",
248 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
249 | }, {
250 | "name" : "nats.server.nats_timeout_ms",
251 | "type" : "java.lang.String",
252 | "description" : "true = auto closable, false manual use `.start()` method",
253 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
254 | "defaultValue" : 10000
255 | }, {
256 | "name" : "nats.server.nats_system",
257 | "type" : "java.lang.String",
258 | "description" : "suffix for binary path",
259 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
260 | }, {
261 | "name" : "nats.server.nats_log_name",
262 | "type" : "java.lang.String",
263 | "description" : "java wrapper name",
264 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
265 | "defaultValue" : "Nats"
266 | }, {
267 | "name" : "nats.server.nats_version",
268 | "type" : "java.lang.String",
269 | "description" : "Overwrites Nats server version on path",
270 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
271 | "defaultValue" : "v2.12.1"
272 | }, {
273 | "name" : "nats.server.nats_download_url",
274 | "type" : "java.net.URL",
275 | "description" : "Path to Nats binary or zip file",
276 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig",
277 | "defaultValue" : "https://github.com/nats-io/nats-server/releases/download/%NATS_VERSION%/nats-server-%NATS_VERSION%-%NATS_SYSTEM%.zip"
278 | }, {
279 | "name" : "nats.server.nats_binary_path",
280 | "type" : "java.nio.file.Path",
281 | "description" : "Target Path to Nats binary or zip file - auto from NATS_DOWNLOAD_URL",
282 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
283 | }, {
284 | "name" : "nats.server.nats_property_file",
285 | "type" : "java.nio.file.Path",
286 | "description" : "Additional config file (properties / KV) same as DSL configs",
287 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
288 | }, {
289 | "name" : "nats.server.nats_args",
290 | "type" : "java.lang.String",
291 | "description" : "custom arguments separated by &&",
292 | "sourceType" : "berlin.yuna.natsserver.config.NatsConfig"
293 | } ]
294 | }
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | berlin.yuna
8 | nats-server-embedded
9 | 2.12.2-rc.1
10 | jar
11 |
12 | nats-server-embedded
13 | Nats server embedded for testing which contains the original Nats server
14 |
15 | https://github.com/YunaBraska/nats-server-embedded
16 |
17 |
18 | scm:git:ssh://git@github.com/YunaBraska/nats-server-embedded.git
19 | scm:git:ssh://git@github.com/YunaBraska/nats-server-embedded.git
20 | https://github.com/YunaBraska/nats-server-embedded.git
21 |
22 |
23 |
24 |
25 | Yuna Morgenstern
26 | io@yuna.berlin
27 |
28 |
29 |
30 |
31 |
32 | The Apache License, Version 2.0
33 | http://www.apache.org/licenses/LICENSE-2.0.txt
34 |
35 |
36 |
37 |
38 |
39 | 17
40 | UTF-8
41 | ${project.encoding}
42 | ${project.encoding}
43 |
44 |
45 | [2.7.7,3.0.0)
46 | 2.12.1
47 | 2.1.47
48 | 2025.12.3440513
49 |
50 |
51 | 6.0.1
52 | 3.1.0
53 | 3.27.6
54 | 6.0.1
55 |
56 |
57 | 2.13.2
58 | 2.0.6
59 |
60 |
61 | 3.2.7
62 | 3.2.1
63 | 0.8.14
64 | 3.1.0
65 | 3.14.1
66 | 3.5.4
67 | 0.7.0
68 |
69 |
70 |
71 |
72 | org.springframework.boot
73 | spring-boot-starter-test
74 | ${spring-boot.version}
75 | provided
76 |
77 |
78 | berlin.yuna
79 | nats-server
80 | ${nats-server.version}
81 |
82 |
83 |
84 |
85 | org.springframework.boot
86 | spring-boot-starter
87 | ${spring-boot.version}
88 | test
89 |
90 |
91 | com.google.code.gson
92 | gson
93 | ${gson.version}
94 | test
95 |
96 |
97 | berlin.yuna
98 | config-metadata-generator
99 | ${config-metadata-generator.version}
100 | test
101 |
102 |
103 | com.vdurmont
104 | semver4j
105 | ${semver4j.version}
106 | test
107 |
108 |
109 | org.junit.jupiter
110 | junit-jupiter-api
111 | ${junit.version}
112 | test
113 |
114 |
115 | org.junit.jupiter
116 | junit-jupiter-engine
117 | ${junit.version}
118 | test
119 |
120 |
121 | org.junit.platform
122 | junit-platform-launcher
123 | ${junit-launcher.version}
124 | test
125 |
126 |
127 | org.assertj
128 | assertj-core
129 | ${assertj-core.version}
130 | test
131 |
132 |
133 |
134 |
135 |
136 |
137 | org.apache.maven.plugins
138 | maven-compiler-plugin
139 | ${maven-compiler-plugin.version}
140 |
141 | ${java-version}
142 | ${java-version}
143 | ${java-version}
144 |
145 |
146 |
147 | org.apache.maven.plugins
148 | maven-surefire-plugin
149 | ${maven-surefire-plugin.version}
150 |
151 |
152 | **/*Test.java
153 |
154 |
155 |
156 |
157 | org.jacoco
158 | jacoco-maven-plugin
159 | ${jacoco-maven-plugin.version}
160 |
161 |
162 |
167 | **/*/config/**/*
168 | **/*/model/**/*
169 | **/*/domain/**/*
170 | **/*/persistence/**/*
171 | **/*/target/**/*
172 |
173 |
174 |
175 |
176 |
177 | prepare-agent
178 |
179 |
180 | ${project.build.directory}/jacoco-ut.exec
181 |
182 |
183 |
184 | pre-integration-prepare
185 |
186 | prepare-agent-integration
187 |
188 |
189 |
190 | report
191 | post-integration-test
192 |
193 | merge
194 |
195 |
196 |
197 |
198 | ${project.build.directory}
199 |
200 | *.exec
201 |
202 |
203 |
204 |
205 |
206 |
207 | merged-report-generation
208 | verify
209 |
210 | report
211 |
212 |
213 |
214 |
215 |
216 | org.codehaus.mojo
217 | versions-maven-plugin
218 | 2.14.2
219 |
220 |
221 | org.springframework.boot:spring-boot-starter
222 | org.springframework.boot:spring-boot-starter-test
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 | release
234 |
235 |
236 | release
237 | true
238 |
239 | false
240 |
241 |
242 |
243 |
244 |
245 | org.apache.maven.plugins
246 | maven-javadoc-plugin
247 | ${maven-javadoc-plugin.version}
248 |
249 |
250 | attach-javadocs
251 |
252 | jar
253 |
254 |
255 | ${java-version}
256 | true
257 | true
258 |
259 | none
260 | false
261 |
262 |
263 |
264 |
265 |
266 | org.apache.maven.plugins
267 | maven-source-plugin
268 | ${maven-source-plugin.version}
269 |
270 |
271 | attach-sources
272 |
273 | jar-no-fork
274 |
275 |
276 |
277 |
278 |
279 | org.apache.maven.plugins
280 | maven-gpg-plugin
281 | ${maven-gpg-plugin.version}
282 |
283 |
284 | sign-artifacts
285 | verify
286 |
287 | sign
288 |
289 |
290 |
291 |
292 |
293 | --pinentry-mode
294 | loopback
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 | org.sonatype.central
305 | central-publishing-maven-plugin
306 | ${central-publishing-maven-plugin.version}
307 | true
308 |
309 | central
310 | true
311 | ${project.groupId}:${project.artifactId}:${project.version}
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
--------------------------------------------------------------------------------