|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2024 the original author or authors. |
| 2 | + * Copyright 2012-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -41,6 +41,32 @@ void getBindsFromEnvironment() {
|
41 | 41 | assertThat(properties).isEqualTo(new GraylogExtendedLogFormatProperties("spring", new Service("1.2.3")));
|
42 | 42 | }
|
43 | 43 |
|
| 44 | + @Test |
| 45 | + void getBindsFromEnvironmentWhenHostIsPresentAndServiceIsMissing() { |
| 46 | + MockEnvironment environment = new MockEnvironment(); |
| 47 | + environment.setProperty("logging.structured.gelf.host", "spring"); |
| 48 | + GraylogExtendedLogFormatProperties properties = GraylogExtendedLogFormatProperties.get(environment); |
| 49 | + assertThat(properties).isEqualTo(new GraylogExtendedLogFormatProperties("spring", new Service(null))); |
| 50 | + } |
| 51 | + |
| 52 | + @Test |
| 53 | + void getBindsFromEnvironmentWhenHostIsPresentAndServiceIsMissingUsesApplicationVersion() { |
| 54 | + MockEnvironment environment = new MockEnvironment(); |
| 55 | + environment.setProperty("logging.structured.gelf.host", "spring"); |
| 56 | + environment.setProperty("spring.application.version", "1.2.3"); |
| 57 | + GraylogExtendedLogFormatProperties properties = GraylogExtendedLogFormatProperties.get(environment); |
| 58 | + assertThat(properties).isEqualTo(new GraylogExtendedLogFormatProperties("spring", new Service("1.2.3"))); |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + void getBindsFromEnvironmentWhenVersionIsPresentAndHostIsMissingUsesApplicationName() { |
| 63 | + MockEnvironment environment = new MockEnvironment(); |
| 64 | + environment.setProperty("spring.application.name", "spring"); |
| 65 | + environment.setProperty("logging.structured.gelf.service.version", "1.2.3"); |
| 66 | + GraylogExtendedLogFormatProperties properties = GraylogExtendedLogFormatProperties.get(environment); |
| 67 | + assertThat(properties).isEqualTo(new GraylogExtendedLogFormatProperties("spring", new Service("1.2.3"))); |
| 68 | + } |
| 69 | + |
44 | 70 | @Test
|
45 | 71 | void getWhenNoServiceNameUsesApplicationName() {
|
46 | 72 | MockEnvironment environment = new MockEnvironment();
|
|
0 commit comments