Skip to content

Commit 7d3d9d0

Browse files
Merge pull request #32 from TechnologyBrewery/31-parent-update-10
#31 ⬆️ update to parent version 10 (JDK 17, default Python fo…
2 parents d297c64 + 49d6cb7 commit 7d3d9d0

File tree

7 files changed

+91
-57
lines changed

7 files changed

+91
-57
lines changed

krausening-python/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
<plugin>
1919
<groupId>org.technologybrewery.habushu</groupId>
2020
<artifactId>habushu-maven-plugin</artifactId>
21+
<configuration>
22+
<pythonVersion>${version.python.default}</pythonVersion>
23+
</configuration>
2124
</plugin>
2225
</plugins>
2326
</build>

krausening-python/src/krausening/logging/log_manager.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ class LogManager:
55
"""
66
Class for handling logging.
77
"""
8-
DEFAULT_LOG_LEVEL = 'INFO'
8+
9+
DEFAULT_LOG_LEVEL = "INFO"
910

1011
LOG_LEVELS = {
11-
'CRITICAL': logging.CRITICAL,
12-
'ERROR': logging.ERROR,
13-
'WARNING': logging.WARNING,
14-
'INFO': logging.INFO,
15-
'DEBUG': logging.DEBUG,
16-
'NOTSET': logging.NOTSET,
17-
}
12+
"CRITICAL": logging.CRITICAL,
13+
"ERROR": logging.ERROR,
14+
"WARNING": logging.WARNING,
15+
"INFO": logging.INFO,
16+
"DEBUG": logging.DEBUG,
17+
"NOTSET": logging.NOTSET,
18+
}
1819

1920
__instance = None
2021

@@ -39,7 +40,9 @@ def __init__(self):
3940
def _get_log_level(self, log_level: str) -> int:
4041
return self.LOG_LEVELS.get(log_level, self.LOG_LEVELS[self.DEFAULT_LOG_LEVEL])
4142

42-
def get_logger(self, name: str, log_level: str = DEFAULT_LOG_LEVEL) -> logging.Logger:
43+
def get_logger(
44+
self, name: str, log_level: str = DEFAULT_LOG_LEVEL
45+
) -> logging.Logger:
4346
logger = logging.getLogger(name)
4447
logger.addHandler(LogManager.__handler)
4548

krausening-python/tests/features/steps/logging_steps.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,48 @@
22
from krausening.logging import LogManager
33

44
LOG_LEVEL_MAPPING = {
5-
50: 'CRITICAL',
6-
40: 'ERROR',
7-
30: 'WARNING',
8-
20: 'INFO',
9-
10: 'DEBUG',
10-
0: 'NOTSET',
11-
}
12-
13-
@given('a name for the logger')
5+
50: "CRITICAL",
6+
40: "ERROR",
7+
30: "WARNING",
8+
20: "INFO",
9+
10: "DEBUG",
10+
0: "NOTSET",
11+
}
12+
13+
14+
@given("a name for the logger")
1415
def step_impl(context):
15-
context.name = 'test_logger'
16+
context.name = "test_logger"
1617

17-
@given('a log level of {log_level}')
18+
19+
@given("a log level of {log_level}")
1820
def step_impl(context, log_level):
1921
context.log_level = log_level
2022

21-
@given('no log level specification')
23+
24+
@given("no log level specification")
2225
def step_impl(context):
2326
context.log_level = None
2427

25-
@given('an invalid log level specification')
28+
29+
@given("an invalid log level specification")
2630
def step_impl(context):
27-
context.log_level = 'WARNIG'
31+
context.log_level = "WARNIG"
32+
2833

29-
@when('the get logger method is called')
34+
@when("the get logger method is called")
3035
def step_impl(context):
3136
if context.log_level:
32-
context.logger = LogManager.get_instance().get_logger(context.name, context.log_level)
37+
context.logger = LogManager.get_instance().get_logger(
38+
context.name, context.log_level
39+
)
3340
else:
3441
context.logger = LogManager.get_instance().get_logger(context.name)
3542

36-
@then('a logger is returned with a log level of {log_level}')
43+
44+
@then("a logger is returned with a log level of {log_level}")
3745
def step_impl(context, log_level):
3846
assigned_log_level = LOG_LEVEL_MAPPING[context.logger.level]
39-
assert assigned_log_level == log_level, f'The specified log level ({log_level}) does not match the assigned log level ({assigned_log_level}).'
47+
assert (
48+
assigned_log_level == log_level
49+
), f"The specified log level ({log_level}) does not match the assigned log level ({assigned_log_level})."

krausening/pom.xml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
<dependency>
2727
<groupId>org.apache.commons</groupId>
2828
<artifactId>commons-lang3</artifactId>
29-
<version>3.14.0</version>
29+
<version>3.17.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>commons-io</groupId>
3333
<artifactId>commons-io</artifactId>
34-
<version>2.16.1</version>
34+
<version>2.17.0</version>
3535
<scope>compile</scope>
3636
</dependency>
3737
<dependency>
@@ -72,6 +72,17 @@
7272

7373
<build>
7474
<plugins>
75+
<plugin>
76+
<groupId>org.apache.maven.plugins</groupId>
77+
<artifactId>maven-compiler-plugin</artifactId>
78+
<configuration>
79+
<!--
80+
While we build with Java 17, continue to release Java 11 compatible code until
81+
Maven 4 is the minimum supported version
82+
-->
83+
<release>11</release>
84+
</configuration>
85+
</plugin>
7586
<plugin>
7687
<groupId>org.apache.maven.plugins</groupId>
7788
<artifactId>maven-compiler-plugin</artifactId>

krausening/src/main/java/org/technologybrewery/krausening/Krausening.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
package org.technologybrewery.krausening;
22

3+
import org.apache.commons.io.filefilter.SuffixFileFilter;
4+
import org.apache.commons.lang3.StringUtils;
5+
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
6+
import org.jasypt.iv.RandomIvGenerator;
7+
import org.jasypt.properties.EncryptableProperties;
8+
import org.slf4j.Logger;
9+
import org.slf4j.LoggerFactory;
10+
311
import java.io.File;
412
import java.io.FileReader;
513
import java.io.FilenameFilter;
@@ -11,35 +19,27 @@
1119
import java.util.UUID;
1220
import java.util.concurrent.ConcurrentHashMap;
1321

14-
import org.apache.commons.io.filefilter.SuffixFileFilter;
15-
import org.apache.commons.lang3.StringUtils;
16-
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
17-
import org.jasypt.iv.RandomIvGenerator;
18-
import org.jasypt.properties.EncryptableProperties;
19-
import org.slf4j.Logger;
20-
import org.slf4j.LoggerFactory;
21-
2222
/**
2323
* In brewing, krausening (KROI-zen-ing) refers to adding a small amount of
2424
* fresh wort to prime finished beer for carbonation. In Java, Krausening is a
2525
* project to populate finished archives for deployment. This approach allows
2626
* Properties files to be externalized from deployment units, enabling the same
2727
* deployment unit to be leveraged repeatedly without the need to rebuild or
2828
* hacking the archive.
29-
*
29+
*
3030
* To use, you need to minimally set a system property "KRAUSENING_BASE", which
3131
* points to a directory where your {@link Properties} files will be located.
3232
* Krausening will load those up and make them available via the
3333
* {@code getProperties(<file name>)} method.
34-
*
34+
*
3535
* You can then use a system property called "KRAUSENING_EXTENSIONS" to set up
3636
* extensions to the {@link Properties} files located in "KRAUSENING_BASE". The
3737
* first the base properties will be loaded, with anything in the extensions
3838
* location being added on to the top. This allows value to be added or
3939
* overridden, which is especially useful when you have a standard configuration
4040
* defined in your base files, but need to specialize some values for different
4141
* deployments.
42-
*
42+
*
4343
* Only .properties files will be loaded. Any other file encountered will be
4444
* skipped.
4545
*/
@@ -84,9 +84,9 @@ public final class Krausening {
8484

8585
/** Whether or not KRAUSENING_PASSWORD is non-blank. */
8686
private boolean hasMasterPassword;
87-
87+
8888
private static Map<String, Krausening> instanceMap = new HashMap<>();
89-
89+
9090
private static String defaultInstanceKey = UUID.randomUUID().toString();
9191

9292
/**
@@ -97,7 +97,7 @@ private Krausening() {}
9797

9898
/**
9999
* Returns the singleton instance of this class.
100-
*
100+
*
101101
* @return singleton reference to Krausening
102102
*/
103103
public static Krausening getInstance() {
@@ -109,14 +109,14 @@ public static Krausening getInstance() {
109109
}
110110
return instance;
111111
}
112-
112+
113113
protected void updateDefaultInstance() {
114114
instanceMap.put(defaultInstanceKey, this);
115115
}
116-
116+
117117
/**
118118
* Returns an instance of the class based on the overrideExtensionsSubfolder requested.
119-
*
119+
*
120120
* @param overrideExtensionsSubfolder
121121
* @return
122122
*/
@@ -186,7 +186,7 @@ protected void setEncryptionFoundation() {
186186
/**
187187
* Log an error for the file and location type when the location does not
188188
* exist.
189-
*
189+
*
190190
* @param file
191191
* The file that does not exist
192192
* @param location
@@ -228,7 +228,7 @@ private boolean setLocations() {
228228

229229
/**
230230
* Loads all .properties files from the passed location.
231-
*
231+
*
232232
* @param location
233233
* the location containing properties files
234234
* @param locationType
@@ -267,7 +267,7 @@ private void loadPropertiesFromLocation(File location, String locationType) {
267267
/**
268268
* Creates an empty Properties file, either standard or encrypted, based on
269269
* whether or not the master password is set.
270-
*
270+
*
271271
* @return An empty properties instance
272272
*/
273273
private Properties createEmptyProperties() {
@@ -291,7 +291,7 @@ private Properties createEmptyProperties() {
291291

292292
/**
293293
* Returns the properties file loaded by Krausening for given file name.
294-
*
294+
*
295295
* @param propertiesFileName
296296
* The file name to retrieve
297297
* @return The file or null if that file name is not know
@@ -306,7 +306,7 @@ public Properties getProperties(String propertiesFileName) {
306306
* for the entire system. It acts a second level extension effectively. A
307307
* property is first set in base, the extensions, then finally in a
308308
* subfolder within the override extension location.
309-
*
309+
*
310310
* @param overrideExtensionSubfolder
311311
*/
312312
protected void setOverrideExtensionsSubfolder(String overrideExtensionSubfolder) {
@@ -315,7 +315,7 @@ protected void setOverrideExtensionsSubfolder(String overrideExtensionSubfolder)
315315
// extensions directory
316316
this.overrideExtensionSubfolder = overrideExtensionSubfolder;
317317
}
318-
319-
320-
318+
319+
320+
321321
}

krausening/src/test/java/org/technologybrewery/krausening/TestEncryptedKrausening.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.junit.Assert.assertNotNull;
55

66
import java.util.Properties;
7+
import java.util.Set;
78

89
import org.aeonbits.owner.KrauseningConfig;
910
import org.aeonbits.owner.KrauseningConfig.KrauseningSources;
@@ -28,6 +29,13 @@ public void testEncryptedPropertyReadProvidesDecryptedValue() {
2829
krausening.loadProperties();
2930
Properties properties = krausening.getProperties(ENCRYPTED_PROPERTIES);
3031
assertNotNull(properties);
32+
Set<Object> keys = properties.keySet();
33+
for (Object key : keys) {
34+
String keyAsString = key.toString();
35+
if (PASSWORD_KEY.equals(keyAsString)) {
36+
assertEquals(DECRYPTED_PASSWORD_VALUE, properties.getProperty(keyAsString));
37+
}
38+
}
3139
assertEquals(DECRYPTED_PASSWORD_VALUE, properties.getProperty(PASSWORD_KEY));
3240
}
3341

pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>org.technologybrewery</groupId>
55
<artifactId>parent</artifactId>
6-
<version>9</version>
6+
<version>10</version>
77
</parent>
88

99
<modelVersion>4.0.0</modelVersion>
@@ -47,7 +47,6 @@
4747
<connection>scm:git:ssh://git@github.com/TechnologyBrewery/krausening.git</connection>
4848
<developerConnection>scm:git:ssh://git@github.com/TechnologyBrewery/krausening.git</developerConnection>
4949
<url>https://github.com/TechnologyBrewery/krausening</url>
50-
<tag>krausening-root-16</tag>
5150
</scm>
5251

5352
<modules>
@@ -61,7 +60,7 @@
6160
<plugin>
6261
<groupId>org.technologybrewery.habushu</groupId>
6362
<artifactId>habushu-maven-plugin</artifactId>
64-
<version>2.15.0</version>
63+
<version>2.16.1</version>
6564
<extensions>true</extensions>
6665
</plugin>
6766
</plugins>

0 commit comments

Comments
 (0)