diff --git a/.gitignore b/.gitignore index 1b15e100..a0deefa2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,10 @@ target bin metadata-parser-test/src/main/resources/META-INF metadata-parser-test/src/test/java -api-javaee/src/ -api-misc/src/ -impl-jboss/src/main/java/ -impl-misc/src/main/java/ +api-javaee/src +api-misc/src +impl-jboss/src +impl-misc/src +impl-javaee/src +impl-jboss/src +impl-misc/src diff --git a/api-base/src/main/java/org/jboss/shrinkwrap/descriptor/api/DescriptorNamespaceReader.java b/api-base/src/main/java/org/jboss/shrinkwrap/descriptor/api/DescriptorNamespaceReader.java new file mode 100644 index 00000000..adfcf5f5 --- /dev/null +++ b/api-base/src/main/java/org/jboss/shrinkwrap/descriptor/api/DescriptorNamespaceReader.java @@ -0,0 +1,14 @@ +package org.jboss.shrinkwrap.descriptor.api; + +import java.util.List; + +public interface DescriptorNamespaceReader +{ + + /** + * Returns all existing namespaces. + * @return a list of all existing namespaces. + */ + public List getNamespaces(); + +} diff --git a/api-base/src/main/java/org/jboss/shrinkwrap/descriptor/api/Immutable.java b/api-base/src/main/java/org/jboss/shrinkwrap/descriptor/api/Immutable.java new file mode 100644 index 00000000..b57c40b0 --- /dev/null +++ b/api-base/src/main/java/org/jboss/shrinkwrap/descriptor/api/Immutable.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.api; + +/** + * A read-only view which supports conversion to a {@link Mutable} view. + * + * @author Andrew Lee Rubinger + */ +public interface Immutable, IMMUTABLEVIEW extends Immutable> { + + /** + * Returns the mutable view of this object. + * + * @return + */ + MUTABLEVIEW toMutable(); +} diff --git a/api-base/src/main/java/org/jboss/shrinkwrap/descriptor/api/Mutable.java b/api-base/src/main/java/org/jboss/shrinkwrap/descriptor/api/Mutable.java new file mode 100644 index 00000000..50859fdd --- /dev/null +++ b/api-base/src/main/java/org/jboss/shrinkwrap/descriptor/api/Mutable.java @@ -0,0 +1,32 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.api; + +/** + * A mutable view which supports converstion to a read-only {@link Immutable} view. + * + * @author Andrew Lee Rubinger + */ +public interface Mutable, MUTABLEVIEW extends Mutable> { + + /** + * Returns the immutable view of this object. + * + * @return + */ + IMMUTABLEVIEW toImmutable(); +} \ No newline at end of file diff --git a/api-javaee-prototype/pom.xml b/api-javaee-prototype/pom.xml new file mode 100644 index 00000000..4a7054b0 --- /dev/null +++ b/api-javaee-prototype/pom.xml @@ -0,0 +1,36 @@ + + + + + + org.jboss.shrinkwrap.descriptors + shrinkwrap-descriptors-parent + 2.0.0-alpha-4-SNAPSHOT + ../pom.xml + + + + 4.0.0 + + + shrinkwrap-descriptors-api-javaee-prototype + ShrinkWrap Descriptors Prototype Java EE API + Client View of the ShrinkWrap Descriptors Project + + + + + org.jboss.shrinkwrap.descriptors + shrinkwrap-descriptors-api-base + ${project.version} + + + + junit + junit + test + + + + + diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationDescriptor.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationDescriptor.java new file mode 100644 index 00000000..f6cb82fb --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationDescriptor.java @@ -0,0 +1,82 @@ +package org.jboss.shrinkwrap.descriptor.api.application5; + +import java.util.List; + +import org.jboss.shrinkwrap.descriptor.api.Immutable; +/** + *

+ * This deployment descriptor provides the functionalities as described in the specification + *

+ * Example: + *

+ * + * ApplicationDescriptor descriptor = Descriptors.create(ApplicationDescriptor.class); + * + * + * + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public interface ApplicationDescriptor extends ApplicationDescriptorBase, + Immutable { + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationDescriptor ElementName: xsd:string ElementType : description + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns all description elements + * @return list of description + */ + public List getAllDescription(); + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationDescriptor ElementName: xsd:token ElementType : display-name + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns all display-name elements + * @return list of display-name + */ + public List getAllDisplayName(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationDescriptor ElementName: javaee:moduleType ElementType : module + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: false + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns all module elements + * @return list of module + */ + public List> getAllModule(); + + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationDescriptor ElementName: xsd:token ElementType : library-directory + // MaxOccurs: -1 isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the library-directory element + * @return the node defined for the element library-directory + */ + public String getLibraryDirectory(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationDescriptor ElementName: xsd:token ElementType : version + // MaxOccurs: - isGeneric: false isAttribute: true isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the version attribute + * @return the value defined for the attribute version + */ + public String getVersion(); +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationDescriptorBase.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationDescriptorBase.java new file mode 100644 index 00000000..5f5e6f0e --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationDescriptorBase.java @@ -0,0 +1,23 @@ +package org.jboss.shrinkwrap.descriptor.api.application5; + +import org.jboss.shrinkwrap.descriptor.api.Descriptor; +/** + *

+ * This deployment descriptor provides the functionalities as described in the specification + *

+ * Example: + *

+ * + * ApplicationDescriptorBase descriptor = Descriptors.create(ApplicationDescriptorBase.class); + * + * + * + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public interface ApplicationDescriptorBase, DESCRIPTORTYPE + extends ApplicationDescriptorBase> + extends Descriptor { +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationType.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationType.java new file mode 100644 index 00000000..19e8a4bc --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationType.java @@ -0,0 +1,71 @@ +package org.jboss.shrinkwrap.descriptor.api.application5; + +import java.util.List; + +/** + * This class implements the applicationType xsd type + * + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public interface ApplicationType extends ApplicationTypeBase { + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationType ElementName: xsd:string ElementType : description + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns all description elements + * @return list of description + */ + public List getAllDescription(); + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationType ElementName: xsd:token ElementType : display-name + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns all display-name elements + * @return list of display-name + */ + public List getAllDisplayName(); + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationType ElementName: javaee:moduleType ElementType : module + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: false + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns all module elements + * @return list of module + */ + public List> getAllModule(); + + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationType ElementName: xsd:token ElementType : library-directory + // MaxOccurs: -1 isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the library-directory element + * @return the node defined for the element library-directory + */ + public String getLibraryDirectory(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationType ElementName: xsd:token ElementType : version + // MaxOccurs: - isGeneric: false isAttribute: true isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the version attribute + * @return the value defined for the attribute version + */ + public String getVersion(); +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationTypeBase.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationTypeBase.java new file mode 100644 index 00000000..d9282403 --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationTypeBase.java @@ -0,0 +1,19 @@ +package org.jboss.shrinkwrap.descriptor.api.application5; + +import org.jboss.shrinkwrap.descriptor.api.Child; + +/** + * Base support for read-only views of this descriptors root element. Not intended for direct use by users; + * + * @param + * The true type to be returned for this references (covarient return) + * + * @param + * The type of this elements parent + * + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public interface ApplicationTypeBase, PARENTTYPE> extends Child { +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationTypeMutable.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationTypeMutable.java new file mode 100644 index 00000000..1255be01 --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationTypeMutable.java @@ -0,0 +1,145 @@ +package org.jboss.shrinkwrap.descriptor.api.application5; + +import java.util.List; + +/** + * This interface defines the contract for the applicationType xsd type + * + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public interface ApplicationTypeMutable extends ApplicationTypeBase { + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationTypeMutable ElementName: xsd:string ElementType : description + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Creates for all String objects representing description elements, + * a new description element + * @param values list of description objects + * @return the current instance of ApplicationTypeMutable + */ + public ApplicationTypeMutable description(String ... values); + + /** + * Returns all description elements + * @return list of description + */ + public List getAllDescription(); + + /** + * Removes the description element + * @return the current instance of ApplicationTypeMutable + */ + public ApplicationTypeMutable removeAllDescription(); + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationTypeMutable ElementName: xsd:token ElementType : display-name + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Creates for all String objects representing display-name elements, + * a new display-name element + * @param values list of display-name objects + * @return the current instance of ApplicationTypeMutable + */ + public ApplicationTypeMutable displayName(String ... values); + + /** + * Returns all display-name elements + * @return list of display-name + */ + public List getAllDisplayName(); + + /** + * Removes the display-name element + * @return the current instance of ApplicationTypeMutable + */ + public ApplicationTypeMutable removeAllDisplayName(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationTypeMutable ElementName: javaee:moduleType ElementType : module + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: false + // --------------------------------------------------------------------------------------------------------|| + + /** + * If not already created, a new module element will be created and returned. + * Otherwise, the first existing module element will be returned. + * @return the instance defined for the element module + */ + public ModuleType getOrCreateModule(); + + /** + * Creates a new module element + * @return the new created instance of ModuleType + */ + public ModuleType createModule(); + + /** + * Returns all module elements + * @return list of module + */ + public List> getAllModule(); + + /** + * Removes all module elements + * @return the current instance of ModuleType + */ + public ApplicationTypeMutable removeAllModule(); + + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationTypeMutable ElementName: xsd:token ElementType : library-directory + // MaxOccurs: -1 isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the library-directory element + * @param libraryDirectory the value for the element library-directory + * @return the current instance of ApplicationTypeMutable + */ + public ApplicationTypeMutable libraryDirectory(String libraryDirectory); + + /** + * Returns the library-directory element + * @return the node defined for the element library-directory + */ + public String getLibraryDirectory(); + + /** + * Removes the library-directory element + * @return the current instance of ApplicationTypeMutable + */ + public ApplicationTypeMutable removeLibraryDirectory(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationTypeMutable ElementName: xsd:token ElementType : version + // MaxOccurs: - isGeneric: false isAttribute: true isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the version attribute + * @param version the value for the attribute version + * @return the current instance of ApplicationTypeMutable + */ + public ApplicationTypeMutable version(String version); + + /** + * Returns the version attribute + * @return the value defined for the attribute version + */ + public String getVersion(); + + /** + * Removes the version attribute + * @return the current instance of ApplicationTypeMutable + */ + public ApplicationTypeMutable removeVersion(); +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ModuleType.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ModuleType.java new file mode 100644 index 00000000..8f3f3644 --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ModuleType.java @@ -0,0 +1,140 @@ +package org.jboss.shrinkwrap.descriptor.api.application5; + +import java.util.ArrayList; +import java.util.List; +import org.jboss.shrinkwrap.descriptor.api.Child; +import org.jboss.shrinkwrap.descriptor.api.application5.WebType; + +/** + * This interface defines the contract for the moduleType xsd type + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public interface ModuleType extends Child +{ + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleType ElementName: xsd:token ElementType : connector + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the connector element + * @param connector the value for the element connector + * @return the current instance of ModuleType + */ + public ModuleType connector(String connector); + + /** + * Returns the connector element + * @return the node defined for the element connector + */ + public String getConnector(); + + /** + * Removes the connector element + * @return the current instance of ModuleType + */ + public ModuleType removeConnector(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleType ElementName: xsd:token ElementType : ejb + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the ejb element + * @param ejb the value for the element ejb + * @return the current instance of ModuleType + */ + public ModuleType ejb(String ejb); + + /** + * Returns the ejb element + * @return the node defined for the element ejb + */ + public String getEjb(); + + /** + * Removes the ejb element + * @return the current instance of ModuleType + */ + public ModuleType removeEjb(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleType ElementName: xsd:token ElementType : java + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the java element + * @param java the value for the element java + * @return the current instance of ModuleType + */ + public ModuleType java(String java); + + /** + * Returns the java element + * @return the node defined for the element java + */ + public String getJava(); + + /** + * Removes the java element + * @return the current instance of ModuleType + */ + public ModuleType removeJava(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleType ElementName: javaee:webType ElementType : web + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: false + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the web element. + * @return the existing instance of WebType>, or null if not found + */ + public WebType> getWeb(); + + /** + * If not already created, a new web element with the given value will be created. + * Otherwise, the existing web element will be returned. + * @return a new or existing instance of WebType> + */ + public WebType> getOrCreateWeb(); + + /** + * Removes the web element + * @return the current instance of ModuleType + */ + public ModuleType removeWeb(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleType ElementName: xsd:token ElementType : alt-dd + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the alt-dd element + * @param altDd the value for the element alt-dd + * @return the current instance of ModuleType + */ + public ModuleType altDd(String altDd); + + /** + * Returns the alt-dd element + * @return the node defined for the element alt-dd + */ + public String getAltDd(); + + /** + * Removes the alt-dd element + * @return the current instance of ModuleType + */ + public ModuleType removeAltDd(); +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ModuleTypeReader.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ModuleTypeReader.java new file mode 100644 index 00000000..c81526e1 --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/ModuleTypeReader.java @@ -0,0 +1,75 @@ +package org.jboss.shrinkwrap.descriptor.api.application5; + +import java.util.ArrayList; +import java.util.List; +import org.jboss.shrinkwrap.descriptor.api.Child; +import org.jboss.shrinkwrap.descriptor.api.application5.WebTypeReader; + +/** + * This interface defines the contract for the moduleType xsd type + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public interface ModuleTypeReader extends Child +{ + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleTypeReader ElementName: xsd:token ElementType : connector + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the connector element + * @return the node defined for the element connector + */ + public String getConnector(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleTypeReader ElementName: xsd:token ElementType : ejb + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the ejb element + * @return the node defined for the element ejb + */ + public String getEjb(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleTypeReader ElementName: xsd:token ElementType : java + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the java element + * @return the node defined for the element java + */ + public String getJava(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleTypeReader ElementName: javaee:webType ElementType : web + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: false + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the web element. + * @return the existing instance of WebTypeReader>, or null if not found + */ + public WebTypeReader> getWeb(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleTypeReader ElementName: xsd:token ElementType : alt-dd + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the alt-dd element + * @return the node defined for the element alt-dd + */ + public String getAltDd(); +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/MutableApplicationDescriptor.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/MutableApplicationDescriptor.java new file mode 100644 index 00000000..06c14327 --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/MutableApplicationDescriptor.java @@ -0,0 +1,155 @@ +package org.jboss.shrinkwrap.descriptor.api.application5; + +import java.util.List; + +import org.jboss.shrinkwrap.descriptor.api.Mutable; +/** + *

+ * This deployment descriptor provides the functionalities as described in the specification + *

+ * Example: + *

+ * + * MutableApplicationDescriptor descriptor = Descriptors.create(MutableApplicationDescriptor.class); + * + * + * + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public interface MutableApplicationDescriptor extends ApplicationDescriptorBase, + Mutable { + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: MutableApplicationDescriptor ElementName: xsd:string ElementType : description + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Creates for all String objects representing description elements, + * a new description element + * @param values list of description objects + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor description(String ... values); + + /** + * Returns all description elements + * @return list of description + */ + public List getAllDescription(); + + /** + * Removes the description element + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor removeAllDescription(); + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: MutableApplicationDescriptor ElementName: xsd:token ElementType : display-name + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Creates for all String objects representing display-name elements, + * a new display-name element + * @param values list of display-name objects + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor displayName(String ... values); + + /** + * Returns all display-name elements + * @return list of display-name + */ + public List getAllDisplayName(); + + /** + * Removes the display-name element + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor removeAllDisplayName(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: MutableApplicationDescriptor ElementName: javaee:moduleType ElementType : module + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: false + // --------------------------------------------------------------------------------------------------------|| + + /** + * If not already created, a new module element will be created and returned. + * Otherwise, the first existing module element will be returned. + * @return the instance defined for the element module + */ + public ModuleType getOrCreateModule(); + + /** + * Creates a new module element + * @return the new created instance of ModuleType + */ + public ModuleType createModule(); + + /** + * Returns all module elements + * @return list of module + */ + public List> getAllModule(); + + /** + * Removes all module elements + * @return the current instance of ModuleType + */ + public MutableApplicationDescriptor removeAllModule(); + + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: MutableApplicationDescriptor ElementName: xsd:token ElementType : library-directory + // MaxOccurs: -1 isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the library-directory element + * @param libraryDirectory the value for the element library-directory + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor libraryDirectory(String libraryDirectory); + + /** + * Returns the library-directory element + * @return the node defined for the element library-directory + */ + public String getLibraryDirectory(); + + /** + * Removes the library-directory element + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor removeLibraryDirectory(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: MutableApplicationDescriptor ElementName: xsd:token ElementType : version + // MaxOccurs: - isGeneric: false isAttribute: true isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the version attribute + * @param version the value for the attribute version + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor version(String version); + + /** + * Returns the version attribute + * @return the value defined for the attribute version + */ + public String getVersion(); + + /** + * Removes the version attribute + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor removeVersion(); +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/WebType.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/WebType.java new file mode 100644 index 00000000..d74ca8bf --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/WebType.java @@ -0,0 +1,65 @@ +package org.jboss.shrinkwrap.descriptor.api.application5; + +import java.util.ArrayList; +import java.util.List; +import org.jboss.shrinkwrap.descriptor.api.Child; + +/** + * This interface defines the contract for the webType xsd type + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public interface WebType extends Child +{ + public void set(String webUri, String contextRoot); + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: WebType ElementName: xsd:token ElementType : web-uri + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the web-uri element + * @param webUri the value for the element web-uri + * @return the current instance of WebType + */ + public WebType webUri(String webUri); + + /** + * Returns the web-uri element + * @return the node defined for the element web-uri + */ + public String getWebUri(); + + /** + * Removes the web-uri element + * @return the current instance of WebType + */ + public WebType removeWebUri(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: WebType ElementName: xsd:token ElementType : context-root + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the context-root element + * @param contextRoot the value for the element context-root + * @return the current instance of WebType + */ + public WebType contextRoot(String contextRoot); + + /** + * Returns the context-root element + * @return the node defined for the element context-root + */ + public String getContextRoot(); + + /** + * Removes the context-root element + * @return the current instance of WebType + */ + public WebType removeContextRoot(); +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/WebTypeReader.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/WebTypeReader.java new file mode 100644 index 00000000..7b3f2218 --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/WebTypeReader.java @@ -0,0 +1,38 @@ +package org.jboss.shrinkwrap.descriptor.api.application5; + +import java.util.ArrayList; +import java.util.List; +import org.jboss.shrinkwrap.descriptor.api.Child; + +/** + * This interface defines the contract for the webType xsd type + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public interface WebTypeReader extends Child +{ + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: WebTypeReader ElementName: xsd:token ElementType : web-uri + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the web-uri element + * @return the node defined for the element web-uri + */ + public String getWebUri(); + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: WebTypeReader ElementName: xsd:token ElementType : context-root + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the context-root element + * @return the node defined for the element context-root + */ + public String getContextRoot(); +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/package-info.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/package-info.java new file mode 100644 index 00000000..5d5b3313 --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/application5/package-info.java @@ -0,0 +1,5 @@ + /** + * Provides the interfaces and enumeration types as defined in the schema + */ + +package org.jboss.shrinkwrap.descriptor.api.application5; diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webapp30/WebAppDescriptor.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webapp30/WebAppDescriptor.java new file mode 100644 index 00000000..c08672ec --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webapp30/WebAppDescriptor.java @@ -0,0 +1,33 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.api.webapp30; + +import org.jboss.shrinkwrap.descriptor.api.Immutable; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterType; + +/** + * Read-only view of a web application deployment descriptor (ie. web.xml). + * + * @author Andrew Lee Rubinger + */ +/* + * TODO: This is for use by end-users, and correctly closes the generic context + */ +public interface WebAppDescriptor extends WebAppDescriptorBase, + Immutable { + +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webapp30/WebAppDescriptorBase.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webapp30/WebAppDescriptorBase.java new file mode 100644 index 00000000..84b6dee4 --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webapp30/WebAppDescriptorBase.java @@ -0,0 +1,54 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.api.webapp30; + +import java.util.List; + +import org.jboss.shrinkwrap.descriptor.api.Descriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterTypeBase; + +/** + * Base support for read-only views of the "web-app" element. Not intended for direct use by users; instead use + * {@link WebAppDescriptor}. + * + * @author Andrew Lee Rubinger + * @param + * The return type representing filterelements + */ +/* + * TODO: Each element type will need a generic param, which admittedly will make this declaration really verbose. + */ +public interface WebAppDescriptorBase, WEBAPPDESCRIPTORTYPE extends WebAppDescriptorBase> + extends Descriptor { + + /** + * Returns a copied view of all filter elements, such that changes to the returned {@link List} will + * have no impact on this object. + * + * @return list of filter + */ + /* + * TODO: Must return a copied view, note changed documentation above to reflect this. + */ + List getAllFilter(); + + /* + * TODO: We need to account for removing a single Filter. To do this, FILTERTYPE should support .equals and + * .hashCode implementations such that one may be removed + */ + +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webapp30/WebAppMutableDescriptor.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webapp30/WebAppMutableDescriptor.java new file mode 100644 index 00000000..507ea488 --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webapp30/WebAppMutableDescriptor.java @@ -0,0 +1,65 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.api.webapp30; + +import org.jboss.shrinkwrap.descriptor.api.Mutable; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterMutableType; + +/** + * Mutable view of a web application deployment descriptor (ie. web.xml). + * + * @author Andrew Lee Rubinger + */ +/* + * TODO: This is for use by end-users, and correctly closes the generic context + */ +public interface WebAppMutableDescriptor extends WebAppDescriptorBase, + Mutable { + + /* + * TODO: Methods below this line copied / modified from existing WebAppDescriptor + */ + + /** + * If not already created, a new filter element will be created and returned. Otherwise, the first + * existing filter element will be returned. + * + * @return the instance defined for the element filter + */ + public FilterMutableType getOrCreateFilter(); + + /** + * Creates a new filter element + * + * @return the new created instance of FilterType + */ + /* + * TODO: Note error in @return documentation above, to be fixed TODO: Return FILTERTYPE + */ + public FilterMutableType createFilter(); + + /** + * Removes all filter elements + * + * @return the current instance of FilterType + */ + /* + * TODO: Note error in @return documentation above, to be fixed TODO: Return FILTERTYPE TODO: API Naming, should be + * "removeAllFilterElements?" To be discussed. + */ + public WebAppMutableDescriptor removeAllFilter(); +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webcommon30/FilterMutableType.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webcommon30/FilterMutableType.java new file mode 100644 index 00000000..2d052f4e --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webcommon30/FilterMutableType.java @@ -0,0 +1,77 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.api.webcommon30; + +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptor; + +/** + * End-user view of a "web-app/filter" element which is mutable. + * + * @author Andrew Lee Rubinger + */ +/* + * TODO: Note how we close the generic context in the type declaration + */ +public interface FilterMutableType extends FilterTypeBase { + + /* + * TODO: This method ADDED as part of prototyping + */ + + /** + * Removes the description element with the specified value. If the specified value is not a current + * description, this call will be a no-op. + * + * @param value + * @return This instance + * @throws IllegalArgumentException + * If the value is not specified + */ + FilterMutableType removeDescription(String value) throws IllegalArgumentException; + + /* + * TODO: Methods below this line ported from existing impl, with changes as noted. + */ + + // TODO: Update documentation to explain we're removing *all* X elements. + /** + * Removes the description element + * + * @return the current instance of FilterType + */ + /* + * TODO: Changed return type TODO: API Naming: would it work to make this: "removeAll[X]Elements" ie. + * "removeAllDescriptionElements"? + */ + public FilterMutableType removeAllDescription(); + + /** + * Creates for all String objects representing description elements, a new description + * element + * + * @param values + * list of description objects + * @return the current instance of FilterType + * @throws IllegalArgumentException + * If no values are specified or if any specified value is blank or null + */ + /* + * TODO: Changed return type to TRUETYPE TODO: Added throws clause and its JavaDoc TODO: Implementation will need to + * perform precondition check to validate throws clause + */ + public FilterMutableType description(String... values) throws IllegalArgumentException; +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webcommon30/FilterType.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webcommon30/FilterType.java new file mode 100644 index 00000000..0d4ce3b3 --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webcommon30/FilterType.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.api.webcommon30; + +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; + +/** + * End-user read-only view of the "web-app/filter" element + * + * @author Andrew Lee Rubinger + */ +/* + * TODO: Note how we close the generic context in the type declaration + */ +public interface FilterType extends FilterTypeBase { + +} diff --git a/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webcommon30/FilterTypeBase.java b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webcommon30/FilterTypeBase.java new file mode 100644 index 00000000..9fd80b89 --- /dev/null +++ b/api-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/api/webcommon30/FilterTypeBase.java @@ -0,0 +1,53 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.api.webcommon30; + +import java.util.List; + +import org.jboss.shrinkwrap.descriptor.api.Child; + +/** + * Base support for read-only views of the "web-app/filter" element. Not intended for direct use by users; instead use + * {@link FilterType}. + * + * @author Andrew Lee Rubinger + * @param + * The true type to be returned for this references (covarient return) + * @param + * The type of this element's parent + */ +/* + * TODO: Note changed interface signature to accommodate covarient return TODO: Note additional documentation above for + * generic types + */ +public interface FilterTypeBase, PARENTTYPE> extends + Child { + + /* + * TODO: + * + * This method is always to return a *copied* view, as noted in the changed description in the API JavaDoc below. + */ + + /** + * Returns a copied view of all description elements, such that changes to the returned {@link List} + * will have no impact on this object. + * + * @return list of description + */ + public List getAllDescription(); +} diff --git a/api-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationDescriptorTestCase.java b/api-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationDescriptorTestCase.java new file mode 100644 index 00000000..f805e6ed --- /dev/null +++ b/api-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/api/application5/ApplicationDescriptorTestCase.java @@ -0,0 +1,264 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, 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.api.application5; + + +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Tests to ensure that the API contract for {@link ApplicationDescriptor} + * is working as expected + * + */ +@Ignore +public class ApplicationDescriptorTestCase +{ + + @Test + public void subElementRoundtrip() + { + final ApplicationDescriptor appDescriptor = null; + final MutableApplicationDescriptor appDescriptorMutable = null; + + // test all nested elements are immutable by default + appDescriptor.getAllModule().get(0).getWeb().getContextRoot(); + appDescriptor.getAllModule().get(0).getWeb().getWebUri(); + appDescriptor.getAllDescription(); + appDescriptor.getAllDisplayName(); + appDescriptor.getLibraryDirectory(); + appDescriptor.getAllModule().get(0).getWeb().up().up(); + + appDescriptorMutable.createModule(); + + + // test toMutable() and traversing back to the original descriptor +// appDescriptor.getAllModule().get(0).toMutable().getOrCreateWeb().removeContextRoot().removeWebUri().up().up(); + + appDescriptorMutable.createModule().altDd("").connector("").ejb("").getOrCreateWeb().up().up(); + + +// appTypeImmutable.; +// appTypeMutable.toImmutable().toMutable(); + +// appTypeMutable.createModule(). + } + +// @Test +// public void subElementRoundtripCopy() +// { +// final org.jboss.shrinkwrap.descriptor.api.application5.copy.ModuleTypeMutable moduleType = null; +// moduleType. +// +// +// +// +// final ApplicationTypeMutable appTypeMutable = null; +// final ApplicationTypeImmutable appTypeImmutable; +// +// appTypeMutable.toImmutable().toMutable(); +// +// appTypeMutable.createModule().getOrCreateWeb(). +// } + + + @Test + public void mutableRoundtrip() + { + // Make a new descriptor + final ApplicationDescriptor readonly = null; + + // Get a mutable view + final MutableApplicationDescriptor mutable = readonly.toMutable(); + + mutable.getOrCreateModule().getOrCreateWeb().webUri("two").up().up(); + + // Roundtrip to immutable + final ApplicationDescriptor roundtrip = mutable.toImmutable(); + + roundtrip.getAllModule().get(0).getWeb().getWebUri(); +// roundtrip.getAllModule().get(0).getWeb().removeWebUri(); // not allowed ... + + System.out.println("Roundtrip: "+roundtrip.exportAsString()); + + // Ensure the roundtrip still has a filter w/ two descriptions +// Assert.assertEquals(2, roundtrip..getAllFilter().get(0).getAllDescription().size()); + + + } + +// This experiment shows that there are fundamental design issues not solved ... I believe +// that after the API change this will be easier to solve. + +// private class ApplicationDescriptorImpl implements ApplicationDescriptor, MutableApplicationDescriptor +// { +// +// @Override +// public String getDescriptorName() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public String exportAsString() throws DescriptorExportException +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public void exportTo(OutputStream output) throws DescriptorExportException, IllegalArgumentException +// { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public MutableApplicationType toMutable() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public List getAllDescription() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public List getAllDisplayName() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public List> getAllModule() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// public List> getAllModule() { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public String getLibraryDirectory() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public String getVersion() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public ApplicationType toImmutable() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public MutableApplicationDescriptor description(String... values) +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public MutableApplicationDescriptor removeAllDescription() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public MutableApplicationDescriptor displayName(String... values) +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public MutableApplicationDescriptor removeAllDisplayName() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public MutableModuleType getOrCreateModule() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public MutableModuleType createModule() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public MutableApplicationDescriptor removeAllModule() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public MutableApplicationDescriptor libraryDirectory(String libraryDirectory) +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public MutableApplicationDescriptor removeLibraryDirectory() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public MutableApplicationDescriptor version(String version) +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public MutableApplicationDescriptor removeVersion() +// { +// // TODO Auto-generated method stub +// return null; +// } +// +// } +} diff --git a/gen/pom.xml b/gen/pom.xml index 0722cc86..e67a6f7a 100644 --- a/gen/pom.xml +++ b/gen/pom.xml @@ -111,10 +111,12 @@ executionJ2ee13 validate + J2ee13 false ${basedir}/../api-javaee/src/main/java ${basedir}/../impl-javaee/src/main/java + ${basedir}/../impl-javaee/src/main/resources/META-INF/services @@ -122,9 +124,10 @@ j2ee org.jboss.shrinkwrap.descriptor.api.connector10 org.jboss.shrinkwrap.descriptor.impl.connector10 - ConnectorDescriptor + ConnectorDescriptor connector j2ee:connector + ra.xml @@ -137,11 +140,12 @@ executionJ2ee14 validate + J2ee14 false ${basedir}/../api-javaee/src/main/java ${basedir}/../impl-javaee/src/main/java - + ${basedir}/../impl-javaee/src/main/resources/META-INF/services @@ -169,8 +173,9 @@ ConnectorDescriptor connector j2ee:connectorType + ra.xml - xmlnshttp://java.sun.com/xml/ns/j2ee + xmlnshttp://java.sun.com/xml/ns/j2ee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd @@ -184,6 +189,7 @@ WebJsptaglibraryDescriptor taglib j2ee:tldTaglibType + taglibrary.tld xmlnshttp://java.sun.com/xml/ns/j2ee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -199,6 +205,7 @@ PortletDescriptor portlet-app portlet:portlet-appType + portlet.xml xmlnshttp://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -216,11 +223,12 @@ executionJavaEE5 validate + JavaEE5 false ${basedir}/../api-javaee/src/main/java ${basedir}/../impl-javaee/src/main/java - + ${basedir}/../impl-javaee/src/main/resources/META-INF/services @@ -247,6 +255,7 @@ ApplicationDescriptor application javaee:applicationType + application.xml xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -262,6 +271,7 @@ PersistenceDescriptor persistence persistence:persistence + persistence.xml xmlnshttp://java.sun.com/xml/ns/persistence xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -277,6 +287,7 @@ OrmDescriptor entity-mappings orm:entity-mappings + orm.xml xmlnshttp://java.sun.com/xml/ns/persistence/orm xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -292,6 +303,7 @@ EjbJarDescriptor ejb-jar javaee:ejb-jarType + ejb-jar.xml xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -307,6 +319,7 @@ WebJsptaglibraryDescriptor taglib javaee:tldTaglibType + taglibrary.tld xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -322,6 +335,7 @@ WebFacelettaglibraryDescriptor facelet-taglib javaee:facelet-taglibType + taglib.xml xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -337,6 +351,7 @@ WebFacesConfigDescriptor faces-config javaee:faces-configType + faces-config.xml xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -344,67 +359,108 @@ + + + + + + + + + + + + + + + + + - ${basedir}/src/main/resources/xsd/web-facesconfig_2_1.xsd + ${basedir}/src/main/resources/xsd/web-partialresponse_2_0.xsd javaee - org.jboss.shrinkwrap.descriptor.api.facesconfig21 - org.jboss.shrinkwrap.descriptor.impl.facesconfig21 - WebFacesConfigDescriptor - faces-config - javaee:faces-configType + org.jboss.shrinkwrap.descriptor.api.facespartialresponse20 + org.jboss.shrinkwrap.descriptor.impl.facespartialresponse20 + WebFacesPartialResponseDescriptor + partial-response + javaee:partial-responseType + default.xml xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance - xsi:schemaLocationhttp://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd + xsi:schemaLocationhttp://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-partialresponse_2_0.xsd + + + + parse + + + + + executionJavaEE5_facesconfig_2_1 + validate + + JavaEE5_facesconfig_2_1 + false + + ${basedir}/../api-javaee/src/main/java + ${basedir}/../impl-javaee/src/main/java + ${basedir}/../impl-javaee/src/main/resources/META-INF/services + + + + ${basedir}/src/main/resources/xsd/javaee_5.xsd + javaee + org.jboss.shrinkwrap.descriptor.api.javaee5 + org.jboss.shrinkwrap.descriptor.impl.javaee5 + false + + - ${basedir}/src/main/resources/xsd/web-facesuicomponent_2_0.xsd + ${basedir}/src/main/resources/xsd/javaee_web_services_client_1_2.xsd javaee - org.jboss.shrinkwrap.descriptor.api.facesuicomponent20 - org.jboss.shrinkwrap.descriptor.impl.facesuicomponent20 - WebFacesUIComponentDescriptor - attribute - javaee:uicomponent-attributeType - - xmlnshttp://java.sun.com/xml/ns/javaee - xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance - xsi:schemaLocationhttp://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesuicomponent_2_0.xsd - + org.jboss.shrinkwrap.descriptor.api.javaeewebservicesclient12 + org.jboss.shrinkwrap.descriptor.impl.javaeewebservicesclient12 + false - ${basedir}/src/main/resources/xsd/web-partialresponse_2_0.xsd + ${basedir}/src/main/resources/xsd/web-facesconfig_2_1.xsd javaee - org.jboss.shrinkwrap.descriptor.api.facespartialresponse20 - org.jboss.shrinkwrap.descriptor.impl.facespartialresponse20 - WebFacesPartialResponseDescriptor - partial-response - javaee:partial-responseType + org.jboss.shrinkwrap.descriptor.api.facesconfig21 + org.jboss.shrinkwrap.descriptor.impl.facesconfig21 + WebFacesConfigDescriptor + faces-config + javaee:faces-configType + faces-config.xml xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance - xsi:schemaLocationhttp://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-partialresponse_2_0.xsd + xsi:schemaLocationhttp://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd + parse - + executionJavaEE6 validate + JavaEE6 false ${basedir}/../api-javaee/src/main/java ${basedir}/../impl-javaee/src/main/java - + ${basedir}/../impl-javaee/src/main/resources/META-INF/services @@ -447,6 +503,7 @@ ApplicationDescriptor application javaee:applicationType + application.xml xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -462,6 +519,7 @@ WebAppDescriptor web-app javaee:web-appType + web.xml xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -477,6 +535,7 @@ PersistenceDescriptor persistence persistence:persistence + persistence.xml xmlnshttp://java.sun.com/xml/ns/persistence xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -492,6 +551,7 @@ OrmDescriptor entity-mappings orm:entity-mappings + orm.xml xmlnshttp://java.sun.com/xml/ns/persistence/orm xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -506,6 +566,7 @@ WebFragmentDescriptor web-fragment javaee:web-fragmentType + webfragment.xml xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -521,6 +582,7 @@ EjbJarDescriptor ejb-jar javaee:ejb-jarType + ejb-jar.xml xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -536,6 +598,7 @@ ConnectorDescriptor connector javaee:connectorType + ra.xml xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -551,6 +614,7 @@ BeansDescriptor beans javaee:beans + beans.xml xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -569,10 +633,12 @@ executionJBossEE5 validate + JBossEE5 false ${basedir}/../api-jboss/src/main/java - ${basedir}/../impl-jboss/src/main/java + ${basedir}/../impl-jboss/src/main/java + ${basedir}/../impl-jboss/src/main/resources/META-INF/services @@ -615,6 +681,7 @@ JbossDescriptor jboss jboss:jbossType + jboss.xml xmlnshttp://www.jboss.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -632,10 +699,12 @@ executionJBossEE6 validate + JBossEE6 false ${basedir}/../api-jboss/src/main/java - ${basedir}/../impl-jboss/src/main/java + ${basedir}/../impl-jboss/src/main/java + ${basedir}/../impl-jboss/src/main/resources/META-INF/services @@ -678,6 +747,7 @@ JbossWebDescriptor jboss-web jboss:jboss-webType + jboss-web.xml xmlnshttp://www.jboss.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance @@ -695,6 +765,7 @@ executionMisc validate + Misc false ${basedir}/../api-misc/src/main/java @@ -710,6 +781,7 @@ JettyDescriptor Configure jetty7:Configure + jetty.xml diff --git a/impl-javaee-prototype/pom.xml b/impl-javaee-prototype/pom.xml new file mode 100644 index 00000000..1cde85a1 --- /dev/null +++ b/impl-javaee-prototype/pom.xml @@ -0,0 +1,63 @@ + + + + + + org.jboss.shrinkwrap.descriptors + shrinkwrap-descriptors-parent + 2.0.0-alpha-4-SNAPSHOT + ../pom.xml + + + + 4.0.0 + + + shrinkwrap-descriptors-impl-javaee-prototype + ShrinkWrap Descriptors Prototype Java EE Impl + Prototype Implementation of the ShrinkWrap Descriptors Project + + + + + org.jboss.shrinkwrap.descriptors + shrinkwrap-descriptors-api-javaee-prototype + ${project.version} + + + org.jboss.shrinkwrap.descriptors + shrinkwrap-descriptors-impl-base + ${project.version} + + + org.jboss.shrinkwrap.descriptors + shrinkwrap-descriptors-impl-base + ${project.version} + test-jar + test + + + + junit + junit + test + + + + + + + + + maven-surefire-plugin + + + ${env.JAVA5_HOME}/bin/java + + once + + + + + diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/ApplicationDescriptorBaseImpl.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/ApplicationDescriptorBaseImpl.java new file mode 100644 index 00000000..a55d726b --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/ApplicationDescriptorBaseImpl.java @@ -0,0 +1,80 @@ +package org.jboss.shrinkwrap.descriptor.impl.application5; + +import java.util.ArrayList; +import java.util.List; +import org.jboss.shrinkwrap.descriptor.api.Child; +import org.jboss.shrinkwrap.descriptor.api.application5.ApplicationDescriptorBase; +import org.jboss.shrinkwrap.descriptor.api.application5.ApplicationTypeBase; +import org.jboss.shrinkwrap.descriptor.api.Descriptor; +import org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorImplBase; +import org.jboss.shrinkwrap.descriptor.impl.base.XMLDate; +import org.jboss.shrinkwrap.descriptor.spi.node.Node; +import org.jboss.shrinkwrap.descriptor.api.Mutable; +import org.jboss.shrinkwrap.descriptor.api.Immutable; +/** + *

+ * This deployment descriptor provides the functionalities as described in the specification + *

+ * Example: + *

+ * + * ApplicationDescriptorBaseImpl descriptor = Descriptors.create(ApplicationDescriptorBaseImpl.class); + * + * + * + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public abstract class ApplicationDescriptorBaseImpl, DESCRIPTORTYPE + extends ApplicationDescriptorBase> + extends NodeDescriptorImplBase + implements ApplicationDescriptorBase { + // -------------------------------------------------------------------------------------|| + // Instance Members + // -------------------------------------------------------------------------------------|| + + private Node model; + + // -------------------------------------------------------------------------------------|| + // Constructor + // -------------------------------------------------------------------------------------|| + + public ApplicationDescriptorBaseImpl(String descriptorName) + { + this(descriptorName, new Node("application")); + } + + public ApplicationDescriptorBaseImpl(String descriptorName, Node node) + { + super(descriptorName); + this.model = node; + addDefaultNamespaces(); + } + + + public Node getRootNode() + { + return model; + } + + + /** + * Adds the default namespaces as defined in the specification + */ + private void addDefaultNamespaces() + { + addNamespace("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); + addNamespace("xsi:schemaLocation", "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"); + addNamespace("xmlns", "http://java.sun.com/xml/ns/javaee"); + } + + /** + * Adds a new namespace + */ + private void addNamespace(String name, String value) + { + model.attribute(name, value); + } + +} diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/ApplicationDescriptorImpl.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/ApplicationDescriptorImpl.java new file mode 100644 index 00000000..b9df0471 --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/ApplicationDescriptorImpl.java @@ -0,0 +1,133 @@ +package org.jboss.shrinkwrap.descriptor.impl.application5; + +import java.util.ArrayList; +import java.util.List; + +import org.jboss.shrinkwrap.descriptor.api.application5.ApplicationDescriptor; +import org.jboss.shrinkwrap.descriptor.api.application5.ApplicationType; +import org.jboss.shrinkwrap.descriptor.api.application5.ModuleTypeReader; +import org.jboss.shrinkwrap.descriptor.api.application5.MutableApplicationDescriptor; +import org.jboss.shrinkwrap.descriptor.spi.node.Node; +/** + *

+ * This deployment descriptor provides the functionalities as described in the specification + *

+ * Example: + *

+ * + * ApplicationDescriptorImpl descriptor = Descriptors.create(ApplicationDescriptorImpl.class); + * + * + * + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public final class ApplicationDescriptorImpl extends ApplicationDescriptorBaseImpl + implements ApplicationDescriptor { + + public ApplicationDescriptorImpl(final String descriptorName, final Node model) { + super(descriptorName, model); + } + + public ApplicationDescriptorImpl(final String descriptorName) { + super(descriptorName); + } + + public MutableApplicationDescriptor toMutable() { + return new MutableApplicationDescriptorImpl(this.getDescriptorName(), this.getRootNode()); + } + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationDescriptor ElementName: xsd:string ElementType : description + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns all description elements + * @return list of description + */ + public List getAllDescription() + { + List result = new ArrayList(); + List nodes = getRootNode().get("description"); + for (Node node : nodes) + { + result.add(node.getText()); + } + return result; + } + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationDescriptor ElementName: xsd:token ElementType : display-name + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns all display-name elements + * @return list of display-name + */ + public List getAllDisplayName() + { + List result = new ArrayList(); + List nodes = getRootNode().get("display-name"); + for (Node node : nodes) + { + result.add(node.getText()); + } + return result; + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationDescriptor ElementName: javaee:moduleType ElementType : module + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: false + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns all module elements + * @return list of module + */ + public List> getAllModule() + { + List> list = new ArrayList>(); + List nodeList = getRootNode().get("module"); + for(Node node: nodeList) + { + ModuleTypeReader type = new ModuleTypeReaderImpl(this, "module", getRootNode(), node); + list.add(type); + } + return list; + } + + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationDescriptor ElementName: xsd:token ElementType : library-directory + // MaxOccurs: -1 isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the library-directory element + * @return the node defined for the element library-directory + */ + public String getLibraryDirectory() + { + return getRootNode().getTextValueForPatternName("library-directory"); + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ApplicationDescriptor ElementName: xsd:token ElementType : version + // MaxOccurs: - isGeneric: false isAttribute: true isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the version attribute + * @return the value defined for the attribute version + */ + public String getVersion() + { + return getRootNode().getAttribute("version"); + } +} diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/ModuleTypeImpl.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/ModuleTypeImpl.java new file mode 100644 index 00000000..6a46acf5 --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/ModuleTypeImpl.java @@ -0,0 +1,234 @@ +package org.jboss.shrinkwrap.descriptor.impl.application5; + +import org.jboss.shrinkwrap.descriptor.spi.node.Node; +import org.jboss.shrinkwrap.descriptor.api.application5.ModuleType; +import java.util.ArrayList; +import java.util.List; +import org.jboss.shrinkwrap.descriptor.api.Child; +import org.jboss.shrinkwrap.descriptor.impl.base.XMLDate; +import org.jboss.shrinkwrap.descriptor.impl.base.Strings; +import org.jboss.shrinkwrap.descriptor.api.DescriptorExporter; +import org.jboss.shrinkwrap.descriptor.api.application5.WebType; +import org.jboss.shrinkwrap.descriptor.impl.application5.WebTypeImpl; + + +/** + * This class implements the moduleType xsd type + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public class ModuleTypeImpl implements Child, ModuleType +{ + // -------------------------------------------------------------------------------------|| + // Instance Members + // -------------------------------------------------------------------------------------|| + + private T t; + private Node childNode; + // -------------------------------------------------------------------------------------|| + // Constructor + // -------------------------------------------------------------------------------------|| + + public ModuleTypeImpl(T t, String nodeName, Node node) { + this.t = t; + this.childNode = node.createChild(nodeName); + } + + public ModuleTypeImpl(T t, String nodeName, Node node, Node childNode) { + this.t = t; + this.childNode = childNode; + } + + + public T up() + { + return t ; + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleType ElementName: xsd:token ElementType : connector + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the connector element + * @param connector the value for the element connector + * @return the current instance of ModuleType + */ + public ModuleType connector(String connector) + { + childNode.getOrCreate("connector").text(connector); + return this; + } + + /** + * Returns the connector element + * @return the node defined for the element connector + */ + public String getConnector() + { + return childNode.getTextValueForPatternName("connector"); + } + + /** + * Removes the connector element + * @return the current instance of ModuleType + */ + public ModuleType removeConnector() + { + childNode.removeChildren("connector"); + return this; + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleType ElementName: xsd:token ElementType : ejb + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the ejb element + * @param ejb the value for the element ejb + * @return the current instance of ModuleType + */ + public ModuleType ejb(String ejb) + { + childNode.getOrCreate("ejb").text(ejb); + return this; + } + + /** + * Returns the ejb element + * @return the node defined for the element ejb + */ + public String getEjb() + { + return childNode.getTextValueForPatternName("ejb"); + } + + /** + * Removes the ejb element + * @return the current instance of ModuleType + */ + public ModuleType removeEjb() + { + childNode.removeChildren("ejb"); + return this; + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleType ElementName: xsd:token ElementType : java + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the java element + * @param java the value for the element java + * @return the current instance of ModuleType + */ + public ModuleType java(String java) + { + childNode.getOrCreate("java").text(java); + return this; + } + + /** + * Returns the java element + * @return the node defined for the element java + */ + public String getJava() + { + return childNode.getTextValueForPatternName("java"); + } + + /** + * Removes the java element + * @return the current instance of ModuleType + */ + public ModuleType removeJava() + { + childNode.removeChildren("java"); + return this; + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleType ElementName: javaee:webType ElementType : web + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: false + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the web element. + * @return the existing instance of WebType>, or null if not found + */ + public WebType> getWeb() + { + Node node = childNode.getSingle("web"); + if (node != null) + { + return new WebTypeImpl>(this, "web", childNode, node); + } + return null; + } + + /** + * If not already created, a new web element with the given value will be created. + * Otherwise, the existing web element will be returned. + * @return a new or existing instance of WebType> + */ + public WebType> getOrCreateWeb() + { + Node node = childNode.getOrCreate("web"); + WebType> web = new WebTypeImpl>(this, "web", childNode, node); + return web; + } + + /** + * Removes the web element + * @return the current instance of ModuleType + */ + public ModuleType removeWeb() + { + childNode.removeChildren("web"); + return this; + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleType ElementName: xsd:token ElementType : alt-dd + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the alt-dd element + * @param altDd the value for the element alt-dd + * @return the current instance of ModuleType + */ + public ModuleType altDd(String altDd) + { + childNode.getOrCreate("alt-dd").text(altDd); + return this; + } + + /** + * Returns the alt-dd element + * @return the node defined for the element alt-dd + */ + public String getAltDd() + { + return childNode.getTextValueForPatternName("alt-dd"); + } + + /** + * Removes the alt-dd element + * @return the current instance of ModuleType + */ + public ModuleType removeAltDd() + { + childNode.removeChildren("alt-dd"); + return this; + } +} diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/ModuleTypeReaderImpl.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/ModuleTypeReaderImpl.java new file mode 100644 index 00000000..842d4d35 --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/ModuleTypeReaderImpl.java @@ -0,0 +1,128 @@ +package org.jboss.shrinkwrap.descriptor.impl.application5; + +import org.jboss.shrinkwrap.descriptor.spi.node.Node; +import org.jboss.shrinkwrap.descriptor.api.application5.ModuleTypeReader; +import java.util.ArrayList; +import java.util.List; +import org.jboss.shrinkwrap.descriptor.api.Child; +import org.jboss.shrinkwrap.descriptor.impl.base.XMLDate; +import org.jboss.shrinkwrap.descriptor.impl.base.Strings; +import org.jboss.shrinkwrap.descriptor.api.DescriptorExporter; +import org.jboss.shrinkwrap.descriptor.api.application5.WebTypeReader; +import org.jboss.shrinkwrap.descriptor.impl.application5.WebTypeReaderImpl; + + +/** + * This class implements the moduleType xsd type + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public class ModuleTypeReaderImpl implements Child, ModuleTypeReader +{ + // -------------------------------------------------------------------------------------|| + // Instance Members + // -------------------------------------------------------------------------------------|| + + private T t; + private Node childNode; + // -------------------------------------------------------------------------------------|| + // Constructor + // -------------------------------------------------------------------------------------|| + + public ModuleTypeReaderImpl(T t, String nodeName, Node node) { + this.t = t; + this.childNode = node.createChild(nodeName); + } + + public ModuleTypeReaderImpl(T t, String nodeName, Node node, Node childNode) { + this.t = t; + this.childNode = childNode; + } + + + public T up() + { + return t ; + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleTypeReader ElementName: xsd:token ElementType : connector + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the connector element + * @return the node defined for the element connector + */ + public String getConnector() + { + return childNode.getTextValueForPatternName("connector"); + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleTypeReader ElementName: xsd:token ElementType : ejb + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the ejb element + * @return the node defined for the element ejb + */ + public String getEjb() + { + return childNode.getTextValueForPatternName("ejb"); + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleTypeReader ElementName: xsd:token ElementType : java + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the java element + * @return the node defined for the element java + */ + public String getJava() + { + return childNode.getTextValueForPatternName("java"); + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleTypeReader ElementName: javaee:webType ElementType : web + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: false + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the web element. + * @return the existing instance of WebTypeReader>, or null if not found + */ + public WebTypeReader> getWeb() + { + Node node = childNode.getSingle("web"); + if (node != null) + { + return new WebTypeReaderImpl>(this, "web", childNode, node); + } + return null; + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: ModuleTypeReader ElementName: xsd:token ElementType : alt-dd + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the alt-dd element + * @return the node defined for the element alt-dd + */ + public String getAltDd() + { + return childNode.getTextValueForPatternName("alt-dd"); + } +} diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/MutableApplicationDescriptorImpl.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/MutableApplicationDescriptorImpl.java new file mode 100644 index 00000000..d13d3560 --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/MutableApplicationDescriptorImpl.java @@ -0,0 +1,265 @@ +package org.jboss.shrinkwrap.descriptor.impl.application5; + +import java.util.ArrayList; +import java.util.List; + +import org.jboss.shrinkwrap.descriptor.api.application5.ApplicationDescriptor; +import org.jboss.shrinkwrap.descriptor.api.application5.ApplicationTypeMutable; +import org.jboss.shrinkwrap.descriptor.api.application5.ModuleType; +import org.jboss.shrinkwrap.descriptor.api.application5.MutableApplicationDescriptor; +import org.jboss.shrinkwrap.descriptor.spi.node.Node; +/** + *

+ * This deployment descriptor provides the functionalities as described in the specification + *

+ * Example: + *

+ * + * MutableApplicationDescriptorImpl descriptor = Descriptors.create(MutableApplicationDescriptorImpl.class); + * + * + * + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public final class MutableApplicationDescriptorImpl extends ApplicationDescriptorBaseImpl + implements MutableApplicationDescriptor { + + public MutableApplicationDescriptorImpl(final String descriptorName, final Node model) { + super(descriptorName, model); + } + + public MutableApplicationDescriptorImpl(final String descriptorName) { + super(descriptorName); + } + + public ApplicationDescriptor toImmutable() { + return new ApplicationDescriptorImpl(this.getDescriptorName(), this.getRootNode()); + } + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: MutableApplicationDescriptor ElementName: xsd:string ElementType : description + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Creates for all String objects representing description elements, + * a new description element + * @param values list of description objects + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor description(String ... values) + { + if (values != null) + { + for(String name: values) + { + getRootNode().createChild("description").text(name); + } + } + return this; + } + + /** + * Returns all description elements + * @return list of description + */ + public List getAllDescription() + { + List result = new ArrayList(); + List nodes = getRootNode().get("description"); + for (Node node : nodes) + { + result.add(node.getText()); + } + return result; + } + + /** + * Removes the description element + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor removeAllDescription() + { + getRootNode().removeChildren("description"); + return this; + } + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: MutableApplicationDescriptor ElementName: xsd:token ElementType : display-name + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Creates for all String objects representing display-name elements, + * a new display-name element + * @param values list of display-name objects + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor displayName(String ... values) + { + if (values != null) + { + for(String name: values) + { + getRootNode().createChild("display-name").text(name); + } + } + return this; + } + + /** + * Returns all display-name elements + * @return list of display-name + */ + public List getAllDisplayName() + { + List result = new ArrayList(); + List nodes = getRootNode().get("display-name"); + for (Node node : nodes) + { + result.add(node.getText()); + } + return result; + } + + /** + * Removes the display-name element + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor removeAllDisplayName() + { + getRootNode().removeChildren("display-name"); + return this; + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: MutableApplicationDescriptor ElementName: javaee:moduleType ElementType : module + // MaxOccurs: -unbounded isGeneric: false isAttribute: false isEnum: false isDataType: false + // --------------------------------------------------------------------------------------------------------|| + + /** + * If not already created, a new module element will be created and returned. + * Otherwise, the first existing module element will be returned. + * @return the instance defined for the element module + */ + public ModuleType getOrCreateModule() + { + List nodeList = getRootNode().get("module"); + if (nodeList != null && nodeList.size() > 0) + { + return new ModuleTypeImpl(this, "module", getRootNode(), nodeList.get(0)); + } + return createModule(); + } + + /** + * Creates a new module element + * @return the new created instance of ModuleType + */ + public ModuleType createModule() + { + return new ModuleTypeImpl(this, "module", getRootNode()); + } + + /** + * Returns all module elements + * @return list of module + */ + public List> getAllModule() + { + List> list = new ArrayList>(); + List nodeList = getRootNode().get("module"); + for(Node node: nodeList) + { + ModuleType type = new ModuleTypeImpl(this, "module", getRootNode(), node); + list.add(type); + } + return list; + } + + /** + * Removes all module elements + * @return the current instance of ModuleType + */ + public MutableApplicationDescriptor removeAllModule() + { + getRootNode().removeChildren("module"); + return this; + } + + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: MutableApplicationDescriptor ElementName: xsd:token ElementType : library-directory + // MaxOccurs: -1 isGeneric: false isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the library-directory element + * @param libraryDirectory the value for the element library-directory + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor libraryDirectory(String libraryDirectory) + { + getRootNode().getOrCreate("library-directory").text(libraryDirectory); + return this; + } + + /** + * Returns the library-directory element + * @return the node defined for the element library-directory + */ + public String getLibraryDirectory() + { + return getRootNode().getTextValueForPatternName("library-directory"); + } + + /** + * Removes the library-directory element + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor removeLibraryDirectory() + { + getRootNode().removeChildren("library-directory"); + return this; + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: MutableApplicationDescriptor ElementName: xsd:token ElementType : version + // MaxOccurs: - isGeneric: false isAttribute: true isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the version attribute + * @param version the value for the attribute version + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor version(String version) + { + getRootNode().attribute("version", version); + return this; + } + + /** + * Returns the version attribute + * @return the value defined for the attribute version + */ + public String getVersion() + { + return getRootNode().getAttribute("version"); + } + + /** + * Removes the version attribute + * @return the current instance of MutableApplicationDescriptor + */ + public MutableApplicationDescriptor removeVersion() + { + getRootNode().removeAttribute("version"); + return this; + } +} diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/WebTypeImpl.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/WebTypeImpl.java new file mode 100644 index 00000000..46a46513 --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/WebTypeImpl.java @@ -0,0 +1,120 @@ +package org.jboss.shrinkwrap.descriptor.impl.application5; + +import org.jboss.shrinkwrap.descriptor.spi.node.Node; +import org.jboss.shrinkwrap.descriptor.api.application5.WebType; +import java.util.ArrayList; +import java.util.List; +import org.jboss.shrinkwrap.descriptor.api.Child; +import org.jboss.shrinkwrap.descriptor.impl.base.XMLDate; +import org.jboss.shrinkwrap.descriptor.impl.base.Strings; +import org.jboss.shrinkwrap.descriptor.api.DescriptorExporter; + + +/** + * This class implements the webType xsd type + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public class WebTypeImpl implements Child, WebType +{ + // -------------------------------------------------------------------------------------|| + // Instance Members + // -------------------------------------------------------------------------------------|| + + private T t; + private Node childNode; + // -------------------------------------------------------------------------------------|| + // Constructor + // -------------------------------------------------------------------------------------|| + + public WebTypeImpl(T t, String nodeName, Node node) { + this.t = t; + this.childNode = node.createChild(nodeName); + } + + public WebTypeImpl(T t, String nodeName, Node node, Node childNode) { + this.t = t; + this.childNode = childNode; + } + + + public T up() + { + return t ; + } + + public void set(String webUri, String contextRoot) { + } + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: WebType ElementName: xsd:token ElementType : web-uri + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the web-uri element + * @param webUri the value for the element web-uri + * @return the current instance of WebType + */ + public WebType webUri(String webUri) + { + childNode.getOrCreate("web-uri").text(webUri); + return this; + } + + /** + * Returns the web-uri element + * @return the node defined for the element web-uri + */ + public String getWebUri() + { + return childNode.getTextValueForPatternName("web-uri"); + } + + /** + * Removes the web-uri element + * @return the current instance of WebType + */ + public WebType removeWebUri() + { + childNode.removeChildren("web-uri"); + return this; + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: WebType ElementName: xsd:token ElementType : context-root + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Sets the context-root element + * @param contextRoot the value for the element context-root + * @return the current instance of WebType + */ + public WebType contextRoot(String contextRoot) + { + childNode.getOrCreate("context-root").text(contextRoot); + return this; + } + + /** + * Returns the context-root element + * @return the node defined for the element context-root + */ + public String getContextRoot() + { + return childNode.getTextValueForPatternName("context-root"); + } + + /** + * Removes the context-root element + * @return the current instance of WebType + */ + public WebType removeContextRoot() + { + childNode.removeChildren("context-root"); + return this; + } +} diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/WebTypeReaderImpl.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/WebTypeReaderImpl.java new file mode 100644 index 00000000..18754995 --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/WebTypeReaderImpl.java @@ -0,0 +1,76 @@ +package org.jboss.shrinkwrap.descriptor.impl.application5; + +import org.jboss.shrinkwrap.descriptor.spi.node.Node; +import org.jboss.shrinkwrap.descriptor.api.application5.WebTypeReader; +import java.util.ArrayList; +import java.util.List; +import org.jboss.shrinkwrap.descriptor.api.Child; +import org.jboss.shrinkwrap.descriptor.impl.base.XMLDate; +import org.jboss.shrinkwrap.descriptor.impl.base.Strings; +import org.jboss.shrinkwrap.descriptor.api.DescriptorExporter; + + +/** + * This class implements the webType xsd type + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + * @since Generation date :2012-07-08T16:29:08.216+02:00 + */ +public class WebTypeReaderImpl implements Child, WebTypeReader +{ + // -------------------------------------------------------------------------------------|| + // Instance Members + // -------------------------------------------------------------------------------------|| + + private T t; + private Node childNode; + // -------------------------------------------------------------------------------------|| + // Constructor + // -------------------------------------------------------------------------------------|| + + public WebTypeReaderImpl(T t, String nodeName, Node node) { + this.t = t; + this.childNode = node.createChild(nodeName); + } + + public WebTypeReaderImpl(T t, String nodeName, Node node, Node childNode) { + this.t = t; + this.childNode = childNode; + } + + + public T up() + { + return t ; + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: WebTypeReader ElementName: xsd:token ElementType : web-uri + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the web-uri element + * @return the node defined for the element web-uri + */ + public String getWebUri() + { + return childNode.getTextValueForPatternName("web-uri"); + } + + + // --------------------------------------------------------------------------------------------------------|| + // ClassName: WebTypeReader ElementName: xsd:token ElementType : context-root + // MaxOccurs: - isGeneric: true isAttribute: false isEnum: false isDataType: true + // --------------------------------------------------------------------------------------------------------|| + + /** + * Returns the context-root element + * @return the node defined for the element context-root + */ + public String getContextRoot() + { + return childNode.getTextValueForPatternName("context-root"); + } +} diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/package-info.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/package-info.java new file mode 100644 index 00000000..06174449 --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/application5/package-info.java @@ -0,0 +1,5 @@ + /** + * Provides the implementation classes as defined in the schema + */ + +package org.jboss.shrinkwrap.descriptor.impl.application5; diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppDescriptorImpl.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppDescriptorImpl.java new file mode 100644 index 00000000..ee0d2667 --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppDescriptorImpl.java @@ -0,0 +1,65 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.impl.webapp30; + +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterType; +import org.jboss.shrinkwrap.descriptor.impl.webcommon30.FilterTypeImpl; +import org.jboss.shrinkwrap.descriptor.spi.node.Node; + +/** + * Concrete implementation of {@link WebAppDescriptor} + * + * @author Andrew Lee Rubinger + */ +public final class WebAppDescriptorImpl extends WebAppDescriptorImplBase implements + WebAppDescriptor { + + public WebAppDescriptorImpl(final String descriptorName) { + super(descriptorName); + } + + /* + * TODO: This ctor: package-private + */ + WebAppDescriptorImpl(final String descriptorName, final Node model) { + super(descriptorName, model); + } + + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.impl.webapp30.WebAppDescriptorImplBase#createNewFilterViewForModel(org.jboss.shrinkwrap.descriptor.spi.node.Node) + */ + @Override + FilterType createNewFilterViewForModel(final Node filterModel) { + assert filterModel != null : "filter model must be specified"; + return new FilterTypeImpl(this, filterModel); + } + + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.api.Immutable#toMutable() + */ + @Override + public WebAppMutableDescriptor toMutable() { + return new WebAppMutableDescriptorImpl(this.getDescriptorName(), this.getRootNode().deepCopy()); + } + +} diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppDescriptorImplBase.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppDescriptorImplBase.java new file mode 100644 index 00000000..008b378f --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppDescriptorImplBase.java @@ -0,0 +1,94 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.impl.webapp30; + +import java.util.ArrayList; +import java.util.List; + +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptorBase; +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterTypeBase; +import org.jboss.shrinkwrap.descriptor.spi.node.Node; +import org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorImplBase; + +/** + * Base support for building implementations of {@link WebAppDescriptor} and {@link WebAppMutableDescriptor} + * + * @author Andrew Lee Rubinger + */ +abstract class WebAppDescriptorImplBase, WEBAPPDESCRIPTORTYPE extends WebAppDescriptorBase> + extends NodeDescriptorImplBase implements WebAppDescriptorBase { + + /** + * Backing model for this view + */ + private Node model; + + public WebAppDescriptorImplBase(final String descriptorName) { + this(descriptorName, new Node("web-app")); + } + + public WebAppDescriptorImplBase(final String descriptorName, final Node model) { + super(descriptorName); + this.model = model; + // Add default namespaces + this.model + .attribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") + .attribute("xsi:schemaLocation", + "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd") + .attribute("xmlns", "http://java.sun.com/xml/ns/javaee"); + } + + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptor#getRootNode() + */ + @Override + public Node getRootNode() { + return this.model; + } + + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptorBase#getAllFilter() + */ + // TODO Update doc to the above + // TODO Add @Override + @Override + public List getAllFilter() { + + final List list = new ArrayList(); + final List nodeList = model.get("filter"); + for (final Node node : nodeList) { + final FILTERTYPE filter = this.createNewFilterViewForModel(node); + list.add(filter); + } + + return list; + } + + /** + * Creates and returns a typesafe view of the FILTERTYPE + * + * @param filterModel + * @return + */ + abstract FILTERTYPE createNewFilterViewForModel(final Node filterModel); +} diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppMutableDescriptorImpl.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppMutableDescriptorImpl.java new file mode 100644 index 00000000..e8f8e03f --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppMutableDescriptorImpl.java @@ -0,0 +1,109 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.impl.webapp30; + +import java.util.List; + +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterMutableType; +import org.jboss.shrinkwrap.descriptor.impl.webcommon30.FilterTypeMutableImpl; +import org.jboss.shrinkwrap.descriptor.spi.node.Node; + +/** + * Concrete implementation of {@link WebAppMutableDescriptor} + * + * @author Andrew Lee Rubinger + */ +public final class WebAppMutableDescriptorImpl extends + WebAppDescriptorImplBase implements WebAppMutableDescriptor { + + public WebAppMutableDescriptorImpl(final String descriptorName) { + super(descriptorName); + } + + /* + * TODO: This ctor: package-private + */ + WebAppMutableDescriptorImpl(final String descriptorName, final Node model) { + super(descriptorName, model); + } + + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.impl.webapp30.WebAppDescriptorImplBase#createNewFilterViewForModel(org.jboss.shrinkwrap.descriptor.spi.node.Node) + */ + @Override + FilterMutableType createNewFilterViewForModel(final Node filterModel) { + assert filterModel != null : "filter model must be specified"; + return new FilterTypeMutableImpl(this, filterModel); + } + + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptorBase#getOrCreateFilter() + */ + // TODO Update doc to the above + // TODO Add @Override + @Override + public FilterMutableType getOrCreateFilter() { + final List nodeList = this.getRootNode().get("filter"); + if (nodeList.size() > 0) { + return createNewFilterViewForModel(nodeList.get(0)); + } + return createFilter(); + } + + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptorBase#createFilter() + */ + // TODO Update doc to the above + // TODO Add @Override + @Override + public FilterMutableType createFilter() { + final Node filter = this.getRootNode().createChild("filter"); + return this.createNewFilterViewForModel(filter); + } + + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptorBase#removeAllFilter() + */ + // TODO Update doc to the above + // TODO Add @Override + @Override + public WebAppMutableDescriptor removeAllFilter() { + this.getRootNode().removeChildren("filter"); + return this; + } + + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.api.Mutable#toImmutable() + */ + @Override + public WebAppDescriptor toImmutable() { + return new WebAppDescriptorImpl(this.getDescriptorName(), this.getRootNode()); + } + +} diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterTypeImpl.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterTypeImpl.java new file mode 100644 index 00000000..958b68a5 --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterTypeImpl.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.impl.webcommon30; + +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterType; +import org.jboss.shrinkwrap.descriptor.spi.node.Node; + +/** + * Concrete implementation of {@link FilterType} + * + * @author Andrew Lee Rubinger + */ +public final class FilterTypeImpl extends FilterTypeImplBase implements FilterType { + + /** + * Create a new instance with the specified parent and using the specified model + * + * @param parent + * @param model + * @throws IllegalArgumentException + * If either the parent of model is not specified + */ + public FilterTypeImpl(final WebAppDescriptor parent, final Node model) throws IllegalArgumentException { + super(parent, model); + } +} diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterTypeImplBase.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterTypeImplBase.java new file mode 100644 index 00000000..4e7fbb15 --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterTypeImplBase.java @@ -0,0 +1,87 @@ +package org.jboss.shrinkwrap.descriptor.impl.webcommon30; + +import java.util.ArrayList; +import java.util.List; + +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptorBase; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterMutableType; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterType; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterTypeBase; +import org.jboss.shrinkwrap.descriptor.spi.node.Node; +import org.jboss.shrinkwrap.descriptor.spi.node.NodeModel; + +/** + * Base support for building implementations of {@link FilterType} and {@link FilterMutableType}. + * + * @author Andrew Lee Rubinger + * @author Ralf Battenfeld + */ +abstract class FilterTypeImplBase, WEBAPPDESCRIPTORTYPE extends WebAppDescriptorBase> + implements FilterTypeBase, NodeModel { + + private WEBAPPDESCRIPTORTYPE parent; + private Node model; + + /** + * Creates a new instance using the specified parent and the specified backing {@link Node} model + * + * @param parent + * @param model + * @throws IllegalArgumentException + * If either the parent or model is not specified + */ + FilterTypeImplBase(final WEBAPPDESCRIPTORTYPE parent, final Node model) throws IllegalArgumentException { + if (parent == null) { + throw new IllegalArgumentException("parent must be specified"); + } + if (model == null) { + throw new IllegalArgumentException("model must be specified"); + } + this.parent = parent; + this.model = model; + } + + // TODO Add @Override + // TODO Use the below JavaDoc + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.api.Child#up() + */ + @Override + public final WEBAPPDESCRIPTORTYPE up() { + return parent; + } + + /** + * Returns all description elements + * + * @return list of description + */ + // TODO Update documentation to the following: + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterTypeBase#getAllDescription() + */ + // TODO Add @Override + @Override + public List getAllDescription() { + final List result = new ArrayList(); + final List nodes = this.getRootNode().get("description"); + for (final Node node : nodes) { + result.add(node.getText()); + } + return result; + } + + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.spi.node.NodeModel#getRootNode() + */ + @Override + public Node getRootNode() { + return this.model; + } +} diff --git a/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterTypeMutableImpl.java b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterTypeMutableImpl.java new file mode 100644 index 00000000..6f9d54c4 --- /dev/null +++ b/impl-javaee-prototype/src/main/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterTypeMutableImpl.java @@ -0,0 +1,124 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.impl.webcommon30; + +import java.util.List; + +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterMutableType; +import org.jboss.shrinkwrap.descriptor.spi.node.Node; + +/** + * Concrete implementation of {@link FilterMutableType} + * + * @author Andrew Lee Rubinger + */ +public final class FilterTypeMutableImpl extends FilterTypeImplBase + implements FilterMutableType { + + /** + * Create a new instance with the specified parent and using the specified model + * + * @param parent + * @param model + * @throws IllegalArgumentException + * If either the parent of model is not specified + */ + public FilterTypeMutableImpl(final WebAppMutableDescriptor parent, final Node model) + throws IllegalArgumentException { + super(parent, model); + } + + /** + * Creates for all String objects representing description elements, a new description + * element + * + * @param values + * list of description objects + * @return the current instance of FilterType + */ + // TODO: Update documentation to the following: + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterMutableType#description(java.lang.String[]) + */ + // TODO Add @Override + @Override + // TODO Accept final values + // TODO put explicit IllegalArgumentException in throws clause (just to be clear) + public FilterMutableType description(final String... values) throws IllegalArgumentException { + // TODO Added precondition checks per the docs + for (final String name : values) { + if (name == null || name.length() == 0) { + throw new IllegalArgumentException("no value for description may be null or blank"); + } + this.getRootNode().createChild("description").text(name); + } + return this; + } + + /** + * Removes the description element + * + * @return the current instance of FilterType + */ + // TODO Update documentation to the following: + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterMutableTypeBase#removeAllDescription() + */ + // TODO Add @Override + @Override + public FilterMutableType removeAllDescription() { + this.getRootNode().removeChildren("description"); + return this; + } + + // TODO This method is new, added as part of prototyping + /** + * {@inheritDoc} + * + * @see org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterMutableTypeBase#removeDescription(java.lang.String) + */ + @Override + public FilterMutableType removeDescription(final String value) throws IllegalArgumentException { + // Precondition checks + if (value == null || value.length() == 0) { + throw new IllegalArgumentException("value must be specified"); + } + + // Get all "description" elements + final List descriptions = this.getRootNode().get("description"); + if (descriptions != null) { + // For each description + for (final Node description : descriptions) { + // If matches + if (description.getText().equals(value)) { + // Remove + description.getParent().removeChild(description); + System.out.println(description); + } + } + } + + // Return + return this; + } + +} diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor b/impl-javaee-prototype/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor similarity index 100% rename from impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor rename to impl-javaee-prototype/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor diff --git a/impl-javaee-prototype/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptor b/impl-javaee-prototype/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptor new file mode 100644 index 00000000..a35049e7 --- /dev/null +++ b/impl-javaee-prototype/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptor @@ -0,0 +1,3 @@ +implClass=org.jboss.shrinkwrap.descriptor.impl.webapp30.WebAppMutableDescriptorImpl +importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl +defaultName=web.xml \ No newline at end of file diff --git a/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/common/DescriptorNameTestDelegate.java b/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/common/DescriptorNameTestDelegate.java new file mode 100644 index 00000000..e795fd1e --- /dev/null +++ b/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/common/DescriptorNameTestDelegate.java @@ -0,0 +1,71 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.impl.common; + +import junit.framework.Assert; + +import org.jboss.shrinkwrap.descriptor.api.Descriptor; +import org.jboss.shrinkwrap.descriptor.api.Descriptors; + +/** + * Centralizes name-based assertions for {@link Descriptor} tests + * + * @author Andrew Lee Rubinger + */ +public class DescriptorNameTestDelegate { + + /** + * Ensures that a newly-created {@link Descriptor} of the specified type defaults to the specified name + * + * @param descriptorType + * @param expectedDefaultName + * @throws IllegalArgumentException + * If either argument is not provided + */ + public void assertDefaultName(final Class descriptorType, final String expectedDefaultName) + throws IllegalArgumentException { + if (descriptorType == null) { + throw new IllegalArgumentException("descriptor type must be specified"); + } + if (expectedDefaultName == null || expectedDefaultName.length() == 0) { + throw new IllegalArgumentException("expected default name must be specified"); + } + final Descriptor descriptor = Descriptors.create(descriptorType); + Assert.assertEquals("Default name was not as expected", expectedDefaultName, descriptor.getDescriptorName()); + } + + /** + * Ensures that a newly-created {@link Descriptor} of the specified type is assigned the specified name + * + * @param descriptorType + * @param explicitName + * @throws IllegalArgumentException + * If either argument is not provided + */ + public void assertExplicitName(final Class descriptorType, final String explicitName) + throws IllegalArgumentException { + if (descriptorType == null) { + throw new IllegalArgumentException("descriptor type must be specified"); + } + if (explicitName == null || explicitName.length() == 0) { + throw new IllegalArgumentException("explicit name must be specified"); + } + final Descriptor descriptor = Descriptors.create(descriptorType, explicitName); + Assert.assertEquals("Explicit name was not assigned as expected", explicitName, descriptor.getDescriptorName()); + } + +} diff --git a/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppDescriptorTestCase.java b/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppDescriptorTestCase.java new file mode 100644 index 00000000..237277e0 --- /dev/null +++ b/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppDescriptorTestCase.java @@ -0,0 +1,141 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.impl.webapp30; + +import java.util.List; + +import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterType; +import org.jboss.shrinkwrap.descriptor.impl.common.DescriptorNameTestDelegate; +import org.junit.Assert; +import org.junit.Test; + +/** + * Test cases asserting the validity of {@link WebAppDescriptor} operations + * + * @author Andrew Lee Rubinger + */ +public class WebAppDescriptorTestCase { + + /** + * Ensures that adding a {@link FilterType} to the {@link List} returned from the read-only view of + * {@link WebAppDescriptor} does not affect the descriptor's model. + */ + @Test + public void addFilterToCopiedListDoesNotAffectDescriptor() { + // Make a new descriptor + final WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class); + + // Get the filters and ensure empty to start + final List filters = descriptor.getAllFilter(); + Assert.assertTrue("filters should be empty to start", filters.size() == 0); + + // Add manually to the returned list + filters.add(new FilterType() { + @Override + public WebAppDescriptor up() { + return null; + } + + @Override + public List getAllDescription() { + return null; + } + }); + + // Ensure that the filters in the descriptor are still empty even + // though we added to the reference returned from the descriptor + Assert.assertTrue("filters in the descriptor should be empty", descriptor.getAllFilter().size() == 0); + } + + /** + * Ensures that an explicit name may be assigned to {@link WebAppDescriptor} + */ + @Test + public void explicitName() { + new DescriptorNameTestDelegate().assertExplicitName(WebAppDescriptor.class, "alrWeb.xml"); + } + + /** + * Ensures that the correct default name is assigned for {@link WebAppDescriptor} + */ + @Test + public void defaultName() { + new DescriptorNameTestDelegate().assertDefaultName(WebAppDescriptor.class, "web.xml"); + } + + /** + * Ensures that the read-only view may be converted to a mutable view, support adding data, conversion back to a + * read-only view, and keep the data model intact. + */ + @Test + public void mutableViewToImmutableRetainsDataModel() { + // Make a new descriptor + final WebAppDescriptor readonly = Descriptors.create(WebAppDescriptor.class); + + // Get a mutable view + final WebAppMutableDescriptor mutable = readonly.toMutable(); + + // Add a filter with two descriptions + Assert.assertEquals(2, mutable.getOrCreateFilter().description("one", "two").getAllDescription().size()); + + // Roundtrip to immutable + final WebAppDescriptor roundtrip = mutable.toImmutable(); + + // Ensure the roundtrip still has a filter w/ two descriptions + Assert.assertEquals(2, roundtrip.getAllFilter().get(0).getAllDescription().size()); + } + + /** + * Ensures that changes made to the model of a mutable view + * obtained via an immutable view do not affect the original + * immutable view + */ + @Test + public void immutableViewToMutableReturnsCopy() { + // Make a new descriptor + final WebAppDescriptor readonly = Descriptors.create(WebAppDescriptor.class); + + // Ensure the original immutable view still has no filters + Assert.assertEquals(0, readonly.getAllFilter().size()); + + // Get a mutable view + final WebAppMutableDescriptor mutable = readonly.toMutable(); + + // Add a filter with two descriptions + Assert.assertEquals(2, mutable.getOrCreateFilter().description("one", "two").getAllDescription().size()); + + // Ensure the original immutable view still has no filters + Assert.assertEquals( + "Changes to a mutable view obtained from an immutable view should not affect the original immutable view", + 0, readonly.getAllFilter().size()); + } + + /** + * Ensures we cannot simply cast from an immutable view to a mutable one (ensuring we cannot write to the impl + * without invoking on the copy operation {@link WebAppDescriptor#toMutable()}). + */ + @Test(expected = ClassCastException.class) + public void cannotCastFromImmutableToMutable() { + // Make a new descriptor + final WebAppDescriptor readonly = Descriptors.create(WebAppDescriptor.class); + WebAppMutableDescriptor.class.cast(readonly); + } + +} diff --git a/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppMutableDescriptorTestCase.java b/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppMutableDescriptorTestCase.java new file mode 100644 index 00000000..9ce6ae40 --- /dev/null +++ b/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/webapp30/WebAppMutableDescriptorTestCase.java @@ -0,0 +1,111 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.impl.webapp30; + +import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterMutableType; +import org.jboss.shrinkwrap.descriptor.impl.common.DescriptorNameTestDelegate; +import org.junit.Assert; +import org.junit.Test; + +/** + * Test cases asserting the validity of {@link WebAppMutableDescriptor} operations + * + * @author Andrew Lee Rubinger + */ +public class WebAppMutableDescriptorTestCase { + + /** + * Ensures that an explicit name may be assigned to {@link WebAppMutableDescriptor} + */ + @Test + public void explicitName() { + new DescriptorNameTestDelegate().assertExplicitName(WebAppMutableDescriptor.class, "alrWeb.xml"); + } + + /** + * Ensures that the correct default name is assigned for {@link WebAppMutableDescriptor} + */ + @Test + public void defaultName() { + new DescriptorNameTestDelegate().assertDefaultName(WebAppMutableDescriptor.class, "web.xml"); + } + + /** + * Ensures that the mutable view may be converted to a read-only view, converted back to a mutable view, and keep + * the data model intact. + */ + @Test + public void immutableRoundtrip() { + // Make a new descriptor + final WebAppMutableDescriptor mutable = Descriptors.create(WebAppMutableDescriptor.class); + + // Add a filter with two descriptions + Assert.assertEquals(2, mutable.getOrCreateFilter().description("one", "two").getAllDescription().size()); + + // Roundtrip to mutable + final WebAppMutableDescriptor roundtrip = mutable.toImmutable().toMutable(); + + // Ensure the roundtrip still has a filter w/ two descriptions + Assert.assertEquals(2, roundtrip.getAllFilter().get(0).getAllDescription().size()); + } + + /** + * Ensures that {@link WebAppMutableDescriptor#getOrCreateFilter()}, when invoked, creates a + * {@link FilterMutableType} first if no filters exist, and returns a {@link FilterMutableType} for the + * previously-created model if it's already been created. + */ + @Test + public void getOrCreateFilter() { + // Make a new descriptor + final WebAppMutableDescriptor descriptor = Descriptors.create(WebAppMutableDescriptor.class); + + // Ensure no filters + Assert.assertEquals(0, descriptor.getAllFilter().size()); + + // Create a filter with some descriptions + descriptor.getOrCreateFilter().description("one", "two", "three"); + + // Get a new filter view + final FilterMutableType secondFilterView = descriptor.getOrCreateFilter(); + + // Ensure the new view returns the same model that's been created before + Assert.assertEquals(1, descriptor.getAllFilter().size()); + Assert.assertEquals(3, secondFilterView.getAllDescription().size()); + } + + /** + * Ensures that a call to {@link WebAppMutableDescriptor#removeAllFilter()} removes all current filter elements + */ + @Test + public void removeAllFilter() { + // Make a new descriptor with 3 filters + final WebAppMutableDescriptor descriptor = Descriptors.create(WebAppMutableDescriptor.class).createFilter() + .up().createFilter().up().createFilter().up(); + + // Ensure 3 filters + Assert.assertEquals(3, descriptor.getAllFilter().size()); + + // Remove all filters + descriptor.removeAllFilter(); + + // Ensure no filters + Assert.assertEquals(0, descriptor.getAllFilter().size()); + } + +} diff --git a/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterMutableTypeTestCase.java b/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterMutableTypeTestCase.java new file mode 100644 index 00000000..280a837a --- /dev/null +++ b/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterMutableTypeTestCase.java @@ -0,0 +1,125 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.impl.webcommon30; + +import java.util.List; + +import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterMutableType; +import org.junit.Assert; +import org.junit.Test; + +/** + * Test cases asserting the validity of {@link FilterMutableType} operations + * + * @author Andrew Lee Rubinger + */ +public class FilterMutableTypeTestCase { + + /** + * Ensures that {@link FilterMutableType#description(String...)} rejects null input + */ + @Test(expected = IllegalArgumentException.class) + public void descriptionRejectsNullInput() { + Descriptors.create(WebAppMutableDescriptor.class).getOrCreateFilter().description((String) null); + } + + /** + * Ensures that {@link FilterMutableType#description(String...)} rejects null input even in presence of valid vararg + * preceding it + */ + @Test(expected = IllegalArgumentException.class) + public void descriptionRequiresAllParamsToNotBeNull() { + Descriptors.create(WebAppMutableDescriptor.class).getOrCreateFilter().description("valid", null); + } + + /** + * Ensures that {@link FilterMutableType#description(String...)} rejects blank input even in presence of valid + * vararg preceding it + */ + @Test(expected = IllegalArgumentException.class) + public void descriptionRequiresAllParamsToNotBeBlank() { + Descriptors.create(WebAppMutableDescriptor.class).getOrCreateFilter().description("valid", ""); + } + + /** + * Ensures we can add filter/description elements + */ + @Test + public void addDescriptions() { + // Delegate + this.createAndValidateDescriptorWithFilterDescriptions(); + } + + /** + * Ensures we can add filter/description elements + */ + @Test + public void removeDescriptions() { + // Delegate for creation + final WebAppMutableDescriptor descriptor = this.createAndValidateDescriptorWithFilterDescriptions(); + + // Now remove all descriptions + final FilterMutableType filter = descriptor.getAllFilter().get(0); + filter.removeAllDescription(); + + // Ensure all removed + Assert.assertEquals(0, filter.getAllDescription().size()); + } + + /** + * Ensures we can remove a single filter description + */ + @Test + public void removeDescription() { + // Delegate for creation + final WebAppMutableDescriptor descriptor = this.createAndValidateDescriptorWithFilterDescriptions(); + + // Remove a single description + final FilterMutableType filter = descriptor.getAllFilter().get(0); + filter.removeDescription("Lee"); + final List descriptions = filter.getAllDescription(); + + // Ensure the other descriptions are intact + Assert.assertEquals(2, filter.getAllDescription().size()); + Assert.assertEquals("Andrew", descriptions.get(0)); + Assert.assertEquals("Rubinger", descriptions.get(1)); + } + + /** + * Centralized helper to create and assert upon new filter descriptions + * + * @return + */ + private WebAppMutableDescriptor createAndValidateDescriptorWithFilterDescriptions() { + // Make a new descriptor and add filter descriptions + final WebAppMutableDescriptor descriptor = Descriptors.create(WebAppMutableDescriptor.class) + .getOrCreateFilter().description("Andrew", "Lee", "Rubinger").up(); + + // Get the descriptions back out and ensure they're correct + final List descriptions = descriptor.getAllFilter().get(0).getAllDescription(); + Assert.assertEquals(3, descriptions.size()); + Assert.assertEquals("Andrew", descriptions.get(0)); + Assert.assertEquals("Lee", descriptions.get(1)); + Assert.assertEquals("Rubinger", descriptions.get(2)); + + // Return + return descriptor; + } + +} diff --git a/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterTypeTestCase.java b/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterTypeTestCase.java new file mode 100644 index 00000000..816af941 --- /dev/null +++ b/impl-javaee-prototype/src/test/java/org/jboss/shrinkwrap/descriptor/impl/webcommon30/FilterTypeTestCase.java @@ -0,0 +1,55 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.impl.webcommon30; + +import java.util.List; + +import junit.framework.Assert; + +import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppMutableDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterType; +import org.junit.Test; + +/** + * Test cases asserting the validity of {@link FilterType} operations + * + * @author Andrew Lee Rubinger + */ +public class FilterTypeTestCase { + + /** + * Ensures that {@link FilterType#getAllDescription()} is working as contracted + */ + @Test + public void getAllDescription() { + // Make a descriptor and populate with description elements + final WebAppDescriptor descriptor = Descriptors.create(WebAppMutableDescriptor.class).getOrCreateFilter() + .description("one", "two", "three").up().toImmutable(); + + // Ensure the three descriptions are as specified via the immutable view + final List filters = descriptor.getAllFilter(); + Assert.assertEquals(1, filters.size()); + final FilterType filter = filters.get(0); + final List descriptions = filter.getAllDescription(); + Assert.assertEquals("one", descriptions.get(0)); + Assert.assertEquals("two", descriptions.get(1)); + Assert.assertEquals("three", descriptions.get(2)); + } + +} diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.application5.ApplicationDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.application5.ApplicationDescriptor deleted file mode 100644 index 152f345a..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.application5.ApplicationDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.application5.ApplicationDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=application.xml \ No newline at end of file diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.application6.ApplicationDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.application6.ApplicationDescriptor deleted file mode 100644 index 6a37861b..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.application6.ApplicationDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.application6.ApplicationDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=application.xml \ No newline at end of file diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.beans10.BeansDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.beans10.BeansDescriptor deleted file mode 100644 index 90b46cc5..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.beans10.BeansDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.beans10.BeansDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=beans.xml \ No newline at end of file diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.connector10.ConnectorDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.connector10.ConnectorDescriptor deleted file mode 100644 index 5bd7e38c..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.connector10.ConnectorDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.connector10.ConnectorDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=ra.xml \ No newline at end of file diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.connector15.ConnectorDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.connector15.ConnectorDescriptor deleted file mode 100644 index d280bb55..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.connector15.ConnectorDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.connector15.ConnectorDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=ra.xml \ No newline at end of file diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.connector16.ConnectorDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.connector16.ConnectorDescriptor deleted file mode 100644 index 6b689bbf..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.connector16.ConnectorDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.connector16.ConnectorDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=ra.xml \ No newline at end of file diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.ejbjar30.EjbJarDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.ejbjar30.EjbJarDescriptor deleted file mode 100644 index ddea3a82..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.ejbjar30.EjbJarDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.ejbjar30.EjbJarDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=ejb-jar.xml \ No newline at end of file diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.ejbjar31.EjbJarDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.ejbjar31.EjbJarDescriptor deleted file mode 100644 index eaf3ef65..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.ejbjar31.EjbJarDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.ejbjar31.EjbJarDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=ejb-jar.xml \ No newline at end of file diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facelettaglibrary20.WebFacelettaglibraryDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facelettaglibrary20.WebFacelettaglibraryDescriptor deleted file mode 100644 index e07f0c01..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facelettaglibrary20.WebFacelettaglibraryDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.facelettaglibrary20.WebFacelettaglibraryDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=taglib.xml diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facesconfig20.WebFacesConfigDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facesconfig20.WebFacesConfigDescriptor deleted file mode 100644 index 4a15fcac..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facesconfig20.WebFacesConfigDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.facesconfig20.WebFacesConfigDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=faces-config.xml diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facesconfig21.WebFacesConfigDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facesconfig21.WebFacesConfigDescriptor deleted file mode 100644 index 4008f608..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facesconfig21.WebFacesConfigDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.facesconfig21.WebFacesConfigDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=faces-config.xml diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facespartialresponse20.WebFacesPartialResponseDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facespartialresponse20.WebFacesPartialResponseDescriptor deleted file mode 100644 index 00f41681..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facespartialresponse20.WebFacesPartialResponseDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.facespartialresponse20.WebFacesPartialResponseDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=default.xml diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facesuicomponent20.WebFacesUIComponentDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facesuicomponent20.WebFacesUIComponentDescriptor deleted file mode 100644 index 2f06c29e..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.facesuicomponent20.WebFacesUIComponentDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.facesuicomponent20.WebFacesUIComponentDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=default.xml diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jsptaglibrary20.WebJsptaglibraryDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jsptaglibrary20.WebJsptaglibraryDescriptor deleted file mode 100644 index cdd745a9..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jsptaglibrary20.WebJsptaglibraryDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.jsptaglibrary20.WebJsptaglibraryDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=taglibrary.tld \ No newline at end of file diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jsptaglibrary21.WebJsptaglibraryDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jsptaglibrary21.WebJsptaglibraryDescriptor deleted file mode 100644 index b174b263..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jsptaglibrary21.WebJsptaglibraryDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.jsptaglibrary21.WebJsptaglibraryDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=taglibrary.tld \ No newline at end of file diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.persistence10.PersistenceDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.persistence10.PersistenceDescriptor deleted file mode 100644 index 3ab5b87a..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.persistence10.PersistenceDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.persistence10.PersistenceDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=persistence.xml \ No newline at end of file diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor deleted file mode 100644 index 1748877e..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.persistence20.PersistenceDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=persistence.xml \ No newline at end of file diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.portletapp20.PortletDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.portletapp20.PortletDescriptor index 7d3b5779..dd3696c0 100644 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.portletapp20.PortletDescriptor +++ b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.portletapp20.PortletDescriptor @@ -1,3 +1,3 @@ implClass=org.jboss.shrinkwrap.descriptor.impl.portletapp20.PortletDescriptorImpl importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=portlet.xml \ No newline at end of file +defaultName=portlet.xml diff --git a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.webfragment30.WebFragmentDescriptor b/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.webfragment30.WebFragmentDescriptor deleted file mode 100644 index fe3aebd7..00000000 --- a/impl-javaee/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.webfragment30.WebFragmentDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.webfragment30.WebFragmentDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=web-fragment.xml \ No newline at end of file diff --git a/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.datasources10.DatasourcesDescriptor b/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.datasources10.DatasourcesDescriptor deleted file mode 100644 index 3a42f91a..00000000 --- a/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.datasources10.DatasourcesDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.datasources10.DatasourcesDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=datasources.xml \ No newline at end of file diff --git a/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.ironjacamar10.IronjacamarDescriptor b/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.ironjacamar10.IronjacamarDescriptor deleted file mode 100644 index 9c3ca305..00000000 --- a/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.ironjacamar10.IronjacamarDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.ironjacamar10.IronjacamarDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=ironjacamar.xml \ No newline at end of file diff --git a/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jboss51.JbossDescriptor b/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jboss51.JbossDescriptor deleted file mode 100644 index 35e1da52..00000000 --- a/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jboss51.JbossDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.jboss51.JbossDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=jboss.xml \ No newline at end of file diff --git a/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jbossweb60.JbossWebDescriptor b/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jbossweb60.JbossWebDescriptor deleted file mode 100644 index e64a11dc..00000000 --- a/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jbossweb60.JbossWebDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.jbossweb60.JbossWebDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=jboss-web.xml \ No newline at end of file diff --git a/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.resourceadapters10.ResourceAdaptersDescriptor b/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.resourceadapters10.ResourceAdaptersDescriptor deleted file mode 100644 index 33ab8e4e..00000000 --- a/impl-jboss/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.resourceadapters10.ResourceAdaptersDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.resourceadapters10.ResourceAdaptersDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=resourceadapters.xml \ No newline at end of file diff --git a/impl-misc/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jetty7.JettyDescriptor b/impl-misc/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jetty7.JettyDescriptor deleted file mode 100644 index 894d4c34..00000000 --- a/impl-misc/src/main/resources/META-INF/services/org.jboss.shrinkwrap.descriptor.api.jetty7.JettyDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.shrinkwrap.descriptor.impl.jetty7.JettyDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=default.xml diff --git a/metadata-parser-test/pom.xml b/metadata-parser-test/pom.xml index 0db0a8a0..1b05f5be 100644 --- a/metadata-parser-test/pom.xml +++ b/metadata-parser-test/pom.xml @@ -58,6 +58,7 @@ execution1 validate + IronJacamer false ${basedir}/src/main/java @@ -73,6 +74,7 @@ IronjacamarDescriptor ironjacamar ironjacamar:ironjacamarType + default.xml @@ -83,6 +85,7 @@ DatasourcesDescriptor datasources datasources:datasourcesType + default.xml @@ -93,6 +96,7 @@ ResourceadapterDescriptor resource-adapters resourceadapters:resource-adaptersType + default.xml @@ -103,6 +107,7 @@ ConnectorDescriptor connector j2ee:connector + ra.xml diff --git a/metadata-parser-test/src/main/resources/META-INF/services/org.jboss.datasources.api.DatasourcesDescriptor b/metadata-parser-test/src/main/resources/META-INF/services/org.jboss.datasources.api.DatasourcesDescriptor deleted file mode 100644 index 2d927c22..00000000 --- a/metadata-parser-test/src/main/resources/META-INF/services/org.jboss.datasources.api.DatasourcesDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.datasources.impl.DatasourcesDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=default.xml diff --git a/metadata-parser-test/src/main/resources/META-INF/services/org.jboss.ironjacamar.api.IronjacamarDescriptor b/metadata-parser-test/src/main/resources/META-INF/services/org.jboss.ironjacamar.api.IronjacamarDescriptor deleted file mode 100644 index 12d9b536..00000000 --- a/metadata-parser-test/src/main/resources/META-INF/services/org.jboss.ironjacamar.api.IronjacamarDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.ironjacamar.impl.IronjacamarDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=default.xml diff --git a/metadata-parser-test/src/main/resources/META-INF/services/org.jboss.resourceadapters.api.ResourceAdaptersDescriptor b/metadata-parser-test/src/main/resources/META-INF/services/org.jboss.resourceadapters.api.ResourceAdaptersDescriptor deleted file mode 100644 index 0b84dedc..00000000 --- a/metadata-parser-test/src/main/resources/META-INF/services/org.jboss.resourceadapters.api.ResourceAdaptersDescriptor +++ /dev/null @@ -1,3 +0,0 @@ -implClass=org.jboss.resourceadapters.impl.ResourceAdaptersDescriptorImpl -importerClass=org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomNodeDescriptorImporterImpl -defaultName=default.xml diff --git a/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/ConnectorDescriptorTestCase.java b/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/ConnectorDescriptorTestCase.java index 4be5c14e..8bdad207 100644 --- a/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/ConnectorDescriptorTestCase.java +++ b/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/ConnectorDescriptorTestCase.java @@ -23,6 +23,7 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.connector10.ConnectorDescriptor; +import org.jboss.shrinkwrap.descriptor.api.connector10.MutableConnectorDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Test; @@ -43,7 +44,7 @@ public void testSetName() throws Exception @Test public void testHornetQExample() throws Exception { - ConnectorDescriptor jca10Generated = create() + MutableConnectorDescriptor jca10Generated = create() .displayName("Sample Adapter") .description("It is a sample resource adapter") .vendorName("JBoss") @@ -98,9 +99,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private ConnectorDescriptor create() + private MutableConnectorDescriptor create() { - return Descriptors.create(ConnectorDescriptor.class); + return Descriptors.create(MutableConnectorDescriptor.class); } } diff --git a/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/DataSourcesTestCase.java b/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/DataSourcesTestCase.java index 95de2be1..48d3abf9 100644 --- a/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/DataSourcesTestCase.java +++ b/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/DataSourcesTestCase.java @@ -5,7 +5,7 @@ import java.text.SimpleDateFormat; import java.util.TimeZone; -import org.jboss.datasources.api.DatasourcesDescriptor; +import org.jboss.datasources.api.MutableDatasourcesDescriptor; import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Before; @@ -25,8 +25,8 @@ public void init() @Test public void testGeneratedDataSourcesXml() throws Exception { - DatasourcesDescriptor dataSourcesGenerated = create() - .addDefaultNamespaces() + MutableDatasourcesDescriptor dataSourcesGenerated = create() +// .addDefaultNamespaces() .createDatasource() .jta(true).jndiName("jndi-name1").poolName("pool-name1") .enabled(true).useJavaContext(true).spy(false).useCcm(true) @@ -193,9 +193,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private DatasourcesDescriptor create() + private MutableDatasourcesDescriptor create() { - return Descriptors.create(DatasourcesDescriptor.class); + return Descriptors.create(MutableDatasourcesDescriptor.class); } } diff --git a/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/IronJacamarTestCase.java b/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/IronJacamarTestCase.java index 361ef097..bcd3a4e3 100644 --- a/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/IronJacamarTestCase.java +++ b/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/IronJacamarTestCase.java @@ -6,6 +6,7 @@ import java.util.TimeZone; import org.jboss.ironjacamar.api.IronjacamarDescriptor; +import org.jboss.ironjacamar.api.MutableIronjacamarDescriptor; import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Before; @@ -25,8 +26,8 @@ public void init() @Test public void testGeneratedIronJacamarXml() throws Exception { - IronjacamarDescriptor ironJacamarGenerated = create() - .addDefaultNamespaces() + MutableIronjacamarDescriptor ironJacamarGenerated = create() +// .addDefaultNamespaces() .getOrCreateBeanValidationGroups() .beanValidationGroup("bean-validation-group0") .beanValidationGroup("bean-validation-group1").up() @@ -144,9 +145,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private IronjacamarDescriptor create() + private MutableIronjacamarDescriptor create() { - return Descriptors.create(IronjacamarDescriptor.class); + return Descriptors.create(MutableIronjacamarDescriptor.class); } } diff --git a/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/ResourceAdaptersTestCase.java b/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/ResourceAdaptersTestCase.java index b044a029..d861418c 100644 --- a/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/ResourceAdaptersTestCase.java +++ b/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/ResourceAdaptersTestCase.java @@ -5,7 +5,7 @@ import java.text.SimpleDateFormat; import java.util.TimeZone; -import org.jboss.resourceadapters.api.ResourceadapterDescriptor; +import org.jboss.resourceadapters.api.MutableResourceadapterDescriptor; import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Before; @@ -25,8 +25,8 @@ public void init() @Test public void testGeneratedDataSourcesXml() throws Exception { - ResourceadapterDescriptor resourceAdaptersGenerated = create() - .addDefaultNamespaces() + MutableResourceadapterDescriptor resourceAdaptersGenerated = create() +// .addDefaultNamespaces() .createResourceAdapter() .archive("archive0") .getOrCreateBeanValidationGroups() @@ -222,9 +222,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private ResourceadapterDescriptor create() + private MutableResourceadapterDescriptor create() { - return Descriptors.create(ResourceadapterDescriptor.class); + return Descriptors.create(MutableResourceadapterDescriptor.class); } } diff --git a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/FilterChain.java b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/FilterChain.java index 442fb24c..86b994c2 100644 --- a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/FilterChain.java +++ b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/FilterChain.java @@ -15,6 +15,7 @@ import org.jboss.shrinkwrap.descriptor.metadata.filter.RestrictionFilter; import org.jboss.shrinkwrap.descriptor.metadata.filter.SimpleContentFilter; import org.jboss.shrinkwrap.descriptor.metadata.filter.UnionFilter; +import org.jboss.shrinkwrap.descriptor.metadata.filter.XsdElementEnum; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.traversal.TreeWalker; @@ -34,6 +35,8 @@ public class FilterChain { private final List filterList = new ArrayList(); + private int seqNo = 0; + public FilterChain() { filterList.add(new GroupFilter()); filterList.add(new ElementFilter()); @@ -58,15 +61,21 @@ public FilterChain() { * logging purposes. */ public void traverseAndFilter(final TreeWalker walker, final String indent, - final Metadata metadata, final StringBuilder sb) { + final Metadata metadata, final Integer currSeqNo, final StringBuilder sb) { final Node parend = walker.getCurrentNode(); final boolean isLogged = appendText(indent, (Element) parend, sb); - + + Integer nodeSeqNo = null; + if (XsdElementEnum.sequence.isTagNameEqual(((Element) parend).getTagName())) { + nodeSeqNo = ++seqNo; + } + + metadata.setCurrentSeqNo(currSeqNo); for (final Filter filter : filterList) { if (filter.filter(metadata, walker)) { - appendText(" catched by: " + filter.getClass().getSimpleName(), sb); + appendText(" catched by: " + filter.getClass().getSimpleName() + " seqNo: " + currSeqNo, sb); break; } } @@ -76,7 +85,7 @@ public void traverseAndFilter(final TreeWalker walker, final String indent, } for (Node n = walker.firstChild(); n != null; n = walker.nextSibling()) { - traverseAndFilter(walker, indent + " ", metadata, sb); + traverseAndFilter(walker, indent + " ", metadata, nodeSeqNo, sb); } walker.setCurrentNode(parend); diff --git a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/Metadata.java b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/Metadata.java index c2a6dd25..b9e4c94a 100644 --- a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/Metadata.java +++ b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/Metadata.java @@ -37,9 +37,11 @@ public class Metadata private final List packageImplList = new ArrayList(); private List metadataDescriptorList = new ArrayList(); private String currentNamespace; + private String currentContext; private String currentSchmema; private String currentPackageApi; private String currentPackageImpl; + private Integer currentSeqNo; public List getMetadataDescriptorList() { @@ -123,6 +125,24 @@ public List getPackageImplList() return packageImplList; } + public Integer getCurrentSeqNo() + { + return currentSeqNo; + } + + public void setCurrentSeqNo(final Integer currentSeqNo) + { + this.currentSeqNo = currentSeqNo; + } + + public String getCurrentContext() { + return currentContext; + } + + public void setCurrentContext(final String currentContext) { + this.currentContext = currentContext; + } + /** * Adds a enumeration value to the specified enumeration name. If no enumeration class is * found, then a new enumeration class will be created. @@ -210,6 +230,7 @@ public void addGroupReference(final String groupName, final MetadataElement grou public void addClassElement(final String className, final MetadataElement classElement) { classElement.setType(getNamespaceValue(classElement.getType())); + classElement.setSeqNo(currentSeqNo); for (MetadataItem item: classList) { if (item.getName().equals(className) && item.getNamespace().equals(getCurrentNamespace()) @@ -334,4 +355,4 @@ private void preResolveDataTypeImpl(final MetadataItem metadataClass) } } -} \ No newline at end of file +} diff --git a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataDescriptor.java b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataDescriptor.java index 0766b750..d10ee499 100644 --- a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataDescriptor.java +++ b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataDescriptor.java @@ -30,6 +30,8 @@ public class MetadataDescriptor extends BaseMetadataItem private String rootElementName; private String rootElementType; + + private String defaultFileName; private boolean generateClasses; @@ -78,5 +80,14 @@ public boolean isGenerateClasses() public void setGenerateClasses(final boolean generateClasses) { this.generateClasses = generateClasses; + } + + public String getDefaultFileName() { + return defaultFileName; + } + + public void setDefaultFileName(final String defaultFileName) { + this.defaultFileName = defaultFileName; } + } diff --git a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataElement.java b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataElement.java index c2b74772..21bba15b 100644 --- a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataElement.java +++ b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataElement.java @@ -34,6 +34,7 @@ public class MetadataElement private String minOccurs; private String maxOccurs; private String mappedTo; + private Integer seqNo; /** * Creates a new and empty instance. @@ -140,6 +141,16 @@ public void setMappedTo(final String mappedTo) { this.mappedTo = mappedTo; } + + public Integer getSeqNo() + { + return seqNo; + } + + public void setSeqNo(final Integer seqID) + { + this.seqNo = seqID; + } } diff --git a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParser.java b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParser.java index 46b78359..159b9df0 100644 --- a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParser.java +++ b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParser.java @@ -72,7 +72,7 @@ public Metadata getMetadata() * @param verbose if true, additional parsing information are printed out, otherwise not. * @throws Exception */ - public void parse(final MetadataParserPath path, final List confList, final boolean verbose) throws Exception + public void parse(final MetadataParserPath path, final List confList, final boolean verbose, final String context) throws Exception { checkArguments(path, confList); @@ -87,17 +87,19 @@ public void parse(final MetadataParserPath path, final List confList, final b metadata.setCurrentSchmema(metadataConf.getPathToXsd()); metadata.setCurrentPackageApi(metadataConf.getPackageApi()); metadata.setCurrentPackageImpl(metadataConf.getPackageImpl()); - - final MetadataDescriptor metadataDescriptor = new MetadataDescriptor(metadataConf.getDescriptorName()); - metadataDescriptor.setRootElementName(metadataConf.getElementName()); - metadataDescriptor.setRootElementType(metadataConf.getElementType()); - metadataDescriptor.setSchemaName(metadataConf.getPathToXsd()); - metadataDescriptor.setPackageApi(metadataConf.getPackageApi()); - metadataDescriptor.setPackageImpl(metadataConf.getPackageImpl()); - metadataDescriptor.setNamespace(metadataConf.getNameSpace()); - metadataDescriptor.setNamespaces(metadataConf.getNamespaces()); - metadataDescriptor.setGenerateClasses(metadataConf.generateClasses); - metadata.getMetadataDescriptorList().add(metadataDescriptor); + metadata.setCurrentContext(context); + + final MetadataDescriptor metadataDescriptor = new MetadataDescriptor(metadataConf.getDescriptorName()); + metadataDescriptor.setRootElementName(metadataConf.getElementName()); + metadataDescriptor.setRootElementType(metadataConf.getElementType()); + metadataDescriptor.setSchemaName(metadataConf.getPathToXsd()); + metadataDescriptor.setPackageApi(metadataConf.getPackageApi()); + metadataDescriptor.setPackageImpl(metadataConf.getPackageImpl()); + metadataDescriptor.setNamespace(metadataConf.getNameSpace()); + metadataDescriptor.setNamespaces(metadataConf.getNamespaces()); + metadataDescriptor.setGenerateClasses(metadataConf.generateClasses); + metadataDescriptor.setDefaultFileName(metadataConf.getDefaultFileName()); + metadata.getMetadataDescriptorList().add(metadataDescriptor); log.info(metadataConf.getPathToXsd()); if (metadataConf.getPathToXsd().endsWith(".dtd")) @@ -120,7 +122,7 @@ public void parse(final MetadataParserPath path, final List confList, final b NodeFilter.SHOW_ELEMENT, null, true); final StringBuilder sb = verbose ? new StringBuilder() : null; - filterChain.traverseAndFilter(walker, "", metadata, sb); + filterChain.traverseAndFilter(walker, "", metadata, null, sb); if(sb!=null){ log.info(sb.toString()); diff --git a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserConfiguration.java b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserConfiguration.java index cd5aec3a..8648458b 100644 --- a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserConfiguration.java +++ b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserConfiguration.java @@ -27,6 +27,7 @@ */ public class MetadataParserConfiguration { + /** * Path to the XSD file to be parsed * @@ -68,6 +69,12 @@ public class MetadataParserConfiguration * */ protected String elementType; + + /** + * The default descriptor file name. + * + */ + protected String defaultFileName; /** * If true, then the classes for this descriptor are generated, otherwise this descriptor @@ -186,5 +193,13 @@ public void setGenerateClasses(final boolean generateClasses) { this.generateClasses = generateClasses; } + + public String getDefaultFileName() { + return defaultFileName; + } + + public void setDefaultFileName(final String defaultFileName) { + this.defaultFileName = defaultFileName; + } } diff --git a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/dom/DomWriter.java b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/dom/DomWriter.java index a8e6f54f..110d0725 100644 --- a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/dom/DomWriter.java +++ b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/dom/DomWriter.java @@ -19,6 +19,10 @@ package org.jboss.shrinkwrap.descriptor.metadata.dom; import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.logging.Logger; import javax.xml.parsers.DocumentBuilder; @@ -129,6 +133,7 @@ public void write(final Metadata metadata, final String pathToMetadata) final Attr generateClassImpl = doc.createAttribute("generateClass"); generateClassImpl.setValue(Boolean.toString(descriptor.isGenerateClasses())); packageImpl.setAttributeNode(generateClassImpl); + packages.appendChild(packageImpl); } @@ -291,6 +296,11 @@ public void write(final Metadata metadata, final String pathToMetadata) attrDocumentation.setValue(""); classElement.setAttributeNode(attrDocumentation); + final Attr attrContext = doc.createAttribute("context"); + attrContext.setValue(metadata.getCurrentContext()); + classElement.setAttributeNode(attrContext); + + checkClassElementSequence(doc, classElement, metadataClass.getElements()); for(MetadataElement element: metadataClass.getElements()) { final Element childElement = doc.createElement("element"); @@ -365,7 +375,11 @@ public void write(final Metadata metadata, final String pathToMetadata) final Attr attrPackageImpl = doc.createAttribute("packageImpl"); attrPackageImpl.setValue(descriptor.getPackageImpl()); - descriptorElement.setAttributeNode(attrPackageImpl); + descriptorElement.setAttributeNode(attrPackageImpl); + + final Attr defaultFileName = doc.createAttribute("defaultFileName"); + defaultFileName.setValue(descriptor.getDefaultFileName()); + descriptorElement.setAttributeNode(defaultFileName); final Element element = doc.createElement("element"); descriptorElement.appendChild(element); @@ -419,4 +433,51 @@ public void write(final Metadata metadata, final String pathToMetadata) tfe.printStackTrace(); } } + + /** + * Checks the existence of sequenced class elements and tries to + * to reflect that into the metadata XML tree. + * @param doc + * @param classElement + * @param classElementList + */ + private void checkClassElementSequence(final Document doc, final Element classElement, final List classElementList) { + final Map> sequencedElementList = new HashMap>(); + for(final MetadataElement metadataElement: classElementList) { + if (metadataElement.getSeqNo() != null) { + if (!sequencedElementList.containsKey(metadataElement.getSeqNo())) { + sequencedElementList.put(metadataElement.getSeqNo(), new ArrayList()); + } + sequencedElementList.get(metadataElement.getSeqNo()).add(metadataElement); + } + } + + for (final List elementList: sequencedElementList.values()) { + if (elementList.size() > 1 && elementList.size() < 6) { + final Element childElement = doc.createElement("sequence"); + + for (MetadataElement element: elementList) { + final Element sequenceElement = doc.createElement("element"); + + final Attr elName = doc.createAttribute("name"); + elName.setValue(element.getName()); + sequenceElement.setAttributeNode(elName); + + final Attr elType = doc.createAttribute("type"); + elType.setValue(element.getType()); + sequenceElement.setAttributeNode(elType); + + if (element.getMaxOccurs() != null) + { + final Attr elMaxOccurs = doc.createAttribute("maxOccurs"); + elMaxOccurs.setValue(element.getMaxOccurs()); + sequenceElement.setAttributeNode(elMaxOccurs); + } + childElement.appendChild(sequenceElement); + } + + classElement.appendChild(childElement); + } + } + } } diff --git a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/mojo/MetadataParserMojo.java b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/mojo/MetadataParserMojo.java index ec95a5bd..3099beb2 100644 --- a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/mojo/MetadataParserMojo.java +++ b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/mojo/MetadataParserMojo.java @@ -50,6 +50,13 @@ public class MetadataParserMojo extends AbstractMojo * @parameter */ protected boolean verbose; + + /** + * Defines the context for this configuration. E.g. JavaEE5. + * + * @parameter + */ + protected String context; @Override public void execute() throws MojoExecutionException, MojoFailureException @@ -57,7 +64,7 @@ public void execute() throws MojoExecutionException, MojoFailureException try { final MetadataParser metadataParser = new MetadataParser(); - metadataParser.parse(path, descriptors, verbose); + metadataParser.parse(path, descriptors, verbose, context); } catch (final Throwable t) { diff --git a/metadata-parser/src/main/resources/META-INF/ddJavaAll.xsl b/metadata-parser/src/main/resources/META-INF/ddJavaAll.xsl index 80e12fae..7f2d67c4 100644 --- a/metadata-parser/src/main/resources/META-INF/ddJavaAll.xsl +++ b/metadata-parser/src/main/resources/META-INF/ddJavaAll.xsl @@ -18,40 +18,27 @@ - - javaee:emptyType; - javaee:ordering-othersType; - javaee:facelet-taglib-extensionType; - javaee:facelet-taglib-tag-behavior-extensionType; - javaee:facelet-taglib-tag-component-extensionType; - javaee:facelet-taglib-tag-converter-extensionType; - javaee:facelet-taglib-tag-extensionType; - javaee:facelet-taglib-tag-validator-extensionType; - javaee:faces-config-application-extensionType; - javaee:faces-config-attribute-extensionType; - javaee:faces-config-behavior-extensionType; - javaee:faces-config-component-extensionType; - javaee:faces-config-converter-extensionType; - javaee:faces-config-extensionType; - javaee:faces-config-facet-extensionType; - javaee:faces-config-factory-extensionType; - javaee:faces-config-lifecycle-extensionType; - javaee:faces-config-managed-bean-extensionType; - javaee:faces-config-navigation-rule-extensionType; - javaee:faces-config-null-valueType; - javaee:faces-config-ordering-othersType; - javaee:faces-config-property-extensionType; - javaee:faces-config-render-kit-extensionType; - javaee:faces-config-renderer-extensionType; - javaee:faces-config-validator-extensionType; - javaee:partial-response-extensionType; - extensibleType; - - - + javaee:emptyType; javaee:ordering-othersType; javaee:facelet-taglib-extensionType; javaee:facelet-taglib-tag-behavior-extensionType; javaee:facelet-taglib-tag-component-extensionType; javaee:facelet-taglib-tag-converter-extensionType; + javaee:facelet-taglib-tag-extensionType; javaee:facelet-taglib-tag-validator-extensionType; javaee:faces-config-application-extensionType; javaee:faces-config-attribute-extensionType; javaee:faces-config-behavior-extensionType; javaee:faces-config-component-extensionType; + javaee:faces-config-converter-extensionType; javaee:faces-config-extensionType; javaee:faces-config-facet-extensionType; javaee:faces-config-factory-extensionType; javaee:faces-config-lifecycle-extensionType; javaee:faces-config-managed-bean-extensionType; + javaee:faces-config-navigation-rule-extensionType; javaee:faces-config-null-valueType; javaee:faces-config-ordering-othersType; javaee:faces-config-property-extensionType; javaee:faces-config-render-kit-extensionType; javaee:faces-config-renderer-extensionType; + javaee:faces-config-validator-extensionType; javaee:partial-response-extensionType; extensibleType; + + + + + @@ -66,13 +53,85 @@ + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -174,6 +233,13 @@ + + + + + + + @@ -183,24 +249,42 @@ - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -213,7 +297,14 @@ - + + + + + + + + @@ -221,10 +312,548 @@ + + + + + + + + + + + + + : : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + : : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -238,7 +867,57 @@ - + + + + <T> + extends Child<T> + + { + + + + + + + + + + + + + + + + + + + + } + + + + + + + + + + + + + + + : : + + + + + + + + + <T> @@ -247,14 +926,14 @@ { - + - + @@ -273,10 +952,31 @@ - + + + + + + + + + + + + + + + + @@ -285,10 +985,33 @@ - + + + + + + + + + + + + + + + + @@ -297,12 +1020,18 @@ - + - + + + + + + + @@ -323,28 +1052,203 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -356,7 +1260,7 @@ - + import org.jboss.shrinkwrap.descriptor.api.Descriptor; import org.jboss.shrinkwrap.descriptor.api.DescriptorNamespace; @@ -368,18 +1272,102 @@ - + - + } + --> + + + + + + + + + + + + + + + + + + + + + { + + + + + + + + + + + + + + + + + } + + + + + + + + @@ -399,7 +1387,7 @@ - + @@ -413,16 +1401,19 @@ - + + + + - + - + @@ -435,6 +1426,59 @@ + + + + + + + + + + + + + + + import org.jboss.shrinkwrap.descriptor.spi.node.Node; + + + + + + + + + <T> + implements Child<T>, + + + { + + + + + + + + + + + + + + + + + + + + + } + + + + @@ -444,12 +1488,8 @@ - - - @@ -462,9 +1502,10 @@ - + import org.jboss.shrinkwrap.descriptor.api.DescriptorNamespace; + import org.jboss.shrinkwrap.descriptor.api.DescriptorNamespaceReader; import org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorImplBase; import org.jboss.shrinkwrap.descriptor.impl.base.XMLDate; import org.jboss.shrinkwrap.descriptor.spi.node.Node; @@ -472,7 +1513,7 @@ - + { @@ -483,16 +1524,16 @@ - + - + - + @@ -503,6 +1544,277 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + import org.jboss.shrinkwrap.descriptor.api.DescriptorNamespaceReader; + import org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorImplBase; + import org.jboss.shrinkwrap.descriptor.impl.base.XMLDate; + import org.jboss.shrinkwrap.descriptor.spi.node.Node; + + + + + + { + + + + + + + + + + + + + + + + + + + + + + + } + + + + + @@ -535,11 +1847,11 @@ - + - + @@ -831,22 +2143,24 @@ + + - + - + - + @@ -864,61 +2178,96 @@ + + - + - + - + - + - + - - + - - - - + + + + + + + + + + + - + + + + + + + + + + - - - - - + + + + + + + + + + + + - + + + + + + + + + + + + @@ -932,38 +2281,39 @@ + - + - + - + - + - + - + @@ -974,6 +2324,7 @@ + @@ -981,10 +2332,30 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -1001,6 +2372,7 @@ + @@ -1018,12 +2390,32 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1034,6 +2426,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1108,8 +2526,11 @@ - + + + + @@ -1127,10 +2548,10 @@ - + - + @@ -1149,7 +2570,7 @@ - + @@ -1166,8 +2587,54 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1237,6 +2704,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1256,10 +2781,18 @@ - - - - + + + + + + + + + + + + @@ -1428,8 +2961,16 @@ - - + + + + + + + + + + @@ -1496,14 +3037,14 @@ - - + + - + @@ -1516,27 +3057,49 @@ + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -1822,20 +3385,38 @@ + + - - - - - - + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + @@ -1988,23 +3569,63 @@ + - - - - + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + - - @@ -2043,6 +3664,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2292,7 +3984,7 @@ - + @@ -2356,10 +4048,17 @@ - - - - + + + + + + + + + + + @@ -2453,8 +4152,8 @@ - - + + @@ -2462,8 +4161,8 @@ package ; - - + + @@ -2473,7 +4172,6 @@ - @@ -2483,8 +4181,8 @@ - - + + @@ -2524,7 +4222,7 @@ - + @@ -2586,6 +4284,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + super(descriptorName, model); + } + + + + { + super(descriptorName); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2624,12 +4397,13 @@ - + + + - + - @@ -2645,81 +4419,189 @@ } + + + + + + + + + + + + + + + + + + + + + + + + + // -------------------------------------------------------------------------------------|| // Namespace // -------------------------------------------------------------------------------------|| + + + + + + + + + + { + + + + + } + + + + + + + public List<String> getNamespaces() + { + + + + + + + + + + + + } + + + + + + + + { + + + } + + + + + + + + + + { + + + + + } + + + + + + + + { + + + } + + + + + + + public List<String> getNamespaces() + { + + + + + + + + + + + + } + + + + + + + + { + + + + + + + + + + + + + + + + } + + + + + + + + + + - - + { - } + - - + { - - } - - - - - - public List<String> getNamespaces() - { - - - - - - - - - - - } - - - - - - { - - - - - - - - - - - - - - - - } + @@ -2733,6 +4615,7 @@ + @@ -2767,6 +4650,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2789,8 +4711,8 @@ - - + + @@ -2811,8 +4733,8 @@ - - + + @@ -2829,8 +4751,8 @@ - - + + @@ -2852,7 +4774,7 @@ - + @@ -2914,9 +4836,9 @@ - + - + + "/> @@ -2987,8 +4908,8 @@ " /> - - + + @@ -3030,7 +4951,7 @@ - + @@ -3083,8 +5004,8 @@ - - + + @@ -3109,8 +5030,8 @@ - @@ -3119,13 +5040,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3134,7 +5093,7 @@ - + @@ -3179,5 +5138,110 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/DomTestUtil.java b/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/DomTestUtil.java index 664a550c..44c1830b 100644 --- a/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/DomTestUtil.java +++ b/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/DomTestUtil.java @@ -37,7 +37,7 @@ public static Metadata parse(final String xmlFragment, final boolean isLogging) final TreeWalker walker = traversal.createTreeWalker(w3cDoc.getDocumentElement(), NodeFilter.SHOW_ELEMENT, null, true); - filterChain.traverseAndFilter(walker, "", metadata, sb); + filterChain.traverseAndFilter(walker, "", metadata, null, sb); if (isLogging) { log.info(sb.toString()); diff --git a/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserTest.java b/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserTest.java index d495334a..a135b6b9 100644 --- a/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserTest.java +++ b/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserTest.java @@ -23,7 +23,7 @@ public void testParseWithNullArguments() throws Exception { final MetadataParser parser = new MetadataParser(); boolean isRuntimeExceptionThrown = false; try { - parser.parse(null, null, false); + parser.parse(null, null, false, ""); } catch(IllegalArgumentException ex) { isRuntimeExceptionThrown = true; @@ -37,7 +37,7 @@ public void testParseWithPathNull() throws Exception { final MetadataParser parser = new MetadataParser(); boolean isRuntimeExceptionThrown = false; try { - parser.parse(null, new ArrayList(), false); + parser.parse(null, new ArrayList(), false, ""); } catch(IllegalArgumentException ex) { isRuntimeExceptionThrown = true; @@ -51,7 +51,7 @@ public void testParseWithDescriptorsNull() throws Exception { final MetadataParser parser = new MetadataParser(); boolean isRuntimeExceptionThrown = false; try { - parser.parse(new MetadataParserPath(), null, false); + parser.parse(new MetadataParserPath(), null, false, ""); } catch(IllegalArgumentException ex) { isRuntimeExceptionThrown = true; @@ -96,7 +96,7 @@ public void testParseAndMetadataGeneration() throws Exception { confList.add(conf); final MetadataParser parser = new MetadataParser(); - parser.parse(path, confList, true); + parser.parse(path, confList, true, ""); final String pathToMetadata = parser.getPathToMetadataFile(); Assert.assertNotNull(pathToMetadata); diff --git a/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/filter/ElementFilterTestCase.java b/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/filter/ElementFilterTestCase.java index d3504094..1be9f760 100644 --- a/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/filter/ElementFilterTestCase.java +++ b/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/filter/ElementFilterTestCase.java @@ -1,5 +1,6 @@ package org.jboss.shrinkwrap.descriptor.metadata.filter; +import java.io.File; import java.util.List; import junit.framework.Assert; @@ -7,6 +8,7 @@ import org.jboss.shrinkwrap.descriptor.metadata.DomTestUtil; import org.jboss.shrinkwrap.descriptor.metadata.Metadata; import org.jboss.shrinkwrap.descriptor.metadata.MetadataElement; +import org.jboss.shrinkwrap.descriptor.metadata.dom.DomWriter; import org.junit.Test; /** @@ -42,7 +44,7 @@ public void testElementsWithComplexTypeAsParent() throws Exception { @Test public void testElementsWithGroupAsParent() throws Exception { - final boolean isLogging = false; + final boolean isLogging = true; final String xmlFragment = "" + " " + @@ -81,6 +83,87 @@ public void testElementsWithGroupAsParent() throws Exception { DomTestUtil.assertElement(e.get(10), ""); } + @Test + public void testElementsWithMultipleSequences() throws Exception { + final boolean isLogging = true; + final String xmlFragment = + "" + +// " " + +// " " + +// " " + +// " " + +// " " + +// " " + +// " " + +// " " + +// " " + +// " " + +// " " + +// " " + +// " " + +// " " + +// " " + +// " " + +// " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + +// " " + + ""; + + final Metadata metadata = DomTestUtil.parse(xmlFragment, isLogging); + +// Assert.assertEquals("jndiEnvironmentRefsGroup", metadata.getGroupList().get(0).getName(), "jndiEnvironmentRefsGroup"); +// +// final List e = metadata.getGroupList().get(0).getElements(); +// DomTestUtil.assertElement(e.get(0), " "); +// DomTestUtil.assertElement(e.get(1), " "); +// DomTestUtil.assertElement(e.get(2), ""); +// DomTestUtil.assertElement(e.get(3), ""); +// DomTestUtil.assertElement(e.get(4), ""); +// DomTestUtil.assertElement(e.get(5), " "); +// DomTestUtil.assertElement(e.get(6), ""); +// DomTestUtil.assertElement(e.get(7), ""); +// DomTestUtil.assertElement(e.get(8), " "); +// DomTestUtil.assertElement(e.get(9), ""); +// DomTestUtil.assertElement(e.get(10), ""); + + File tempFile = File.createTempFile("tempMetadata", ".xml"); + new DomWriter().write(metadata, tempFile.getAbsolutePath()); + } + @Test public void testElementsWithReferencedElements() throws Exception { final boolean isLogging = false; diff --git a/pom.xml b/pom.xml index 84a04c99..93dab430 100644 --- a/pom.xml +++ b/pom.xml @@ -56,6 +56,7 @@ api-base api-javaee + api-javaee-prototype api-jboss api-misc bom @@ -63,6 +64,7 @@ gen impl-base impl-javaee + impl-javaee-prototype impl-jboss impl-misc spi diff --git a/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/Node.java b/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/Node.java index 35a61512..73b653dd 100644 --- a/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/Node.java +++ b/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/Node.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; /** @@ -520,6 +521,55 @@ public List getChildren() { return Collections.unmodifiableList(children); } + + /** + * Returns a deep copy of this {@link Node} + * + * @return + */ + public Node deepCopy() { + // Create new Node + final Node newRoot = new Node(this.getName()); + + // Set attributes + this.deepCopy(newRoot); + + // Return + return newRoot; + } + + /** + * Copies this reference to the specified {@link Node} + * @param copyTarget + * @return + */ + private Node deepCopy(final Node copyTarget){ + + // Precondition checks + assert copyTarget != null : "Node to copy information into must be specified"; + + // Set attributes + final Map attributes = this.getAttributes(); + final Set attributeKeys = attributes.keySet(); + for (final String key : attributeKeys) { + final String value = attributes.get(key); + copyTarget.attribute(key, value); + } + + // Set text + copyTarget.text(this.getText()); + + // Set children + final List children = this.getChildren(); + for (final Node child : children) { + final Node newChild = copyTarget.createChild(child.getName()); + // Recurse in + child.deepCopy(newChild); + } + + // Return + return this; + } // -------------------------------------------------------------------------------------|| // Override ----------------------------------------------------------------------------|| diff --git a/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/NodeDescriptor.java b/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/NodeDescriptor.java index 77d60f2e..461b9e4b 100644 --- a/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/NodeDescriptor.java +++ b/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/NodeDescriptor.java @@ -19,18 +19,10 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptor; /** - * A {@link Descriptor} based on a {@link Node} model - * (ie. hierarchal, typically representing XML metadata). - * + * A {@link Descriptor} based on a {@link NodeModel} (ie. hierarchal, typically representing XML metadata). + * * @author Aslak Knutsen * @author ALR */ -public interface NodeDescriptor extends Descriptor -{ - /** - * Obtains the top-level root {@link Node} for this - * {@link NodeDescriptor} - * @return - */ - Node getRootNode(); +public interface NodeDescriptor extends Descriptor, NodeModel { } diff --git a/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/NodeModel.java b/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/NodeModel.java new file mode 100644 index 00000000..fccdaf7f --- /dev/null +++ b/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/NodeModel.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, 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.spi.node; + +/** + * Any model based on a root {@link Node} structure (ie. hierarchal, typically representing XML metadata). + * + * @author Andrew Lee Rubinger + */ +public interface NodeModel { + /** + * Obtains the top-level root {@link Node} for this {@link NodeModel} + * + * @return + */ + Node getRootNode(); +} diff --git a/spi/src/test/java/org/jboss/shrinkwrap/descriptor/spi/node/NodeTestCase.java b/spi/src/test/java/org/jboss/shrinkwrap/descriptor/spi/node/NodeTestCase.java index 934d87df..1f7bbab5 100644 --- a/spi/src/test/java/org/jboss/shrinkwrap/descriptor/spi/node/NodeTestCase.java +++ b/spi/src/test/java/org/jboss/shrinkwrap/descriptor/spi/node/NodeTestCase.java @@ -638,4 +638,42 @@ public void shouldBeAbleToCreateNodeWithValueWithEqualsInIt() Assert.assertEquals("Verify correct value set", child3ValueNotEscaped, found.getText()); } + @Test + public void deepCopyUnequalByReference() { + final Node node = new Node("ALR"); + final Node copy = node.deepCopy(); + Assert.assertTrue("Deep copy should be unequal by reference to original", node != copy); + } + + @Test + public void deepCopyEqualityByValue() { + + // Make a node with some child content + final Node node = new Node("ALR"); + final Node child = node.createChild("child"); + node.createChild("secondChild"); + child.attribute("key", "value"); + child.text("text"); + final Node grandChild = child.createChild("grandChild"); + grandChild.text("grandText"); + + System.out.println(node.toString(true)); + + // Copy it + final Node copy = node.deepCopy(); + + System.out.println(copy.toString(true)); + final Node copyChild = copy.getChildren().get(0); + + // Check values + Assert.assertEquals(2, copy.getChildren().size()); + Assert.assertEquals("ALR", copy.getName()); + Assert.assertEquals("text", copyChild.getText()); + Assert.assertEquals("value", copyChild.getAttributes().get("key")); + Assert.assertEquals(1, copyChild.getAttributes().keySet().size()); + final Node copyGrandChild = copyChild.getChildren().get(0); + Assert.assertEquals("grandText", copyGrandChild.getText()); + } + + } \ No newline at end of file diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/application5/ApplicationDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/application5/ApplicationDescriptorTestCase.java index c75e2381..50919eb6 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/application5/ApplicationDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/application5/ApplicationDescriptorTestCase.java @@ -24,6 +24,7 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.application5.ApplicationDescriptor; +import org.jboss.shrinkwrap.descriptor.api.application5.MutableApplicationDescriptor; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -59,12 +60,12 @@ public class ApplicationDescriptorTestCase /** * Default, empty application descriptor */ - private ApplicationDescriptor emptyDescriptor; + private MutableApplicationDescriptor emptyDescriptor; /** * Fully-populated application descriptor */ - private ApplicationDescriptor fullyPopulatedDescriptor; + private MutableApplicationDescriptor fullyPopulatedDescriptor; //-------------------------------------------------------------------------------------|| // Lifecycle --------------------------------------------------------------------------|| @@ -73,13 +74,13 @@ public class ApplicationDescriptorTestCase @Before public void createEmptyDescriptor() { - emptyDescriptor = Descriptors.create(ApplicationDescriptor.class); + emptyDescriptor = Descriptors.create(MutableApplicationDescriptor.class); } @Before public void createFullyPopulatedDescriptor() { - fullyPopulatedDescriptor = Descriptors.importAs(ApplicationDescriptor.class).fromStream( + fullyPopulatedDescriptor = Descriptors.importAs(MutableApplicationDescriptor.class).fromStream( Thread.currentThread().getContextClassLoader().getResourceAsStream(NAME_EAR_XML)); log.info(fullyPopulatedDescriptor.exportAsString()); } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/application6/ApplicationDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/application6/ApplicationDescriptorTestCase.java index 257f3eac..d1ffdc2f 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/application6/ApplicationDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/application6/ApplicationDescriptorTestCase.java @@ -7,6 +7,7 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.application6.ApplicationDescriptor; +import org.jboss.shrinkwrap.descriptor.api.application6.MutableApplicationDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Before; import org.junit.Test; @@ -17,8 +18,7 @@ public class ApplicationDescriptorTestCase @Test public void testImportGeneratedApplicationXml() throws Exception { - ApplicationDescriptor app6Descr = create() - .addDefaultNamespaces() + MutableApplicationDescriptor app6Descr = create() .version("6") .applicationName("application-name0") .description("description0") @@ -218,9 +218,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private ApplicationDescriptor create() + private MutableApplicationDescriptor create() { - return Descriptors.create(ApplicationDescriptor.class); + return Descriptors.create(MutableApplicationDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/beans10/BeansDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/beans10/BeansDescriptorTestCase.java index 8cf1f05a..6fc6bed1 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/beans10/BeansDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/beans10/BeansDescriptorTestCase.java @@ -23,6 +23,7 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.beans10.BeansDescriptor; +import org.jboss.shrinkwrap.descriptor.api.beans10.MutableBeansDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Test; @@ -40,8 +41,8 @@ public class BeansDescriptorTestCase @Test public void testGeneratedXml() throws Exception { - final BeansDescriptor beansDescr = create() - .addDefaultNamespaces() + final MutableBeansDescriptor beansDescr = create() +// .addDefaultNamespaces() .getOrCreateInterceptors() .clazz("class0") .clazz("class1") @@ -85,8 +86,8 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private BeansDescriptor create() + private MutableBeansDescriptor create() { - return Descriptors.create(BeansDescriptor.class); + return Descriptors.create(MutableBeansDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/connector10/ConnectorDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/connector10/ConnectorDescriptorTestCase.java index d5ba707d..d7770919 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/connector10/ConnectorDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/connector10/ConnectorDescriptorTestCase.java @@ -25,6 +25,7 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.connector10.ConnectorDescriptor; +import org.jboss.shrinkwrap.descriptor.api.connector10.MutableConnectorDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Test; @@ -51,7 +52,7 @@ public void testSetName() throws Exception @Test public void testHornetQExample() throws Exception { - ConnectorDescriptor jca10Generated = create() + MutableConnectorDescriptor jca10Generated = create() .displayName("Sample Adapter") .description("It is a sample resource adapter") .vendorName("JBoss") @@ -106,9 +107,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private ConnectorDescriptor create() + private MutableConnectorDescriptor create() { - return Descriptors.create(ConnectorDescriptor.class); + return Descriptors.create(MutableConnectorDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/connector15/ConnectorDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/connector15/ConnectorDescriptorTestCase.java index e09f4e55..b950329e 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/connector15/ConnectorDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/connector15/ConnectorDescriptorTestCase.java @@ -25,6 +25,7 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.connector15.ConnectorDescriptor; +import org.jboss.shrinkwrap.descriptor.api.connector15.MutableConnectorDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Test; @@ -51,8 +52,8 @@ public void testSetName() throws Exception @Test public void testHornetQExample() throws Exception { - ConnectorDescriptor jca15Generated = create() - .addDefaultNamespaces() + MutableConnectorDescriptor jca15Generated = create() +// .addDefaultNamespaces() .version("1.5") .description("HornetQ 2.0 Resource Adapter") .displayName("HornetQ 2.0 Resource Adapter") @@ -150,9 +151,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private ConnectorDescriptor create() + private MutableConnectorDescriptor create() { - return Descriptors.create(ConnectorDescriptor.class); + return Descriptors.create(MutableConnectorDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/connector16/ConnectorDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/connector16/ConnectorDescriptorTestCase.java index 6235c9ba..b2a2024e 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/connector16/ConnectorDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/connector16/ConnectorDescriptorTestCase.java @@ -23,6 +23,7 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.connector16.ConnectorDescriptor; +import org.jboss.shrinkwrap.descriptor.api.connector16.MutableConnectorDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Test; @@ -49,8 +50,8 @@ public void testSetName() throws Exception @Test public void testGenExample() throws Exception { - ConnectorDescriptor jca16Descr = create() - .addDefaultNamespaces() + MutableConnectorDescriptor jca16Descr = create() +// .addDefaultNamespaces() .version("1.6") .moduleName("module-name0") .description("description0") @@ -142,9 +143,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private ConnectorDescriptor create() + private MutableConnectorDescriptor create() { - return Descriptors.create(ConnectorDescriptor.class); + return Descriptors.create(MutableConnectorDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/ejb30/EjbJarDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/ejb30/EjbJarDescriptorTestCase.java index d83a1870..1086bb9f 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/ejb30/EjbJarDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/ejb30/EjbJarDescriptorTestCase.java @@ -20,6 +20,7 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.ejbjar30.EjbJarDescriptor; +import org.jboss.shrinkwrap.descriptor.api.ejbjar30.MutableEjbJarDescriptor; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -46,7 +47,7 @@ public class EjbJarDescriptorTestCase /** * Descriptor under test */ - private EjbJarDescriptor fullyPopulatedDescriptor; + private MutableEjbJarDescriptor fullyPopulatedDescriptor; /** * Creates the fully-populated descriptor @@ -54,7 +55,7 @@ public class EjbJarDescriptorTestCase @Before public void createDescriptor() { - fullyPopulatedDescriptor = Descriptors.importAs(EjbJarDescriptor.class).fromStream( + fullyPopulatedDescriptor = Descriptors.importAs(MutableEjbJarDescriptor.class).fromStream( Thread.currentThread().getContextClassLoader().getResourceAsStream(NAME_EJB_JAR)); log.info(fullyPopulatedDescriptor.exportAsString()); } @@ -64,7 +65,7 @@ public void test() { //TODO Placeholder for porting tests // SHRINKDESC-61 @SuppressWarnings("unused") - final EjbJarDescriptor d = Descriptors.create(EjbJarDescriptor.class); + final MutableEjbJarDescriptor d = Descriptors.create(MutableEjbJarDescriptor.class); log.info(fullyPopulatedDescriptor.exportAsString()); } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/ejbjar31/EjbJarDescriptorReaderTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/ejbjar31/EjbJarDescriptorReaderTestCase.java new file mode 100644 index 00000000..87ff6e9c --- /dev/null +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/ejbjar31/EjbJarDescriptorReaderTestCase.java @@ -0,0 +1,556 @@ +package org.jboss.shrinkwrap.descriptor.test.ejbjar31; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.text.SimpleDateFormat; +import java.util.TimeZone; +import java.util.logging.Logger; + +import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.ejbjar31.EjbJarDescriptor; +import org.jboss.shrinkwrap.descriptor.api.ejbjar31.EnterpriseBeansTypeReader; +import org.jboss.shrinkwrap.descriptor.api.ejbjar31.MessageDrivenBeanTypeReader; +import org.jboss.shrinkwrap.descriptor.api.ejbjar31.MethodParamsTypeReader; +import org.jboss.shrinkwrap.descriptor.api.ejbjar31.NamedMethodTypeReader; +import org.jboss.shrinkwrap.descriptor.api.ejbjar31.TimerScheduleTypeReader; +import org.jboss.shrinkwrap.descriptor.api.ejbjar31.TimerTypeReader; +import org.jboss.shrinkwrap.descriptor.api.javaee6.IconTypeReader; +import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; +import org.junit.Before; +import org.junit.Test; + + +public class EjbJarDescriptorReaderTestCase +{ + final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-DD hh:mm:ss"); + + /** + * Logger + */ + private static final Logger log = Logger.getLogger(EjbJarDescriptorReaderTestCase.class.getName()); + + @Before + public void init() + { + sdf.setTimeZone(TimeZone.getTimeZone("GMT")); + } + + @Test + public void testGeneratedEjbJarReaderXml() throws Exception + { + final EjbJarDescriptor ejbJarReader = importFromString(getResourceContents("src/test/resources/test-gen-ejbjar31.xml")); + assertEquals(ejbJarReader.getVersion(), "3.1"); + assertEquals(ejbJarReader.getModuleName(), "module-name0"); + assertEquals(ejbJarReader.getAllDescription().get(0), "description0"); + assertEquals(ejbJarReader.getAllDisplayName().get(0), "display-name0"); + + final IconTypeReader iconTypeReader = ejbJarReader.getAllIcon().get(0); + assertEquals(iconTypeReader.getSmallIcon(), "small-icon0"); + assertEquals(iconTypeReader.getLargeIcon(), "large-icon0"); + + final EnterpriseBeansTypeReader enterpriseBeansTypeReader = ejbJarReader.getEnterpriseBeans(); + final MessageDrivenBeanTypeReader messageDrivenBeanTypeReader = (MessageDrivenBeanTypeReader) enterpriseBeansTypeReader.getAllMessageDriven().get(0); + + assertEquals(messageDrivenBeanTypeReader.getAllDescription().get(0), "description1"); + assertEquals(messageDrivenBeanTypeReader.getAllDisplayName().get(0), "display-name1"); + + final IconTypeReader iconTypeReader2 = (IconTypeReader) messageDrivenBeanTypeReader.getAllIcon().get(0); + assertEquals(iconTypeReader2.getSmallIcon(), "small-icon1"); + assertEquals(iconTypeReader2.getLargeIcon(), "large-icon1"); + + assertEquals(messageDrivenBeanTypeReader.getEjbName(), "ejb-name0"); + assertEquals(messageDrivenBeanTypeReader.getMappedName(), "mapped-name0"); + assertEquals(messageDrivenBeanTypeReader.getEjbClass(), "ejb-class0"); + assertEquals(messageDrivenBeanTypeReader.getMessagingType(), "messaging-type0"); + + final NamedMethodTypeReader namedMethodTypeReader = messageDrivenBeanTypeReader.getTimeoutMethod(); + assertEquals(namedMethodTypeReader.getMethodName(), "method-name0"); + + final MethodParamsTypeReader methodParamsTypeReader = namedMethodTypeReader.getMethodParams(); + assertEquals(methodParamsTypeReader.getAllMethodParam().get(0), "method-param0"); + + final TimerTypeReader timerTypeReader = (TimerTypeReader) messageDrivenBeanTypeReader.getAllTimer().get(0); + assertEquals(timerTypeReader.getAllDescription().get(0), "description2"); + + final TimerScheduleTypeReader timerScheduleTypeReader = timerTypeReader.getSchedule(); + assertEquals(timerScheduleTypeReader.getSecond(), "second0"); + assertEquals(timerScheduleTypeReader.getMinute(), "minute0"); + assertEquals(timerScheduleTypeReader.getHour(), "hour0"); + assertEquals(timerScheduleTypeReader.getDayOfMonth(), "day-of-month0"); + assertEquals(timerScheduleTypeReader.getMonth(), "month0"); + assertEquals(timerScheduleTypeReader.getDayOfWeek(), "day-of-week0"); + assertEquals(timerScheduleTypeReader.getYear(), "year0"); + + final NamedMethodTypeReader namedMethodTypeReader2 = messageDrivenBeanTypeReader.getTimeoutMethod(); + assertEquals(namedMethodTypeReader2.getMethodName(), "method-name0"); + + final MethodParamsTypeReader methodParamsTypeReader2 = namedMethodTypeReader2.getMethodParams(); + assertEquals(methodParamsTypeReader2.getAllMethodParam().get(0), "method-param0"); + + assertFalse(timerTypeReader.isPersistent()); + assertEquals(timerTypeReader.getTimezone(), "timezone0"); + assertEquals(timerTypeReader.getInfo(), "info0"); + + assertEquals(messageDrivenBeanTypeReader.getTransactionTypeAsString(), "Bean"); + assertEquals(messageDrivenBeanTypeReader.getMessageDestinationType(), "message-destination-type0"); + assertEquals(messageDrivenBeanTypeReader.getMessageDestinationLink(), "message-destination-link0"); + +// rest comes later ... + +// .getOrCreateActivationConfig() +// .description("description3") +// .createActivationConfigProperty() +// .activationConfigPropertyName("activation-config-property-name0") +// .activationConfigPropertyValue("activation-config-property-value0").up().up() +// .createAroundInvoke() +// .clazz("class0") +// .methodName("$").up() +// .createAroundTimeout() +// .clazz("class1") +// .methodName("$").up() +// .createEnvEntry() +// .description("description4") +// .envEntryName("env-entry-name0") +// .envEntryType("env-entry-type0") +// .envEntryValue("env-entry-value0") +// .mappedName("mapped-name1") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class0") +// .injectionTargetName("$").up() +// .lookupName("lookup-name0").up() +// .createEjbRef() +// .description("description5") +// .ejbRefName("ejb-ref-name0") +// .ejbRefType("Entity") +// .home("home0") +// .remote("remote0") +// .ejbLink("ejb-link0") +// .mappedName("mapped-name2") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class1") +// .injectionTargetName("$").up() +// .lookupName("lookup-name1").up() +// .createEjbLocalRef() +// .description("description6") +// .ejbRefName("ejb-ref-name1") +// .ejbRefType("Entity") +// .localHome("local-home0") +// .local("local0") +// .ejbLink("ejb-link1") +// .mappedName("mapped-name3") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class2") +// .injectionTargetName("$").up() +// .lookupName("lookup-name2").up() +// .createServiceRef() +// .description("description7") +// .displayName("display-name2") +// .createIcon() +// .smallIcon("small-icon2") +// .largeIcon("large-icon2").up() +// .serviceRefName("service-ref-name0") +// .serviceInterface("service-interface0") +// .serviceRefType("service-ref-type0") +// .wsdlFile("http://www.oxygenxml.com/") +// .jaxrpcMappingFile("jaxrpc-mapping-file0") +// .serviceQname("qName") +// .createPortComponentRef() +// .serviceEndpointInterface("service-endpoint-interface0") +// .enableMtom(false) +// .mtomThreshold(50) +// .getOrCreateAddressing() +// .enabled(false) +// .required(false) +// .responses("ANONYMOUS").up() +// .getOrCreateRespectBinding() +// .enabled(false).up() +// .portComponentLink("port-component-link0").up() +// .getOrCreateHandlerChains() +// .createHandlerChain() +// .protocolBindings("##a ##a http://www.oxygenxml.com/") +// .createHandler() +// .handlerName("handler-name0") +// .handlerClass("handler-class0").up().up().up() +// .mappedName("mapped-name4") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class3") +// .injectionTargetName("$").up() +// .lookupName("lookup-name3").up() +// .createResourceRef() +// .description("description8") +// .resRefName("res-ref-name0") +// .resType("res-type0") +// .resAuth("Application") +// .resSharingScope("Shareable") +// .mappedName("mapped-name5") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class4") +// .injectionTargetName("$").up() +// .lookupName("lookup-name4").up() +// .createResourceEnvRef() +// .description("description9") +// .resourceEnvRefName("resource-env-ref-name0") +// .resourceEnvRefType("resource-env-ref-type0") +// .mappedName("mapped-name6") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class5") +// .injectionTargetName("$").up() +// .lookupName("lookup-name5").up() +// .createMessageDestinationRef() +// .description("description10") +// .messageDestinationRefName("message-destination-ref-name0") +// .messageDestinationType("message-destination-type1") +// .messageDestinationUsage("Consumes") +// .messageDestinationLink("message-destination-link1") +// .mappedName("mapped-name7") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class6") +// .injectionTargetName("$").up() +// .lookupName("lookup-name6").up() +// .createPersistenceContextRef() +// .description("description11") +// .persistenceContextRefName("persistence-context-ref-name0") +// .persistenceUnitName("persistence-unit-name0") +// .persistenceContextType("Transaction") +// .createPersistenceProperty() +// .name("name0") +// .value("value0").up() +// .mappedName("mapped-name8") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class7") +// .injectionTargetName("$").up().up() +// .createPersistenceUnitRef() +// .description("description12") +// .persistenceUnitRefName("persistence-unit-ref-name0") +// .persistenceUnitName("persistence-unit-name1") +// .mappedName("mapped-name9") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class8") +// .injectionTargetName("$").up().up() +// .createPostConstruct() +// .lifecycleCallbackClass("lifecycle-callback-class0") +// .lifecycleCallbackMethod("$").up() +// .createPreDestroy() +// .lifecycleCallbackClass("lifecycle-callback-class1") +// .lifecycleCallbackMethod("$").up() +// .createDataSource() +// .description("description13") +// .name("name1") +// .className("class-name0") +// .serverName("server-name0") +// .portNumber(0) +// .databaseName("database-name0") +// .url("jdbc::") +// .user("user0") +// .password("password0") +// .createProperty() +// .name("name2") +// .value("value1").up() +// .loginTimeout(0) +// .transactional(false) +// .isolationLevel("TRANSACTION_READ_UNCOMMITTED") +// .initialPoolSize(0) +// .maxPoolSize(0) +// .minPoolSize(0) +// .maxIdleTime(0) +// .maxStatements(0).up() +// .createSecurityRoleRef() +// .description("description14") +// .roleName("role-name0") +// .roleLink("role-link0").up() +// .getOrCreateSecurityIdentity() +// .description("description15") +// .getOrCreateRunAs() +// .description("description16") +// .roleName("role-name1").up().up().up().up() +// .getOrCreateInterceptors() +// .description("description17") +// .createInterceptor() +// .description("description18") +// .interceptorClass("interceptor-class0") +// .createAroundInvoke() +// .clazz("class2") +// .methodName("$").up() +// .createAroundTimeout() +// .clazz("class3") +// .methodName("$").up() +// .createEnvEntry() +// .description("description19") +// .envEntryName("env-entry-name1") +// .envEntryType("env-entry-type1") +// .envEntryValue("env-entry-value1") +// .mappedName("mapped-name10") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class9") +// .injectionTargetName("$").up() +// .lookupName("lookup-name7").up() +// .createEjbRef() +// .description("description20") +// .ejbRefName("ejb-ref-name2") +// .ejbRefType("Entity") +// .home("home1") +// .remote("remote1") +// .ejbLink("ejb-link2") +// .mappedName("mapped-name11") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class10") +// .injectionTargetName("$").up() +// .lookupName("lookup-name8").up() +// .createEjbLocalRef() +// .description("description21") +// .ejbRefName("ejb-ref-name3") +// .ejbRefType("Entity") +// .localHome("local-home1") +// .local("local1") +// .ejbLink("ejb-link3") +// .mappedName("mapped-name12") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class11") +// .injectionTargetName("$").up() +// .lookupName("lookup-name9").up() +// .createServiceRef() +// .description("description22") +// .displayName("display-name3") +// .createIcon() +// .smallIcon("small-icon3") +// .largeIcon("large-icon3").up() +// .serviceRefName("service-ref-name1") +// .serviceInterface("service-interface1") +// .serviceRefType("service-ref-type1") +// .wsdlFile("http://www.oxygenxml.com/") +// .jaxrpcMappingFile("jaxrpc-mapping-file1") +// .serviceQname("qName") +// .createPortComponentRef() +// .serviceEndpointInterface("service-endpoint-interface1") +// .enableMtom(false) +// .mtomThreshold(50) +// .getOrCreateAddressing() +// .enabled(false) +// .required(false) +// .responses("ANONYMOUS").up() +// .getOrCreateRespectBinding() +// .enabled(false).up() +// .portComponentLink("port-component-link1").up() +// .createHandler() +// .description("description23") +// .displayName("display-name4") +// .createIcon() +// .smallIcon("small-icon1") +// .largeIcon("large-icon1").up() +// .handlerName("handler-name1") +// .handlerClass("handler-class1") +// .createInitParam() +// .paramName("param-name0") +// .paramValue("param-value0").up() +// .soapHeader("qName") +// .soapRole("soap-role0") +// .portName("port-name0").up() +// .mappedName("mapped-name13") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class12") +// .injectionTargetName("$").up() +// .lookupName("lookup-name10").up() +// .createResourceRef() +// .description("description24") +// .resRefName("res-ref-name1") +// .resType("res-type1") +// .resAuth("Application") +// .resSharingScope("Shareable") +// .mappedName("mapped-name14") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class13") +// .injectionTargetName("$").up() +// .lookupName("lookup-name11").up() +// .createResourceEnvRef() +// .description("description25") +// .resourceEnvRefName("resource-env-ref-name1") +// .resourceEnvRefType("resource-env-ref-type1") +// .mappedName("mapped-name15") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class14") +// .injectionTargetName("$").up() +// .lookupName("lookup-name12").up() +// .createMessageDestinationRef() +// .description("description26") +// .messageDestinationRefName("message-destination-ref-name1") +// .messageDestinationType("message-destination-type2") +// .messageDestinationUsage("Consumes") +// .messageDestinationLink("message-destination-link2") +// .mappedName("mapped-name16") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class15") +// .injectionTargetName("$").up() +// .lookupName("lookup-name13").up() +// .createPersistenceContextRef() +// .description("description27") +// .persistenceContextRefName("persistence-context-ref-name1") +// .persistenceUnitName("persistence-unit-name2") +// .persistenceContextType("Transaction") +// .createPersistenceProperty() +// .name("name3") +// .value("value2").up() +// .mappedName("mapped-name17") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class16") +// .injectionTargetName("$").up().up() +// .createPersistenceUnitRef() +// .description("description28") +// .persistenceUnitRefName("persistence-unit-ref-name1") +// .persistenceUnitName("persistence-unit-name3") +// .mappedName("mapped-name18") +// .createInjectionTarget() +// .injectionTargetClass("injection-target-class17") +// .injectionTargetName("$").up().up() +// .createPostConstruct() +// .lifecycleCallbackClass("lifecycle-callback-class2") +// .lifecycleCallbackMethod("$").up() +// .createPreDestroy() +// .lifecycleCallbackClass("lifecycle-callback-class3") +// .lifecycleCallbackMethod("$").up() +// .createDataSource() +// .description("description29") +// .name("name4") +// .className("class-name1") +// .serverName("server-name1") +// .portNumber(0) +// .databaseName("database-name1") +// .url("jdbc::") +// .user("user1") +// .password("password1") +// .createProperty() +// .name("name5") +// .value("value3").up() +// .loginTimeout(0) +// .transactional(false) +// .isolationLevel("TRANSACTION_READ_UNCOMMITTED") +// .initialPoolSize(0) +// .maxPoolSize(0) +// .minPoolSize(0) +// .maxIdleTime(0) +// .maxStatements(0).up() +// .createPostActivate() +// .lifecycleCallbackClass("lifecycle-callback-class4") +// .lifecycleCallbackMethod("$").up() +// .createPrePassivate() +// .lifecycleCallbackClass("lifecycle-callback-class5") +// .lifecycleCallbackMethod("$").up() .up().up() +// .getOrCreateRelationships() +// .description("description30") +// .createEjbRelation() +// .description("description31") +// .ejbRelationName("ejb-relation-name0") +// .createEjbRelationshipRole() +// .description("description32") +// .ejbRelationshipRoleName("ejb-relationship-role-name0") +// .multiplicity("One") +// .getOrCreateRelationshipRoleSource() +// .description("description33") +// .ejbName("ejb-name1").up() +// .getOrCreateCmrField() +// .description("description34") +// .cmrFieldName("cmr-field-name0") +// .cmrFieldType("java.util.Collection").up().up() +// .createEjbRelationshipRole() +// .description("description35") +// .ejbRelationshipRoleName("ejb-relationship-role-name1") +// .multiplicity("One") +// .cascadeDelete() +// .getOrCreateRelationshipRoleSource() +// .description("description36") +// .ejbName("ejb-name2").up() +// .getOrCreateCmrField() +// .description("description37") +// .cmrFieldName("cmr-field-name1") +// .cmrFieldType("java.util.Collection").up().up().up().up() +// .getOrCreateAssemblyDescriptor() +// .createSecurityRole() +// .description("description38") +// .roleName("role-name2").up() +// .createMethodPermission() +// .description("description39") +// .unchecked() +// .createMethod() +// .description("description40") +// .ejbName("ejb-name3") +// .methodIntf("Home") +// .methodName("method-name6") +// .getOrCreateMethodParams() +// .methodParam("method-param1").up().up().up() +// .createContainerTransaction() +// .description("description41") +// .createMethod() +// .description("description42") +// .ejbName("ejb-name4") +// .methodIntf("Home") +// .methodName("method-name7") +// .getOrCreateMethodParams() +// .methodParam("method-param2").up().up() +// .transAttribute("NotSupported").up() +// .createInterceptorBinding() +// .description("description43") +// .ejbName("ejb-name5") +// .interceptorClass("interceptor-class1") +// .excludeDefaultInterceptors(false) +// .excludeClassInterceptors(false) +// .getOrCreateMethod() +// .methodName("method-name8") +// .getOrCreateMethodParams() +// .methodParam("method-param3").up().up().up() +// .createMessageDestination() +// .description("description44") +// .displayName("display-name5") +// .createIcon() +// .smallIcon("small-icon4") +// .largeIcon("large-icon4").up() +// .messageDestinationName("message-destination-name0") +// .mappedName("mapped-name19") +// .lookupName("lookup-name14").up() +// .getOrCreateExcludeList() +// .description("description45") +// .createMethod() +// .description("description46") +// .ejbName("ejb-name6") +// .methodIntf("Home") +// .methodName("method-name9") +// .getOrCreateMethodParams() +// .methodParam("method-param4").up().up().up() +// .createApplicationException() +// .exceptionClass("exception-class0") +// .rollback(false) +// .inherited(false).up().up() +// .ejbClientJar("ejb-client-jar0"); + + String webXmlGenerated = ejbJarReader.exportAsString(); + String webXmlOriginal = getResourceContents("src/test/resources/test-gen-ejbjar31.xml"); + + XmlAssert.assertIdentical(webXmlOriginal, webXmlGenerated); + } + + + // -------------------------------------------------------------------------------------|| + // Helper Methods ----------------------------------------------------------------------|| + // -------------------------------------------------------------------------------------|| + + 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(); + } + + private EjbJarDescriptor importFromString(final String str) + { + return Descriptors.importAs(EjbJarDescriptor.class).from(str); + } + +} diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/ejbjar31/EjbJarDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/ejbjar31/EjbJarDescriptorTestCase.java index 0a7806ec..fdccdb0e 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/ejbjar31/EjbJarDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/ejbjar31/EjbJarDescriptorTestCase.java @@ -8,6 +8,7 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.ejbjar31.EjbJarDescriptor; +import org.jboss.shrinkwrap.descriptor.api.ejbjar31.MutableEjbJarDescriptor; import org.jboss.shrinkwrap.descriptor.test.application5.ApplicationDescriptorTestCase; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Before; @@ -32,8 +33,8 @@ public void init() @Test public void testGeneratedEjbJarXml() throws Exception { - EjbJarDescriptor ejbJarGenerated = create() - .addDefaultNamespaces() + MutableEjbJarDescriptor ejbJarGenerated = create() +// .addDefaultNamespaces() .version("3.1") .moduleName("module-name0") .description("description0") @@ -512,8 +513,8 @@ public void testGeneratedEjbJarXml() throws Exception @Test public void testInterceptors() throws Exception { - EjbJarDescriptor ejbJarGenerated = create() - .addDefaultNamespaces() + MutableEjbJarDescriptor ejbJarGenerated = create() +// .addDefaultNamespaces() .version("3.1") .getOrCreateInterceptors() .createInterceptor().interceptorClass(" enterprise.annot_ovd_interceptor_ejb.NullChecker ").up() @@ -557,9 +558,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private EjbJarDescriptor create() + private MutableEjbJarDescriptor create() { - return Descriptors.create(EjbJarDescriptor.class); + return Descriptors.create(MutableEjbJarDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/facesconfig20/FacesConfigDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/facesconfig20/FacesConfigDescriptorTestCase.java index f48dbcd3..f24088ff 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/facesconfig20/FacesConfigDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/facesconfig20/FacesConfigDescriptorTestCase.java @@ -11,6 +11,7 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.facesconfig20.FacesConfigVersionType; +import org.jboss.shrinkwrap.descriptor.api.facesconfig20.MutableWebFacesConfigDescriptor; import org.jboss.shrinkwrap.descriptor.api.facesconfig20.WebFacesConfigDescriptor; import org.jboss.shrinkwrap.descriptor.spi.node.Node; import org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptor; @@ -68,14 +69,14 @@ public void verifySchemaLocation() { @Test public void shouldBeAbleToOverrideVersionInWebFacesConfigDescriptor() throws Exception { // Make a descriptor - final WebFacesConfigDescriptor facesConfig = Descriptors.importAs(WebFacesConfigDescriptor.class).fromString(source); + final MutableWebFacesConfigDescriptor facesConfig = Descriptors.importAs(MutableWebFacesConfigDescriptor.class).fromString(source); facesConfig.version("2.0"); Assert.assertEquals("2.0", facesConfig.getVersionAsString()); // Get as Node structure final InputStream stream = new ByteArrayInputStream(facesConfig.exportAsString().getBytes()); - final WebFacesConfigDescriptor fromFacesConfigXml = Descriptors.importAs(WebFacesConfigDescriptor.class).fromStream( + final MutableWebFacesConfigDescriptor fromFacesConfigXml = Descriptors.importAs(MutableWebFacesConfigDescriptor.class).fromStream( stream); final Node root = ((NodeDescriptor) fromFacesConfigXml).getRootNode(); @@ -92,8 +93,8 @@ public void shouldBeAbleToOverrideVersionInWebFacesConfigDescriptor() throws Exc @Test public void testGeneratedFacesConfigXml() throws Exception { - final WebFacesConfigDescriptor facesConfig = create() - .addDefaultNamespaces() + final MutableWebFacesConfigDescriptor facesConfig = create() +// .addDefaultNamespaces() .version(FacesConfigVersionType._2_0) .name("SeamBooking") .getOrCreateNavigationRule() @@ -217,8 +218,8 @@ private String getResourceContents(String resource) throws Exception { return builder.toString(); } - private WebFacesConfigDescriptor create() { - return Descriptors.create(WebFacesConfigDescriptor.class); + private MutableWebFacesConfigDescriptor create() { + return Descriptors.create(MutableWebFacesConfigDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jbossweb60/JbossWebDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jbossweb60/JbossWebDescriptorTestCase.java index 784c6782..462d4582 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jbossweb60/JbossWebDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jbossweb60/JbossWebDescriptorTestCase.java @@ -7,6 +7,7 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.jbossweb60.JbossWebDescriptor; +import org.jboss.shrinkwrap.descriptor.api.jbossweb60.MutableJbossWebDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Before; import org.junit.Test; @@ -25,8 +26,8 @@ public void init() @Test public void testGeneratedJbossWeb60Xml() throws Exception { - JbossWebDescriptor ejbJarGenerated = create() - .addDefaultNamespaces() + MutableJbossWebDescriptor ejbJarGenerated = create() +// .addDefaultNamespaces() .version("6.0") .getOrCreateClassLoading().javaClassLoadingCompliance(false) .getOrCreateLoaderRepository().loaderRepositoryClass("loaderRepositoryClass1") @@ -591,9 +592,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private JbossWebDescriptor create() + private MutableJbossWebDescriptor create() { - return Descriptors.create(JbossWebDescriptor.class); + return Descriptors.create(MutableJbossWebDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jetty7/Jetty7TestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jetty7/Jetty7TestCase.java index 45092814..edbc9d1b 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jetty7/Jetty7TestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jetty7/Jetty7TestCase.java @@ -8,7 +8,7 @@ import org.custommonkey.xmlunit.XMLUnit; import org.jboss.shrinkwrap.descriptor.api.Descriptors; -import org.jboss.shrinkwrap.descriptor.api.jetty7.JettyDescriptor; +import org.jboss.shrinkwrap.descriptor.api.jetty7.MutableJettyDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Test; import org.xml.sax.EntityResolver; @@ -22,7 +22,7 @@ public class Jetty7TestCase @Test public void testJettyConfiguration() throws Exception { - final JettyDescriptor jetty7Generated = create().clazz("class0").id("id0") + final MutableJettyDescriptor jetty7Generated = create().clazz("class0").id("id0") .getOrCreateNew().clazz("class1").id("id1") .createArg().type("type0") .getOrCreateArray().type("type1").id("id2") @@ -113,9 +113,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private JettyDescriptor create() + private MutableJettyDescriptor create() { - return Descriptors.create(JettyDescriptor.class); + return Descriptors.create(MutableJettyDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jsptaglibrary20/WebJspTagLibraryDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jsptaglibrary20/WebJspTagLibraryDescriptorTestCase.java index f49a5700..d343f111 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jsptaglibrary20/WebJspTagLibraryDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jsptaglibrary20/WebJspTagLibraryDescriptorTestCase.java @@ -23,6 +23,7 @@ import java.util.logging.Logger; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.jsptaglibrary20.MutableWebJsptaglibraryDescriptor; import org.jboss.shrinkwrap.descriptor.api.jsptaglibrary20.WebJsptaglibraryDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Before; @@ -48,8 +49,8 @@ public void init() @Test public void testGeneratedWebJspTagLibrary20Xml() throws Exception { - WebJsptaglibraryDescriptor ejbJarGenerated = create() - .addDefaultNamespaces() + MutableWebJsptaglibraryDescriptor ejbJarGenerated = create() +// .addDefaultNamespaces() .version("2.0") .description("description0") .description("description1") @@ -237,9 +238,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private WebJsptaglibraryDescriptor create() + private MutableWebJsptaglibraryDescriptor create() { - return Descriptors.create(WebJsptaglibraryDescriptor.class); + return Descriptors.create(MutableWebJsptaglibraryDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jsptaglibrary21/WebJspTagLibraryDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jsptaglibrary21/WebJspTagLibraryDescriptorTestCase.java index 8dc8ee4e..877fcbf9 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jsptaglibrary21/WebJspTagLibraryDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/jsptaglibrary21/WebJspTagLibraryDescriptorTestCase.java @@ -22,6 +22,7 @@ import java.util.TimeZone; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.jsptaglibrary21.MutableWebJsptaglibraryDescriptor; import org.jboss.shrinkwrap.descriptor.api.jsptaglibrary21.WebJsptaglibraryDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Before; @@ -45,8 +46,8 @@ public void init() @Test public void testGeneratedWebJspTagLibrary21Xml() throws Exception { - WebJsptaglibraryDescriptor ejbJarGenerated = create() - .addDefaultNamespaces() + MutableWebJsptaglibraryDescriptor ejbJarGenerated = create() +// .addDefaultNamespaces() .version("2.1") .description("description0") .description("description1") @@ -233,9 +234,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private WebJsptaglibraryDescriptor create() + private MutableWebJsptaglibraryDescriptor create() { - return Descriptors.create(WebJsptaglibraryDescriptor.class); + return Descriptors.create(MutableWebJsptaglibraryDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/persistence10/PersistenceDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/persistence10/PersistenceDescriptorTestCase.java index 26406b2d..124879e4 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/persistence10/PersistenceDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/persistence10/PersistenceDescriptorTestCase.java @@ -4,6 +4,7 @@ import java.io.FileReader; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.persistence10.MutablePersistenceDescriptor; import org.jboss.shrinkwrap.descriptor.api.persistence10.PersistenceDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Test; @@ -14,8 +15,8 @@ public class PersistenceDescriptorTestCase @Test public void testGeneratedPersistenceXml() throws Exception { - final PersistenceDescriptor persistence = create() - .addDefaultNamespaces() + final MutablePersistenceDescriptor persistence = create() +// .addDefaultNamespaces() .version("1.0") .createPersistenceUnit() .name("name1") @@ -77,8 +78,8 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private PersistenceDescriptor create() + private MutablePersistenceDescriptor create() { - return Descriptors.create(PersistenceDescriptor.class); + return Descriptors.create(MutablePersistenceDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/persistence20/PersistenceDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/persistence20/PersistenceDescriptorTestCase.java index 09a9cb29..e810b6e3 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/persistence20/PersistenceDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/persistence20/PersistenceDescriptorTestCase.java @@ -4,6 +4,7 @@ import java.io.FileReader; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.persistence20.MutablePersistenceDescriptor; import org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Test; @@ -14,8 +15,8 @@ public class PersistenceDescriptorTestCase @Test public void testGeneratedPersistenceXml() throws Exception { - final PersistenceDescriptor persistence = create() - .addDefaultNamespaces() + final MutablePersistenceDescriptor persistence = create() +// .addDefaultNamespaces() .version("2.0") .createPersistenceUnit() .name("name1") @@ -83,8 +84,8 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private PersistenceDescriptor create() + private MutablePersistenceDescriptor create() { - return Descriptors.create(PersistenceDescriptor.class); + return Descriptors.create(MutablePersistenceDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/BeansDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/BeansDescriptorTestCase.java index 3c5b6d30..c4056f24 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/BeansDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/BeansDescriptorTestCase.java @@ -30,6 +30,7 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.beans10.BeansDescriptor; +import org.jboss.shrinkwrap.descriptor.api.beans10.MutableBeansDescriptor; import org.junit.Ignore; import org.junit.Test; @@ -81,7 +82,7 @@ public void shouldCreateDefaultName() throws Exception @Test public void shouldBeAbleToSetName() throws Exception { - Assert.assertEquals("test.xml", Descriptors.create(BeansDescriptor.class, "test.xml").getDescriptorName()); + Assert.assertEquals("test.xml", Descriptors.create(MutableBeansDescriptor.class, "test.xml").getDescriptorName()); } @Test @@ -233,7 +234,7 @@ public void shouldBeAbleToReadWhatWasExported() throws Exception final String desc = create().getOrCreateDecorators() .clazz(TestDecorator.class.getName(), TestDecorator.class.getName()).up().exportAsString(); - final String roundtrip = Descriptors.importAs(BeansDescriptor.class).fromString(desc).exportAsString(); + final String roundtrip = Descriptors.importAs(MutableBeansDescriptor.class).fromString(desc).exportAsString(); assertPresenceUsingXPath(roundtrip, "/beans/decorators/class", TestDecorator.class.getName(), TestDecorator.class.getName()); @@ -246,7 +247,7 @@ public void shouldBeAbleToReadWhatWasExported() throws Exception @Test public void shouldBeAbleToGenerateComplexDescriptor() throws Exception { - final BeansDescriptor beans = Descriptors.create(BeansDescriptor.class).getOrCreateInterceptors() + final MutableBeansDescriptor beans = Descriptors.create(MutableBeansDescriptor.class).getOrCreateInterceptors() .clazz(TestInterceptor.class.getName(), TestAnotherInterceptor.class.getName()).up() .getOrCreateDecorators().clazz(TestDecorator.class.getName()).up().getOrCreateAlternatives() .stereotype(TestAlternativeStereoType.class.getName()).up(); @@ -261,8 +262,8 @@ public void shouldBeAbleToGenerateComplexDescriptor() throws Exception // Internal Helper --------------------------------------------------------------------|| //-------------------------------------------------------------------------------------|| - private BeansDescriptor create() + private MutableBeansDescriptor create() { - return Descriptors.create(BeansDescriptor.class); + return Descriptors.create(MutableBeansDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/DescriptorExporterTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/DescriptorExporterTestCase.java index 3b84cc7d..30f00d0d 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/DescriptorExporterTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/DescriptorExporterTestCase.java @@ -19,6 +19,7 @@ import java.io.ByteArrayOutputStream; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.webapp30.MutableWebAppDescriptor; import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; import org.junit.Assert; import org.junit.Ignore; @@ -38,7 +39,7 @@ public class DescriptorExporterTestCase public void shouldBeAbleToExportToStream() throws Exception { final String name = DescriptorExporterTestCase.class.getName(); - final WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class).displayName(name); + final MutableWebAppDescriptor descriptor = Descriptors.create(MutableWebAppDescriptor.class).displayName(name); final ByteArrayOutputStream output = new ByteArrayOutputStream(); descriptor.exportTo(output); diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/PersistenceDescriptorEclipseLinkTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/PersistenceDescriptorEclipseLinkTestCase.java index 46b3b933..4ce9f3d5 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/PersistenceDescriptorEclipseLinkTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/PersistenceDescriptorEclipseLinkTestCase.java @@ -3,6 +3,7 @@ import static org.jboss.shrinkwrap.descriptor.test.util.XmlAssert.assertPresenceUsingXPath; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.persistence20.MutablePersistenceDescriptor; import org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor; import org.junit.Ignore; import org.junit.Test; @@ -65,9 +66,9 @@ private void shouldBeAbleSetSchemaGenerationMode(String providerType, String gen // assertPresenceUsingXPath(desc, "/persistence/persistence-unit/properties/property/@value", expectedValue); } - private PersistenceDescriptor create() + private MutablePersistenceDescriptor create() { - return Descriptors.create(PersistenceDescriptor.class).getOrCreatePersistenceUnit().name(this.getClass().getSimpleName()).up(); + return Descriptors.create(MutablePersistenceDescriptor.class).getOrCreatePersistenceUnit().name(this.getClass().getSimpleName()).up(); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/PersistenceDescriptorHibernateTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/PersistenceDescriptorHibernateTestCase.java index 84783052..b1e98500 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/PersistenceDescriptorHibernateTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/PersistenceDescriptorHibernateTestCase.java @@ -3,6 +3,7 @@ import static org.jboss.shrinkwrap.descriptor.test.util.XmlAssert.assertPresenceUsingXPath; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.persistence20.MutablePersistenceDescriptor; import org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor; import org.junit.Ignore; import org.junit.Test; @@ -95,8 +96,8 @@ public void shouldBeAbleToSetSchemaGenerationModeHibernateUpdate() throws Except // assertPresenceUsingXPath(desc, "/persistence/persistence-unit/properties/property/@value", expectedValue); // } // - private PersistenceDescriptor create() + private MutablePersistenceDescriptor create() { - return Descriptors.create(PersistenceDescriptor.class).getOrCreatePersistenceUnit().name(this.getClass().getSimpleName()).up(); + return Descriptors.create(MutablePersistenceDescriptor.class).getOrCreatePersistenceUnit().name(this.getClass().getSimpleName()).up(); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/PersistenceDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/PersistenceDescriptorTestCase.java index cd857376..ee4441e4 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/PersistenceDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/PersistenceDescriptorTestCase.java @@ -25,7 +25,9 @@ import junit.framework.Assert; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.persistence20.MutablePersistenceDescriptor; import org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor; +import org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceMutable; import org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceUnit; import org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceUnitTransactionType; import org.jboss.shrinkwrap.descriptor.api.persistence20.Properties; @@ -126,9 +128,8 @@ public void shouldBeAbleToAddClasses() throws Exception @Test public void shouldBeAbleToAddDescription() throws Exception { - PersistenceUnit unit = create().getOrCreatePersistenceUnit().description(name); - String desc = unit.up() - .exportAsString(); + PersistenceUnit unit = create().getOrCreatePersistenceUnit().description(name); + String desc = unit.up().exportAsString(); assertPresenceUsingXPath(desc, "/persistence/persistence-unit/description", name); Assert.assertEquals(name, unit.getDescription()); } @@ -152,7 +153,7 @@ public void shouldBeAbleToSetIncludeUnlistedClasses() throws Exception @Test public void shouldBeAbleToSetJTADataSource() throws Exception { - PersistenceUnit unit = create().getOrCreatePersistenceUnit().jtaDataSource(name); + PersistenceUnit unit = create().getOrCreatePersistenceUnit().jtaDataSource(name); String desc = unit.up().exportAsString(); assertPresenceUsingXPath(desc, "/persistence/persistence-unit/jta-data-source", name); @@ -182,7 +183,7 @@ public void shouldBeAbleToReplaceNonJTADataSourceWithJTADataSource() throws Exce @Test public void shouldBeAbleToSetNonJtaDataSource() throws Exception { - PersistenceUnit unit = create().getOrCreatePersistenceUnit().nonJtaDataSource(name); + PersistenceUnit unit = create().getOrCreatePersistenceUnit().nonJtaDataSource(name); String desc = unit.up().exportAsString(); assertPresenceUsingXPath(desc, "/persistence/persistence-unit/non-jta-data-source", name); @@ -260,12 +261,12 @@ public void addingDuplicateNamePropertyUpdatesExisting() throws Exception @Test public void shouldBeAbleToGetProperties() throws Exception { - PersistenceUnit def = create().getOrCreatePersistenceUnit() + Properties> def = create().getOrCreatePersistenceUnit() .getOrCreateProperties() .createProperty().name(name).value(name2).up() - .createProperty().name(name2).value(name).up().up(); + .createProperty().name(name2).value(name).up(); - List>>> properties = def.getOrCreateProperties().getAllProperty(); + List>>> properties = def.getAllProperty(); assertEquals(2, properties.size()); assertEquals(name, properties.get(0).getName()); assertEquals(name2, properties.get(0).getValue()); @@ -310,12 +311,12 @@ public void shouldBeAbleToGetProperties() throws Exception @Test public void shouldBeAbleToClearProperties() throws Exception { - Properties> def = create().getOrCreatePersistenceUnit() + Properties> def = create().getOrCreatePersistenceUnit() .getOrCreateProperties() .createProperty().name(name).value(name2).up() .createProperty().name(name2).value(name).up(); - List>>> props = def.getAllProperty(); + List>>> props = def.getAllProperty(); assertEquals(2, props.size()); def.removeAllProperty(); @@ -327,12 +328,12 @@ public void shouldBeAbleToClearProperties() throws Exception @Test public void shouldBeAbleToClearPropertiesAndAddNew() throws Exception { - Properties> def = create().getOrCreatePersistenceUnit() + Properties> def = create().getOrCreatePersistenceUnit() .getOrCreateProperties() .createProperty().name(name).value(name2).up() .createProperty().name(name2).value(name).up(); - List>>> props = def.getAllProperty(); + List>>> props = def.getAllProperty(); assertEquals(2, props.size()); def.removeAllProperty(); @@ -385,7 +386,7 @@ public void shouldBeAbleToIncludeMultiplePersistenceUnit() throws Exception final String eclipseLinkProvider = "org.eclipse.persistence.jpa.PersistenceProvider"; final String nonjtaDataSource = "jdbc/__default"; - final PersistenceDescriptor persistence = Descriptors.create(PersistenceDescriptor.class) + final MutablePersistenceDescriptor persistence = Descriptors.create(MutablePersistenceDescriptor.class) .createPersistenceUnit().name(hibernateUnit).transactionType(txTypeJta) .provider(providerTypeHibernate).jtaDataSource(jtaDataSource).clazz(PersistenceDescriptor.class.getName()).up() .createPersistenceUnit().name(eclipseLinkUnit).transactionType(txTypeResourceLocal) @@ -412,8 +413,8 @@ public void shouldBeAbleToIncludeMultiplePersistenceUnit() throws Exception // Internal Helper --------------------------------------------------------------------|| // -------------------------------------------------------------------------------------|| - private PersistenceDescriptor create() + private MutablePersistenceDescriptor create() { - return Descriptors.create(PersistenceDescriptor.class).getOrCreatePersistenceUnit().name(name).up(); + return Descriptors.create(MutablePersistenceDescriptor.class).getOrCreatePersistenceUnit().name(name).up(); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/WebAppDefTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/WebAppDefTestCase.java index 7cabbaaa..3f9b4384 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/WebAppDefTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portedfrompoc/WebAppDefTestCase.java @@ -26,9 +26,11 @@ import java.util.logging.Logger; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.webapp30.MutableWebAppDescriptor; import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; import org.jboss.shrinkwrap.descriptor.api.webcommon30.ServletMappingType; import org.jboss.shrinkwrap.descriptor.api.webcommon30.ServletType; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.WebAppTypeMutable; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -105,7 +107,7 @@ public void shouldBeAbleToSetName() throws Exception @Test public void verifySchemaLocation() { - final WebAppDescriptor desc = create(); + final MutableWebAppDescriptor desc = create(); final String descString = desc.exportAsString(); log.info(descString); final String expectedSchemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"; @@ -154,7 +156,7 @@ public void shouldBeAbleToDetermineReadServletClass() throws Exception String name = "FacesServlet"; String clazz = "javax.faces.webapp." + name; - ServletType servlet = create().getOrCreateServlet().servletClass(clazz).servletName(name); + ServletType servlet = create().getOrCreateServlet().servletClass(clazz).servletName(name); assertEquals(clazz, servlet.getServletClass()); } @@ -166,11 +168,11 @@ public void shouldBeAbleToQueryServlets() throws Exception final String clazz = "javax.faces.webapp." + name; final String mapping = "/*"; - final WebAppDescriptor webXml = create().getOrCreateServlet().servletClass(clazz).servletName(name).up() + final MutableWebAppDescriptor webXml = create().getOrCreateServlet().servletClass(clazz).servletName(name).up() .getOrCreateServletMapping().servletName(name).urlPattern(mapping).up(); - final List> servlets = webXml.getAllServlet(); - final List> mappings = webXml.getAllServletMapping(); + final List> servlets = webXml.getAllServlet(); + final List> mappings = webXml.getAllServletMapping(); assertEquals(1, servlets.size()); assertEquals(name, servlets.get(0).getServletName()); assertEquals(mapping, mappings.get(0).getAllUrlPattern().get(0)); @@ -287,7 +289,7 @@ public void shouldHaveSecurityConstraintDisplayName() throws Exception { final String securityConstraintDisplayName = "Default security constraint"; - final String webAppDescriptor = Descriptors.create(WebAppDescriptor.class).getOrCreateSecurityConstraint() + final String webAppDescriptor = Descriptors.create(MutableWebAppDescriptor.class).getOrCreateSecurityConstraint() .displayName(securityConstraintDisplayName).up().exportAsString().trim(); assertPresenceUsingXPath(webAppDescriptor, "/web-app/security-constraint/display-name", securityConstraintDisplayName); @@ -307,9 +309,9 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private WebAppDescriptor create() + private MutableWebAppDescriptor create() { - return Descriptors.create(WebAppDescriptor.class); + return Descriptors.create(MutableWebAppDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portlet20/PortletDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portlet20/PortletDescriptorTestCase.java index ce7cccfe..5830bc1b 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portlet20/PortletDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/portlet20/PortletDescriptorTestCase.java @@ -4,6 +4,7 @@ import java.io.FileReader; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.portletapp20.MutablePortletDescriptor; import org.jboss.shrinkwrap.descriptor.api.portletapp20.PortletDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Test; @@ -14,8 +15,8 @@ public class PortletDescriptorTestCase @Test public void testGeneratedPortletXml() throws Exception { - final PortletDescriptor portlet = create() - .addDefaultNamespaces() + final MutablePortletDescriptor portlet = create() +// .addDefaultNamespaces() .version("2.0") .createPortlet() .portletName("HelloPortlet") @@ -61,8 +62,8 @@ private String getResourceContents(String resource) throws Exception return builder.toString(); } - private PortletDescriptor create() + private MutablePortletDescriptor create() { - return Descriptors.create(PortletDescriptor.class); + return Descriptors.create(MutablePortletDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorAttributeGroupTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorAttributeGroupTestCase.java index 69e513a7..1c3c3583 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorAttributeGroupTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorAttributeGroupTestCase.java @@ -6,6 +6,7 @@ import java.util.logging.Logger; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.webapp30.MutableWebAppDescriptor; import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; import org.junit.Test; @@ -26,7 +27,7 @@ public class WebAppDescriptorAttributeGroupTestCase @Test public void testDescription() throws Exception { - final WebAppDescriptor webApp = create() + final MutableWebAppDescriptor webApp = create() .createServlet() .description("Description1") .description("Description2").up(); @@ -42,7 +43,7 @@ public void testDescription() throws Exception @Test public void testDisplayName() throws Exception { - final WebAppDescriptor webApp = create() + final MutableWebAppDescriptor webApp = create() .createFilter() .displayName("displayName1") .displayName("displayName2").up(); @@ -58,7 +59,7 @@ public void testDisplayName() throws Exception @Test public void testIcon() throws Exception { - final WebAppDescriptor webApp = create() + final MutableWebAppDescriptor webApp = create() .createFilter().createIcon().largeIcon("largeIcon1").up() .createIcon().smallIcon("smallIcon2").up().up(); @@ -81,8 +82,8 @@ public void testIcon() throws Exception // Helper Methods ----------------------------------------------------------------------|| // -------------------------------------------------------------------------------------|| - private WebAppDescriptor create() + private MutableWebAppDescriptor create() { - return Descriptors.create(WebAppDescriptor.class); + return Descriptors.create(MutableWebAppDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorComplexTypeTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorComplexTypeTestCase.java index 0e7ef94c..618cd5f3 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorComplexTypeTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorComplexTypeTestCase.java @@ -7,6 +7,7 @@ import java.util.logging.Logger; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.webapp30.MutableWebAppDescriptor; import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; import org.junit.Test; @@ -33,7 +34,7 @@ public class WebAppDescriptorComplexTypeTestCase @Test public void testWebResourceCollection() throws Exception { - final WebAppDescriptor webApp = create() + final MutableWebAppDescriptor webApp = create() .createSecurityConstraint() .createWebResourceCollection() .webResourceName("resource1") @@ -87,7 +88,7 @@ public void testWebResourceCollection() throws Exception @Test public void testLocaleEncodingMappingList() throws Exception { - final WebAppDescriptor webApp = create().createLocaleEncodingMappingList() + final MutableWebAppDescriptor webApp = create().createLocaleEncodingMappingList() .createLocaleEncodingMapping().locale("locale1").encoding("encoding1").up() .createLocaleEncodingMapping().locale("locale2").encoding("encoding2").up().up(); @@ -119,8 +120,8 @@ public void testLocaleEncodingMappingList() throws Exception // Helper Methods ----------------------------------------------------------------------|| // -------------------------------------------------------------------------------------|| - private WebAppDescriptor create() + private MutableWebAppDescriptor create() { - return Descriptors.create(WebAppDescriptor.class); + return Descriptors.create(MutableWebAppDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorImportAsTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorImportAsTestCase.java index 4548ce4b..299a512c 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorImportAsTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorImportAsTestCase.java @@ -8,6 +8,7 @@ import java.util.logging.Logger; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.webapp30.MutableWebAppDescriptor; import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; import org.junit.Test; @@ -38,7 +39,7 @@ public class WebAppDescriptorImportAsTestCase public void shouldBeAbleToImport() throws Exception { // Make a descriptor - final WebAppDescriptor web = Descriptors.importAs(WebAppDescriptor.class).fromString( + final MutableWebAppDescriptor web = Descriptors.importAs(MutableWebAppDescriptor.class).fromString( source); log.info(web.exportAsString()); @@ -54,7 +55,7 @@ public void testImportGeneratedTutorialWebXml() throws Exception { String web_source_generated = getResourceContents("src/test/resources/test-orig-webapp30.xml"); - final WebAppDescriptor webapp = Descriptors.importAs(WebAppDescriptor.class).fromString( + final MutableWebAppDescriptor webapp = Descriptors.importAs(MutableWebAppDescriptor.class).fromString( web_source_generated); assertTrue(webapp.getAllDisplayName().size() == 1); @@ -86,7 +87,7 @@ public void testImportGeneratedWebXml() throws Exception { String web_source_generated = getResourceContents("src/test/resources/test-gen-webapp30.xml"); - final WebAppDescriptor web = Descriptors.importAs(WebAppDescriptor.class).fromString( + final MutableWebAppDescriptor web = Descriptors.importAs(MutableWebAppDescriptor.class).fromString( web_source_generated); assertEquals(web.getAllModuleName().get(0), "module-name0"); diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorNamespaceTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorNamespaceTestCase.java index d06781f2..3c51d05a 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorNamespaceTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorNamespaceTestCase.java @@ -6,10 +6,9 @@ import static org.jboss.shrinkwrap.descriptor.test.util.XmlAssert.assertSchemaLocation; import static org.junit.Assert.assertTrue; -import java.util.List; - import org.jboss.shrinkwrap.descriptor.api.Descriptors; -import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webapp30.MutableWebAppDescriptor; +import org.junit.Ignore; import org.junit.Test; @@ -20,7 +19,7 @@ public class WebAppDescriptorNamespaceTestCase public void shouldAddDefaultNamespaces() throws Exception { final String app = create() - .addDefaultNamespaces() +// .addDefaultNamespaces() .exportAsString(); final String expectedJavaEENamespace= "http://java.sun.com/xml/ns/javaee"; @@ -31,31 +30,32 @@ public void shouldAddDefaultNamespaces() throws Exception } - @Test - public void testReturnAllNamespaces() throws Exception - { - final List nsList = create() - .addDefaultNamespaces() - .getNamespaces(); - - final String expectedJavaEENamespace= "http://java.sun.com/xml/ns/javaee"; - final String expectedXmlNamespace = "http://www.w3.org/2001/XMLSchema-instance"; - final String expectedSchemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"; - - assertTrue(nsList.size() == 3); - assertTrue(nsList.contains("xmlns=" + expectedJavaEENamespace)); - assertTrue(nsList.contains("xmlns:xsi=" + expectedXmlNamespace)); - assertTrue(nsList.contains("xsi:schemaLocation=" + expectedSchemaLocation)); - } +// @Test +// public void testReturnAllNamespaces() throws Exception +// { +// final List nsList = create() +//// .addDefaultNamespaces() +// .getNamespaces(); +// +// final String expectedJavaEENamespace= "http://java.sun.com/xml/ns/javaee"; +// final String expectedXmlNamespace = "http://www.w3.org/2001/XMLSchema-instance"; +// final String expectedSchemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"; +// +// assertTrue(nsList.size() == 3); +// assertTrue(nsList.contains("xmlns=" + expectedJavaEENamespace)); +// assertTrue(nsList.contains("xmlns:xsi=" + expectedXmlNamespace)); +// assertTrue(nsList.contains("xsi:schemaLocation=" + expectedSchemaLocation)); +// } @Test + @Ignore public void testRemoveAllNamespaces() throws Exception { final String app = create() .version("3.0") - .addDefaultNamespaces() - .removeAllNamespaces() +// .addDefaultNamespaces() +// .removeAllNamespaces() .exportAsString(); assertTrue(app.indexOf("xmlns") == -1); @@ -73,20 +73,20 @@ public void shouldAddNamespace() throws Exception // check javaee namespace only final String app1 = create() - .addNamespace("xmlns", "http://java.sun.com/xml/ns/javaee") +// .addNamespace("xmlns", "http://java.sun.com/xml/ns/javaee") .exportAsString(); assertDefaultNamespace(app1, expectedJavaEENamespace); // check xml namespace only final String app2 = create() - .addNamespace("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") +// .addNamespace("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") .exportAsString(); assertNamespaceURIDefined(app2, "xsi", expectedXmlNamespace); // check schema location only final String app3 = create() - .addNamespace("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") - .addNamespace("xsi:schemaLocation", "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd") +// .addNamespace("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") +// .addNamespace("xsi:schemaLocation", "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd") .exportAsString(); assertSchemaLocation(app3, "http://www.w3.org/2001/XMLSchema-instance", expectedSchemaLocation); } @@ -95,8 +95,8 @@ public void shouldAddNamespace() throws Exception // Helper Methods ----------------------------------------------------------------------|| // -------------------------------------------------------------------------------------|| - private WebAppDescriptor create() + private MutableWebAppDescriptor create() { - return Descriptors.create(WebAppDescriptor.class); + return Descriptors.create(MutableWebAppDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorSimpleTypeTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorSimpleTypeTestCase.java index 325623a9..4476ad4f 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorSimpleTypeTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorSimpleTypeTestCase.java @@ -7,6 +7,7 @@ import java.util.logging.Logger; import org.jboss.shrinkwrap.descriptor.api.Descriptors; +import org.jboss.shrinkwrap.descriptor.api.webapp30.MutableWebAppDescriptor; import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; import org.junit.Test; @@ -28,7 +29,7 @@ public class WebAppDescriptorSimpleTypeTestCase @Test public void testLoadOnStartupType() throws Exception { - final WebAppDescriptor webApp = create().createServlet().loadOnStartup(1).up(); + final MutableWebAppDescriptor webApp = create().createServlet().loadOnStartup(1).up(); assertTrue(webApp.getAllServlet().get(0).getLoadOnStartup()==1); webApp.exportAsString(); assertPresenceUsingXPath(webApp.exportAsString(), "/web-app/servlet/load-on-startup", "1"); @@ -43,7 +44,7 @@ public void testLoadOnStartupType() throws Exception @Test public void testWebAppVersionType() throws Exception { - final WebAppDescriptor webApp = create().version("3.0"); + final MutableWebAppDescriptor webApp = create().version("3.0"); assertEquals(webApp.getVersionAsString(), "3.0"); assertPresenceUsingXPath(webApp.exportAsString(), "/web-app/@version", "3.0"); @@ -56,8 +57,8 @@ public void testWebAppVersionType() throws Exception // Helper Methods ----------------------------------------------------------------------|| // -------------------------------------------------------------------------------------|| - private WebAppDescriptor create() + private MutableWebAppDescriptor create() { - return Descriptors.create(WebAppDescriptor.class); + return Descriptors.create(MutableWebAppDescriptor.class); } } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorTestCase.java index f970ef5d..130c8996 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/webapp30/WebAppDescriptorTestCase.java @@ -1,7 +1,7 @@ package org.jboss.shrinkwrap.descriptor.test.webapp30; -import static org.jboss.shrinkwrap.descriptor.test.util.XmlAssert.*; - +import static org.jboss.shrinkwrap.descriptor.test.util.XmlAssert.assertPresenceUsingXPath; +import static org.jboss.shrinkwrap.descriptor.test.util.XmlAssert.assertSchemaLocation; import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; @@ -13,9 +13,11 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.javaee6.IconType; +import org.jboss.shrinkwrap.descriptor.api.webapp30.MutableWebAppDescriptor; import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; import org.jboss.shrinkwrap.descriptor.api.webcommon30.FilterType; import org.jboss.shrinkwrap.descriptor.api.webcommon30.TrackingModeType; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.WebAppTypeMutable; import org.jboss.shrinkwrap.descriptor.spi.node.Node; import org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptor; import org.junit.Test; @@ -52,7 +54,7 @@ public void shouldCreateDefaultName() throws Exception @Test public void shouldBeAbleToSetName() throws Exception { - Assert.assertEquals("test.xml", Descriptors.create(WebAppDescriptor.class, "test.xml").getDescriptorName()); + Assert.assertEquals("test.xml", Descriptors.create(MutableWebAppDescriptor.class, "test.xml").getDescriptorName()); } /** @@ -107,13 +109,13 @@ public void shouldBeAbleToSetWelcomeFiles() throws Exception @Test public void shouldBeAbleToGetFilterIcons() throws Exception { - WebAppDescriptor web = create() + MutableWebAppDescriptor web = create() .createFilter() .createIcon().smallIcon("small1").largeIcon("large1").up() .createIcon().smallIcon("small2").largeIcon("large2").up() .up(); - List>> list = web.getAllFilter().get(0).getAllIcon(); + List>> list = web.getAllFilter().get(0).getAllIcon(); assertTrue(list.size() == 2); for (IconType icon: list) { @@ -193,7 +195,7 @@ public void shouldBeAbleToCreateSessionCookieConfig() throws Exception public void shouldBeAbleToOverrideVersionInWebAppDescriptor() throws Exception { // Make a descriptor - final WebAppDescriptor web = Descriptors.importAs(WebAppDescriptor.class).fromString( + final MutableWebAppDescriptor web = Descriptors.importAs(MutableWebAppDescriptor.class).fromString( source); web.version("3.0"); @@ -201,7 +203,7 @@ public void shouldBeAbleToOverrideVersionInWebAppDescriptor() throws Exception // Get as Node structure final InputStream stream = new ByteArrayInputStream(web.exportAsString().getBytes()); - final WebAppDescriptor fromWebXml = Descriptors.importAs(WebAppDescriptor.class).fromStream(stream); + final MutableWebAppDescriptor fromWebXml = Descriptors.importAs(MutableWebAppDescriptor.class).fromStream(stream); final Node root = ((NodeDescriptor) fromWebXml).getRootNode(); // Preconditions @@ -222,8 +224,8 @@ public void shouldBeAbleToOverrideVersionInWebAppDescriptor() throws Exception // Helper Methods ----------------------------------------------------------------------|| // -------------------------------------------------------------------------------------|| - private WebAppDescriptor create() + private MutableWebAppDescriptor create() { - return Descriptors.create(WebAppDescriptor.class); + return Descriptors.create(MutableWebAppDescriptor.class); } }