[richfaces-svn-commits] JBoss Rich Faces SVN: r15863 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/templatecompiler/model and 2 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Wed Nov 11 13:14:52 EST 2009


Author: nbelaevski
Date: 2009-11-11 13:14:51 -0500 (Wed, 11 Nov 2009)
New Revision: 15863

Added:
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java
Modified:
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
   root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
   root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd
   root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
Log:
https://jira.jboss.org/jira/browse/RF-7732

Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java	2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java	2009-11-11 18:14:51 UTC (rev 15863)
@@ -25,21 +25,21 @@
 
 package org.richfaces.cdk.templatecompiler;
 
+import java.io.File;
+
 import org.richfaces.cdk.CdkContext;
 import org.richfaces.cdk.CdkException;
 import org.richfaces.cdk.ModelBuilder;
 import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.RenderKit;
+import org.richfaces.cdk.model.Renderer;
 import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
 import org.richfaces.cdk.templatecompiler.model.Template;
 import org.richfaces.cdk.xmlconfig.JAXBBinding;
 
-import javax.xml.stream.XMLStreamException;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
 /**
  * <p class="changed_added_4_0"></p>
  * @author asmirnov at exadel.com
@@ -72,11 +72,12 @@
                     component.getRenderers().add(renderer);
                 }
 
-                String family = compositeInterface.getFamily();
+                String family = compositeInterface.getComponentFamily();
 
                 if (null != family) {
                     renderer.setFamily(family);
                 }
+                
                 renderer.setRendererClass(new ClassDescription(compositeInterface.getJavaClass()));
                 renderer.setTemplate(template);
 //            } catch (FileNotFoundException e) {

Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java	2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java	2009-11-11 18:14:51 UTC (rev 15863)
@@ -50,17 +50,20 @@
     private String methodSignature;
     
     @XmlAttribute
-    private String applyTo;
+    private String targets;
     
     @XmlAttribute
     private boolean required;
     
     @XmlAttribute
-    private boolean preffered;
+    private boolean preferred;
     
     @XmlAttribute
     private boolean expert;
 
+    @XmlAttribute
+    private String type = Object.class.getName();
+    
     /**
      * <p class="changed_added_4_0"></p>
      * @return the name
@@ -143,18 +146,18 @@
 
     /**
      * <p class="changed_added_4_0"></p>
-     * @return the applyTo
+     * @return the targets
      */
-    public String getApplyTo() {
-        return this.applyTo;
+    public String getTargets() {
+        return this.targets;
     }
 
     /**
      * <p class="changed_added_4_0"></p>
-     * @param applyTo the applyTo to set
+     * @param targets the targets to set
      */
-    public void setApplyTo(String applyTo) {
-        this.applyTo = applyTo;
+    public void setTargets(String applyTo) {
+        this.targets = applyTo;
     }
 
     /**
@@ -177,16 +180,16 @@
      * <p class="changed_added_4_0"></p>
      * @return the preffered
      */
-    public boolean isPreffered() {
-        return this.preffered;
+    public boolean isPreferred() {
+        return this.preferred;
     }
 
     /**
      * <p class="changed_added_4_0"></p>
      * @param preffered the preffered to set
      */
-    public void setPreffered(boolean preffered) {
-        this.preffered = preffered;
+    public void setPreferred(boolean preffered) {
+        this.preferred = preffered;
     }
 
     /**
@@ -205,4 +208,20 @@
         this.expert = expert;
     }
     
+    /**
+     * <p class="changed_added_4_0"></p>
+	 * @return the type
+	 */
+    //TODO: add handling
+	public String getType() {
+		return type;
+	}
+	
+	/**
+     * <p class="changed_added_4_0"></p>
+	 * @param type the type to set
+	 */
+	public void setType(String type) {
+		this.type = type;
+	}
 }

Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java	2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java	2009-11-11 18:14:51 UTC (rev 15863)
@@ -27,6 +27,7 @@
 
 import javax.faces.render.RenderKitFactory;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlType;
 
 /**
@@ -39,10 +40,12 @@
     
     private String componentType;
     
-    private String family;
+    private String componentFamily;
     
     private List<Attribute> attributes;
 
+    private List<ResourceDependency> resourceDependencies;
+    
     private String renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
 
     private String javaClass;
@@ -50,6 +53,9 @@
     private String baseClass;
 
     private String rendererType;
+    
+    private boolean rendersChildren = true;
+    
     /**
      * <p class="changed_added_4_0"></p>
      * @return the componentType
@@ -71,17 +77,17 @@
      * <p class="changed_added_4_0"></p>
      * @return the family
      */
-    @XmlElement(name="family",namespace=Template.CDK_NAMESPACE)
-    public String getFamily() {
-        return this.family;
+    @XmlElement(name="component-family",namespace=Template.CDK_NAMESPACE)
+    public String getComponentFamily() {
+        return this.componentFamily;
     }
 
     /**
      * <p class="changed_added_4_0"></p>
      * @param family the family to set
      */
-    public void setFamily(String family) {
-        this.family = family;
+    public void setComponentFamily(String family) {
+        this.componentFamily = family;
     }
 
     /**
@@ -103,9 +109,28 @@
 
     /**
      * <p class="changed_added_4_0"></p>
+	 * @return the resourceDependencies
+	 */
+    @XmlElementWrapper(name = "resource-dependencies", namespace = Template.CDK_NAMESPACE)
+    @XmlElement(name="resource-dependency", namespace=Template.CDK_NAMESPACE)
+	public List<ResourceDependency> getResourceDependencies() {
+		return resourceDependencies;
+	}
+	
+	/**
+     * <p class="changed_added_4_0"></p>
+	 * @param resourceDependencies the resourceDependencies to set
+	 */
+	public void setResourceDependencies(
+			List<ResourceDependency> resourceDependencies) {
+		this.resourceDependencies = resourceDependencies;
+	}
+    
+    /**
+     * <p class="changed_added_4_0"></p>
      * @return the renderKitId
      */
-    @XmlElement(name="render-kit",namespace=Template.CDK_NAMESPACE)
+    @XmlElement(name="renderkit-id",namespace=Template.CDK_NAMESPACE)
     public String getRenderKitId() {
         return this.renderKitId;
     }
@@ -168,5 +193,21 @@
     public void setBaseClass(String baseClass) {
         this.baseClass = baseClass;
     }
-    
+ 
+    /**
+     * <p class="changed_added_4_0"></p>
+	 * @return the rendersChildren
+	 */
+    //TODO: add handling
+    @XmlElement(name="renders-children",namespace=Template.CDK_NAMESPACE)
+	public boolean isRendersChildren() {
+		return rendersChildren;
+	}
+	
+	/**
+	 * @param rendersChildren the rendersChildren to set
+	 */
+	public void setRendersChildren(boolean rendersChildren) {
+		this.rendersChildren = rendersChildren;
+	}
 }

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java	2009-11-11 18:14:51 UTC (rev 15863)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt 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.richfaces.cdk.templatecompiler.model;
+
+import java.text.MessageFormat;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+ at XmlType(name = "resourceDependencyType", namespace = Template.CDK_NAMESPACE)
+public class ResourceDependency {
+
+	private String name;
+	
+	private String library;
+	
+	private String target = "head";
+
+	/**
+     * <p class="changed_added_4_0"></p>
+	 * @return the name
+	 */
+	@XmlAttribute(name = "name", required = true)
+	public String getName() {
+		return name;
+	}
+
+	/**
+     * <p class="changed_added_4_0"></p>
+	 * @param name the name to set
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/**
+     * <p class="changed_added_4_0"></p>
+	 * @return the libraryName
+	 */
+	@XmlAttribute(name = "library")
+	public String getLibrary() {
+		return library;
+	}
+
+	/**
+     * <p class="changed_added_4_0"></p>
+	 * @param library the libraryName to set
+	 */
+	public void setLibrary(String library) {
+		this.library = library;
+	}
+
+	/**
+     * <p class="changed_added_4_0"></p>
+	 * @return the target
+	 */
+	@XmlAttribute(name = "target")
+	public String getTarget() {
+		return target;
+	}
+
+	/**
+     * <p class="changed_added_4_0"></p>
+	 * @param target the target to set
+	 */
+	public void setTarget(String target) {
+		this.target = target;
+	}
+	
+	@Override
+	public String toString() {
+		return MessageFormat.format("ResourceDependency[name={0}, library={1}, target={2}]", getName(), getLibrary(), getTarget());
+	}
+}

Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java	2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java	2009-11-11 18:14:51 UTC (rev 15863)
@@ -25,7 +25,6 @@
 
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSeeAlso;
 
 /**
  * <p class="changed_added_4_0"></p>

Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd	2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd	2009-11-11 18:14:51 UTC (rev 15863)
@@ -6,8 +6,8 @@
 	xmlns:javaee="http://java.sun.com/xml/ns/javaee"
 	xmlns:cc="http://java.sun.com/jsf/composite">
 	
-    <xs:import schemaLocation="web-facesuicomponent_2_0.xsd" namespace="http://java.sun.com/xml/ns/javaee"/>
-    <xs:import schemaLocation="faces-composite.xsd" namespace="http://java.sun.com/jsf/composite"/>
+    <xs:import schemaLocation="web-facesuicomponent_2_0.xsd" namespace="http://java.sun.com/xml/ns/javaee" />
+    <xs:import schemaLocation="faces-composite.xsd" namespace="http://java.sun.com/jsf/composite" />
 
 	<xs:simpleType name="elStrictExpression">
 		<xs:restriction base="xs:string">
@@ -42,19 +42,46 @@
 		</xs:complexType>
 	</xs:element>
 
-	<xs:element name="metadata">
+	<xs:simpleType name="resourceDependencyTargets">
+		<xs:restriction base="xs:string">
+			<xs:enumeration value="body" />
+			<xs:enumeration value="form" />
+			<xs:enumeration value="head" />
+		</xs:restriction>
+	</xs:simpleType>
+
+    <xs:complexType name="resource-dependenciesComplexType">
+    	<xs:sequence minOccurs="0" maxOccurs="unbounded">
+    		<xs:element name="resource-dependency" type="resourceDependencyType" />
+    	</xs:sequence>
+    </xs:complexType>
+
+	<xs:complexType name="resourceDependencyType">
+		<xs:attribute name="name" use="required" form="unqualified" />
+		<xs:attribute name="library" form="unqualified" />
+		<xs:attribute name="target" form="unqualified" type="resourceDependencyTargets" />
+	</xs:complexType>
+
+	<xs:element name="resource-dependencies">
 		<xs:complexType>
-			<xs:sequence>
-				<xs:element minOccurs="0" name="class" type="javaee:fully-qualified-classType" default="javax.faces.render.Renderer" />
-				<xs:element minOccurs="0" name="base-class" type="javaee:fully-qualified-classType" />				
-				<xs:element minOccurs="0" name="component-class" type="javaee:fully-qualified-classType" default="javax.faces.component.UIComponent" />				
-				<xs:element minOccurs="0" name="render-kit-id" />				
-				<xs:element minOccurs="0" name="component-family" />				
-				<xs:element minOccurs="0" name="renderer-type" />				
+			<xs:sequence minOccurs="0" maxOccurs="unbounded">
+				<xs:choice>
+					<xs:element name="resource-dependency" type="resourceDependencyType" />
+				</xs:choice>
 			</xs:sequence>
 		</xs:complexType>
 	</xs:element>
 
+	<xs:element name="class" type="javaee:fully-qualified-classType" />
+	<xs:element name="superclass" type="javaee:fully-qualified-classType" />
+
+	<xs:element name="component-type" />
+
+	<xs:element name="renderkit-id" />
+	<xs:element name="component-family" />
+	<xs:element name="renderer-type" />
+	<xs:element name="renders-children" type="xs:boolean" />
+
 	<xs:group name="structural">
 		<xs:choice>
 			<xs:element name="body">
@@ -70,7 +97,6 @@
 		</xs:choice>
 	</xs:group>
 
-
 	<xs:element name="if">
 		<xs:complexType mixed="true">
 			<xs:choice>

Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd	2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/faces-composite.xsd	2009-11-11 18:14:51 UTC (rev 15863)
@@ -17,14 +17,14 @@
 				</xs:documentation>
 			</xs:annotation>
 		</xs:attribute>
-		<xs:attribute name="preferred" type="xs:boolean">
+		<xs:attribute name="preferred" type="xs:boolean" default="false">
 			<xs:annotation>
 				<xs:documentation>Is this a "preferred" component. The value of this
 					attribute will be set as the value for this property on the
 					composite component bean descriptor.</xs:documentation>
 			</xs:annotation>
 		</xs:attribute>
-		<xs:attribute name="expert" type="xs:boolean">
+		<xs:attribute name="expert" type="xs:boolean" default="false">
 			<xs:annotation>
 				<xs:documentation>Is this component only for expert users? The value
 					of this attribute will be set as the value for this property on the
@@ -73,7 +73,7 @@
 				</xs:documentation>
 			</xs:annotation>
 		</xs:attribute>
-		<xs:attribute name="targets" use="required">
+		<xs:attribute name="targets">
 			<xs:annotation>
 				<xs:documentation>
 					If this element has a method-signature attribute, the value of the
@@ -103,7 +103,7 @@
 				</xs:documentation>
 			</xs:annotation>
 		</xs:attribute>
-		<xs:attribute name="required" type="xs:boolean">
+		<xs:attribute name="required" type="xs:boolean" default="false">
 			<xs:annotation>
 				<xs:documentation>
 					True if the page author must supply a value for
@@ -166,8 +166,7 @@
 
 					Example:
 
-					java.lang.String nickName(
-					java.lang.String, int )
+					java.lang.String nickName(java.lang.String, int)
 				</xs:documentation>
 			</xs:annotation>
 		</xs:attribute>
@@ -202,8 +201,7 @@
 	<xs:complexType name="compositeInterfaceType">
 		<xs:sequence minOccurs="0" maxOccurs="unbounded">
 			<xs:choice>
-				<xs:element ref="cc:extension" />
-				<xs:element ref="cc:attribute" />
+				<xs:any namespace="##any" processContents="lax" />
 			</xs:choice>
 		</xs:sequence>
 		<xs:attribute type="xs:string" name="name">

Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java	2009-11-11 01:29:38 UTC (rev 15862)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java	2009-11-11 18:14:51 UTC (rev 15863)
@@ -23,7 +23,11 @@
 
 package org.richfaces.cdk.templatecompiler.model;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.List;
 
@@ -42,6 +46,7 @@
     private static final String TEMPLATE_EPILOG = "</cc:implementation></cdk:root>";
     private static final String TEMPLATE_MIDDLE = "</cc:interface><cc:implementation>";
     public static final String TEMPLATE_PROLOG = "<cdk:root xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:cdk=\"http://richfaces.org/cdk\" xmlns:cc=\"http://java.sun.com/jsf/composite\"><cc:interface>";
+	private static final Object DEFAULT_ATTRIBUTE_TYPE = Object.class.getName();
 
     @Test
     public void testTemplate() throws Exception {
@@ -64,4 +69,197 @@
         assertEquals(AnyElement.class, children.get(1).getClass());
         assertEquals(String.class, children.get(2).getClass());
     }
+
+    @Test
+	public void testInterface() throws Exception {
+        Template template = unmarshal(Template.class, TEMPLATE_PROLOG + 
+        		"	<cdk:class>org.richfaces.renderkit.html.TreeRenderer</cdk:class>" +
+        		"	<cdk:superclass>org.richfaces.renderkit.TreeRendererBase</cdk:superclass>" +
+        		"	<cdk:component-family>org.richfaces.TreeFamily</cdk:component-family>" +
+        		"	<cdk:component-type>org.richfaces.Tree</cdk:component-type>" +
+        		"	<cdk:renderer-type>org.richfaces.TreeRenderer</cdk:renderer-type>" +
+        		"	<cdk:renderkit-id>RF4_XHTML</cdk:renderkit-id>" +
+        		"	<cdk:renders-children>false</cdk:renders-children>" +
+        		TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
+		
+        CompositeInterface interfaceSection = template.getInterface();
+        assertNotNull(interfaceSection);
+		
+        assertEquals("org.richfaces.renderkit.html.TreeRenderer", interfaceSection.getJavaClass());
+        assertEquals("org.richfaces.renderkit.TreeRendererBase", interfaceSection.getBaseClass());
+		assertEquals("org.richfaces.TreeFamily", interfaceSection.getComponentFamily());
+		assertEquals("org.richfaces.Tree", interfaceSection.getComponentType());
+		assertEquals("org.richfaces.TreeRenderer", interfaceSection.getRendererType());
+		assertEquals("RF4_XHTML", interfaceSection.getRenderKitId());
+		assertFalse(interfaceSection.isRendersChildren());
+		
+    }
+
+    @Test
+	public void testAttributes() throws Exception {
+        Template template = unmarshal(Template.class, TEMPLATE_PROLOG + 
+        		"<cc:attribute name=\"onclick\" />" +
+        		"<cc:attribute name=\"mode\" default=\"ajax\" />" +
+        		"<cc:attribute name=\"action\" method-signature=\"void action()\" />" +
+        		"<cc:attribute name=\"changeListener\" method-signature=\"void changeListener(ValueChangeEvent)\" targets=\"changes changes1\" />" +
+        		"<cc:attribute name=\"disabled\" type=\"boolean\" />" +
+        		"<cc:attribute name=\"delay\" type=\"java.lang.Integer\" />" +
+        		"<cc:attribute name=\"id\" required=\"true\" />" +
+        		"<cc:attribute name=\"experts\" shortDescription=\"For use by experts\" displayName=\"Expert attribute\" expert=\"true\" />" +
+        		"<cc:attribute name=\"preferred\" shortDescription=\"It's a preferred attribute\" displayName=\"Preferred attribute\" preferred=\"true\" />" +
+        		TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
+        
+        CompositeInterface interfaceSection = template.getInterface();
+        assertNotNull(interfaceSection);
+        
+        List<Attribute> attributes = interfaceSection.getAttributes();
+        assertNotNull(attributes);
+        assertEquals(9, attributes.size());
+        
+        Attribute attribute;
+        
+        attribute = attributes.get(0);
+        assertNotNull(attribute);
+        assertEquals("onclick", attribute.getName());
+        assertNull(attribute.getDefaultValue());
+        assertNull(attribute.getMethodSignature());
+        assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+        assertNull(attribute.getTargets());
+        assertFalse(attribute.isRequired());
+        assertFalse(attribute.isExpert());
+        assertFalse(attribute.isPreferred());
+        
+        attribute = attributes.get(1);
+        assertNotNull(attribute);
+        assertEquals("mode", attribute.getName());
+        assertEquals("ajax", attribute.getDefaultValue());
+        assertNull(attribute.getMethodSignature());
+        assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+        assertNull(attribute.getTargets());
+        assertFalse(attribute.isRequired());
+        assertFalse(attribute.isExpert());
+        assertFalse(attribute.isPreferred());
+
+        attribute = attributes.get(2);
+        assertNotNull(attribute);
+        assertEquals("action", attribute.getName());
+        assertNull(attribute.getDefaultValue());
+        assertEquals("void action()", attribute.getMethodSignature());
+        assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+        assertNull(attribute.getTargets());
+        assertFalse(attribute.isRequired());
+        assertFalse(attribute.isExpert());
+        assertFalse(attribute.isPreferred());
+
+        attribute = attributes.get(3);
+        assertNotNull(attribute);
+        assertEquals("changeListener", attribute.getName());
+        assertNull(attribute.getDefaultValue());
+        assertEquals("void changeListener(ValueChangeEvent)", attribute.getMethodSignature());
+        assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+        assertEquals("changes changes1", attribute.getTargets());
+        assertFalse(attribute.isRequired());
+        assertFalse(attribute.isExpert());
+        assertFalse(attribute.isPreferred());
+
+        attribute = attributes.get(4);
+        assertNotNull(attribute);
+        assertEquals("disabled", attribute.getName());
+        assertNull(attribute.getDefaultValue());
+        assertNull(attribute.getMethodSignature());
+        assertEquals("boolean", attribute.getType());
+        assertNull(attribute.getTargets());
+        assertFalse(attribute.isRequired());
+        assertFalse(attribute.isExpert());
+        assertFalse(attribute.isPreferred());
+
+        attribute = attributes.get(5);
+        assertNotNull(attribute);
+        assertEquals("delay", attribute.getName());
+        assertNull(attribute.getDefaultValue());
+        assertNull(attribute.getMethodSignature());
+        assertEquals("java.lang.Integer", attribute.getType());
+        assertNull(attribute.getTargets());
+        assertFalse(attribute.isRequired());
+        assertFalse(attribute.isExpert());
+        assertFalse(attribute.isPreferred());
+
+        attribute = attributes.get(6);
+        assertNotNull(attribute);
+        assertEquals("id", attribute.getName());
+        assertNull(attribute.getDefaultValue());
+        assertNull(attribute.getMethodSignature());
+        assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+        assertNull(attribute.getTargets());
+        assertTrue(attribute.isRequired());
+        assertFalse(attribute.isExpert());
+        assertFalse(attribute.isPreferred());
+
+        attribute = attributes.get(7);
+        assertNotNull(attribute);
+        assertFalse(attribute.isRequired());
+        assertEquals("experts", attribute.getName());
+        assertNull(attribute.getDefaultValue());
+        assertNull(attribute.getMethodSignature());
+        assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+        assertNull(attribute.getTargets());
+        assertEquals("For use by experts", attribute.getShortDescription());
+        assertEquals("Expert attribute", attribute.getDisplayName());
+        assertTrue(attribute.isExpert());
+        assertFalse(attribute.isPreferred());
+        
+        attribute = attributes.get(8);
+        assertNotNull(attribute);
+        assertFalse(attribute.isRequired());
+        assertFalse(attribute.isExpert());
+        assertEquals("preferred", attribute.getName());
+        assertNull(attribute.getDefaultValue());
+        assertNull(attribute.getMethodSignature());
+        assertEquals(DEFAULT_ATTRIBUTE_TYPE, attribute.getType());
+        assertEquals("It's a preferred attribute", attribute.getShortDescription());
+        assertEquals("Preferred attribute", attribute.getDisplayName());
+        assertTrue(attribute.isPreferred());
+    }
+    
+    @Test
+	public void testResourceDependencies() throws Exception {
+        Template template = unmarshal(Template.class, TEMPLATE_PROLOG + 
+        		"	<cdk:resource-dependencies>" + 
+    			"		<cdk:resource-dependency name=\"jquery.js\" />" +
+    			"		<cdk:resource-dependency name=\"richfaces.css\" library=\"org.richfaces\" />" +
+    			"		<cdk:resource-dependency name=\"richfaces.js\" library=\"org.richfaces\" target=\"body\" /> " +
+    			"	</cdk:resource-dependencies> " +
+
+        		TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
+		
+        CompositeInterface interfaceSection = template.getInterface();
+        assertNotNull(interfaceSection);
+		
+        List<ResourceDependency> resourceDependencies = interfaceSection.getResourceDependencies();
+		assertNotNull(resourceDependencies);
+		assertEquals(3, resourceDependencies.size());
+		
+		ResourceDependency resourceDependency;
+		
+		resourceDependency = resourceDependencies.get(0);
+		assertNotNull(resourceDependency);
+		assertEquals("jquery.js", resourceDependency.getName());
+		assertNull(resourceDependency.getLibrary());
+		assertEquals("head", resourceDependency.getTarget());
+
+		resourceDependency = resourceDependencies.get(1);
+		assertNotNull(resourceDependency);
+		assertEquals("richfaces.css", resourceDependency.getName());
+		assertEquals("org.richfaces", resourceDependency.getLibrary());
+		assertEquals("head", resourceDependency.getTarget());
+
+		resourceDependency = resourceDependencies.get(2);
+		assertNotNull(resourceDependency);
+		assertEquals("richfaces.js", resourceDependency.getName());
+		assertEquals("org.richfaces", resourceDependency.getLibrary());
+		assertEquals("body", resourceDependency.getTarget());
+	}
+    
 }
+
+



More information about the richfaces-svn-commits mailing list