forked from kumuluz/kumuluzee-config-mp
-
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.
- Loading branch information
Showing
4 changed files
with
152 additions
and
159 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
201 changes: 100 additions & 101 deletions
201
src/test/java/com/kumuluz/ee/config/microprofile/tests/ArrayInjectionTest.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 |
---|---|---|
@@ -1,101 +1,100 @@ | ||
/* | ||
* Copyright (c) 2014-2017 Kumuluz and/or its affiliates | ||
* and other contributors as indicated by the @author tags and | ||
* the contributor list. | ||
* | ||
* Licensed under the MIT License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/MIT | ||
* | ||
* The software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, express or | ||
* implied, including but not limited to the warranties of merchantability, | ||
* fitness for a particular purpose and noninfringement. in no event shall the | ||
* authors or copyright holders be liable for any claim, damages or other | ||
* liability, whether in an action of contract, tort or otherwise, arising from, | ||
* out of or in connection with the software or the use or other dealings in the | ||
* software. See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.kumuluz.ee.config.microprofile.tests; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.testng.Arquillian; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* Tests that check MP Config array/list injection from KumuluzEE's config.yaml | ||
* | ||
* @author Yog Sothoth | ||
* @since 1.4 | ||
* | ||
*/ | ||
@Test | ||
public class ArrayInjectionTest extends Arquillian { | ||
@Deployment | ||
public static JavaArchive deploy() { | ||
JavaArchive testJar = ShrinkWrap | ||
.create(JavaArchive.class, "arrayInjectionTest.jar") | ||
.addClasses(ArrayInjectionTest.class) | ||
.addAsResource("config.yaml") | ||
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") | ||
.as(JavaArchive.class); | ||
return testJar; | ||
} | ||
|
||
@Inject | ||
@ConfigProperty(name="parameter.arrayParameter") | ||
private List<String> listParam; | ||
|
||
@Inject | ||
@ConfigProperty(name="parameter.arrayParameter") | ||
private String[] arrayParam; | ||
|
||
@Inject | ||
@ConfigProperty(name="parameter.arrayParameter") | ||
private Optional<String[]> arrayParamOpt; | ||
|
||
@Inject | ||
@ConfigProperty(name="parameter.stringParameter") | ||
private Optional<String> stringParam; | ||
|
||
@Inject | ||
@ConfigProperty(name="parameter.arrayParameter[0]") | ||
private String arrayItemParam; | ||
|
||
private static final String[] TEST_TARGET = | ||
new String[]{"one ", " two", " [three, four] "}; | ||
|
||
@Test | ||
public void testNotParsingDelimeters() { | ||
Assert.assertEquals("[here be, dragons]", stringParam.get()); | ||
} | ||
|
||
@Test | ||
public void testArrayItemInjection() { | ||
Assert.assertEquals(TEST_TARGET[0], arrayItemParam); | ||
} | ||
|
||
@Test | ||
public void testArrayInjection() { | ||
Assert.assertEquals(TEST_TARGET, arrayParamOpt.get()); | ||
Assert.assertEquals(TEST_TARGET, arrayParam); | ||
} | ||
|
||
@Test | ||
public void testListInjection() { | ||
Assert.assertEquals(Arrays.asList(TEST_TARGET), listParam); | ||
} | ||
} | ||
/* | ||
* Copyright (c) 2014-2017 Kumuluz and/or its affiliates | ||
* and other contributors as indicated by the @author tags and | ||
* the contributor list. | ||
* | ||
* Licensed under the MIT License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/MIT | ||
* | ||
* The software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, express or | ||
* implied, including but not limited to the warranties of merchantability, | ||
* fitness for a particular purpose and noninfringement. in no event shall the | ||
* authors or copyright holders be liable for any claim, damages or other | ||
* liability, whether in an action of contract, tort or otherwise, arising from, | ||
* out of or in connection with the software or the use or other dealings in the | ||
* software. See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.kumuluz.ee.config.microprofile.tests; | ||
|
||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.testng.Arquillian; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import javax.inject.Inject; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Tests that check MP Config array/list injection from KumuluzEE's config.yaml | ||
* | ||
* @author Yog Sothoth | ||
* @since 1.4 | ||
*/ | ||
@Test | ||
public class ArrayInjectionTest extends Arquillian { | ||
|
||
private static final String[] TEST_TARGET = | ||
new String[]{"one ", " two", " [three, four] "}; | ||
|
||
@Inject | ||
@ConfigProperty(name = "parameter.arrayParameter") | ||
private List<String> listParam; | ||
|
||
@Inject | ||
@ConfigProperty(name = "parameter.arrayParameter") | ||
private String[] arrayParam; | ||
|
||
@Inject | ||
@ConfigProperty(name = "parameter.arrayParameter") | ||
private Optional<String[]> arrayParamOpt; | ||
|
||
@Inject | ||
@ConfigProperty(name = "parameter.stringParameter") | ||
private Optional<String> stringParam; | ||
|
||
@Inject | ||
@ConfigProperty(name = "parameter.arrayParameter[0]") | ||
private String arrayItemParam; | ||
|
||
@Deployment | ||
public static JavaArchive deploy() { | ||
JavaArchive testJar = ShrinkWrap | ||
.create(JavaArchive.class, "arrayInjectionTest.jar") | ||
.addClasses(ArrayInjectionTest.class) | ||
.addAsResource("config.yaml") | ||
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") | ||
.as(JavaArchive.class); | ||
return testJar; | ||
} | ||
|
||
@Test | ||
public void testNotParsingDelimeters() { | ||
Assert.assertEquals("[here be, dragons]", stringParam.get()); | ||
} | ||
|
||
@Test | ||
public void testArrayItemInjection() { | ||
Assert.assertEquals(TEST_TARGET[0], arrayItemParam); | ||
} | ||
|
||
@Test | ||
public void testArrayInjection() { | ||
Assert.assertEquals(TEST_TARGET, arrayParamOpt.get()); | ||
Assert.assertEquals(TEST_TARGET, arrayParam); | ||
} | ||
|
||
@Test | ||
public void testListInjection() { | ||
Assert.assertEquals(Arrays.asList(TEST_TARGET), listParam); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
parameter: | ||
stringParameter: "[here be, dragons]" | ||
arrayParameter: | ||
- "one " | ||
- " two" | ||
- " [three\\, four] " | ||
- five: | ||
six: seven | ||
eight: nine | ||
parameter: | ||
stringParameter: "[here be, dragons]" | ||
arrayParameter: | ||
- "one " | ||
- " two" | ||
- " [three\\, four] " | ||
- five: | ||
six: seven | ||
eight: nine |