-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zj/spring add configuration bean (#672)
* Add Configuration Bean into Spring project.
- Loading branch information
1 parent
35b7303
commit 5c60356
Showing
12 changed files
with
425 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...config/src/test/java/test/microstream/integrations/spring/boot/ConfigurationBeanTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package test.microstream.integrations.spring.boot; | ||
|
||
/*- | ||
* #%L | ||
* microstream-integrations-spring-boot | ||
* %% | ||
* Copyright (C) 2019 - 2023 MicroStream Software | ||
* %% | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License, v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is | ||
* available at https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
* #L% | ||
*/ | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import one.microstream.integrations.spring.boot.types.config.StorageManagerConfiguration; | ||
import one.microstream.integrations.spring.boot.types.config.StorageManagerProvider; | ||
import one.microstream.storage.embedded.types.EmbeddedStorageFoundation; | ||
import one.microstream.storage.embedded.types.EmbeddedStorageManager; | ||
|
||
@SpringBootTest | ||
public class ConfigurationBeanTest | ||
{ | ||
@Autowired | ||
StorageManagerConfiguration configuration; | ||
|
||
@Autowired | ||
StorageManagerProvider provider; | ||
|
||
private final String TEST_SENTENCE = "I love MicroStream Spring Extension"; | ||
|
||
@Test | ||
void testReloadData() | ||
{ | ||
Assertions.assertNotNull(configuration); | ||
Assertions.assertNotNull(provider); | ||
|
||
EmbeddedStorageFoundation<?> embeddedStorageFoundation = provider.embeddedStorageFoundation(configuration.getValues()); | ||
TestData data = new TestData(TEST_SENTENCE); | ||
try (EmbeddedStorageManager storage = embeddedStorageFoundation.start(data)) { | ||
} | ||
|
||
EmbeddedStorageFoundation<?> embeddedStorageFoundation2 = provider.embeddedStorageFoundation(configuration.getValues()); | ||
TestData data2 = new TestData(); | ||
try (EmbeddedStorageManager storage2 = embeddedStorageFoundation2.start(data2)) { | ||
Assertions.assertEquals(TEST_SENTENCE, data2.getValue()); | ||
} | ||
} | ||
|
||
@Test | ||
void testReloadDataWithoutFoundation() | ||
{ | ||
Assertions.assertNotNull(configuration); | ||
Assertions.assertNotNull(provider); | ||
|
||
try (EmbeddedStorageManager storageManager = provider.create(configuration.getValues())) { | ||
TestData data = new TestData(TEST_SENTENCE); | ||
storageManager.start(); | ||
storageManager.setRoot(data); | ||
storageManager.storeRoot(); | ||
} | ||
|
||
try (EmbeddedStorageManager storageManager2 = provider.create(configuration.getValues())) { | ||
|
||
TestData data2 = new TestData(); | ||
storageManager2.start(); | ||
TestData readData = (TestData) storageManager2.root(); | ||
Assertions.assertEquals(TEST_SENTENCE, readData.getValue()); | ||
|
||
} | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
.../src/it/core-config/src/test/java/test/microstream/integrations/spring/boot/TestData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package test.microstream.integrations.spring.boot; | ||
|
||
/*- | ||
* #%L | ||
* microstream-integrations-spring-boot | ||
* %% | ||
* Copyright (C) 2019 - 2023 MicroStream Software | ||
* %% | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License, v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is | ||
* available at https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
* #L% | ||
*/ | ||
|
||
public class TestData | ||
{ | ||
private String value = ""; | ||
|
||
public TestData() | ||
{ | ||
} | ||
|
||
public TestData(String value) | ||
{ | ||
this.value = value; | ||
} | ||
|
||
public String getValue() | ||
{ | ||
return value; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...va/one/microstream/integrations/spring/boot/types/config/StorageManagerConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package one.microstream.integrations.spring.boot.types.config; | ||
|
||
/*- | ||
* #%L | ||
* microstream-integrations-spring-boot | ||
* %% | ||
* Copyright (C) 2019 - 2023 MicroStream Software | ||
* %% | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License, v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is | ||
* available at https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
* #L% | ||
*/ | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class StorageManagerConfiguration | ||
{ | ||
private Map<String, String> values; | ||
|
||
public StorageManagerConfiguration() | ||
{ | ||
} | ||
|
||
public StorageManagerConfiguration(Map<String, String> values) | ||
{ | ||
this.values = values; | ||
} | ||
|
||
public Map<String, String> getValues() | ||
{ | ||
return values; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.