forked from helidon-io/helidon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dmitry Aleksandrov <[email protected]>
- Loading branch information
1 parent
67362f9
commit 8484dc3
Showing
17 changed files
with
245 additions
and
142 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
114 changes: 0 additions & 114 deletions
114
...profile/config/src/test/java/io/helidon/microprofile/config/ConfigBeanDescriptorTest.java
This file was deleted.
Oops, something went wrong.
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
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,70 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2023 Oracle and/or its affiliates. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.helidon.microprofile.tests</groupId> | ||
<artifactId>helidon-microprofile-tests-project</artifactId> | ||
<version>4.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>helidon-microprofile-tests-config</artifactId> | ||
<name>Helidon Microprofile Config Tests</name> | ||
|
||
<description> | ||
Microprofile config implementation. | ||
</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.helidon.microprofile.config</groupId> | ||
<artifactId>helidon-microprofile-config</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.microprofile.cdi</groupId> | ||
<artifactId>helidon-microprofile-cdi</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-all</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.microprofile.testing</groupId> | ||
<artifactId>helidon-microprofile-testing-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
115 changes: 115 additions & 0 deletions
115
...oprofile/tests/config/src/test/java/io/helidon/microprofile/config/ObjectMappingTest.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,115 @@ | ||
/* | ||
* Copyright (c) 2020, 2021 Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.helidon.microprofile.config; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import io.helidon.config.mp.MpConfigSources; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
import org.eclipse.microprofile.config.spi.ConfigProviderResolver; | ||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.collection.IsCollectionWithSize.hasSize; | ||
|
||
class ObjectMappingTest { | ||
private static ClassLoader classLoader; | ||
private static ConfigProviderResolver resolver; | ||
|
||
@BeforeAll | ||
static void initClass() { | ||
classLoader = Thread.currentThread().getContextClassLoader(); | ||
resolver = ConfigProviderResolver.instance(); | ||
} | ||
|
||
@Test | ||
void testIt() { | ||
// Removed use of system properties, as those stay around after test is finished | ||
Map<String, String> configMap = Map.of("built.it", "configured", | ||
"list.0.it", "first", | ||
"list.1.it", "second"); | ||
|
||
resolver.registerConfig(resolver.getBuilder() | ||
.withSources(MpConfigSources.create(configMap)) | ||
.build(), | ||
classLoader); | ||
|
||
// need to go through resolver to wrap config in our SE/MP wrapper | ||
Config config = resolver.getConfig(classLoader); | ||
io.helidon.config.Config helidonConfig = (io.helidon.config.Config) config; | ||
|
||
try { | ||
Built built = helidonConfig.get("built").as(Built.class).get(); | ||
assertThat(built.it, is("configured")); | ||
|
||
List<Built> list = helidonConfig.get("list").asList(Built.class).get(); | ||
assertThat(list, hasSize(2)); | ||
assertThat(list, Matchers.contains(new Built("first"), new Built("second"))); | ||
|
||
} finally { | ||
resolver.releaseConfig(config); | ||
} | ||
} | ||
|
||
public static class Built { | ||
private final String it; | ||
|
||
private Built(Builder builder) { | ||
this.it = builder.it; | ||
} | ||
|
||
private Built(String it) { | ||
this.it = it; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
Built built = (Built) o; | ||
return it.equals(built.it); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(it); | ||
} | ||
|
||
public static class Builder { | ||
private String it; | ||
|
||
public Builder it(String it) { | ||
this.it = it; | ||
return this; | ||
} | ||
|
||
public Built build() { | ||
return new Built(this); | ||
} | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
microprofile/tests/config/src/test/resources/META-INF/microprofile-config.properties
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,22 @@ | ||
# | ||
# Copyright (c) 2020, 2021 Oracle and/or its affiliates. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# needed to run unit tests independently based on explicit beans using SeContainerInitializer | ||
mp.initializer.allow=true | ||
mp.initializer.warn=false | ||
|
||
camelCase=yes | ||
yamlProperty=no |
Oops, something went wrong.