Author: apetrelli
Date: Sun Feb 24 08:38:18 2008
New Revision: 630635
URL: http://svn.apache.org/viewvc?rev=630635&view=rev
Log:
TILES-249
Added test for BasicRendererFactory.
Added:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/renderer/impl/BasicRendererFactoryTest.java
(with props)
Added:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/renderer/impl/BasicRendererFactoryTest.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/renderer/impl/BasicRendererFactoryTest.java?rev=630635&view=auto
==============================================================================
---
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/renderer/impl/BasicRendererFactoryTest.java
(added)
+++
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/renderer/impl/BasicRendererFactoryTest.java
Sun Feb 24 08:38:18 2008
@@ -0,0 +1,121 @@
+/*
+ * $Id$
+ *
+ * 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.
+ */
+package org.apache.tiles.renderer.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tiles.TilesApplicationContext;
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.TilesException;
+import org.apache.tiles.context.TilesContextFactory;
+import org.apache.tiles.renderer.AttributeRenderer;
+import org.easymock.EasyMock;
+
+import junit.framework.TestCase;
+
+/**
+ * Basic renderer factory implementation.
+ *
+ * @version $Rev$ $Date$
+ * @since 2.1.0
+ */
+public class BasicRendererFactoryTest extends TestCase {
+
+ /**
+ * The renderer factory.
+ */
+ private BasicRendererFactory rendererFactory;
+
+ /** [EMAIL PROTECTED] */
+ @Override
+ public void setUp() throws Exception {
+ rendererFactory = new BasicRendererFactory();
+ TilesApplicationContext applicationContext = EasyMock
+ .createMock(TilesApplicationContext.class);
+ TilesContextFactory contextFactory = EasyMock
+ .createMock(TilesContextFactory.class);
+ TilesContainer container = EasyMock.createMock(TilesContainer.class);
+ rendererFactory.setApplicationContext(applicationContext);
+ rendererFactory.setContextFactory(contextFactory);
+ rendererFactory.setContainer(container);
+ EasyMock.replay(applicationContext, contextFactory, container);
+ }
+
+ /**
+ * Tests [EMAIL PROTECTED] BasicRendererFactory#init(Map)} and
+ * [EMAIL PROTECTED] BasicRendererFactory#getRenderer(String)}.
+ *
+ * @throws TilesException If something goes wrong.
+ */
+ public void testInitAndGetRenderer() throws TilesException {
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(BasicRendererFactory.TYPE_RENDERERS_INIT_PARAM, "test,"
+ + StringAttributeRenderer.class.getName());
+ rendererFactory.init(params);
+ AttributeRenderer renderer = rendererFactory.getRenderer("string");
+ assertNotNull("The renderer is null", renderer);
+ assertTrue("The class of the renderer is wrong", renderer instanceof
StringAttributeRenderer);
+ renderer = rendererFactory.getRenderer("test");
+ assertNotNull("The renderer is null", renderer);
+ assertTrue("The class of the renderer is wrong", renderer instanceof
StringAttributeRenderer);
+ renderer = rendererFactory.getRenderer(StringAttributeRenderer.class
+ .getName());
+ assertNotNull("The renderer is null", renderer);
+ assertTrue("The class of the renderer is wrong", renderer instanceof
StringAttributeRenderer);
+ }
+
+ /**
+ * Tests [EMAIL PROTECTED]
BasicRendererFactory#setContainer(TilesContainer)}.
+ */
+ public void testSetContainer() {
+ assertNotNull("The container is null", rendererFactory.container);
+ }
+
+ /**
+ * Tests [EMAIL PROTECTED]
BasicRendererFactory#setContextFactory(TilesContextFactory)}.
+ */
+ public void testSetContextFactory() {
+ assertNotNull("The context factory is null",
+ rendererFactory.contextFactory);
+ }
+
+ /**
+ * Tests
+ * [EMAIL PROTECTED]
BasicRendererFactory#setApplicationContext(TilesApplicationContext)}.
+ */
+ public void testSetApplicationContext() {
+ assertNotNull("The application context is null",
+ rendererFactory.applicationContext);
+ }
+
+ /**
+ * Tests [EMAIL PROTECTED]
BasicRendererFactory#initializeRenderer(AttributeRenderer)}.
+ */
+ public void testInitializeRenderer() {
+ DefinitionAttributeRenderer renderer = new
DefinitionAttributeRenderer();
+ rendererFactory.initializeRenderer(renderer);
+ assertNotNull("The container is null", renderer.container);
+ assertNotNull("The context factory is null", renderer.contextFactory);
+ assertNotNull("The application context is null",
+ renderer.applicationContext);
+ }
+}
Propchange:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/renderer/impl/BasicRendererFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/renderer/impl/BasicRendererFactoryTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL