This repository has been archived by the owner on Oct 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
boost-common/src/main/java/boost/common/boosters/BeanValidationBoosterConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
boost-maven/boost-boosters/booster-beanValidation20/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...src/main/java/boost/runtimes/openliberty/boosters/LibertyBeanValidationBoosterConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
|
||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
...berty/src/test/java/io/openliberty/boost/runtimes/boosters/BeanValidationBoosterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} | ||
|
||
} |