diff --git a/appclient/src/main/resources/schema/jboss-client_9_0.xsd b/appclient/src/main/resources/schema/jboss-client_9_0.xsd new file mode 100644 index 000000000..647add38c --- /dev/null +++ b/appclient/src/main/resources/schema/jboss-client_9_0.xsd @@ -0,0 +1,79 @@ + + + + + + + + ... + + + The instance documents may indicate the published version of + the schema using the xsi:schemaLocation attribute for the + Java EE namespace with the following location: + + https://www.jboss.org/j2ee/schema/jboss-client_9_0.xsd + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/appclient/src/test/java/org/jboss/test/metadata/appclient/AppclientSpecDescriptorTestCase.java b/appclient/src/test/java/org/jboss/test/metadata/appclient/AppclientSpecDescriptorTestCase.java index a122e55f0..bdcc9911b 100644 --- a/appclient/src/test/java/org/jboss/test/metadata/appclient/AppclientSpecDescriptorTestCase.java +++ b/appclient/src/test/java/org/jboss/test/metadata/appclient/AppclientSpecDescriptorTestCase.java @@ -38,7 +38,7 @@ public class AppclientSpecDescriptorTestCase extends SpecDescriptorTestCase { @Parameters public static List parameters() { // The spec descriptor should be guarded in schema - return Arrays.asList(new Object[][]{{"schema/application-client_6.xsd"},{"schema/application-client_7.xsd"},{"schema/application-client_8.xsd"}}); + return Arrays.asList(new Object[][]{{"schema/application-client_6.xsd"},{"schema/application-client_7.xsd"},{"schema/application-client_8.xsd"},{"schema/application-client_9.xsd"}}); } public AppclientSpecDescriptorTestCase(String xsd) { diff --git a/ear/src/main/java/org/jboss/metadata/ear/jboss/JBossAppMetaData.java b/ear/src/main/java/org/jboss/metadata/ear/jboss/JBossAppMetaData.java index 9ad243a90..56b4d2a91 100644 --- a/ear/src/main/java/org/jboss/metadata/ear/jboss/JBossAppMetaData.java +++ b/ear/src/main/java/org/jboss/metadata/ear/jboss/JBossAppMetaData.java @@ -48,7 +48,7 @@ public class JBossAppMetaData extends EarMetaData { private String distinctName; public JBossAppMetaData() { - super(EarVersion.APP_8_0); + super(EarVersion.APP_10_0); } public JBossAppMetaData(EarVersion earVersion) { diff --git a/ear/src/main/resources/schema/jboss-app_9_0.xsd b/ear/src/main/resources/schema/jboss-app_9_0.xsd new file mode 100644 index 000000000..ef52a8ab3 --- /dev/null +++ b/ear/src/main/resources/schema/jboss-app_9_0.xsd @@ -0,0 +1,122 @@ + + + + + + + + ... + + + The instance documents may indicate the published version of + the schema using the xsi:schemaLocation attribute for the + Java EE namespace with the following location: + + https://www.jboss.org/schema/jbossas/jboss-app_10_0.xsd + + ]]> + + + + + + + + + + + + + + + + Root element for JBoss specific configurations in a .ear + + + + + + + + + The distinct-name for this application. + + + + + + + The security domain application for this application. + + + + + + + The principal that will be used for unauthenticated requests in this application + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ear/src/test/java/org/jboss/test/metadata/ear/JBossApp9xEverythingUnitTestCase.java b/ear/src/test/java/org/jboss/test/metadata/ear/JBossApp9xEverythingUnitTestCase.java new file mode 100644 index 000000000..2ea0b93aa --- /dev/null +++ b/ear/src/test/java/org/jboss/test/metadata/ear/JBossApp9xEverythingUnitTestCase.java @@ -0,0 +1,181 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2013, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.test.metadata.ear; + +import org.jboss.metadata.ear.jboss.JBossAppMetaData; +import org.jboss.metadata.ear.jboss.ServiceModuleMetaData; +import org.jboss.metadata.ear.spec.ConnectorModuleMetaData; +import org.jboss.metadata.ear.spec.EarMetaData; +import org.jboss.metadata.ear.spec.EjbModuleMetaData; +import org.jboss.metadata.ear.spec.JavaModuleMetaData; +import org.jboss.metadata.ear.spec.ModuleMetaData; +import org.jboss.metadata.ear.spec.ModulesMetaData; +import org.jboss.metadata.ear.spec.WebModuleMetaData; +import org.jboss.metadata.javaee.spec.SecurityRoleMetaData; +import org.jboss.metadata.javaee.spec.SecurityRolesMetaData; +import org.jboss.metadata.ear.merge.JBossAppMetaDataMerger; +import org.jboss.metadata.ear.parser.jboss.JBossAppMetaDataParser; +import org.jboss.metadata.ear.parser.spec.EarMetaDataParser; +import org.jboss.test.metadata.javaee.AbstractJavaEEMetaDataTest; +import org.junit.Test; + +/** + * Test jboss-app.xml which uses jboss-app_9_0.xsd + * + * @author Jaikiran Pai + */ +public class JBossApp9xEverythingUnitTestCase extends AbstractJavaEEMetaDataTest { + + private boolean hasJBossAppOverride = false; + + protected JBossAppMetaData unmarshal() throws Exception { + return JBossAppMetaDataParser.INSTANCE.parse(getReader()); + } + + @Test + public void testOverride() throws Exception { + EarMetaData spec = EarMetaDataParser.INSTANCE.parse(getReader("Ear10xEverything_testEverything.xml")); + JBossAppMetaData jbossAppMD = new JBossAppMetaData(); + JBossAppMetaDataMerger.merge(jbossAppMD, null, spec); + hasJBossAppOverride = false; + assertEveryting(jbossAppMD); + } + + @Test + public void testEverything() + throws Exception { + //enableTrace("org.jboss.xb"); + EarMetaData spec = EarMetaDataParser.INSTANCE.parse(getReader("Ear10xEverything_testEverything.xml")); + JBossAppMetaData jbossAppXml = unmarshal(); + assertEquals("Unexpected distinct-name", "foo", jbossAppXml.getDistinctName()); + JBossAppMetaData jbossAppMD = new JBossAppMetaData(); + JBossAppMetaDataMerger.merge(jbossAppMD, jbossAppXml, spec); + hasJBossAppOverride = true; + assertEveryting(jbossAppMD); + assertEquals("jboss-app-id", jbossAppMD.getId()); + assertEveryting(jbossAppMD); + } + + protected void assertEveryting(JBossAppMetaData ear) throws Exception { + assertSecurityRoles(ear); + assertLibraryDirectory(ear); + assertModules(ear); + } + + protected void assertSecurityRoles(JBossAppMetaData ear) { + SecurityRolesMetaData roles = ear.getSecurityRoles(); + assertEquals("There are 2 roles " + roles, 2, roles.size()); + SecurityRoleMetaData role0 = roles.get("securityRoleRef1RoleLink"); + SecurityRoleMetaData role1 = roles.get("securityRoleRef2RoleLink"); + if (hasJBossAppOverride) { + assertEquals("security-role0", role0.getId()); + assertEquals("securityRoleRef1RoleLink", role0.getName()); + assertEquals("en-securityRole1-desc", role0.getDescriptions().value()[0].value()); + + assertEquals("security-role1", role1.getId()); + assertEquals("securityRoleRef2RoleLink", role1.getName()); + assertEquals("en-securityRole2-desc", role1.getDescriptions().value()[0].value()); + + assertTrue("1 principal in role0", role0.getPrincipals().size() == 1); + assertEquals("principal0", role0.getPrincipals().toArray()[0]); + assertEquals("principal1", role1.getPrincipals().toArray()[0]); + } else { + assertEquals("securityRole1-id", role0.getId()); + assertEquals("securityRoleRef1RoleLink", role0.getName()); + assertEquals("en-securityRole1-desc", role0.getDescriptions().value()[0].value()); + + assertEquals("securityRole2-id", role1.getId()); + assertEquals("securityRoleRef2RoleLink", role1.getName()); + assertEquals("en-securityRole2-desc", role1.getDescriptions().value()[0].value()); + } + } + + protected void assertLibraryDirectory(JBossAppMetaData ear) { + if (hasJBossAppOverride) { + assertEquals("jboss-app-lib0", ear.getLibraryDirectory()); + } else { + assertEquals("lib0", ear.getLibraryDirectory()); + } + } + + protected void assertModules(JBossAppMetaData ear) { + ModulesMetaData modules = ear.getModules(); + if (hasJBossAppOverride) { + assertEquals(9, modules.size()); + } else { + assertEquals(6, modules.size()); + } + ModuleMetaData connector = modules.get(0); + assertEquals("connector0", connector.getId()); + ConnectorModuleMetaData connectorMD = (ConnectorModuleMetaData) connector.getValue(); + assertEquals("rar0.rar", connectorMD.getConnector()); + ModuleMetaData java = modules.get(1); + assertEquals("java0", java.getId()); + JavaModuleMetaData javaMD = (JavaModuleMetaData) java.getValue(); + assertEquals("client0.jar", javaMD.getClientJar()); + ModuleMetaData ejb0 = modules.get(2); + assertEquals("ejb0", ejb0.getId()); + EjbModuleMetaData ejb0MD = (EjbModuleMetaData) ejb0.getValue(); + assertEquals("ejb-jar0.jar", ejb0MD.getEjbJar()); + ModuleMetaData ejb1 = modules.get(3); + assertEquals("ejb1", ejb1.getId()); + EjbModuleMetaData ejb1MD = (EjbModuleMetaData) ejb1.getValue(); + assertEquals("ejb-jar1.jar", ejb1MD.getEjbJar()); + ModuleMetaData web0 = modules.get(4); + assertEquals("web0", web0.getId()); + WebModuleMetaData web0MD = (WebModuleMetaData) web0.getValue(); + assertEquals("/web0", web0MD.getContextRoot()); + assertEquals("web-app0.war", web0MD.getWebURI()); + ModuleMetaData web1 = modules.get(5); + assertEquals("web1", web1.getId()); + WebModuleMetaData web1MD = (WebModuleMetaData) web1.getValue(); + if (hasJBossAppOverride) { + assertEquals("/web1-override", web1MD.getContextRoot()); + } else { + assertEquals("/web1", web1MD.getContextRoot()); + } + assertEquals("web-app1.war", web1MD.getWebURI()); + if (hasJBossAppOverride) { + // Validate the sar, web2, har added in jboss-app.xml + ModuleMetaData sar = modules.get(6); + assertEquals("sar0", sar.getId()); + ServiceModuleMetaData sarMD = (ServiceModuleMetaData) sar.getValue(); + assertEquals("sar0.sar", sarMD.getSar()); + ModuleMetaData web2 = modules.get(7); + assertEquals("web2", web2.getId()); + WebModuleMetaData web2MD = (WebModuleMetaData) web2.getValue(); + assertEquals("/web2", web2MD.getContextRoot()); + assertEquals("web-app2.war", web2MD.getWebURI()); + ModuleMetaData har = modules.get(8); + assertEquals("har0", har.getId()); + ServiceModuleMetaData harMD = (ServiceModuleMetaData) har.getValue(); + assertEquals("har0.har", harMD.getSar()); + } + // Validate lookup by module file name + ModuleMetaData mmd = modules.get("rar0.rar"); + assertEquals(connector, mmd); + mmd = modules.get("ejb-jar1.jar"); + assertEquals(ejb1, mmd); + mmd = modules.get("web-app0.war"); + assertEquals(web0, mmd); + } +} diff --git a/ear/src/test/resources/org/jboss/test/metadata/ear/JBossApp9xEverything_testEverything.xml b/ear/src/test/resources/org/jboss/test/metadata/ear/JBossApp9xEverything_testEverything.xml new file mode 100644 index 000000000..0f207e7d2 --- /dev/null +++ b/ear/src/test/resources/org/jboss/test/metadata/ear/JBossApp9xEverything_testEverything.xml @@ -0,0 +1,64 @@ + + + + + + foo + jboss-app-lib0 + + + + sar0.sar + + + + + web-app1.war + /web1-override + + + + + + web-app2.war + /web2 + + + + har0.har + + + The 0 security role + securityRoleRef1RoleLink + principal0 + + + The 1 security role + securityRoleRef2RoleLink + principal1 + +