Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SHRINKDESC-167] Add modified feature-pack.xsd and generate from it, …
…plus a test.
- Loading branch information
1 parent
0910fb0
commit 08fad02
Showing
5 changed files
with
264 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
109 changes: 109 additions & 0 deletions
109
gen/src/main/resources/xsd/wildfly-feature-pack-1_1.xsd
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,109 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
~ Copyright 2014 Red Hat, Inc. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns="urn:wildfly:feature-pack:1.1" | ||
targetNamespace="urn:wildfly:feature-pack:1.1" | ||
elementFormDefault="qualified" | ||
attributeFormDefault="unqualified"> | ||
|
||
<xs:element name="feature-pack" type="feature-pack-type"> | ||
</xs:element> | ||
|
||
<xs:complexType name="feature-pack-type"> | ||
<xs:sequence> | ||
<xs:element name="dependencies" type="dependencies-type" minOccurs="0" maxOccurs="1" /> | ||
<xs:element name="artifact-versions" type="artifact-versions-type" minOccurs="0" maxOccurs="1" /> | ||
<xs:element name="config" type="config-type" minOccurs="0" maxOccurs="1" /> | ||
<xs:element name="copy-artifacts" type="copy-artifacts-type" minOccurs="0" maxOccurs="1"/> | ||
<xs:element name="file-permissions" type="file-permissions-type" minOccurs="0" maxOccurs="1"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:complexType name="dependencies-type"> | ||
<xs:sequence> | ||
<xs:element name="artifact" type="named-type" maxOccurs="unbounded" minOccurs="0" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:complexType name="named-type"> | ||
<xs:attribute name="name" type="xs:string"/> | ||
</xs:complexType> | ||
|
||
<xs:complexType name="artifact-versions-type"> | ||
<xs:sequence> | ||
<xs:element name="artifact" type="artifact-type" maxOccurs="unbounded" minOccurs="0" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:complexType name="artifact-type"> | ||
<xs:attribute name="groupId" use="required" type="xs:string"/> | ||
<xs:attribute name="artifactId" use="required" type="xs:string"/> | ||
<xs:attribute name="classifier" type="xs:string"/> | ||
<xs:attribute name="extension" type="xs:string"/> | ||
<xs:attribute name="version" use="required" type="xs:string"/> | ||
</xs:complexType> | ||
|
||
<xs:complexType name="config-type"> | ||
<xs:sequence> | ||
<xs:element name="standalone" type="config-file-type" minOccurs="0" maxOccurs="unbounded" /> | ||
<xs:element name="domain" type="config-file-type" minOccurs="0" maxOccurs="unbounded" /> | ||
<xs:element name="host" type="config-file-type" minOccurs="0" maxOccurs="unbounded" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:complexType name="config-file-type"> | ||
<xs:sequence> | ||
<xs:element name="property" type="property-type" minOccurs="0" maxOccurs="unbounded"/> | ||
</xs:sequence> | ||
<xs:attribute name="template" use="required" type="xs:string"/> | ||
<xs:attribute name="subsystems" use="required" type="xs:string"/> | ||
<xs:attribute name="output-file" use="required" type="xs:string" /> | ||
</xs:complexType> | ||
<xs:complexType name="property-type"> | ||
<xs:attribute name="name" use="required" type="xs:string"/> | ||
<xs:attribute name="value" use="required" type="xs:string"/> | ||
</xs:complexType> | ||
|
||
<xs:complexType name="copy-artifacts-type"> | ||
<xs:sequence> | ||
<xs:element name="copy-artifact" type="copy-artifact-type" minOccurs="0" maxOccurs="unbounded"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:complexType name="copy-artifact-type"> | ||
<xs:sequence> | ||
<xs:element name="filter" type="filter-type" minOccurs="0" maxOccurs="unbounded" /> | ||
</xs:sequence> | ||
<xs:attribute name="artifact" type="xs:string"/> | ||
<xs:attribute name="to-location" type="xs:string"/> | ||
<xs:attribute name="extract" use="optional" default="false" type="xs:boolean"/> | ||
</xs:complexType> | ||
<xs:complexType name="filter-type"> | ||
<xs:attribute name="pattern" type="xs:string" use="required" /> | ||
<xs:attribute name="include" type="xs:boolean" use="required" /> | ||
</xs:complexType> | ||
|
||
<xs:complexType name="file-permissions-type"> | ||
<xs:sequence> | ||
<xs:element name="permission" type="file-permission-type" maxOccurs="unbounded" minOccurs="0" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:complexType name="file-permission-type"> | ||
<xs:sequence> | ||
<xs:element name="filter" type="filter-type" minOccurs="0" maxOccurs="unbounded" /> | ||
</xs:sequence> | ||
<xs:attribute name="value" use="required" type="xs:string"/> | ||
</xs:complexType> | ||
|
||
</xs:schema> |
3 changes: 3 additions & 0 deletions
3
...vices/org.jboss.shrinkwrap.descriptor.api.wildflyfeaturepack.WildFlyFeaturePackDescriptor
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,3 @@ | ||
implClass=org.jboss.shrinkwrap.descriptor.impl.wildflyfeaturepack.WildFlyFeaturePackDescriptorImpl | ||
importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl | ||
defaultName=wildfly-feature-pack.xml |
83 changes: 83 additions & 0 deletions
83
...a/org/jboss/shrinkwrap/descriptor/test/wildflyfeaturepack/WildFlyFeaturePackTestcase.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,83 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2009, Red Hat Middleware LLC, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.shrinkwrap.descriptor.test.wildflyfeaturepack; | ||
|
||
|
||
import java.io.BufferedReader; | ||
import java.io.FileReader; | ||
|
||
import org.jboss.shrinkwrap.descriptor.api.Descriptors; | ||
import org.jboss.shrinkwrap.descriptor.api.wildflyfeaturepack11.WildFlyFeaturePackDescriptor; | ||
import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Test Case to verify that the {@link WildFlyFeaturePackDescriptor} | ||
* impl produces the correct XML Descriptor output. | ||
* | ||
* @author <a href="mailto:toby@tcrawley.org">Toby Crawley</a> | ||
*/ | ||
|
||
public class WildFlyFeaturePackTestcase { | ||
|
||
@Test | ||
public void testNothing() throws Exception { | ||
WildFlyFeaturePackDescriptor featurePack = Descriptors.create(WildFlyFeaturePackDescriptor.class); | ||
|
||
featurePack.getOrCreateArtifactVersions() | ||
.createArtifact().groupId("io.undertow").artifactId("undertow-core").version("1.3.0.CR2").up() | ||
.createArtifact().groupId("org.codehaus.woodstox").artifactId("stax2-api").version("3.1.4").up() | ||
.createArtifact().groupId("org.codehaus.woodstox").artifactId("woodstox-core-api").version("4.4.1").up(); | ||
|
||
featurePack.getOrCreateConfig() | ||
.createStandalone().template("configuration/standalone/template.xml").subsystems("configuration/standalone/subsystems.xml").outputFile("standalone/configuration/standalone.xml").up() | ||
.createDomain().template("configuration/domain/template.xml").subsystems("configuration/domain/subsystems.xml").outputFile("domain/configuration/domain.xml").up() | ||
.createHost().template("configuration/host/host.xml").subsystems("configuration/host/subsystems.xml").outputFile("domain/configuration/host.xml").up(); | ||
|
||
featurePack.getOrCreateCopyArtifacts() | ||
.createCopyArtifact().artifact("org.jboss.modules:jboss-modules").toLocation("jboss-modules.jar").up() | ||
.createCopyArtifact().artifact("org.wildfly.core:wildfly-launcher").toLocation("bin/wildfly-launcher.jar").up(); | ||
|
||
featurePack.getOrCreateFilePermissions() | ||
.createPermission().value("755").createFilter().pattern(".sh").include(true).up().up() | ||
.createPermission().value("700").createFilter().pattern("*/tmp/auth").include(true).up().up() | ||
.createPermission().value("600").createFilter().pattern("*-users.properties").include(true).up() | ||
.createFilter().pattern("*/.installation").include(true); | ||
|
||
String featurePackGenerated = featurePack.exportAsString(); | ||
String featurePackExpected = getResourceContents( "src/test/resources/test-wildfly-feature-pack11.xml"); | ||
|
||
XmlAssert.assertIdentical( featurePackExpected, featurePackGenerated ); | ||
} | ||
|
||
// -------------------------------------------------------------------------------------|| | ||
// Internal Helper ---------------------------------------------------------------------|| | ||
// -------------------------------------------------------------------------------------|| | ||
|
||
private String getResourceContents(String resource) throws Exception { | ||
assert resource != null && resource.length() > 0 : "Resource must be specified"; | ||
final BufferedReader reader = new BufferedReader(new FileReader(resource)); | ||
final StringBuilder builder = new StringBuilder(); | ||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
builder.append(line); | ||
builder.append("\n"); | ||
} | ||
return builder.toString(); | ||
} | ||
|
||
} |
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,30 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<feature-pack xmlns="urn:wildfly:feature-pack:1.1"> | ||
<artifact-versions> | ||
<artifact groupId="io.undertow" artifactId="undertow-core" version="1.3.0.CR2"/> | ||
<artifact groupId="org.codehaus.woodstox" artifactId="stax2-api" version="3.1.4"/> | ||
<artifact groupId="org.codehaus.woodstox" artifactId="woodstox-core-asl" version="4.4.1"/> | ||
</artifact-versions> | ||
<config> | ||
<standalone template="configuration/standalone/template.xml" subsystems="configuration/standalone/subsystems.xml" output-file="standalone/configuration/standalone.xml"/> | ||
<domain template="configuration/domain/template.xml" subsystems="configuration/domain/subsystems.xml" output-file="domain/configuration/domain.xml"/> | ||
<host template="configuration/host/host.xml" subsystems="configuration/host/subsystems.xml" output-file="domain/configuration/host.xml"/> | ||
</config> | ||
<copy-artifacts> | ||
<copy-artifact artifact="org.jboss.modules:jboss-modules" to-location="jboss-modules.jar"/> | ||
<copy-artifact artifact="org.wildfly.core:wildfly-launcher" to-location="bin/wildfly-launcher.jar"/> | ||
</copy-artifacts> | ||
<file-permissions> | ||
<permission value="755"> | ||
<filter pattern="*.sh" include="true"/> | ||
</permission> | ||
<permission value="700"> | ||
<filter pattern="*/tmp/auth" include="true"/> | ||
</permission> | ||
<permission value="600"> | ||
<filter pattern="*-users.properties" include="true"/> | ||
<filter pattern="*/.installation" include="true"/> | ||
</permission> | ||
</file-permissions> | ||
</feature-pack> |