Author: apetrelli
Date: Thu May 13 19:30:49 2010
New Revision: 943985
URL: http://svn.apache.org/viewvc?rev=943985&view=rev
Log:
TILESSB-11
Added some more tests.
TILESSB-10
Merged CachingTilesContainer and DefinitionManager.
Added:
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingTilesContainer.java
- copied, changed from r931641,
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java
tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/CannotRenderExceptionTest.java
(with props)
tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/InvalidTemplateExceptionTest.java
(with props)
Removed:
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java
Modified:
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/CannotRenderException.java
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/InvalidTemplateException.java
Modified:
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/CannotRenderException.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/CannotRenderException.java?rev=943985&r1=943984&r2=943985&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/CannotRenderException.java
(original)
+++
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/CannotRenderException.java
Thu May 13 19:30:49 2010
@@ -54,7 +54,7 @@ public class CannotRenderException exten
* @param e The exception to be wrapped.
* @since 2.1.0
*/
- public CannotRenderException(Exception e) {
+ public CannotRenderException(Throwable e) {
super(e);
}
@@ -65,7 +65,7 @@ public class CannotRenderException exten
* @param e The exception to be wrapped.
* @since 2.1.0
*/
- public CannotRenderException(String message, Exception e) {
+ public CannotRenderException(String message, Throwable e) {
super(message, e);
}
Modified:
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/InvalidTemplateException.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/InvalidTemplateException.java?rev=943985&r1=943984&r2=943985&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/InvalidTemplateException.java
(original)
+++
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/InvalidTemplateException.java
Thu May 13 19:30:49 2010
@@ -54,7 +54,7 @@ public class InvalidTemplateException ex
* @param e The exception to be wrapped.
* @since 2.1.0
*/
- public InvalidTemplateException(Exception e) {
+ public InvalidTemplateException(Throwable e) {
super(e);
}
@@ -65,7 +65,7 @@ public class InvalidTemplateException ex
* @param e The exception to be wrapped.
* @since 2.1.0
*/
- public InvalidTemplateException(String message, Exception e) {
+ public InvalidTemplateException(String message, Throwable e) {
super(message, e);
}
}
Copied:
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingTilesContainer.java
(from r931641,
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java)
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingTilesContainer.java?p2=tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingTilesContainer.java&p1=tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java&r1=931641&r2=943985&rev=943985&view=diff
==============================================================================
---
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java
(original)
+++
tiles/sandbox/trunk/tiles3/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingTilesContainer.java
Thu May 13 19:30:49 2010
@@ -28,6 +28,8 @@ import org.apache.tiles.Attribute;
import org.apache.tiles.Definition;
import org.apache.tiles.definition.DefinitionsFactory;
import org.apache.tiles.definition.NoSuchDefinitionException;
+import org.apache.tiles.impl.BasicTilesContainer;
+import org.apache.tiles.mgmt.MutableTilesContainer;
import org.apache.tiles.request.Request;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,12 +40,12 @@ import org.slf4j.LoggerFactory;
*
* @version $Rev$ $Date$
*/
-public class DefinitionManager {
+public class CachingTilesContainer extends BasicTilesContainer implements
MutableTilesContainer {
/**
* The logging object.
*/
- private final Logger log =
LoggerFactory.getLogger(DefinitionManager.class);
+ private final Logger log =
LoggerFactory.getLogger(CachingTilesContainer.class);
/**
* The default name of the attribute in which storing custom definitions.
@@ -52,11 +54,6 @@ public class DefinitionManager {
"org.apache.tiles.impl.mgmt.DefinitionManager.DEFINITIONS";
/**
- * The definitions factory to use to get main definitions.
- */
- private DefinitionsFactory factory;
-
- /**
* The name of the attribute in which storing custom definitions.
*/
private String definitionsAttributeName;
@@ -64,7 +61,7 @@ public class DefinitionManager {
/**
* Constructor.
*/
- public DefinitionManager() {
+ public CachingTilesContainer() {
definitionsAttributeName = DEFAULT_DEFINITIONS_ATTRIBUTE_NAME;
}
@@ -74,7 +71,7 @@ public class DefinitionManager {
* @param definitionsAttributeName The name of the attribute in which
* storing custom definitions.
*/
- public DefinitionManager(String definitionsAttributeName) {
+ public CachingTilesContainer(String definitionsAttributeName) {
this.definitionsAttributeName = definitionsAttributeName;
if (this.definitionsAttributeName == null) {
this.definitionsAttributeName = DEFAULT_DEFINITIONS_ATTRIBUTE_NAME;
@@ -82,24 +79,6 @@ public class DefinitionManager {
}
/**
- * Returns the used definitions factory.
- *
- * @return The used definitions factory.
- */
- public DefinitionsFactory getFactory() {
- return factory;
- }
-
- /**
- * Sets the definitions factory to use.
- *
- * @param factory The definitions factory.
- */
- public void setFactory(DefinitionsFactory factory) {
- this.factory = factory;
- }
-
- /**
* Returns a definition by name.
*
* @param definition The name of the definition.
@@ -115,19 +94,12 @@ public class DefinitionManager {
if (definitions != null && definitions.containsKey(definition)) {
return definitions.get(definition);
}
- return getFactory().getDefinition(definition, request);
+ return super.getDefinition(definition, request);
}
- /**
- * Adds a definition to the set of custom ones.
- *
- * @param definition The definition to add.
- * @param request The current request.
- * @throws org.apache.tiles.definition.DefinitionsFactoryException If
- * something goes wrong during the addition.
- */
- public void addDefinition(Definition definition,
- Request request) {
+ /** {...@inheritdoc} */
+ @Override
+ public void register(Definition definition, Request request) {
Map<String, Definition> definitions = getOrCreateDefinitions(request);
if (definition.getName() == null) {
definition.setName(getNextUniqueDefinitionName(definitions));
@@ -139,6 +111,7 @@ public class DefinitionManager {
}
definitions.put(definition.getName(), definition);
+
}
/**
Added:
tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/CannotRenderExceptionTest.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/CannotRenderExceptionTest.java?rev=943985&view=auto
==============================================================================
---
tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/CannotRenderExceptionTest.java
(added)
+++
tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/CannotRenderExceptionTest.java
Thu May 13 19:30:49 2010
@@ -0,0 +1,77 @@
+/*
+ * $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.impl;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * Tests {...@link CannotRenderException}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CannotRenderExceptionTest {
+
+ /**
+ * Test method for {...@link
CannotRenderException#CannotRenderException()}.
+ */
+ @Test
+ public void testCannotRenderException() {
+ CannotRenderException exception = new CannotRenderException();
+ assertNull(exception.getMessage());
+ assertNull(exception.getCause());
+ }
+
+ /**
+ * Test method for {...@link
CannotRenderException#CannotRenderException(java.lang.String)}.
+ */
+ @Test
+ public void testCannotRenderExceptionString() {
+ CannotRenderException exception = new CannotRenderException("my
message");
+ assertEquals("my message", exception.getMessage());
+ assertNull(exception.getCause());
+ }
+
+ /**
+ * Test method for {...@link
CannotRenderException#CannotRenderException(java.lang.Throwable)}.
+ */
+ @Test
+ public void testCannotRenderExceptionThrowable() {
+ Throwable cause = new Throwable();
+ CannotRenderException exception = new CannotRenderException(cause);
+ assertEquals(cause.toString(), exception.getMessage());
+ assertEquals(cause, exception.getCause());
+ }
+
+ /**
+ * Test method for {...@link
CannotRenderException#CannotRenderException(java.lang.String,
java.lang.Throwable)}.
+ */
+ @Test
+ public void testCannotRenderExceptionStringThrowable() {
+ Throwable cause = new Throwable();
+ CannotRenderException exception = new CannotRenderException("my
message", cause);
+ assertEquals("my message", exception.getMessage());
+ assertEquals(cause, exception.getCause());
+ }
+
+}
Propchange:
tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/CannotRenderExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/CannotRenderExceptionTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added:
tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/InvalidTemplateExceptionTest.java
URL:
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/InvalidTemplateExceptionTest.java?rev=943985&view=auto
==============================================================================
---
tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/InvalidTemplateExceptionTest.java
(added)
+++
tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/InvalidTemplateExceptionTest.java
Thu May 13 19:30:49 2010
@@ -0,0 +1,77 @@
+/*
+ * $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.impl;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * Tests {...@link InvalidTemplateException}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidTemplateExceptionTest {
+
+ /**
+ * Test method for {...@link
InvalidTemplateException#InvalidTemplateException()}.
+ */
+ @Test
+ public void testInvalidTemplateException() {
+ InvalidTemplateException exception = new InvalidTemplateException();
+ assertNull(exception.getMessage());
+ assertNull(exception.getCause());
+ }
+
+ /**
+ * Test method for {...@link
InvalidTemplateException#InvalidTemplateException(java.lang.String)}.
+ */
+ @Test
+ public void testInvalidTemplateExceptionString() {
+ InvalidTemplateException exception = new InvalidTemplateException("my
message");
+ assertEquals("my message", exception.getMessage());
+ assertNull(exception.getCause());
+ }
+
+ /**
+ * Test method for {...@link
InvalidTemplateException#InvalidTemplateException(java.lang.Throwable)}.
+ */
+ @Test
+ public void testInvalidTemplateExceptionThrowable() {
+ Throwable cause = new Throwable();
+ InvalidTemplateException exception = new
InvalidTemplateException(cause);
+ assertEquals(cause.toString(), exception.getMessage());
+ assertEquals(cause, exception.getCause());
+ }
+
+ /**
+ * Test method for {...@link
InvalidTemplateException#InvalidTemplateException(java.lang.String,
java.lang.Throwable)}.
+ */
+ @Test
+ public void testInvalidTemplateExceptionStringThrowable() {
+ Throwable cause = new Throwable();
+ InvalidTemplateException exception = new InvalidTemplateException("my
message", cause);
+ assertEquals("my message", exception.getMessage());
+ assertEquals(cause, exception.getCause());
+ }
+
+}
Propchange:
tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/InvalidTemplateExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tiles/sandbox/trunk/tiles3/tiles-core/src/test/java/org/apache/tiles/impl/InvalidTemplateExceptionTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL