You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/01/26 01:51:11 UTC
svn commit: r1236003 - in /tapestry/tapestry5/trunk/tapestry-ioc/src:
main/java/org/apache/tapestry5/ioc/util/
test/java/org/apache/tapestry5/ioc/internal/services/
test/java/org/apache/tapestry5/ioc/util/
Author: hlship
Date: Thu Jan 26 00:51:10 2012
New Revision: 1236003
URL: http://svn.apache.org/viewvc?rev=1236003&view=rev
Log:
Improve exception reporting when there is not a valid mapping to an adapter
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/StrategyRegistry.java
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/StrategyBuilderImplTest.java
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/StrategyRegistryTest.java
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/StrategyRegistry.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/StrategyRegistry.java?rev=1236003&r1=1236002&r2=1236003&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/StrategyRegistry.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/StrategyRegistry.java Thu Jan 26 00:51:10 2012
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2011 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2011, 2012 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@ package org.apache.tapestry5.ioc.util;
import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
import org.apache.tapestry5.ioc.internal.util.InheritanceSearch;
-import org.apache.tapestry5.ioc.internal.util.InternalUtils;
import java.util.Collection;
import java.util.List;
@@ -127,8 +126,7 @@ public final class StrategyRegistry<A>
if (result != null)
{
cache.put(type, result);
- }
- else
+ } else
{
unmatched.put(type, true);
}
@@ -154,8 +152,8 @@ public final class StrategyRegistry<A>
for (Class t : registrations.keySet())
names.add(t.getName());
- throw new IllegalArgumentException(String.format("No adapter from type %s to type %s is available (registered types are %s).", type.getName(), adapterType.getName(),
- InternalUtils.joinSorted(names)));
+ throw new UnknownValueException(String.format("No adapter from type %s to type %s is available.", type.getName(), adapterType.getName()), null, null,
+ new AvailableValues("registered types", registrations));
}
/**
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/StrategyBuilderImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/StrategyBuilderImplTest.java?rev=1236003&r1=1236002&r2=1236003&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/StrategyBuilderImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/StrategyBuilderImplTest.java Thu Jan 26 00:51:10 2012
@@ -1,4 +1,4 @@
-// Copyright 2006, 2008 The Apache Software Foundation
+// Copyright 2006, 2008, 2012 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -59,11 +59,10 @@ public class StrategyBuilderImplTest ext
{
service.kindOf(null);
unreachable();
- }
- catch (RuntimeException ex)
+ } catch (RuntimeException ex)
{
assertEquals(ex.getMessage(),
- "No adapter from type void to type org.apache.tapestry5.ioc.internal.services.KindOf is available (registered types are java.util.List, java.util.Map).");
+ "No adapter from type void to type org.apache.tapestry5.ioc.internal.services.KindOf is available.");
}
}
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/StrategyRegistryTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/StrategyRegistryTest.java?rev=1236003&r1=1236002&r2=1236003&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/StrategyRegistryTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/StrategyRegistryTest.java Thu Jan 26 00:51:10 2012
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2012 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -14,12 +14,13 @@
package org.apache.tapestry5.ioc.util;
-import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newMap;
import org.apache.tapestry5.ioc.test.IOCTestCase;
import org.testng.annotations.Test;
import java.util.*;
+import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newMap;
+
public class StrategyRegistryTest extends IOCTestCase
{
@Test
@@ -41,12 +42,12 @@ public class StrategyRegistryTest extend
{
r.get(Set.class);
unreachable();
- }
- catch (IllegalArgumentException ex)
+ } catch (UnknownValueException ex)
{
assertEquals(
ex.getMessage(),
- "No adapter from type java.util.Set to type java.lang.Runnable is available (registered types are java.util.List, java.util.Map).");
+ "No adapter from type java.util.Set to type java.lang.Runnable is available.");
+ assertEquals(ex.getAvailableValues().toString(), "AvailableValues[registered types: interface java.util.List, interface java.util.Map]");
}
verify();