diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/AbstractBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/AbstractBoosterConfig.java index acfe895c..cd094850 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/AbstractBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/AbstractBoosterConfig.java @@ -19,6 +19,7 @@ import java.util.List; import org.microshed.boost.common.BoostException; +import org.microshed.boost.common.BoostLoggerI; /** * Interface to describe common function across all technology Booster Pack @@ -62,6 +63,7 @@ public abstract class AbstractBoosterConfig { public static final String MP_RESTCLIENT_VERSION_11 = "1.1" + boostVersion + emptyString; public static final String MP_RESTCLIENT_VERSION_12 = "1.2" + boostVersion + emptyString; public static final String MP_RESTCLIENT_VERSION_13 = "1.3" + boostVersion + emptyString; + protected BoostLoggerI logger; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @@ -81,8 +83,10 @@ public static String getCoordinates(Class klass) throws BoostException { private final String version; - protected AbstractBoosterConfig(String version) { + protected AbstractBoosterConfig(String version, BoostLoggerI logger) { this.version = version; + this.logger = logger; + } /** diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/BeanValidationBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/BeanValidationBoosterConfig.java index 7ad184fe..a256f7ea 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/BeanValidationBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/BeanValidationBoosterConfig.java @@ -22,7 +22,7 @@ public class BeanValidationBoosterConfig extends AbstractBoosterConfig { public BeanValidationBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(BeanValidationBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(BeanValidationBoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/CDIBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/CDIBoosterConfig.java index bc71c105..768ad52e 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/CDIBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/CDIBoosterConfig.java @@ -22,7 +22,7 @@ public class CDIBoosterConfig extends AbstractBoosterConfig { public CDIBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(CDIBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(CDIBoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/JAXRSBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/JAXRSBoosterConfig.java index 157d8515..5d9c487c 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/JAXRSBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/JAXRSBoosterConfig.java @@ -22,7 +22,7 @@ public class JAXRSBoosterConfig extends AbstractBoosterConfig { public JAXRSBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(JAXRSBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(JAXRSBoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/JDBCBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/JDBCBoosterConfig.java index d560c7af..f9806743 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/JDBCBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/JDBCBoosterConfig.java @@ -58,7 +58,7 @@ public class JDBCBoosterConfig extends AbstractBoosterConfig { private Map driverInfo; public JDBCBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(JDBCBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(JDBCBoosterConfig.class)), logger); this.logger = logger; @@ -122,11 +122,13 @@ public Properties getDatasourceProperties() { // Verify correct property configuration if (dependency.contains(DERBY_GROUP_ID)) { - // If there's no DB name and there's no server name then we can create an embedded DB at a default location - if ((!datasourceProperties.containsKey(BoostProperties.DATASOURCE_DATABASE_NAME)) && - (!datasourceProperties.containsKey(BoostProperties.DATASOURCE_SERVER_NAME))) { + // If there's no DB name and there's no server name then we can create an + // embedded DB at a default location + if ((!datasourceProperties.containsKey(BoostProperties.DATASOURCE_DATABASE_NAME)) + && (!datasourceProperties.containsKey(BoostProperties.DATASOURCE_SERVER_NAME))) { datasourceProperties.put(BoostProperties.DATASOURCE_DATABASE_NAME, DERBY_DB); - // Though we want to auto-create our default location DB, I guess if someone already specified a property will honor it + // Though we want to auto-create our default location DB, I guess if someone + // already specified a property will honor it // even though not sure how useful that would be. if (!datasourceProperties.containsKey(BoostProperties.DATASOURCE_CREATE_DATABASE)) { datasourceProperties.put(BoostProperties.DATASOURCE_CREATE_DATABASE, "create"); diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/JPABoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/JPABoosterConfig.java index ba2c1e6e..a2da3d50 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/JPABoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/JPABoosterConfig.java @@ -22,7 +22,7 @@ public class JPABoosterConfig extends AbstractBoosterConfig { public JPABoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(JPABoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(JPABoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/JSONBBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/JSONBBoosterConfig.java index fb3c5702..4da9445d 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/JSONBBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/JSONBBoosterConfig.java @@ -22,7 +22,7 @@ public class JSONBBoosterConfig extends AbstractBoosterConfig { public JSONBBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(JSONBBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(JSONBBoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/JSONPBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/JSONPBoosterConfig.java index 499150cd..a0bde4e1 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/JSONPBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/JSONPBoosterConfig.java @@ -22,7 +22,7 @@ public class JSONPBoosterConfig extends AbstractBoosterConfig { public JSONPBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(JSONPBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(JSONPBoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPConfigBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPConfigBoosterConfig.java index 01a8d8e7..589b7f0d 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPConfigBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPConfigBoosterConfig.java @@ -22,7 +22,7 @@ public class MPConfigBoosterConfig extends AbstractBoosterConfig { public MPConfigBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(MPConfigBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(MPConfigBoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPFaultToleranceBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPFaultToleranceBoosterConfig.java index 486f5fc2..d00019c9 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPFaultToleranceBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPFaultToleranceBoosterConfig.java @@ -22,7 +22,7 @@ public class MPFaultToleranceBoosterConfig extends AbstractBoosterConfig { public MPFaultToleranceBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(MPFaultToleranceBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(MPFaultToleranceBoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPHealthBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPHealthBoosterConfig.java index 447bccae..780a965b 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPHealthBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPHealthBoosterConfig.java @@ -22,7 +22,7 @@ public class MPHealthBoosterConfig extends AbstractBoosterConfig { public MPHealthBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(MPHealthBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(MPHealthBoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPJWTBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPJWTBoosterConfig.java index fa480abd..7a6a72ec 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPJWTBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPJWTBoosterConfig.java @@ -23,7 +23,7 @@ public class MPJWTBoosterConfig extends AbstractBoosterConfig { public MPJWTBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(MPJWTBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(MPJWTBoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPMetricsBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPMetricsBoosterConfig.java index 70735d07..803a2539 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPMetricsBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPMetricsBoosterConfig.java @@ -22,7 +22,7 @@ public class MPMetricsBoosterConfig extends AbstractBoosterConfig { public MPMetricsBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(MPMetricsBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(MPMetricsBoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPOpenAPIBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPOpenAPIBoosterConfig.java index df350a41..10559e30 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPOpenAPIBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPOpenAPIBoosterConfig.java @@ -22,7 +22,7 @@ public class MPOpenAPIBoosterConfig extends AbstractBoosterConfig { public MPOpenAPIBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(MPOpenAPIBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(MPOpenAPIBoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPOpenTracingBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPOpenTracingBoosterConfig.java index 4a9473fe..dd526ac4 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPOpenTracingBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPOpenTracingBoosterConfig.java @@ -22,7 +22,7 @@ public class MPOpenTracingBoosterConfig extends AbstractBoosterConfig { public MPOpenTracingBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(MPOpenTracingBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(MPOpenTracingBoosterConfig.class)), logger); } @Override diff --git a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPRestClientBoosterConfig.java b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPRestClientBoosterConfig.java index 92be919f..7556898b 100644 --- a/boost-common/src/main/java/org/microshed/boost/common/boosters/MPRestClientBoosterConfig.java +++ b/boost-common/src/main/java/org/microshed/boost/common/boosters/MPRestClientBoosterConfig.java @@ -22,7 +22,7 @@ public class MPRestClientBoosterConfig extends AbstractBoosterConfig { public MPRestClientBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { - super(params.getProjectDependencies().get(getCoordinates(MPRestClientBoosterConfig.class))); + super(params.getProjectDependencies().get(getCoordinates(MPRestClientBoosterConfig.class)), logger); } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/LibertyServerConfigGenerator.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/LibertyServerConfigGenerator.java index de1f4844..6a671e73 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/LibertyServerConfigGenerator.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/LibertyServerConfigGenerator.java @@ -40,6 +40,7 @@ import org.microshed.boost.common.boosters.JDBCBoosterConfig; import org.microshed.boost.common.config.BoostProperties; import org.microshed.boost.common.utils.BoostUtil; +import org.microshed.boost.common.BoostException; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -118,12 +119,16 @@ private void generateVariablesXml() throws ParserConfigurationException { * Add a Liberty feature to the server configuration * */ - public void addFeature(String featureName) { - if (!featuresAdded.contains(featureName)) { - Element feature = serverXml.createElement(FEATURE); - feature.appendChild(serverXml.createTextNode(featureName)); - featureManager.appendChild(feature); - featuresAdded.add(featureName); + public void addFeature(String featureName) throws BoostException { + if (featureName != null) { + if (!featuresAdded.contains(featureName)) { + Element feature = serverXml.createElement(FEATURE); + feature.appendChild(serverXml.createTextNode(featureName)); + featureManager.appendChild(feature); + featuresAdded.add(featureName); + } + } else { + throw new BoostException("Request to add feature failed"); } } @@ -131,7 +136,7 @@ public void addFeature(String featureName) { * Add a list of features to the server configuration * */ - public void addFeatures(List features) { + public void addFeatures(List features) throws BoostException { for (String featureName : features) { addFeature(featureName); @@ -139,8 +144,7 @@ public void addFeatures(List features) { } /** - * Write the server.xml and bootstrap.properties to the server config - * directory + * Write the server.xml and bootstrap.properties to the server config directory * * @throws TransformerException * @throws IOException diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyBeanValidationBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyBeanValidationBoosterConfig.java index 3366b787..72fa73d2 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyBeanValidationBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyBeanValidationBoosterConfig.java @@ -21,17 +21,22 @@ public class LibertyBeanValidationBoosterConfig extends BeanValidationBoosterConfig implements LibertyBoosterI { - public LibertyBeanValidationBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) - throws BoostException { + public LibertyBeanValidationBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException { super(params, logger); } - public String getFeature() { + public String getFeature() throws BoostException { + + String feature = null; if (getVersion().startsWith(BEANVALIDATION_VERSION_20)) { - return BEANVALIDATION_20; - } else { - return null; + feature = BEANVALIDATION_20; + } + if (feature == null) { + String msg = "Invalid version " + getVersion() + " returned. Expected " + BEANVALIDATION_VERSION_20 + + "\n Unable to add Feature " + BEANVALIDATION_20 + " to the server configuration"; + throw new BoostException(msg); } + return feature; } public void addServerConfig(LibertyServerConfigGenerator libertyServerConfigGenerator) { diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyBoosterI.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyBoosterI.java index d35d5e91..6cba8f39 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyBoosterI.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyBoosterI.java @@ -15,6 +15,7 @@ public interface LibertyBoosterI { - public String getFeature(); + public String getFeature() throws BoostException; + public void addServerConfig(LibertyServerConfigGenerator libertyServerConfigGenerator) throws BoostException; } \ No newline at end of file diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyCDIBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyCDIBoosterConfig.java index 95410319..999b7b90 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyCDIBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyCDIBoosterConfig.java @@ -25,19 +25,23 @@ public LibertyCDIBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) super(params, logger); } - public String getFeature() { + public String getFeature() throws BoostException { + + String feature = null; if (getVersion().startsWith(CDI_VERSION_20)) { - return CDI_20; - } - if (getVersion().startsWith(CDI_VERSION_12)) { - return CDI_12; + feature = CDI_20; + } else if (getVersion().startsWith(CDI_VERSION_12)) { + feature = CDI_12; } - else { - return null; + if (feature == null) { + String msg = "Invalid version " + getVersion() + " returned. Expected " + CDI_VERSION_20 + " or " + + CDI_VERSION_12 + "\n Unable to add " + CDI_20 + " or " + CDI_12 + " to the server configuration"; + throw new BoostException(msg); } + return feature; } public void addServerConfig(LibertyServerConfigGenerator libertyServerConfigGenerator) { - + } } \ No newline at end of file diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJAXRSBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJAXRSBoosterConfig.java index 73032a3b..2541588b 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJAXRSBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJAXRSBoosterConfig.java @@ -27,13 +27,20 @@ public LibertyJAXRSBoosterConfig(BoosterConfigParams params, BoostLoggerI logger } @Override - public String getFeature() { + public String getFeature() throws BoostException { + + String feature = null; if (getVersion().startsWith(JAXRS_VERSION_20)) { - return JAXRS_20; + feature = JAXRS_20; } else if (getVersion().startsWith(JAXRS_VERSION_21)) { - return JAXRS_21; + feature = JAXRS_21; + } + if (feature == null) { + String msg = "Invalid version " + getVersion() + " returned. Expected " + JAXRS_VERSION_20 + " or " + + JAXRS_VERSION_21; + throw new BoostException(msg); } - return null; + return feature; } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJPABoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJPABoosterConfig.java index 08bd2e5c..b9857e64 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJPABoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJPABoosterConfig.java @@ -27,13 +27,22 @@ public LibertyJPABoosterConfig(BoosterConfigParams params, BoostLoggerI logger) } @Override - public String getFeature() { + public String getFeature() throws BoostException { + + String feature = null; if (getVersion().startsWith(JPA_VERSION_21)) { - return JPA_21; + feature = JPA_21; } else if (getVersion().startsWith(JPA_VERSION_22)) { - return JPA_22; + feature = JPA_22; + } + + if (feature == null) { + String msg = "Invalid version " + getVersion() + " returned. Expected " + JPA_VERSION_21 + " or " + + JPA_VERSION_22 + ".\n Unable to add feature " + JPA_21 + " or " + JPA_22 + + " to the server configuration"; + throw new BoostException(msg); } - return null; + return feature; } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJSONBBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJSONBBoosterConfig.java index e04c43b2..6b95eb2a 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJSONBBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJSONBBoosterConfig.java @@ -26,11 +26,17 @@ public LibertyJSONBBoosterConfig(BoosterConfigParams params, BoostLoggerI logger } @Override - public String getFeature() { + public String getFeature() throws BoostException { + String feature = null; if (getVersion().startsWith(JSONB_VERSION_10)) { - return JSONB_10; + feature = JSONB_10; } - return null; + if (feature == null) { + String msg = "Invalid version " + getVersion() + " returned. Expected " + JSONB_VERSION_10 + + ".\n Unable to add feature " + JSONB_10 + " to the server configuration"; + throw new BoostException(msg); + } + return feature; } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJSONPBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJSONPBoosterConfig.java index 2e72176d..332b5aff 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJSONPBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyJSONPBoosterConfig.java @@ -26,14 +26,21 @@ public LibertyJSONPBoosterConfig(BoosterConfigParams params, BoostLoggerI logger } @Override - public String getFeature() { + public String getFeature() throws BoostException { + + String feature = null; if (getVersion().startsWith(JSONP_VERSION_10)) { - return JSONP_10; + feature = JSONP_10; + } else if (getVersion().startsWith(JSONP_VERSION_11)) { + feature = JSONP_11; } - else if (getVersion().startsWith(JSONP_VERSION_11)) { - return JSONP_11; + if (feature == null) { + String msg = "Invalid version " + getVersion() + " returned. Expected " + JSONP_VERSION_10 + " or " + + JSONP_VERSION_11 + ".\n Unable to add feature " + JSONP_10 + " or " + JSONP_11 + + " to the server configuration"; + throw new BoostException(msg); } - return null; + return feature; } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPConfigBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPConfigBoosterConfig.java index 00f707da..221caa35 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPConfigBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPConfigBoosterConfig.java @@ -26,11 +26,18 @@ public LibertyMPConfigBoosterConfig(BoosterConfigParams params, BoostLoggerI log } @Override - public String getFeature() { + public String getFeature() throws BoostException { + + String feature = null; if (getVersion().startsWith(MP_CONFIG_VERSION_13)) { - return MPCONFIG_13; + feature = MPCONFIG_13; + } + if (feature == null) { + String msg = "Invalid version " + getVersion() + " returned. Expected " + MP_CONFIG_VERSION_13 + + ".\n Unable to add feature " + MP_CONFIG_VERSION_13 + " to the server configuration"; + throw new BoostException(msg); } - return null; + return feature; } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPFaultToleranceBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPFaultToleranceBoosterConfig.java index a8d60394..57cbae29 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPFaultToleranceBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPFaultToleranceBoosterConfig.java @@ -26,14 +26,21 @@ public LibertyMPFaultToleranceBoosterConfig(BoosterConfigParams params, BoostLog } @Override - public String getFeature() { + public String getFeature() throws BoostException { + + String feature = null; if (getVersion().startsWith(MP_FAULTTOLERANCE_VERSION_11)) { - return MPFAULTTOLERANCE_11; + feature = MPFAULTTOLERANCE_11; } else if (getVersion().startsWith(MP_FAULTTOLERANCE_VERSION_20)) { - return MPFAULTTOLERANCE_20; + feature = MPFAULTTOLERANCE_20; } - - return null; + if (feature == null) { + String msg = "Invalid version " + getVersion() + " returned. Expected " + MP_FAULTTOLERANCE_VERSION_11 + + " or " + MP_FAULTTOLERANCE_VERSION_20 + ".\n Unable to add feature " + MPFAULTTOLERANCE_11 + + " or " + MPFAULTTOLERANCE_20 + " to the server configuration"; + throw new BoostException(msg); + } + return feature; } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPHealthBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPHealthBoosterConfig.java index 8ad8f35e..a36ead45 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPHealthBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPHealthBoosterConfig.java @@ -26,16 +26,22 @@ public LibertyMPHealthBoosterConfig(BoosterConfigParams params, BoostLoggerI log } @Override - public String getFeature() { + public String getFeature() throws BoostException { + String feature = null; String version = getVersion(); if (version.startsWith(MP_HEALTH_VERSION_10)) { - return MPHEALTH_10; + feature = MPHEALTH_10; } else if (version.startsWith(MP_HEALTH_VERSION_20)) { - return MPHEALTH_20; + feature = MPHEALTH_20; } - - return null; + if (feature == null) { + String msg = "Invalid version " + getVersion() + "returned. Expected " + MP_HEALTH_VERSION_10 + " or " + + MP_HEALTH_VERSION_20 + ".\n Unable to add feature " + MPHEALTH_10 + " or " + MPHEALTH_20 + + " to the server configuration"; + throw new BoostException(msg); + } + return feature; } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPJWTBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPJWTBoosterConfig.java index 7932b88f..2c8cac2b 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPJWTBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPJWTBoosterConfig.java @@ -29,11 +29,18 @@ public LibertyMPJWTBoosterConfig(BoosterConfigParams params, BoostLoggerI logger } @Override - public String getFeature() { + public String getFeature() throws BoostException { + + String feature = null; if (getVersion().startsWith(MP_JWT_VERSION_11)) { - return MPJWT_11; + feature = MPJWT_11; + } + if (feature == null) { + String msg = "Invalid version " + getVersion() + " returned. Expected " + MP_JWT_VERSION_11 + + ".\n Unable to add feature " + MPJWT_11 + " to the server configuration"; + throw new BoostException(msg); } - return null; + return feature; } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPMetricsBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPMetricsBoosterConfig.java index ca6ebb82..07fa8768 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPMetricsBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPMetricsBoosterConfig.java @@ -29,15 +29,22 @@ public LibertyMPMetricsBoosterConfig(BoosterConfigParams params, BoostLoggerI lo } @Override - public String getFeature() { + public String getFeature() throws BoostException { String version = getVersion(); + String feature = null; if (version.startsWith(MP_METRICS_VERSION_11)) { - return MPMETRICS_11; + feature = MPMETRICS_11; } else if (version.startsWith(MP_METRICS_VERSION_20)) { - return MPMETRICS_20; + feature = MPMETRICS_20; } - return null; + if (feature == null) { + String msg = "Invalid version " + getVersion() + " returned. Expected " + MP_METRICS_VERSION_11 + " or " + + MP_METRICS_VERSION_20 + ".\n Unable to add feature " + MPMETRICS_11 + " or " + MPMETRICS_20 + + " to the server configuration"; + throw new BoostException(msg); + } + return feature; } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPOpenAPIBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPOpenAPIBoosterConfig.java index 7d9891ca..dece6e4c 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPOpenAPIBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPOpenAPIBoosterConfig.java @@ -26,14 +26,20 @@ public LibertyMPOpenAPIBoosterConfig(BoosterConfigParams params, BoostLoggerI lo } @Override - public String getFeature() { + public String getFeature() throws BoostException { + String feature = null; if (getVersion().startsWith(MP_OPENAPI_VERSION_10)) { - return MPOPENAPI_10; + feature = MPOPENAPI_10; } else if (getVersion().startsWith(MP_OPENAPI_VERSION_11)) { - return MPOPENAPI_11; + feature = MPOPENAPI_11; } - - return null; + if (feature == null) { + String msg = "Invalid version " + getVersion() + " returned. Expected " + MP_OPENAPI_VERSION_10 + " or " + + MP_OPENAPI_VERSION_11 + ".\n Unable to add feature " + MPOPENAPI_10 + " or " + MPOPENAPI_11 + + " to the server configuration"; + throw new BoostException(msg); + } + return feature; } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPOpenTracingBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPOpenTracingBoosterConfig.java index 4b73b721..a9917008 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPOpenTracingBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPOpenTracingBoosterConfig.java @@ -26,16 +26,24 @@ public LibertyMPOpenTracingBoosterConfig(BoosterConfigParams params, BoostLogger } @Override - public String getFeature() { + public String getFeature() throws BoostException { + String feature = null; if (getVersion().startsWith(MP_OPENTRACING_VERSION_11)) { - return MPOPENTRACING_11; + feature = MPOPENTRACING_11; } else if (getVersion().startsWith(MP_OPENTRACING_VERSION_12)) { - return MPOPENTRACING_12; + feature = MPOPENTRACING_12; } else if (getVersion().startsWith(MP_OPENTRACING_VERSION_13)) { - return MPOPENTRACING_13; + feature = MPOPENTRACING_13; } + if (feature == null) { + String msg = "Invalid version " + getVersion() + " feature = ed. Expected " + MP_OPENTRACING_VERSION_11 + + ", " + MP_OPENTRACING_VERSION_12 + " or " + MP_OPENTRACING_VERSION_13 + + ".\n Unable to add feature " + MPOPENTRACING_11 + ", " + MPOPENTRACING_12 + " or " + + MPOPENTRACING_13 + " to the server configuration"; + throw new BoostException(msg); + } + return feature; - return null; } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPRestClientBoosterConfig.java b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPRestClientBoosterConfig.java index a9df31d3..3f711f0c 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPRestClientBoosterConfig.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/main/java/org/microshed/boost/runtimes/openliberty/boosters/LibertyMPRestClientBoosterConfig.java @@ -26,16 +26,25 @@ public LibertyMPRestClientBoosterConfig(BoosterConfigParams params, BoostLoggerI } @Override - public String getFeature() { + public String getFeature() throws BoostException { + + String feature = null; if (getVersion().startsWith(MP_RESTCLIENT_VERSION_11)) { - return MPRESTCLIENT_11; + feature = MPRESTCLIENT_11; } else if (getVersion().startsWith(MP_RESTCLIENT_VERSION_12)) { - return MPRESTCLIENT_12; + feature = MPRESTCLIENT_12; } else if (getVersion().startsWith(MP_RESTCLIENT_VERSION_13)) { - return MPRESTCLIENT_13; + feature = MPRESTCLIENT_13; + } + if (feature == null) { + String msg = "Invalid version " + getVersion() + " returned. Expected " + MP_RESTCLIENT_VERSION_11 + ", " + + MP_RESTCLIENT_VERSION_12 + " or " + MP_RESTCLIENT_VERSION_13 + ".\n Unable to add feature " + + MPRESTCLIENT_11 + ", " + MPRESTCLIENT_12 + " or " + MPRESTCLIENT_13 + + " to the server configuration"; + throw new BoostException(msg); } - return null; + return feature; } @Override diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/BeanValidationBoosterTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/BeanValidationBoosterTest.java index 0ca92a3e..2de33d45 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/BeanValidationBoosterTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/BeanValidationBoosterTest.java @@ -21,6 +21,7 @@ import org.junit.Test; import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.BoostLoggerI; import org.microshed.boost.common.config.BoosterConfigParams; import org.microshed.boost.runtimes.openliberty.LibertyServerConfigGenerator; @@ -39,61 +40,75 @@ public class BeanValidationBoosterTest { BoostLoggerI logger = CommonLogger.getInstance(); - /** - * Test that the cdi-1.2 feature is added to server.xml when the CDI booster - * version is set to 1.2-M1-SNAPSHOT - * - */ - @Test - public void testBeanValidationBoosterFeature_20() throws Exception { + private void testBeanValidationBoosterFeature(String version, String feature) throws Exception { + boolean featureFound = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyBeanValidationBoosterConfig.class, "2.0-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyBeanValidationBoosterConfig.class, version); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyBeanValidationBoosterConfig libBeanValidationConfig = new LibertyBeanValidationBoosterConfig(params, logger); + try { + serverConfig.addFeature(libBeanValidationConfig.getFeature()); + serverConfig.writeToServer(); - serverConfig.addFeature(libBeanValidationConfig.getFeature()); - serverConfig.writeToServer(); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + feature + ""); + } catch (BoostException be) { - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + BEANVALIDATION_20 + ""); + } + assertTrue("The " + feature + " feature was not found in the server configuration", featureFound); - assertTrue("The " + BEANVALIDATION_20 + " feature was not found in the server configuration", featureFound); + } + /** + * Test that the cdi-1.2 feature is added to server.xml when the CDI booster + * version is set to 1.2-M1-SNAPSHOT + * + */ + @Test + public void testBeanValidationBoosterFeature_20() throws Exception { + testBeanValidationBoosterFeature("2.0-0.2.2-SNAPSHOT", BEANVALIDATION_20); } /** - * Test that the cdi-2.0 feature is added to server.xml when the CDI booster - * version is set to 2.0-M1-SNAPSHOT + * Test running with a bad version * */ @Test - public void testCDIBoosterFeature_20() throws Exception { + public void testBeanValidationBoosterFeature_20_bad_version() throws Exception { + boolean boostExceptionGenerated = false; + boolean featureFound = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); - Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyCDIBoosterConfig.class, "2.0-0.2.2-SNAPSHOT"); + Map dependencies = BoosterUtil.createDependenciesWithBoosterAndVersion( + LibertyBeanValidationBoosterConfig.class, "1.x-0.2.2-SNAPSHOT"); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); - LibertyCDIBoosterConfig libCDIConfig = new LibertyCDIBoosterConfig(params, logger); - - serverConfig.addFeature(libCDIConfig.getFeature()); - serverConfig.writeToServer(); - - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + CDI_20 + ""); - - assertTrue("The " + CDI_20 + " feature was not found in the server configuration", featureFound); + LibertyBeanValidationBoosterConfig libBeanValidationConfig = new LibertyBeanValidationBoosterConfig(params, + logger); + // Expect null pointer exception since the + try { + serverConfig.addFeature(libBeanValidationConfig.getFeature()); + serverConfig.writeToServer(); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, + "" + BEANVALIDATION_20 + ""); + } catch (BoostException be) { + if (be.toString().indexOf("Invalid version") >= 0) + boostExceptionGenerated = true; + } + + assertTrue("The " + BEANVALIDATION_20 + " feature was found in the server configuration", !featureFound); + assertTrue("No exception was generated while adding feature ", boostExceptionGenerated); } diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/CDIBoosterTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/CDIBoosterTest.java index 5ccb982f..acfce10c 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/CDIBoosterTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/CDIBoosterTest.java @@ -22,6 +22,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; import org.microshed.boost.common.BoostLoggerI; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.config.BoosterConfigParams; import org.microshed.boost.runtimes.openliberty.LibertyServerConfigGenerator; import org.microshed.boost.runtimes.openliberty.boosters.*; @@ -39,31 +40,38 @@ public class CDIBoosterTest { BoostLoggerI logger = CommonLogger.getInstance(); - /** - * Test that the cdi-1.2 feature is added to server.xml when the CDI booster - * version is set to 1.2-M1-SNAPSHOT - * - */ - @Test - public void testCDIBoosterFeature_12() throws Exception { + private void testCDIBoosterFeature(String version, String feature) throws Exception { + boolean featureFound = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyCDIBoosterConfig.class, "1.2-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyCDIBoosterConfig.class, version); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyCDIBoosterConfig libCDIConfig = new LibertyCDIBoosterConfig(params, logger); + try { + serverConfig.addFeature(libCDIConfig.getFeature()); + serverConfig.writeToServer(); - serverConfig.addFeature(libCDIConfig.getFeature()); - serverConfig.writeToServer(); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + feature + ""); + } catch (BoostException be) { + } - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + CDI_12 + ""); + assertTrue("The " + feature + " feature was not found in the server configuration", featureFound); - assertTrue("The " + CDI_12 + " feature was not found in the server configuration", featureFound); + } + /** + * Test that the cdi-1.2 feature is added to server.xml when the CDI booster + * version is set to 1.2-M1-SNAPSHOT + * + */ + @Test + public void testCDIBoosterFeature_12() throws Exception { + testCDIBoosterFeature("1.2-0.2.2-SNAPSHOT", CDI_12); } /** @@ -73,24 +81,38 @@ public void testCDIBoosterFeature_12() throws Exception { */ @Test public void testCDIBoosterFeature_20() throws Exception { + testCDIBoosterFeature("2.0-0.2.2-SNAPSHOT", CDI_20); + } + /** + * Test when incorrect version is passed. + */ + @Test + public void testCDIBoosterFeature_12_bad_version() throws Exception { + + boolean boostExceptionGenerated = false; + boolean featureFound = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyCDIBoosterConfig.class, "2.0-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyCDIBoosterConfig.class, "1.x-0.2.2-SNAPSHOT"); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyCDIBoosterConfig libCDIConfig = new LibertyCDIBoosterConfig(params, logger); - serverConfig.addFeature(libCDIConfig.getFeature()); - serverConfig.writeToServer(); + try { + serverConfig.addFeature(libCDIConfig.getFeature()); + serverConfig.writeToServer(); - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + CDI_20 + ""); - - assertTrue("The " + CDI_20 + " feature was not found in the server configuration", featureFound); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + CDI_12 + ""); + } catch (BoostException be) { + if (be.toString().indexOf("Invalid version") >= 0) + boostExceptionGenerated = true; + } + assertTrue("The " + CDI_12 + " feature was found in the server configuration", !featureFound); + assertTrue("No BoostException generated", boostExceptionGenerated); } - } diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/JAXRSBoosterTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/JAXRSBoosterTest.java index 98ffe8cd..d92ce65a 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/JAXRSBoosterTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/JAXRSBoosterTest.java @@ -22,6 +22,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; import org.microshed.boost.common.BoostLoggerI; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.config.BoosterConfigParams; import org.microshed.boost.runtimes.openliberty.LibertyServerConfigGenerator; import org.microshed.boost.runtimes.openliberty.boosters.*; @@ -39,31 +40,38 @@ public class JAXRSBoosterTest { BoostLoggerI logger = CommonLogger.getInstance(); - /** - * Test that the jaxrs-2.0 feature is added to server.xml when the jaxrs booster - * version is set to 2.0-M1-SNAPSHOT - * - */ - @Test - public void testJAXRSBoosterFeature20() throws Exception { + private void testJAXRSBoosterFeature(String version, String feature) throws Exception { + boolean featureFound = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyJAXRSBoosterConfig.class, "2.0-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyJAXRSBoosterConfig.class, version); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyJAXRSBoosterConfig libJAXRSConfig = new LibertyJAXRSBoosterConfig(params, logger); + try { + serverConfig.addFeature(libJAXRSConfig.getFeature()); + serverConfig.writeToServer(); - serverConfig.addFeature(libJAXRSConfig.getFeature()); - serverConfig.writeToServer(); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + feature + ""); + } catch (BoostException be) { + } - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + JAXRS_20 + ""); + assertTrue("The " + feature + " feature was not found in the server configuration", featureFound); - assertTrue("The " + JAXRS_20 + " feature was not found in the server configuration", featureFound); + } + /** + * Test that the jaxrs-2.0 feature is added to server.xml when the jaxrs booster + * version is set to 2.0-M1-SNAPSHOT + * + */ + @Test + public void testJAXRSBoosterFeature20() throws Exception { + testJAXRSBoosterFeature("2.0-0.2.2-SNAPSHOT", JAXRS_20); } /** @@ -73,24 +81,37 @@ public void testJAXRSBoosterFeature20() throws Exception { */ @Test public void testJAXRSBoosterFeature21() throws Exception { + testJAXRSBoosterFeature("2.1-0.2.2-SNAPSHOT", JAXRS_21); + } + + /* + * Test for failure when using incorrect version + */ + @Test + public void testJAXRSBoosterFeature21_bad_version() throws Exception { + boolean featureFound = false; + boolean boostExceptionGenerated = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyJAXRSBoosterConfig.class, "2.1-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyJAXRSBoosterConfig.class, "2.x-0.2.2-SNAPSHOT"); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyJAXRSBoosterConfig libJAXRSConfig = new LibertyJAXRSBoosterConfig(params, logger); - - serverConfig.addFeature(libJAXRSConfig.getFeature()); - serverConfig.writeToServer(); - - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + JAXRS_21 + ""); - - assertTrue("The " + JAXRS_21 + " feature was not found in the server configuration", featureFound); + try { + serverConfig.addFeature(libJAXRSConfig.getFeature()); + serverConfig.writeToServer(); + + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + JAXRS_21 + ""); + } catch (BoostException be) { + if (be.toString().indexOf("Invalid version") >= 0) + boostExceptionGenerated = true; + } + assertTrue("The " + JAXRS_21 + " feature was found in the server configuration", !featureFound); + assertTrue("No BoostException generated", boostExceptionGenerated); } - } diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/JSONBBoosterTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/JSONBBoosterTest.java index 4727fae5..7e2a6614 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/JSONBBoosterTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/JSONBBoosterTest.java @@ -22,6 +22,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; import org.microshed.boost.common.BoostLoggerI; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.config.BoosterConfigParams; import org.microshed.boost.runtimes.openliberty.LibertyServerConfigGenerator; import org.microshed.boost.runtimes.openliberty.boosters.*; @@ -39,6 +40,29 @@ public class JSONBBoosterTest { BoostLoggerI logger = CommonLogger.getInstance(); + private void testJSONBBoosterFeature(String version, String feature) throws Exception { + + boolean featureFound = false; + LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( + outputDir.getRoot().getAbsolutePath(), null, logger); + + Map dependencies = BoosterUtil + .createDependenciesWithBoosterAndVersion(LibertyJSONBBoosterConfig.class, version); + + BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); + LibertyJSONBBoosterConfig libJSONBConfig = new LibertyJSONBBoosterConfig(params, logger); + try { + serverConfig.addFeature(libJSONBConfig.getFeature()); + serverConfig.writeToServer(); + + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + feature + ""); + } catch (BoostException be) { + } + assertTrue("The " + feature + " feature was not found in the server configuration", featureFound); + + } + /** * Test that the jsonb-1.0 feature is added to server.xml when the jsonb booster * version is set to 0.2.2-SNAPSHOT @@ -46,23 +70,38 @@ public class JSONBBoosterTest { */ @Test public void testJSONBBoosterFeature10() throws Exception { + testJSONBBoosterFeature("1.0-0.2.2-SNAPSHOT", JSONB_10); + } + /* + * Test for Invalid version + */ + @Test + public void testJSONBBoosterFeature10_bad_version() throws Exception { + + boolean featureFound = false; + boolean boostExceptionGenerated = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyJSONBBoosterConfig.class, "1.0-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyJSONBBoosterConfig.class, "1.x-0.2.2-SNAPSHOT"); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyJSONBBoosterConfig libJSONBConfig = new LibertyJSONBBoosterConfig(params, logger); - - serverConfig.addFeature(libJSONBConfig.getFeature()); - serverConfig.writeToServer(); - - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + JSONB_10 + ""); - - assertTrue("The " + JSONB_10 + " feature was not found in the server configuration", featureFound); + try { + serverConfig.addFeature(libJSONBConfig.getFeature()); + serverConfig.writeToServer(); + + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + JSONB_10 + ""); + } catch (BoostException be) { + if (be.toString().indexOf("Invalid version") >= 0) + boostExceptionGenerated = true; + } + + assertTrue("The " + JSONB_10 + " feature was found in the server configuration", !featureFound); + assertTrue("No BoostException generated", boostExceptionGenerated); } diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/JSONPBoosterTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/JSONPBoosterTest.java index efe88c0d..0ba107fa 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/JSONPBoosterTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/JSONPBoosterTest.java @@ -22,6 +22,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; import org.microshed.boost.common.BoostLoggerI; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.config.BoosterConfigParams; import org.microshed.boost.runtimes.openliberty.LibertyServerConfigGenerator; import org.microshed.boost.runtimes.openliberty.boosters.*; @@ -39,31 +40,38 @@ public class JSONPBoosterTest { BoostLoggerI logger = CommonLogger.getInstance(); - /** - * Test that the jsonp-1.0 feature is added to server.xml when the jsonp booster - * version is set to 0.2.2-SNAPSHOT - * - */ - @Test - public void testJSONPBoosterFeature10() throws Exception { + private void testJSONPBoosterFeature(String version, String feature) throws Exception { + boolean featureFound = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyJSONPBoosterConfig.class, "1.0-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyJSONPBoosterConfig.class, version); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyJSONPBoosterConfig libJSONPConfig = new LibertyJSONPBoosterConfig(params, logger); + try { + serverConfig.addFeature(libJSONPConfig.getFeature()); + serverConfig.writeToServer(); - serverConfig.addFeature(libJSONPConfig.getFeature()); - serverConfig.writeToServer(); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + feature + ""); + } catch (BoostException be) { + } - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + JSONP_10 + ""); + assertTrue("The " + feature + " feature was not found in the server configuration", featureFound); - assertTrue("The " + JSONP_10 + " feature was not found in the server configuration", featureFound); + } + /** + * Test that the jsonp-1.0 feature is added to server.xml when the jsonp booster + * version is set to 0.2.2-SNAPSHOT + * + */ + @Test + public void testJSONPBoosterFeature10() throws Exception { + testJSONPBoosterFeature("1.0-0.2.2-SNAPSHOT", JSONP_10); } /** @@ -73,24 +81,36 @@ public void testJSONPBoosterFeature10() throws Exception { */ @Test public void testJSONPBoosterFeature11() throws Exception { + testJSONPBoosterFeature("1.1-0.2.2-SNAPSHOT", JSONP_11); + } + + /* + * Test using an invalid version + */ + @Test + public void testJSONPBoosterFeature11_bad_version() throws Exception { + boolean featureFound = false; + boolean boostExceptionGenerated = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyJSONPBoosterConfig.class, "1.1-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyJSONPBoosterConfig.class, "1.x-0.2.2-SNAPSHOT"); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyJSONPBoosterConfig libJSONPConfig = new LibertyJSONPBoosterConfig(params, logger); - - serverConfig.addFeature(libJSONPConfig.getFeature()); - serverConfig.writeToServer(); - - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + JSONP_11 + ""); - - assertTrue("The " + JSONP_11 + " feature was not found in the server configuration", featureFound); - + try { + serverConfig.addFeature(libJSONPConfig.getFeature()); + serverConfig.writeToServer(); + + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + JSONP_11 + ""); + } catch (BoostException be) { + if (be.toString().indexOf("Invalid version") >= 0) + boostExceptionGenerated = true; + } + assertTrue("The " + JSONP_11 + " feature was found in the server configuration", !featureFound); + assertTrue("No BoostException generated", boostExceptionGenerated); } - } diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPConfigBoosterTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPConfigBoosterTest.java index 3448584c..8632eb30 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPConfigBoosterTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPConfigBoosterTest.java @@ -22,6 +22,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; import org.microshed.boost.common.BoostLoggerI; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.config.BoosterConfigParams; import org.microshed.boost.runtimes.openliberty.LibertyServerConfigGenerator; import org.microshed.boost.runtimes.openliberty.boosters.*; @@ -39,6 +40,29 @@ public class MPConfigBoosterTest { BoostLoggerI logger = CommonLogger.getInstance(); + private void testMPConfigBoosterFeature(String version, String feature) throws Exception { + + boolean featureFound = false; + LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( + outputDir.getRoot().getAbsolutePath(), null, logger); + + Map dependencies = BoosterUtil + .createDependenciesWithBoosterAndVersion(LibertyMPConfigBoosterConfig.class, version); + + BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); + LibertyMPConfigBoosterConfig libMPConfigConfig = new LibertyMPConfigBoosterConfig(params, logger); + try { + serverConfig.addFeature(libMPConfigConfig.getFeature()); + serverConfig.writeToServer(); + + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + feature + ""); + } catch (BoostException be) { + } + assertTrue("The " + feature + " feature was not found in the server configuration", featureFound); + + } + /** * Test that the mpConfig-1.3 feature is added to server.xml when the MPConfig * booster version is set to 1.3-M1-SNAPSHOT @@ -46,25 +70,38 @@ public class MPConfigBoosterTest { */ @Test public void testMPConfigBoosterFeature13() throws Exception { + testMPConfigBoosterFeature("1.3-0.2.2-SNAPSHOT", MPCONFIG_13); + } + /* + * Test invalid version + */ + @Test + public void testMPConfigBoosterFeature13_bad_version() throws Exception { + + boolean featureFound = false; + boolean boostExceptionGenerated = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPConfigBoosterConfig.class, "1.3-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyMPConfigBoosterConfig.class, "1.x-0.2.2-SNAPSHOT"); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPConfigBoosterConfig libMPConfigConfig = new LibertyMPConfigBoosterConfig(params, logger); + try { + serverConfig.addFeature(libMPConfigConfig.getFeature()); + serverConfig.writeToServer(); - serverConfig.addFeature(libMPConfigConfig.getFeature()); - serverConfig.writeToServer(); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + MPCONFIG_13 + ""); + } catch (BoostException be) { + if (be.toString().indexOf("Invalid version") >= 0) + boostExceptionGenerated = true; + } - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPCONFIG_13 + ""); - - assertTrue("The " + MPCONFIG_13 + " feature was not found in the server configuration", featureFound); + assertTrue("The " + MPCONFIG_13 + " feature was found in the server configuration", !featureFound); + assertTrue("No BoostException generated", boostExceptionGenerated); } - } diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPFaultToleranceBoosterTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPFaultToleranceBoosterTest.java index b95ed39f..e98a5fb0 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPFaultToleranceBoosterTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPFaultToleranceBoosterTest.java @@ -22,6 +22,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; import org.microshed.boost.common.BoostLoggerI; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.config.BoosterConfigParams; import org.microshed.boost.runtimes.openliberty.LibertyServerConfigGenerator; import org.microshed.boost.runtimes.openliberty.boosters.*; @@ -39,32 +40,37 @@ public class MPFaultToleranceBoosterTest { BoostLoggerI logger = CommonLogger.getInstance(); - /** - * Test that the mpFaultTolerance-1.1 feature is added to server.xml when the - * MPFaultTolerance booster version is set to 1.1-0.2.2-SNAPSHOT - * - */ - @Test - public void testMPFaultToleranceBoosterFeature11() throws Exception { + private void testMPFaultToleranceBoosterFeature11(String version, String feature) throws Exception { + boolean featureFound = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPFaultToleranceBoosterConfig.class, "1.1-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyMPFaultToleranceBoosterConfig.class, version); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPFaultToleranceBoosterConfig libMPFTConfig = new LibertyMPFaultToleranceBoosterConfig(params, logger); + try { + serverConfig.addFeature(libMPFTConfig.getFeature()); + serverConfig.writeToServer(); - serverConfig.addFeature(libMPFTConfig.getFeature()); - serverConfig.writeToServer(); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + feature + ""); + } catch (BoostException be) { + } + assertTrue("The " + feature + " feature was not found in the server configuration", featureFound); - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPFAULTTOLERANCE_11 + ""); - - assertTrue("The " + MPFAULTTOLERANCE_11 + " feature was not found in the server configuration", featureFound); + } + /** + * Test that the mpFaultTolerance-1.1 feature is added to server.xml when the + * MPFaultTolerance booster version is set to 1.1-0.2.2-SNAPSHOT + * + */ + @Test + public void testMPFaultToleranceBoosterFeature11() throws Exception { + testMPFaultToleranceBoosterFeature11("1.1-0.2.2-SNAPSHOT", MPFAULTTOLERANCE_11); } /** @@ -74,25 +80,37 @@ public void testMPFaultToleranceBoosterFeature11() throws Exception { */ @Test public void testMPFaultToleranceBoosterFeature20() throws Exception { + testMPFaultToleranceBoosterFeature11("2.0-0.2.2-SNAPSHOT", MPFAULTTOLERANCE_20); + } + + /* + * Test with invalid version + */ + @Test + public void testMPFaultToleranceBoosterFeature20_bad_version() throws Exception { + boolean featureFound = false; + boolean boostExceptionGenerated = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); - Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPFaultToleranceBoosterConfig.class, "2.0-0.2.2-SNAPSHOT"); + Map dependencies = BoosterUtil.createDependenciesWithBoosterAndVersion( + LibertyMPFaultToleranceBoosterConfig.class, "2.x-0.2.2-SNAPSHOT"); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPFaultToleranceBoosterConfig libMPFTConfig = new LibertyMPFaultToleranceBoosterConfig(params, logger); - - serverConfig.addFeature(libMPFTConfig.getFeature()); - serverConfig.writeToServer(); - - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPFAULTTOLERANCE_20 + ""); - - assertTrue("The " + MPFAULTTOLERANCE_20 + " feature was not found in the server configuration", featureFound); - + try { + serverConfig.addFeature(libMPFTConfig.getFeature()); + serverConfig.writeToServer(); + + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, + "" + MPFAULTTOLERANCE_20 + ""); + } catch (BoostException be) { + if (be.toString().indexOf("Invalid version") >= 0) + boostExceptionGenerated = true; + } + assertTrue("The " + MPFAULTTOLERANCE_20 + " feature was found in the server configuration", !featureFound); + assertTrue("No BoostException generated", boostExceptionGenerated); } - } diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPHealthBoosterTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPHealthBoosterTest.java index 3accc429..d8eebf72 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPHealthBoosterTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPHealthBoosterTest.java @@ -22,6 +22,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; import org.microshed.boost.common.BoostLoggerI; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.config.BoosterConfigParams; import org.microshed.boost.runtimes.openliberty.LibertyServerConfigGenerator; import org.microshed.boost.runtimes.openliberty.boosters.*; @@ -39,60 +40,80 @@ public class MPHealthBoosterTest { BoostLoggerI logger = CommonLogger.getInstance(); - /** - * Test that the mpHealth-1.0 feature is added to server.xml when the - * booster version is set to 1.0-0.2.2-SNAPSHOT - * - */ - @Test - public void testMPHealthBoosterFeature10() throws Exception { + private void testMPHealthBoosterFeature(String version, String feature) throws Exception { + boolean featureFound = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPHealthBoosterConfig.class, "1.0-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyMPHealthBoosterConfig.class, version); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPHealthBoosterConfig libMPHealthConfig = new LibertyMPHealthBoosterConfig(params, logger); - serverConfig.addFeature(libMPHealthConfig.getFeature()); - serverConfig.writeToServer(); + try { + serverConfig.addFeature(libMPHealthConfig.getFeature()); + serverConfig.writeToServer(); - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPHEALTH_10 + ""); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + feature + ""); + } catch (BoostException be) { + } + assertTrue("The " + feature + " feature was not found in the server configuration", featureFound); - assertTrue("The " + MPHEALTH_10 + " feature was not found in the server configuration", featureFound); + } + /** + * Test that the mpHealth-1.0 feature is added to server.xml when the booster + * version is set to 1.0-0.2.2-SNAPSHOT + * + */ + @Test + public void testMPHealthBoosterFeature10() throws Exception { + testMPHealthBoosterFeature("1.0-0.2.2-SNAPSHOT", MPHEALTH_10); } /** - * Test that the mpHealth-2.0 feature is added to server.xml when the - * MPHealth booster version is set to 2.0-0.2.2-SNAPSHOT + * Test that the mpHealth-2.0 feature is added to server.xml when the MPHealth + * booster version is set to 2.0-0.2.2-SNAPSHOT * */ @Test public void testMPHealthBoosterFeature20() throws Exception { + testMPHealthBoosterFeature("2.0-0.2.2-SNAPSHOT", MPHEALTH_20); + } + /* + * Test when version is invalid. + */ + @Test + public void testMPHealthBoosterFeature20_bad_version() throws Exception { + + boolean featureFound = false; + boolean boostExceptionGenerated = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPHealthBoosterConfig.class, "2.0-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyMPHealthBoosterConfig.class, "2.x-0.2.2-SNAPSHOT"); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPHealthBoosterConfig libMPHealthConfig = new LibertyMPHealthBoosterConfig(params, logger); + try { + serverConfig.addFeature(libMPHealthConfig.getFeature()); + serverConfig.writeToServer(); - serverConfig.addFeature(libMPHealthConfig.getFeature()); - serverConfig.writeToServer(); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + MPHEALTH_20 + ""); + } catch (BoostException be) { - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPHEALTH_20 + ""); + if (be.toString().indexOf("Invalid version") >= 0) + boostExceptionGenerated = true; + } - assertTrue("The " + MPHEALTH_20 + " feature was not found in the server configuration", featureFound); + assertTrue("The " + MPHEALTH_20 + " feature was found in the server configuration", !featureFound); + assertTrue("No BoostException generated", boostExceptionGenerated); } - } diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPMetricsBoosterTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPMetricsBoosterTest.java index 8c12740d..f59fe4cc 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPMetricsBoosterTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPMetricsBoosterTest.java @@ -22,6 +22,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; import org.microshed.boost.common.BoostLoggerI; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.config.BoosterConfigParams; import org.microshed.boost.runtimes.openliberty.LibertyServerConfigGenerator; import org.microshed.boost.runtimes.openliberty.boosters.*; @@ -39,60 +40,76 @@ public class MPMetricsBoosterTest { BoostLoggerI logger = CommonLogger.getInstance(); - /** - * Test that the mpMetrics-1.1 feature is added to server.xml when the - * MPMetrics booster version is set to 1.1-0.2.2-SNAPSHOT - * - */ - @Test - public void testMPMetricsBoosterFeature11() throws Exception { + private void testMPMetricsBoosterFeature(String version, String feature) throws Exception { + boolean featureFound = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPMetricsBoosterConfig.class, "1.1-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyMPMetricsBoosterConfig.class, version); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPMetricsBoosterConfig libMPMetricsConfig = new LibertyMPMetricsBoosterConfig(params, logger); + try { + serverConfig.addFeature(libMPMetricsConfig.getFeature()); + serverConfig.writeToServer(); - serverConfig.addFeature(libMPMetricsConfig.getFeature()); - serverConfig.writeToServer(); - - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPMETRICS_11 + ""); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + feature + ""); + } catch (BoostException be) { + } + assertTrue("The " + feature + " feature was not found in the server configuration", featureFound); - assertTrue("The " + MPMETRICS_11 + " feature was not found in the server configuration", featureFound); + } + /** + * Test that the mpMetrics-1.1 feature is added to server.xml when the MPMetrics + * booster version is set to 1.1-0.2.2-SNAPSHOT + * + */ + @Test + public void testMPMetricsBoosterFeature11() throws Exception { + testMPMetricsBoosterFeature("1.1-0.2.2-SNAPSHOT", MPMETRICS_11); } /** - * Test that the mpMetrics-2.0 feature is added to server.xml when the - * MPMetrics booster version is set to 2.0-0.2.2-SNAPSHOT + * Test that the mpMetrics-2.0 feature is added to server.xml when the MPMetrics + * booster version is set to 2.0-0.2.2-SNAPSHOT * */ @Test public void testMPMetricsBoosterFeature20() throws Exception { + testMPMetricsBoosterFeature("2.0-0.2.2-SNAPSHOT", MPMETRICS_20); + } + + /* + * Test with invalid version + */ + @Test + public void testMPMetricsBoosterFeature20_bad_version() throws Exception { + boolean featureFound = false; + boolean boostExceptionGenerated = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPMetricsBoosterConfig.class, "2.0-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyMPMetricsBoosterConfig.class, "2.x-0.2.2-SNAPSHOT"); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPMetricsBoosterConfig libMPMetricsConfig = new LibertyMPMetricsBoosterConfig(params, logger); - - serverConfig.addFeature(libMPMetricsConfig.getFeature()); - serverConfig.writeToServer(); - - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPMETRICS_20 + ""); - - assertTrue("The " + MPMETRICS_20 + " feature was not found in the server configuration", featureFound); - + try { + serverConfig.addFeature(libMPMetricsConfig.getFeature()); + serverConfig.writeToServer(); + + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + MPMETRICS_20 + ""); + } catch (BoostException be) { + if (be.toString().indexOf("Invalid version") >= 0) + boostExceptionGenerated = true; + } + assertTrue("The " + MPMETRICS_20 + " feature was found in the server configuration", !featureFound); + assertTrue("No BoostException generated", boostExceptionGenerated); } - } diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPOpenAPIBoosterTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPOpenAPIBoosterTest.java index 1a34d793..96982946 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPOpenAPIBoosterTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPOpenAPIBoosterTest.java @@ -22,6 +22,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; import org.microshed.boost.common.BoostLoggerI; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.config.BoosterConfigParams; import org.microshed.boost.runtimes.openliberty.LibertyServerConfigGenerator; import org.microshed.boost.runtimes.openliberty.boosters.*; @@ -39,32 +40,37 @@ public class MPOpenAPIBoosterTest { BoostLoggerI logger = CommonLogger.getInstance(); - /** - * Test that the mpOpenAPI-1.0 feature is added to server.xml when the MPOpenAPI - * booster version is set to 1.0-SNAPSHOT - * - */ - @Test - public void testMPOpenAPIBoosterFeature10() throws Exception { + private void testMPOpenAPIBoosterFeature(String version, String feature) throws Exception { + boolean featureFound = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPOpenAPIBoosterConfig.class, "1.0-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyMPOpenAPIBoosterConfig.class, version); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPOpenAPIBoosterConfig libMPOpenAPIConfig = new LibertyMPOpenAPIBoosterConfig(params, logger); + try { + serverConfig.addFeature(libMPOpenAPIConfig.getFeature()); + serverConfig.writeToServer(); - serverConfig.addFeature(libMPOpenAPIConfig.getFeature()); - serverConfig.writeToServer(); - - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPOPENAPI_10 + ""); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + feature + ""); + } catch (BoostException be) { + } + assertTrue("The " + feature + " feature was not found in the server configuration", featureFound); - assertTrue("The " + MPOPENAPI_10 + " feature was not found in the server configuration", featureFound); + } + /** + * Test that the mpOpenAPI-1.0 feature is added to server.xml when the MPOpenAPI + * booster version is set to 1.0-SNAPSHOT + * + */ + @Test + public void testMPOpenAPIBoosterFeature10() throws Exception { + testMPOpenAPIBoosterFeature("1.0-0.2.2-SNAPSHOT", MPOPENAPI_10); } /** @@ -74,25 +80,38 @@ public void testMPOpenAPIBoosterFeature10() throws Exception { */ @Test public void testMPOpenAPIBoosterFeature11() throws Exception { + testMPOpenAPIBoosterFeature("1.1-0.2.2-SNAPSHOT", MPOPENAPI_11); + } + /* + * Test invalid version + */ + @Test + public void testMPOpenAPIBoosterFeature11_bad_version() throws Exception { + + boolean featureFound = false; + boolean boostExceptionGenerated = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPOpenAPIBoosterConfig.class, "1.1-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyMPOpenAPIBoosterConfig.class, "1.x-0.2.2-SNAPSHOT"); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPOpenAPIBoosterConfig libMPOpenAPIConfig = new LibertyMPOpenAPIBoosterConfig(params, logger); + try { + serverConfig.addFeature(libMPOpenAPIConfig.getFeature()); + serverConfig.writeToServer(); - serverConfig.addFeature(libMPOpenAPIConfig.getFeature()); - serverConfig.writeToServer(); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + MPOPENAPI_11 + ""); + } catch (BoostException be) { + if (be.toString().indexOf("Invalid version") >= 0) + boostExceptionGenerated = true; - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPOPENAPI_11 + ""); - - assertTrue("The " + MPOPENAPI_11 + " feature was not found in the server configuration", featureFound); + } + assertTrue("The " + MPOPENAPI_11 + " feature was found in the server configuration", !featureFound); + assertTrue("No BoostException generated", boostExceptionGenerated); } - } diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPOpenTracingBoosterTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPOpenTracingBoosterTest.java index 8aae03d5..20f3f308 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPOpenTracingBoosterTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPOpenTracingBoosterTest.java @@ -21,6 +21,7 @@ import org.junit.Test; import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.BoostLoggerI; import org.microshed.boost.common.config.BoosterConfigParams; import org.microshed.boost.runtimes.openliberty.LibertyServerConfigGenerator; @@ -39,33 +40,38 @@ public class MPOpenTracingBoosterTest { BoostLoggerI logger = CommonLogger.getInstance(); - /** - * Test that the mpOpenTracing-1.1 feature is added to server.xml when the - * MPOpenTracing booster version is set to 1.1-M1-SNAPSHOT - * - */ - @Test - public void testMPOpenTracingBoosterFeature11() throws Exception { + private void testMPOpenTracingBoosterFeature(String version, String feature) throws Exception { + boolean featureFound = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPOpenTracingBoosterConfig.class, "1.1-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyMPOpenTracingBoosterConfig.class, version); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPOpenTracingBoosterConfig libMPOpenTracingConfig = new LibertyMPOpenTracingBoosterConfig(params, logger); + try { + serverConfig.addFeature(libMPOpenTracingConfig.getFeature()); + serverConfig.writeToServer(); - serverConfig.addFeature(libMPOpenTracingConfig.getFeature()); - serverConfig.writeToServer(); - - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPOPENTRACING_11 + ""); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + feature + ""); + } catch (BoostException be) { + } + assertTrue("The " + feature + " feature was not found in the server configuration", featureFound); - assertTrue("The " + MPOPENTRACING_11 + " feature was not found in the server configuration", featureFound); + } + /** + * Test that the mpOpenTracing-1.1 feature is added to server.xml when the + * MPOpenTracing booster version is set to 1.1-M1-SNAPSHOT + * + */ + @Test + public void testMPOpenTracingBoosterFeature11() throws Exception { + testMPOpenTracingBoosterFeature("1.1-0.2.2-SNAPSHOT", MPOPENTRACING_11); } /** @@ -75,26 +81,7 @@ public void testMPOpenTracingBoosterFeature11() throws Exception { */ @Test public void testMPOpenTracingBoosterFeature12() throws Exception { - - LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( - outputDir.getRoot().getAbsolutePath(), null, logger); - - Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPOpenTracingBoosterConfig.class, "1.2-0.2.2-SNAPSHOT"); - - BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); - LibertyMPOpenTracingBoosterConfig libMPOpenTracingConfig = new LibertyMPOpenTracingBoosterConfig(params, - logger); - - serverConfig.addFeature(libMPOpenTracingConfig.getFeature()); - serverConfig.writeToServer(); - - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPOPENTRACING_12 + ""); - - assertTrue("The " + MPOPENTRACING_12 + " feature was not found in the server configuration", featureFound); - + testMPOpenTracingBoosterFeature("1.2-0.2.2-SNAPSHOT", MPOPENTRACING_12); } /** @@ -104,26 +91,39 @@ public void testMPOpenTracingBoosterFeature12() throws Exception { */ @Test public void testMPOpenTracingBoosterFeature13() throws Exception { + testMPOpenTracingBoosterFeature("1.3-0.2.2-SNAPSHOT", MPOPENTRACING_13); + } + + /* + * Test missing version + */ + @Test + public void testMPOpenTracingBoosterFeature13_bbad_version() throws Exception { + boolean featureFound = false; + boolean boostExceptionGenerated = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPOpenTracingBoosterConfig.class, "1.3-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyMPOpenTracingBoosterConfig.class, "1.x-0.2.2-SNAPSHOT"); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPOpenTracingBoosterConfig libMPOpenTracingConfig = new LibertyMPOpenTracingBoosterConfig(params, logger); - - serverConfig.addFeature(libMPOpenTracingConfig.getFeature()); - serverConfig.writeToServer(); - - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPOPENTRACING_13 + ""); - - assertTrue("The " + MPOPENTRACING_13 + " feature was not found in the server configuration", featureFound); + try { + serverConfig.addFeature(libMPOpenTracingConfig.getFeature()); + serverConfig.writeToServer(); + + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, + "" + MPOPENTRACING_13 + ""); + } catch (BoostException be) { + if (be.toString().indexOf("Invalid version") >= 0) + boostExceptionGenerated = true; + } + assertTrue("The " + MPOPENTRACING_13 + " feature was found in the server configuration", !featureFound); + assertTrue("No BoostException generated", boostExceptionGenerated); } - } diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPRestClientBoosterTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPRestClientBoosterTest.java index bb66e7d1..0168b4d8 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPRestClientBoosterTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/boosters/MPRestClientBoosterTest.java @@ -22,6 +22,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.rules.TemporaryFolder; import org.microshed.boost.common.BoostLoggerI; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.config.BoosterConfigParams; import org.microshed.boost.runtimes.openliberty.LibertyServerConfigGenerator; import org.microshed.boost.runtimes.openliberty.boosters.*; @@ -39,34 +40,41 @@ public class MPRestClientBoosterTest { BoostLoggerI logger = CommonLogger.getInstance(); - /** - * Test that the mpRestClient-1.1 feature is added to server.xml when the - * MPRestClient booster version is set to 1.1-0.2.2-SNAPSHOT - * - */ - @Test - public void testMPRestClientBoosterFeature11() throws Exception { + public void testMPRestClientBoosterFeature(String version, String feature) throws Exception { + boolean featureFound = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPRestClientBoosterConfig.class, "1.1-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyMPRestClientBoosterConfig.class, version); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPRestClientBoosterConfig libMPOpenTracingConfig = new LibertyMPRestClientBoosterConfig(params, logger); - serverConfig.addFeature(libMPOpenTracingConfig.getFeature()); - serverConfig.writeToServer(); + try { + serverConfig.addFeature(libMPOpenTracingConfig.getFeature()); + serverConfig.writeToServer(); - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPRESTCLIENT_11 + ""); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "" + feature + ""); + } catch (BoostException be) { + } - assertTrue("The " + MPRESTCLIENT_11 + " feature was not found in the server configuration", featureFound); + assertTrue("The " + feature + " feature was not found in the server configuration", featureFound); } + /** + * Test that the mpRestClient-1.1 feature is added to server.xml when the + * MPRestClient booster version is set to 1.1-0.2.2-SNAPSHOT + * + */ + @Test + public void testMPRestClientBoosterFeature11() throws Exception { + testMPRestClientBoosterFeature("1.1-0.2.2-SNAPSHOT", MPRESTCLIENT_11); + } + /** * Test that the mpRestClient-1.2 feature is added to server.xml when the * MPRestClient booster version is set to "1.2-0.2.2-SNAPSHOT" @@ -74,25 +82,7 @@ public void testMPRestClientBoosterFeature11() throws Exception { */ @Test public void testMPRestClientBoosterFeature12() throws Exception { - - LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( - outputDir.getRoot().getAbsolutePath(), null, logger); - - Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPRestClientBoosterConfig.class, "1.2-0.2.2-SNAPSHOT"); - - BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); - LibertyMPRestClientBoosterConfig libMPOpenTracingConfig = new LibertyMPRestClientBoosterConfig(params, logger); - - serverConfig.addFeature(libMPOpenTracingConfig.getFeature()); - serverConfig.writeToServer(); - - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPRESTCLIENT_12 + ""); - - assertTrue("The " + MPRESTCLIENT_12 + " feature was not found in the server configuration", featureFound); - + testMPRestClientBoosterFeature("1.2-0.2.2-SNAPSHOT", MPRESTCLIENT_12); } /** @@ -102,25 +92,40 @@ public void testMPRestClientBoosterFeature12() throws Exception { */ @Test public void testMPRestClientBoosterFeature13() throws Exception { + testMPRestClientBoosterFeature("1.3-0.2.2-SNAPSHOT", MPRESTCLIENT_13); + } + /* + * Test Missing version + */ + @Test + public void testMPRestClientBoosterFeature13_bad_version() throws Exception { + + boolean featureFound = false; + boolean boostExceptionGenerated = false; LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); Map dependencies = BoosterUtil - .createDependenciesWithBoosterAndVersion(LibertyMPRestClientBoosterConfig.class, "1.3-0.2.2-SNAPSHOT"); + .createDependenciesWithBoosterAndVersion(LibertyMPRestClientBoosterConfig.class, "1.x-0.2.2-SNAPSHOT"); BoosterConfigParams params = new BoosterConfigParams(dependencies, new Properties()); LibertyMPRestClientBoosterConfig libMPOpenTracingConfig = new LibertyMPRestClientBoosterConfig(params, logger); - serverConfig.addFeature(libMPOpenTracingConfig.getFeature()); - serverConfig.writeToServer(); + try { + serverConfig.addFeature(libMPOpenTracingConfig.getFeature()); + serverConfig.writeToServer(); - String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; - boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, - "" + MPRESTCLIENT_13 + ""); + String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml"; + featureFound = ConfigFileUtils.findStringInServerXml(serverXML, + "" + MPRESTCLIENT_13 + ""); + } catch (BoostException be) { - assertTrue("The " + MPRESTCLIENT_13 + " feature was not found in the server configuration", featureFound); + if (be.toString().indexOf("Invalid version") >= 0) + boostExceptionGenerated = true; + } + assertTrue("The " + MPRESTCLIENT_13 + " feature was found in the server configuration", !featureFound); + assertTrue("No BoostException generated", boostExceptionGenerated); } - } diff --git a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/config/LibertyServerConfigGeneratorTest.java b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/config/LibertyServerConfigGeneratorTest.java index f55e98b3..8cc0cdb7 100644 --- a/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/config/LibertyServerConfigGeneratorTest.java +++ b/boost-maven/boost-runtimes/runtime-openliberty/src/test/java/org/microshed/boost/runtimes/config/LibertyServerConfigGeneratorTest.java @@ -28,6 +28,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.microshed.boost.common.BoostException; import org.microshed.boost.common.BoostLoggerI; import org.microshed.boost.common.boosters.JDBCBoosterConfig; import org.microshed.boost.common.config.BoostProperties; @@ -62,7 +63,8 @@ public class LibertyServerConfigGeneratorTest { * @throws IOException */ @Test - public void testAddSpringFeature() throws ParserConfigurationException, TransformerException, IOException { + public void testAddSpringFeature() + throws ParserConfigurationException, TransformerException, IOException, BoostException { LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator( outputDir.getRoot().getAbsolutePath(), null, logger); @@ -79,8 +81,8 @@ public void testAddSpringFeature() throws ParserConfigurationException, Transfor } /** - * Test that the server.xml and boostrap.properties are fully configured - * with the Derby datasource + * Test that the server.xml and boostrap.properties are fully configured with + * the Derby datasource * * @throws ParserConfigurationException * @throws TransformerException @@ -165,8 +167,8 @@ public void testAddDatasource_Derby() throws Exception { } /** - * Test that the server.xml and boostrap.properties are fully configured - * with the DB2 datasource + * Test that the server.xml and boostrap.properties are fully configured with + * the DB2 datasource * * @throws ParserConfigurationException * @throws TransformerException @@ -251,8 +253,8 @@ public void testAddDatasource_DB2() throws Exception { } /** - * Test that the server.xml and boostrap.properties are fully configured - * with the MySQL datasource + * Test that the server.xml and boostrap.properties are fully configured with + * the MySQL datasource * * @throws ParserConfigurationException * @throws TransformerException @@ -336,8 +338,8 @@ public void testAddJdbcBoosterConfig_MySQL() throws Exception { } /** - * Test that the server.xml and boostrap.properties are fully configured - * with the MySQL datasource + * Test that the server.xml and boostrap.properties are fully configured with + * the MySQL datasource * * @throws ParserConfigurationException * @throws TransformerException