Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit fb4cbf3

Browse files
committed
Refactor runtime version IT checks; add logging to boost properties loading
Signed-off-by: Scott Kurz <[email protected]>
1 parent cc58656 commit fb4cbf3

File tree

2 files changed

+42
-23
lines changed

2 files changed

+42
-23
lines changed

boost-common/src/main/java/org/microshed/boost/common/config/BoostProperties.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ public static Properties getConfiguredBoostProperties(Properties projectProperti
6868
if (entry.getKey().toString().startsWith(BOOST_PROP_PREFIX)
6969
|| entry.getKey().toString().equals(LIBERTY_VERSION)) {
7070

71-
// logger.debug("Found boost property: " +
72-
// entry.getKey() + ":" + entry.getValue());
73-
71+
logger.debug("Found boost property: " + entry.getKey() + ":" + entry.getValue());
7472
boostProperties.put(entry.getKey(), entry.getValue());
7573
}
7674
}
@@ -80,9 +78,7 @@ public static Properties getConfiguredBoostProperties(Properties projectProperti
8078
if (entry.getKey().toString().startsWith(BOOST_PROP_PREFIX)
8179
|| entry.getKey().toString().equals(LIBERTY_VERSION)) {
8280

83-
// logger.debug("Found boost property: " +
84-
// entry.getKey() + ":" + entry.getValue());
85-
81+
logger.debug("Found boost property: " + entry.getKey() + ":" + entry.getValue());
8682
boostProperties.put(entry.getKey(), entry.getValue());
8783
}
8884
}

boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.0/src/test/java/it/LibertyFeatureVersionIT.java

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
import java.io.BufferedReader;
1616
import java.io.File;
1717
import java.io.FileReader;
18+
import java.io.IOException;
1819
import java.util.Arrays;
1920
import java.io.FileInputStream;
21+
import java.io.FileNotFoundException;
2022
import java.util.Properties;
2123

2224
import org.junit.BeforeClass;
@@ -39,13 +41,17 @@
3941
import org.eclipse.aether.transport.http.HttpTransporterFactory;
4042
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
4143

44+
import org.apache.commons.logging.Log;
45+
import org.apache.commons.logging.LogFactory;
46+
4247
public class LibertyFeatureVersionIT {
4348

4449
private static final String JAXRS_20_FEATURE = "<feature>jaxrs-2.0</feature>";
4550
private static String SERVER_XML = "target/liberty/wlp/usr/servers/defaultServer/server.xml";
4651
private static String LIBERTY_PROPERTIES = "target/liberty/wlp/lib/versions/openliberty.properties";
4752
private static String LIBERTY_VERSION = "com.ibm.websphere.productVersion";
4853
private static String runtimeVersion;
54+
private final static Log log = LogFactory.getLog(LibertyFeatureVersionIT.class);
4955

5056
@BeforeClass
5157
public static void init() {
@@ -60,7 +66,7 @@ public static void init() {
6066
* messages.log file when the server is run. Only used when no libertyRunTime
6167
* version is provided.
6268
*/
63-
private String getLatesLibertyRuntimeVersion() {
69+
private String getLatestLibertyRuntimeVersion() {
6470
String libertyVersion = null;
6571

6672
RemoteRepository central = new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/")
@@ -126,17 +132,38 @@ public void testLibertyFeatureVersion() throws Exception {
126132
@Test
127133
public void testLibertyRuntimeVersion() throws Exception {
128134

129-
boolean found = false;
135+
String installedVersion = getLibertyVersionPropertyFromInstall();
130136

131137
if (runtimeVersion == null) {
132-
// This relies on a scan of the maven repository to find the lastest version of
133-
// liberty installed. Not sure what subtle issues this might cause.
134-
// if there are issues matching the runtime versions then
135-
// this may be the culprit and not actually a Boost issue.
136-
runtimeVersion = getLatesLibertyRuntimeVersion();
138+
139+
// The getLatestLibertyRuntimeVersion() relies on a scan of the maven repository
140+
// to find the latest version of liberty available, possibly remotely.
141+
//
142+
// Not sure what subtle issues this might cause. If there are issues matching
143+
// the runtime versions then this may be the culprit and not actually a Boost
144+
// issue.
145+
String expectedVersion = getLatestLibertyRuntimeVersion();
146+
147+
log.info("Found installed version = " + installedVersion
148+
+ ". From Boost we defaulted the runtime version (to the latest). According to the test logic the latest version available is: "
149+
+ expectedVersion);
150+
151+
String assertMsg = "Expected default runtime version not found in installed Liberty properties file. This may be because the "
152+
+ "default to latest version algorithm produced subtly different results when it was called from the runtime code "
153+
+ "vs. the test code trying to validate that the latest was used. As such, this may not be a boost issue, but an "
154+
+ "implementation detail of the underlying Maven APIs.";
155+
assertEquals(assertMsg, expectedVersion, installedVersion);
156+
} else {
157+
158+
log.info("Found installed version = " + installedVersion + ", looking for runtime version = "
159+
+ runtimeVersion);
160+
161+
assertEquals("Didn't find expected runtime version in product install properties file", runtimeVersion,
162+
installedVersion);
137163
}
138-
String assertMsg = "Runtime version is null. This may be an issue with checking for the latest runtime version from maven and may not be a boost issue";
139-
assertNotNull(assertMsg, runtimeVersion);
164+
}
165+
166+
private String getLibertyVersionPropertyFromInstall() throws FileNotFoundException, IOException {
140167

141168
Properties libertyProps = new Properties();
142169
String propsRuntime = null;
@@ -145,19 +172,15 @@ public void testLibertyRuntimeVersion() throws Exception {
145172
fis = new FileInputStream(LIBERTY_PROPERTIES);
146173
libertyProps.load(fis);
147174
propsRuntime = libertyProps.getProperty(LIBERTY_VERSION);
148-
assertNotNull("Property runtime empty", propsRuntime);
149-
if (propsRuntime.equals(runtimeVersion)) {
150-
found = true;
151-
}
152175
} finally {
153176
if (fis != null) {
154177
fis.close();
155178
}
156179
}
157-
assertMsg = "The run time version " + runtimeVersion
158-
+ " was not found in the openliberty.properties. openliberty.properties version = " + propsRuntime
159-
+ ". This may be an issue with checking for the latest runtime version from maven and may not be a boost issue";
180+
assertNotNull("Didn't find property: " + LIBERTY_VERSION + " in file: " + LIBERTY_PROPERTIES, propsRuntime);
181+
assertNotEquals("Found empty-valued property: " + LIBERTY_VERSION + " in file: " + LIBERTY_PROPERTIES, "",
182+
propsRuntime);
160183

161-
assertTrue(assertMsg, found);
184+
return propsRuntime;
162185
}
163186
}

0 commit comments

Comments
 (0)