You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by km...@apache.org on 2008/07/14 18:55:18 UTC
svn commit: r676644 [5/5] - in
/openejb/trunk/openejb3/container/openejb-jee/src:
main/java/org/apache/openejb/jee/ test/java/org/apache/openejb/jee/
test/resources/
Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ObjectFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ObjectFactory.java?rev=676644&r1=676643&r2=676644&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ObjectFactory.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ObjectFactory.java Mon Jul 14 09:55:16 2008
@@ -54,6 +54,7 @@
private final static QName _Connector_QNAME = new QName("http://java.sun.com/xml/ns/j2ee", "connector");
private final static QName _JavaWsdlMapping_QNAME = new QName("http://java.sun.com/xml/ns/j2ee", "java-wsdl-mapping");
private final static QName _Webservices_QNAME = new QName("http://java.sun.com/xml/ns/javaee", "webservices");
+ private final static QName _FacesConfig_QNAME = new QName("http://java.sun.com/xml/ns/javaee", "faces-config");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.openejb.jee2
@@ -163,4 +164,13 @@
public JAXBElement<Webservices> createConnector(Webservices value) {
return new JAXBElement<Webservices>(_Webservices_QNAME, Webservices.class, null, value);
}
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link FacesConfig }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://java.sun.com/xml/ns/javaee", name = "faces-config")
+ public JAXBElement<FacesConfig> createFacesConfig(FacesConfig value) {
+ return new JAXBElement<FacesConfig>(_FacesConfig_QNAME, FacesConfig.class, null, value);
+ }
}
Modified: openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java?rev=676644&r1=676643&r2=676644&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/JeeTest.java Mon Jul 14 09:55:16 2008
@@ -17,15 +17,18 @@
*/
package org.apache.openejb.jee;
-import junit.framework.TestCase;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLFilterImpl;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.ValidationEvent;
@@ -33,13 +36,14 @@
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.sax.SAXSource;
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLFilterImpl;
/**
* @version $Revision$ $Date$
@@ -102,6 +106,29 @@
public void testRar() throws Exception {
marshalAndUnmarshal(Connector.class, "connector-example.xml");
}
+ /**
+ * This test requires that there are three managed beans in faces-config.xml. It will ask JaxbJavaee to load faces-config.xml
+ * and then assert if it found the three managed beans and checks if the class names are correct
+ * @throws Exception
+ */
+ public void testFacesConfig() throws Exception{
+ List<String> managedBeanClasses = new ArrayList<String>();
+ managedBeanClasses.add("org.apache.openejb.faces.EmployeeBean");
+ managedBeanClasses.add("org.apache.openejb.faces.OneBean");
+ managedBeanClasses.add("org.apache.openejb.faces.TwoBean");
+ InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("faces-config.xml");
+ JAXBElement<FacesConfig> element = (JAXBElement<FacesConfig>) JaxbJavaee
+ .unmarshal(FacesConfig.class, inputStream);
+ FacesConfig facesConfig = element.getValue();
+ List<FacesManagedBean> managedBean = facesConfig.getManagedBean();
+ int count = 0;
+ for (FacesManagedBean bean : managedBean) {
+ count++;
+ assertTrue(managedBeanClasses.contains(bean.getManagedBeanClass().trim()));
+ }
+ assertEquals(3, count);
+
+ }
private <T> void marshalAndUnmarshal(Class<T> type, String xmlFileName) throws Exception {
SAXParserFactory factory = SAXParserFactory.newInstance();
Added: openejb/trunk/openejb3/container/openejb-jee/src/test/resources/faces-config.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/faces-config.xml?rev=676644&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/test/resources/faces-config.xml (added)
+++ openejb/trunk/openejb3/container/openejb-jee/src/test/resources/faces-config.xml Mon Jul 14 09:55:16 2008
@@ -0,0 +1,103 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+ version="1.2">
+
+ <application>
+ <message-bundle>org.apache.openejb.faces.Messages</message-bundle>
+ <locale-config>
+ <default-locale>en</default-locale>
+ <supported-locale>de</supported-locale>
+ <supported-locale>fr</supported-locale>
+ <supported-locale>es</supported-locale>
+ </locale-config>
+ <resource-bundle>
+ <base-name>org.apache.openejb.faces.Resources</base-name>
+ <var>bundle</var>
+ </resource-bundle>
+ </application>
+
+<!-- validators -->
+ <validator>
+ <description>
+ Some description about validators
+ </description>
+ <validator-id>CreditCardValidator</validator-id>
+ <validator-class>org.apache.openejb.faces.CreditCardValidator</validator-class>
+ <attribute>
+ <description>
+ The separator between numbers
+ </description>
+ <attribute-name>separator</attribute-name>
+ <attribute-class>java.lang.String</attribute-class>
+ </attribute>
+ </validator>
+
+<!-- converters -->
+ <converter>
+ <description>
+ Social Security Converter
+ </description>
+ <converter-id>SocialSecurityConverter</converter-id>
+ <converter-class>org.apache.openejb.faces.SocialSecurityConverter</converter-class>
+ </converter>
+
+<!-- managed beans -->
+ <managed-bean>
+ <description>
+ Employee managed bean
+ </description>
+ <managed-bean-name>emp</managed-bean-name>
+ <managed-bean-class>
+ org.apache.openejb.faces.EmployeeBean
+ </managed-bean-class>
+ <managed-bean-scope>application</managed-bean-scope>
+ <managed-property>
+ <description>
+ The first name of the employee
+ </description>
+ <property-name>firstName</property-name>
+ <value>Kartar</value>
+ </managed-property>
+ <managed-property>
+ <description>
+ The last name of the employee
+ </description>
+ <property-name>lastName</property-name>
+ <value>Singh</value>
+ </managed-property>
+ </managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>one</managed-bean-name>
+ <managed-bean-class>
+ org.apache.openejb.faces.OneBean
+ </managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>two</managed-bean-name>
+ <managed-bean-class>
+ org.apache.openejb.faces.TwoBean
+ </managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+</faces-config>
\ No newline at end of file