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

Commit

Permalink
Refactor runtime version IT checks; add logging to boost properties l…
Browse files Browse the repository at this point in the history
…oading

Signed-off-by: Scott Kurz <[email protected]>
  • Loading branch information
scottkurz committed Sep 25, 2019
1 parent cc58656 commit fb4cbf3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ public static Properties getConfiguredBoostProperties(Properties projectProperti
if (entry.getKey().toString().startsWith(BOOST_PROP_PREFIX)
|| entry.getKey().toString().equals(LIBERTY_VERSION)) {

// logger.debug("Found boost property: " +
// entry.getKey() + ":" + entry.getValue());

logger.debug("Found boost property: " + entry.getKey() + ":" + entry.getValue());
boostProperties.put(entry.getKey(), entry.getValue());
}
}
Expand All @@ -80,9 +78,7 @@ public static Properties getConfiguredBoostProperties(Properties projectProperti
if (entry.getKey().toString().startsWith(BOOST_PROP_PREFIX)
|| entry.getKey().toString().equals(LIBERTY_VERSION)) {

// logger.debug("Found boost property: " +
// entry.getKey() + ":" + entry.getValue());

logger.debug("Found boost property: " + entry.getKey() + ":" + entry.getValue());
boostProperties.put(entry.getKey(), entry.getValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Properties;

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

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class LibertyFeatureVersionIT {

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

@BeforeClass
public static void init() {
Expand All @@ -60,7 +66,7 @@ public static void init() {
* messages.log file when the server is run. Only used when no libertyRunTime
* version is provided.
*/
private String getLatesLibertyRuntimeVersion() {
private String getLatestLibertyRuntimeVersion() {
String libertyVersion = null;

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

boolean found = false;
String installedVersion = getLibertyVersionPropertyFromInstall();

if (runtimeVersion == null) {
// This relies on a scan of the maven repository to find the lastest version of
// liberty installed. Not sure what subtle issues this might cause.
// if there are issues matching the runtime versions then
// this may be the culprit and not actually a Boost issue.
runtimeVersion = getLatesLibertyRuntimeVersion();

// The getLatestLibertyRuntimeVersion() relies on a scan of the maven repository
// to find the latest version of liberty available, possibly remotely.
//
// Not sure what subtle issues this might cause. If there are issues matching
// the runtime versions then this may be the culprit and not actually a Boost
// issue.
String expectedVersion = getLatestLibertyRuntimeVersion();

log.info("Found installed version = " + installedVersion
+ ". From Boost we defaulted the runtime version (to the latest). According to the test logic the latest version available is: "
+ expectedVersion);

String assertMsg = "Expected default runtime version not found in installed Liberty properties file. This may be because the "
+ "default to latest version algorithm produced subtly different results when it was called from the runtime code "
+ "vs. the test code trying to validate that the latest was used. As such, this may not be a boost issue, but an "
+ "implementation detail of the underlying Maven APIs.";
assertEquals(assertMsg, expectedVersion, installedVersion);
} else {

log.info("Found installed version = " + installedVersion + ", looking for runtime version = "
+ runtimeVersion);

assertEquals("Didn't find expected runtime version in product install properties file", runtimeVersion,
installedVersion);
}
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";
assertNotNull(assertMsg, runtimeVersion);
}

private String getLibertyVersionPropertyFromInstall() throws FileNotFoundException, IOException {

Properties libertyProps = new Properties();
String propsRuntime = null;
Expand All @@ -145,19 +172,15 @@ public void testLibertyRuntimeVersion() throws Exception {
fis = new FileInputStream(LIBERTY_PROPERTIES);
libertyProps.load(fis);
propsRuntime = libertyProps.getProperty(LIBERTY_VERSION);
assertNotNull("Property runtime empty", propsRuntime);
if (propsRuntime.equals(runtimeVersion)) {
found = true;
}
} finally {
if (fis != null) {
fis.close();
}
}
assertMsg = "The run time version " + runtimeVersion
+ " was not found in the openliberty.properties. openliberty.properties version = " + propsRuntime
+ ". This may be an issue with checking for the latest runtime version from maven and may not be a boost issue";
assertNotNull("Didn't find property: " + LIBERTY_VERSION + " in file: " + LIBERTY_PROPERTIES, propsRuntime);
assertNotEquals("Found empty-valued property: " + LIBERTY_VERSION + " in file: " + LIBERTY_PROPERTIES, "",
propsRuntime);

assertTrue(assertMsg, found);
return propsRuntime;
}
}

0 comments on commit fb4cbf3

Please sign in to comment.