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

Commit

Permalink
add new beanValidation booster
Browse files Browse the repository at this point in the history
  • Loading branch information
ajm01 committed Aug 21, 2019
1 parent 8fc1d1c commit 7e63c18
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public abstract class AbstractBoosterConfig {
public static final String JSONP_VERSION_11 = "1.1-" + boostVersion + "-" + milestone + "-SNAPSHOT";
public static final String JPA_VERSION_21 = "2.1-" + boostVersion + "-" + milestone + "-SNAPSHOT";
public static final String JPA_VERSION_22 = "2.2-" + boostVersion + "-" + milestone + "-SNAPSHOT";
public static final String BEANVALIDATION_VERSION_20 = "2.0-" + boostVersion + "-" + milestone + "-SNAPSHOT";
public static final String MP_HEALTH_VERSION_10 = "1.0-" + boostVersion + "-" + milestone + "-SNAPSHOT";
public static final String MP_CONFIG_VERSION_13 = "1.3-" + boostVersion + "-" + milestone + "-SNAPSHOT";
public static final String MP_METRICS_VERSION_11 = "1.1-" + boostVersion + "-" + milestone + "-SNAPSHOT";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2018, 2019 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package boost.common.boosters;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import boost.common.BoostException;
import boost.common.BoostLoggerI;
import boost.common.boosters.AbstractBoosterConfig.BoosterCoordinates;

@BoosterCoordinates(AbstractBoosterConfig.BOOSTERS_GROUP_ID + ":beanValidation")
public class BeanValidationBoosterConfig extends AbstractBoosterConfig {

public BeanValidationBoosterConfig(Map<String, String> dependencies, BoostLoggerI logger) throws BoostException {
super(dependencies.get(getCoordinates(BeanValidationBoosterConfig.class)));
}

@Override
public List<String> getDependencies() {
return new ArrayList<String>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public final class ConfigConstants {
public static final String JPA_22 = "jpa-2.2";
public static final String CDI_12 = "cdi-1.2";
public static final String CDI_20 = "cdi-2.0";
public static final String BEANVALIDATION_20 = "beanValidation-2.0";
public static final String MPHEALTH_10 = "mpHealth-1.0";
public static final String MPOPENAPI_10 = "mpOpenAPI-1.0";
public static final String MPOPENAPI_11 = "mpOpenAPI-1.1";
Expand Down
5 changes: 5 additions & 0 deletions boost-maven/boost-boms/boost-ee8-apis-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
<artifactId>javax.json.bind-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.0.Final</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
8 changes: 8 additions & 0 deletions boost-maven/boost-boms/booster-ee8-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,19 @@
<groupId>boost.boosters</groupId>
<artifactId>cdi</artifactId>
<version>2.0-1.0-M1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>boost.boosters</groupId>
<artifactId>jsonp</artifactId>
<version>1.1-1.0-M1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>boost.boosters</groupId>
<artifactId>beanValidation</artifactId>
<version>2.0-1.0-M1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
29 changes: 29 additions & 0 deletions boost-maven/boost-boosters/booster-beanValidation20/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>boost.boosters</groupId>
<artifactId>beanValidation</artifactId>
<version>2.0-1.0-M1-SNAPSHOT</version>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>boost.boosters</groupId>
<artifactId>boost-ee8-apis-bom</artifactId>
<version>0.1-SNAPSHOT</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
</dependencies>

</project>
1 change: 1 addition & 0 deletions boost-maven/boost-boosters/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<module>booster-jsonb10</module>
<module>booster-jsonp10</module>
<module>booster-jsonp11</module>
<module>booster-beanValidation20</module>
<module>booster-mpConfig13</module>
<module>booster-mpMetrics11</module>
<module>booster-mpFaultTolerance11</module>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2019 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package boost.runtimes.openliberty.boosters;

import static boost.common.config.ConfigConstants.*;

import java.util.Map;

import boost.common.BoostException;
import boost.common.BoostLoggerI;
import boost.common.boosters.BeanValidationBoosterConfig;
import boost.runtimes.openliberty.LibertyServerConfigGenerator;
import boost.runtimes.openliberty.boosters.LibertyBoosterI;

public class LibertyBeanValidationBoosterConfig extends BeanValidationBoosterConfig implements LibertyBoosterI {

public LibertyBeanValidationBoosterConfig(Map<String, String> dependencies, BoostLoggerI logger)
throws BoostException {
super(dependencies, logger);
}

public String getFeature() {
if (getVersion().equals(BEANVALIDATION_VERSION_20)) {
return BEANVALIDATION_20;
} else {
return null;
}
}

public void addServerConfig(LibertyServerConfigGenerator libertyServerConfigGenerator) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*******************************************************************************
* Copyright (c) 2019 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/

package io.openliberty.boost.runtimes.boosters;

import static boost.common.config.ConfigConstants.*;
import static org.junit.Assert.assertTrue;

import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.RestoreSystemProperties;
import org.junit.rules.TemporaryFolder;
import boost.runtimes.openliberty.LibertyServerConfigGenerator;

import boost.common.BoostLoggerI;
import io.openliberty.boost.runtimes.utils.BoosterUtil;
import io.openliberty.boost.runtimes.utils.CommonLogger;
import io.openliberty.boost.runtimes.utils.ConfigFileUtils;
import boost.runtimes.openliberty.boosters.*;

public class BeanValidationBoosterTest {

@Rule
public TemporaryFolder outputDir = new TemporaryFolder();

@Rule
public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();

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 {

LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator(
outputDir.getRoot().getAbsolutePath(), logger);

LibertyBeanValidationBoosterConfig libBeanValidationConfig = new LibertyBeanValidationBoosterConfig(
BoosterUtil.createDependenciesWithBoosterAndVersion(LibertyBeanValidationBoosterConfig.class,
"2.0-1.0-M1-SNAPSHOT"),
logger);

serverConfig.addFeature(libBeanValidationConfig.getFeature());
serverConfig.writeToServer();

String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml";
boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML,
"<feature>" + BEANVALIDATION_20 + "</feature>");

assertTrue("The " + BEANVALIDATION_20 + " feature was not found in the server configuration", featureFound);

}

/**
* 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
public void testCDIBoosterFeature_20() throws Exception {

LibertyServerConfigGenerator serverConfig = new LibertyServerConfigGenerator(
outputDir.getRoot().getAbsolutePath(), logger);

LibertyCDIBoosterConfig libCDIConfig = new LibertyCDIBoosterConfig(BoosterUtil
.createDependenciesWithBoosterAndVersion(LibertyCDIBoosterConfig.class, "2.0-1.0-M1-SNAPSHOT"), logger);

serverConfig.addFeature(libCDIConfig.getFeature());
serverConfig.writeToServer();

String serverXML = outputDir.getRoot().getAbsolutePath() + "/server.xml";
boolean featureFound = ConfigFileUtils.findStringInServerXml(serverXML, "<feature>" + CDI_20 + "</feature>");

assertTrue("The " + CDI_20 + " feature was not found in the server configuration", featureFound);

}

}

0 comments on commit 7e63c18

Please sign in to comment.