|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2023 the original author or authors. |
| 2 | + * Copyright 2012-2024 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.
|
@@ -145,15 +145,28 @@ void addClassLoaderFiles() {
|
145 | 145 | }
|
146 | 146 |
|
147 | 147 | @Test
|
148 |
| - @SuppressWarnings("rawtypes") |
149 | 148 | void getOrAddAttributeWithExistingAttribute() {
|
150 | 149 | Restarter.getInstance().getOrAddAttribute("x", () -> "abc");
|
151 |
| - ObjectFactory objectFactory = mock(ObjectFactory.class); |
| 150 | + ObjectFactory<?> objectFactory = mock(ObjectFactory.class); |
152 | 151 | Object attribute = Restarter.getInstance().getOrAddAttribute("x", objectFactory);
|
153 | 152 | assertThat(attribute).isEqualTo("abc");
|
154 | 153 | then(objectFactory).shouldHaveNoInteractions();
|
155 | 154 | }
|
156 | 155 |
|
| 156 | + @Test |
| 157 | + void getOrAddAttributeWithRecursion() { |
| 158 | + Restarter restarter = Restarter.getInstance(); |
| 159 | + Object added = restarter.getOrAddAttribute("postgresContainer", () -> { |
| 160 | + restarter.getOrAddAttribute("rabbitContainer", () -> "def"); |
| 161 | + return "abc"; |
| 162 | + }); |
| 163 | + ObjectFactory<?> objectFactory = mock(ObjectFactory.class); |
| 164 | + assertThat(added).isEqualTo("abc"); |
| 165 | + assertThat(restarter.getOrAddAttribute("postgresContainer", objectFactory)).isEqualTo("abc"); |
| 166 | + assertThat(restarter.getOrAddAttribute("rabbitContainer", objectFactory)).isEqualTo("def"); |
| 167 | + then(objectFactory).shouldHaveNoInteractions(); |
| 168 | + } |
| 169 | + |
157 | 170 | @Test
|
158 | 171 | void getThreadFactory() throws Exception {
|
159 | 172 | final ClassLoader parentLoader = Thread.currentThread().getContextClassLoader();
|
|
0 commit comments