Author: alexsmirnov
Date: 2010-03-04 20:18:15 -0500 (Thu, 04 Mar 2010)
New Revision: 16529
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
Log:
CODING IN PROGRESS - issue RF-7736: Library model verifier.
https://jira.jboss.org/jira/browse/RF-7736
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-03-04
18:24:19 UTC (rev 16528)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-03-05
01:18:15 UTC (rev 16529)
@@ -78,6 +78,8 @@
// Check render kit name and class.
RenderKitModel renderKit = library.getRenderKits().get(renderKitId);
for (RendererModel renderer : renderKit.getRenderers()) {
+
+ vefifyRenderer(renderer);
// Check type.
// Check family.
@@ -89,6 +91,10 @@
}
}
+ protected void vefifyRenderer(RendererModel renderer) {
+ // TODO Auto-generated method stub
+
+ }
protected void verifyComponents() throws CdkException {
for (ComponentModel component : library.getComponents()) {
@@ -112,15 +118,22 @@
if (component.isGenerate()) {
if (null == component.getBaseClass()) {
log.error("Base class for generated component is not set :" +
component.getType());
+// return;
} else if (null == component.getComponentClass()) {
component.setGeneratedClass(namingConventions.inferUIComponentClass(component.getType()));
}
- } else {
- // TODO?
+ } else if (null == component.getComponentClass()){
+ if (null != component.getBaseClass()) {
+ component.setGeneratedClass(component.getBaseClass());
+ } else {
+ log.error("No class information available for component: " +
component);
+// return;
+ }
}
-
-
// Check family.
+ if(null == component.getFamily()){
+
component.setFamily(namingConventions.inferUIComponentFamily(component.getType()));
+ }
// Check attributes.
// Check renderers.
// compact(component.getAttributes());
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java 2010-03-05
01:18:15 UTC (rev 16529)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.model.validator;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import org.easymock.EasyMock;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.NamingConventions;
+import org.richfaces.cdk.apt.SourceUtils;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ComponentModel;
+
+import com.google.inject.Inject;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.CdkTestBase;
+
+/**
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+(a)RunWith(CdkTestRunner.class)
+public class ModelValidatorTest extends CdkTestBase {
+
+ @Mock
+ private NamingConventions namiingConventions;
+
+ @Mock
+ SourceUtils utils;
+
+ @Mock
+ protected Logger log;
+
+ @Inject
+ private ComponentLibrary library;
+
+ @Inject
+ ValidatorImpl validator;
+ /**
+ * Test method for {@link
org.richfaces.cdk.model.validator.ValidatorImpl#verifyComponent(org.richfaces.cdk.model.ComponentModel)}.
+ */
+ @Test
+ public void testVerifyEmptyComponent() {
+ ComponentModel component = new ComponentModel();
+ log.error((CharSequence) anyObject());expectLastCall();
+ replay(log,utils,namiingConventions);
+ validator.verifyComponent(component);
+ verify(log,utils,namiingConventions);
+ }
+
+ @Test
+ public void testVerifyNoTypeComponent() {
+ ComponentModel component = new ComponentModel();
+ ClassName className = new ClassName("foo.component.UIBar");
+ ComponentModel.Type type = new ComponentModel.Type("foo.Bar");
+ component.setGeneratedClass(className);
+ expect(namiingConventions.inferComponentType(className)).andReturn(type);
+
expect(namiingConventions.inferUIComponentFamily(type)).andReturn("foo.baz");
+ replay(log,utils,namiingConventions);
+ // Validator should set component type from base class.
+ validator.verifyComponent(component);
+ verify(log,utils,namiingConventions);
+ assertEquals(type, component.getType());
+ assertEquals("foo.baz", component.getFamily());
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native