Author: apetrelli
Date: Sun Jul 13 07:16:07 2008
New Revision: 676326
URL: http://svn.apache.org/viewvc?rev=676326&view=rev
Log:
TILES-84
Now the DAOs call "TilesApplicationContext.getResources" to get resourcesm
instead of "getResource".
Modified:
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/definition/dao/BaseLocaleUrlDefinitionDAO.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/LocaleDefinitionsFactoryTest.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/TestReloadableDefinitionsFactory.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/TestUrlDefinitionsFactory.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/CachingLocaleUrlDefinitionDAOTest.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/LocaleUrlDefinitionDAOTest.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/ResolvingLocaleUrlDefinitionDAOTest.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java
Modified:
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/definition/dao/BaseLocaleUrlDefinitionDAO.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/definition/dao/BaseLocaleUrlDefinitionDAO.java?rev=676326&r1=676325&r2=676326&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/definition/dao/BaseLocaleUrlDefinitionDAO.java
(original)
+++
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/definition/dao/BaseLocaleUrlDefinitionDAO.java
Sun Jul 13 07:16:07 2008
@@ -185,15 +185,22 @@
try {
for (int i = 0; i < resources.length; i++) {
- URL resourceUrl = applicationContext.getResource(resources[i]);
- if (resourceUrl != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Adding resource '" + resourceUrl
- + "' to definitions factory.");
+ Set<URL> urls = applicationContext.getResources(resources[i]);
+ if (urls != null && !urls.isEmpty()) {
+ for (URL resourceUrl : urls) {
+ if (resourceUrl != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Adding resource '" + resourceUrl
+ + "' to definitions factory.");
+ }
+ sourceURLs.add(resourceUrl);
+ } else {
+ LOG.warn("Unable to find configured definition '"
+ + resources[i] + "'");
+ }
}
- sourceURLs.add(resourceUrl);
} else {
- LOG.warn("Unable to find configured definition '"
+ LOG.warn("Unable to find resources under the name '"
+ resources[i] + "'");
}
}
Modified:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/LocaleDefinitionsFactoryTest.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/LocaleDefinitionsFactoryTest.java?rev=676326&r1=676325&r2=676326&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/LocaleDefinitionsFactoryTest.java
(original)
+++
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/LocaleDefinitionsFactoryTest.java
Sun Jul 13 07:16:07 2008
@@ -23,8 +23,10 @@
import java.net.URL;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -99,15 +101,24 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
factory.setApplicationContext(applicationContext);
@@ -144,15 +155,24 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
factory.setApplicationContext(applicationContext);
@@ -241,15 +261,24 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
factory.setApplicationContext(applicationContext);
@@ -307,9 +336,12 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
factory.setApplicationContext(applicationContext);
Modified:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/TestReloadableDefinitionsFactory.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/TestReloadableDefinitionsFactory.java?rev=676326&r1=676325&r2=676326&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/TestReloadableDefinitionsFactory.java
(original)
+++
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/TestReloadableDefinitionsFactory.java
Sun Jul 13 07:16:07 2008
@@ -29,7 +29,9 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import org.apache.tiles.Definition;
import org.apache.tiles.TilesApplicationContext;
@@ -107,7 +109,10 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
-
EasyMock.expect(applicationContext.getResource(urlPath)).andReturn(url);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url);
+ EasyMock.expect(applicationContext.getResources(urlPath)).andReturn(
+ urlSet);
EasyMock.replay(applicationContext);
((TilesApplicationContextAware) factory)
.setApplicationContext(applicationContext);
Modified:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/TestUrlDefinitionsFactory.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/TestUrlDefinitionsFactory.java?rev=676326&r1=676325&r2=676326&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/TestUrlDefinitionsFactory.java
(original)
+++
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/TestUrlDefinitionsFactory.java
Sun Jul 13 07:16:07 2008
@@ -23,8 +23,10 @@
import java.net.URL;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -99,15 +101,24 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
factory.setApplicationContext(applicationContext);
TilesRequestContext emptyContext = new
MockOnlyLocaleTilesContext(null);
@@ -145,15 +156,24 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
factory.setApplicationContext(applicationContext);
@@ -243,9 +263,12 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
- EasyMock.expect(applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
+ EasyMock.expect(
+ applicationContext
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
factory.setApplicationContext(applicationContext);
Modified:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/CachingLocaleUrlDefinitionDAOTest.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/CachingLocaleUrlDefinitionDAOTest.java?rev=676326&r1=676325&r2=676326&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/CachingLocaleUrlDefinitionDAOTest.java
(original)
+++
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/CachingLocaleUrlDefinitionDAOTest.java
Sun Jul 13 07:16:07 2008
@@ -31,9 +31,13 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
import org.apache.tiles.Definition;
import org.apache.tiles.TilesApplicationContext;
@@ -46,8 +50,6 @@
import org.apache.tiles.definition.digester.DigesterDefinitionsReader;
import org.easymock.EasyMock;
-import junit.framework.TestCase;
-
/**
* Tests [EMAIL PROTECTED] CachingLocaleUrlDefinitionDAO}.
*
@@ -92,18 +94,24 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
definitionDao.setApplicationContext(applicationContext);
@@ -190,18 +198,24 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
definitionDao.setApplicationContext(applicationContext);
@@ -361,8 +375,10 @@
"org/apache/tiles/config/defs3.xml");
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
- EasyMock.expect(applicationContext.getResource("/WEB-INF/tiles.xml"))
- .andReturn(url1);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
+ EasyMock.expect(applicationContext.getResources("/WEB-INF/tiles.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
Map<String, String> params = new HashMap<String, String>();
definitionDao.setApplicationContext(applicationContext);
@@ -377,18 +393,24 @@
EasyMock.reset(applicationContext);
applicationContext =
EasyMock.createMock(TilesApplicationContext.class);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url1);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
params.clear();
params.put(DefinitionsFactory.READER_IMPL_PROPERTY,
@@ -424,18 +446,24 @@
"org/apache/tiles/config/defs3.xml");
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
Map<String, String> params = new HashMap<String, String>();
params.put(DefinitionsFactory.DEFINITIONS_CONFIG,
@@ -505,7 +533,10 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
-
EasyMock.expect(applicationContext.getResource(urlPath)).andReturn(url);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url);
+ EasyMock.expect(applicationContext.getResources(urlPath)).andReturn(
+ urlSet);
EasyMock.replay(applicationContext);
((TilesApplicationContextAware) definitionDao)
.setApplicationContext(applicationContext);
Modified:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/LocaleUrlDefinitionDAOTest.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/LocaleUrlDefinitionDAOTest.java?rev=676326&r1=676325&r2=676326&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/LocaleUrlDefinitionDAOTest.java
(original)
+++
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/LocaleUrlDefinitionDAOTest.java
Sun Jul 13 07:16:07 2008
@@ -31,9 +31,13 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
import org.apache.tiles.Definition;
import org.apache.tiles.TilesApplicationContext;
@@ -46,8 +50,6 @@
import org.apache.tiles.definition.digester.DigesterDefinitionsReader;
import org.easymock.EasyMock;
-import junit.framework.TestCase;
-
/**
* Tests [EMAIL PROTECTED] LocaleUrlDefinitionDAO}.
*
@@ -92,18 +94,24 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
definitionDao.setApplicationContext(applicationContext);
@@ -190,18 +198,24 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
definitionDao.setApplicationContext(applicationContext);
@@ -361,8 +375,10 @@
"org/apache/tiles/config/defs3.xml");
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
- EasyMock.expect(applicationContext.getResource("/WEB-INF/tiles.xml"))
- .andReturn(url1);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
+ EasyMock.expect(applicationContext.getResources("/WEB-INF/tiles.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
Map<String, String> params = new HashMap<String, String>();
definitionDao.setApplicationContext(applicationContext);
@@ -377,18 +393,24 @@
EasyMock.reset(applicationContext);
applicationContext =
EasyMock.createMock(TilesApplicationContext.class);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url1);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
params.clear();
params.put(DefinitionsFactory.READER_IMPL_PROPERTY,
@@ -424,18 +446,24 @@
"org/apache/tiles/config/defs3.xml");
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
Map<String, String> params = new HashMap<String, String>();
params.put(DefinitionsFactory.DEFINITIONS_CONFIG,
@@ -505,7 +533,10 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
-
EasyMock.expect(applicationContext.getResource(urlPath)).andReturn(url);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url);
+ EasyMock.expect(applicationContext.getResources(urlPath)).andReturn(
+ urlSet);
EasyMock.replay(applicationContext);
((TilesApplicationContextAware) definitionDao)
.setApplicationContext(applicationContext);
Modified:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/ResolvingLocaleUrlDefinitionDAOTest.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/ResolvingLocaleUrlDefinitionDAOTest.java?rev=676326&r1=676325&r2=676326&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/ResolvingLocaleUrlDefinitionDAOTest.java
(original)
+++
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/dao/ResolvingLocaleUrlDefinitionDAOTest.java
Sun Jul 13 07:16:07 2008
@@ -31,9 +31,11 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
import org.apache.tiles.Definition;
import org.apache.tiles.TilesApplicationContext;
@@ -92,18 +94,24 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
definitionDao.setApplicationContext(applicationContext);
@@ -191,18 +199,24 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
definitionDao.setApplicationContext(applicationContext);
@@ -363,8 +377,12 @@
"org/apache/tiles/config/defs3.xml");
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
- EasyMock.expect(applicationContext.getResource("/WEB-INF/tiles.xml"))
- .andReturn(url1);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
+ EasyMock.expect(
+ applicationContext
+ .getResources("/WEB-INF/tiles.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
Map<String, String> params = new HashMap<String, String>();
definitionDao.setApplicationContext(applicationContext);
@@ -379,18 +397,24 @@
EasyMock.reset(applicationContext);
applicationContext =
EasyMock.createMock(TilesApplicationContext.class);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url1);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
params.clear();
params.put(DefinitionsFactory.READER_IMPL_PROPERTY,
@@ -426,18 +450,24 @@
"org/apache/tiles/config/defs3.xml");
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url1);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs1.xml"))
- .andReturn(url1);
+ .getResources("org/apache/tiles/config/defs1.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url2);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs2.xml"))
- .andReturn(url2);
+ .getResources("org/apache/tiles/config/defs2.xml"))
+ .andReturn(urlSet);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url3);
EasyMock.expect(
applicationContext
- .getResource("org/apache/tiles/config/defs3.xml"))
- .andReturn(url3);
+ .getResources("org/apache/tiles/config/defs3.xml"))
+ .andReturn(urlSet);
EasyMock.replay(applicationContext);
Map<String, String> params = new HashMap<String, String>();
params.put(DefinitionsFactory.DEFINITIONS_CONFIG,
@@ -507,7 +537,10 @@
TilesApplicationContext applicationContext = EasyMock
.createMock(TilesApplicationContext.class);
-
EasyMock.expect(applicationContext.getResource(urlPath)).andReturn(url);
+ Set<URL> urlSet = new HashSet<URL>();
+ urlSet.add(url);
+ EasyMock.expect(applicationContext.getResources(urlPath)).andReturn(
+ urlSet);
EasyMock.replay(applicationContext);
((TilesApplicationContextAware) definitionDao)
.setApplicationContext(applicationContext);
Modified:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java?rev=676326&r1=676325&r2=676326&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java
(original)
+++
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java
Sun Jul 13 07:16:07 2008
@@ -25,11 +25,11 @@
import java.net.URL;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import java.util.Vector;
-import javax.servlet.ServletContext;
-
import junit.framework.TestCase;
import org.apache.tiles.TilesApplicationContext;
@@ -116,12 +116,19 @@
KeyedDefinitionsFactoryTilesContainer.DEFINITIONS_CONFIG_PREFIX
+ "two", "/WEB-INF/tiles-two.xml");
try {
+ Set<URL> urlSet;
URL url =
getClass().getResource("/org/apache/tiles/factory/test-defs.xml");
-
EasyMock.expect(context.getResource("/WEB-INF/tiles.xml")).andReturn(url);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url);
+
EasyMock.expect(context.getResources("/WEB-INF/tiles.xml")).andReturn(urlSet);
url =
getClass().getResource("/org/apache/tiles/factory/test-defs-key-one.xml");
-
EasyMock.expect(context.getResource("/WEB-INF/tiles-one.xml")).andReturn(url);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url);
+
EasyMock.expect(context.getResources("/WEB-INF/tiles-one.xml")).andReturn(urlSet);
url =
getClass().getResource("/org/apache/tiles/factory/test-defs-key-two.xml");
-
EasyMock.expect(context.getResource("/WEB-INF/tiles-two.xml")).andReturn(url);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url);
+
EasyMock.expect(context.getResources("/WEB-INF/tiles-two.xml")).andReturn(urlSet);
} catch (MalformedURLException e) {
throw new RuntimeException("Error getting Tiles configuration URL",
e);
@@ -150,19 +157,20 @@
/**
* Tests initialization for postponed definitions factories.
*
- * @throws MalformedURLException If sources are not valid (that should not
- * happen).
+ * @throws IOException If something goes wrong.
*/
@SuppressWarnings("deprecation")
- public void testPostponedDefinitionsFactoryInitialization() throws
MalformedURLException {
+ public void testPostponedDefinitionsFactoryInitialization()
+ throws IOException {
KeyedDefinitionsFactoryTilesContainer container;
- ServletContext context = EasyMock.createMock(ServletContext.class);
+ ContextLikeTilesApplicationContext context = EasyMock
+ .createMock(ContextLikeTilesApplicationContext.class);
+
Vector<String> v = new Vector<String>();
v.add(AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM);
v.add(ChainedTilesContextFactory.FACTORY_CLASS_NAMES);
- EasyMock.reset(context);
EasyMock.expect(context.getInitParameter(
AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM))
.andReturn(KeyedDefinitionsFactoryTilesContainerFactory.class.getName())
@@ -180,12 +188,19 @@
EasyMock.expect(context.getInitParameter(
KeyedDefinitionsFactoryTilesContainerFactory.CONTAINER_KEYS_INIT_PARAM))
.andReturn(null);
+ Set<URL> urlSet = new HashSet<URL>();
URL url =
getClass().getResource("/org/apache/tiles/factory/test-defs.xml");
-
EasyMock.expect(context.getResource("/WEB-INF/tiles.xml")).andReturn(url);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url);
+
EasyMock.expect(context.getResources("/WEB-INF/tiles.xml")).andReturn(urlSet);
url =
getClass().getResource("/org/apache/tiles/factory/test-defs-key-one.xml");
-
EasyMock.expect(context.getResource("/WEB-INF/tiles-one.xml")).andReturn(url);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url);
+
EasyMock.expect(context.getResources("/WEB-INF/tiles-one.xml")).andReturn(urlSet);
url =
getClass().getResource("/org/apache/tiles/factory/test-defs-key-two.xml");
-
EasyMock.expect(context.getResource("/WEB-INF/tiles-two.xml")).andReturn(url);
+ urlSet = new HashSet<URL>();
+ urlSet.add(url);
+
EasyMock.expect(context.getResources("/WEB-INF/tiles-two.xml")).andReturn(urlSet);
EasyMock.expect(context.getInitParameterNames()).andReturn(v.elements()).anyTimes();
EasyMock.replay(context);
KeyedDefinitionsFactoryTilesContainerFactory factory =