-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add the possibility to have a property file for all classes by not ch…
…ange te actual behavior; adjust test classes to work with not english locale and not linux systems
- Loading branch information
Jens Müller
committed
Mar 7, 2023
1 parent
153a510
commit 9b89048
Showing
14 changed files
with
193 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ hs_err_pid* | |
/.project | ||
/doc/ | ||
/property-inject.launch | ||
|
||
/.idea |
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,7 @@ | ||
package io.xlate.inject; | ||
|
||
public interface PropertyFileProvider { | ||
|
||
String getLocation(); | ||
|
||
} |
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
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
79 changes: 79 additions & 0 deletions
79
src/test/java/io/xlate/inject/PropertyResourceProducerBeanWithConfigurationFile.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,79 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2018 xlate.io LLC, http://www.xlate.io | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
******************************************************************************/ | ||
package io.xlate.inject; | ||
|
||
import org.jboss.weld.junit5.WeldInitiator; | ||
import org.jboss.weld.junit5.WeldJunit5Extension; | ||
import org.jboss.weld.junit5.WeldSetup; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.junit.platform.runner.JUnitPlatform; | ||
import org.junit.runner.RunWith; | ||
|
||
import javax.inject.Inject; | ||
import java.util.Properties; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
@RunWith(JUnitPlatform.class) | ||
@ExtendWith(WeldJunit5Extension.class) | ||
class PropertyResourceProducerBeanWithConfigurationFile { | ||
|
||
@WeldSetup | ||
WeldInitiator weld = WeldInitiator | ||
.from(PropertyResourceProducerBean.class, TestFileProvider.class) | ||
.build(); | ||
|
||
|
||
@Inject | ||
@PropertyResource | ||
Properties defaultProps; | ||
|
||
|
||
@Inject | ||
@PropertyResource("io/xlate/inject/PropertyResourceProducerBeanIT2.properties") | ||
Properties props2; | ||
|
||
@Test | ||
void testGlobalFile() { | ||
WeldInitiator weld = WeldInitiator | ||
.from(PropertyResourceProducerBean.class, TestFileProvider.class) | ||
.build(); | ||
assertNotNull(defaultProps); | ||
System.out.println(defaultProps); | ||
assertEquals(3, defaultProps.size()); | ||
assertEquals("x", defaultProps.getProperty("key1")); | ||
assertEquals("y", defaultProps.getProperty("key2")); | ||
assertEquals("false", defaultProps.getProperty("value.is.found")); | ||
} | ||
|
||
@Test | ||
void testGlobalFileOverriddenByLocalLocation() { | ||
WeldInitiator weld = WeldInitiator | ||
.from(PropertyResourceProducerBean.class, TestFileProvider.class) | ||
.build(); | ||
assertNotNull(props2); | ||
System.out.println(props2); | ||
assertEquals(3, props2.size()); | ||
assertEquals("true", props2.getProperty("value.is.found")); | ||
assertEquals("x", props2.getProperty("key1")); | ||
assertEquals("y", props2.getProperty("key2")); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.