You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by pe...@apache.org on 2017/02/27 06:19:23 UTC
[02/11] wicket git commit: restoring PropertyResolverTest.java
restoring PropertyResolverTest.java
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/cd96fb1c
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/cd96fb1c
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/cd96fb1c
Branch: refs/heads/WICKET-6318-configurable-property-expression-resolver
Commit: cd96fb1c565ca59434900636827729a1f99f717d
Parents: 1e5618f
Author: Pedro Henrique Oliveira dos Santos <pe...@apache.org>
Authored: Thu Sep 15 02:15:02 2016 -0300
Committer: Pedro Henrique Oliveira dos Santos <pe...@apache.org>
Committed: Thu Sep 15 02:15:02 2016 -0300
----------------------------------------------------------------------
.../wicket/util/lang/PropertyResolverTest.java | 80 +++++---------------
1 file changed, 21 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/cd96fb1c/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java b/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java
index c2a19e6..1a3278d 100644
--- a/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java
@@ -16,8 +16,6 @@
*/
package org.apache.wicket.util.lang;
-import static org.hamcrest.CoreMatchers.is;
-
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -54,13 +52,10 @@ import org.junit.Test;
public class PropertyResolverTest extends WicketTestCase
{
- private static final int AN_INTEGER = 10;
-
private static final PropertyResolverConverter CONVERTER = new PropertyResolverConverter(
new ConverterLocator(), Locale.US);
private Person person;
- private Map<String, Integer> integerMap = new HashMap<String, Integer>();
/**
* @throws Exception
@@ -86,7 +81,7 @@ public class PropertyResolverTest extends WicketTestCase
@Test
public void simpleExpression() throws Exception
{
- String name = (String)PropertyResolver.getValue("name", person);
+ String name = (String) PropertyResolver.getValue("name", person);
assertNull(name);
PropertyResolver.setValue("name", person, "wicket", CONVERTER);
@@ -213,28 +208,6 @@ public class PropertyResolverTest extends WicketTestCase
* @throws Exception
*/
@Test
- public void shouldAccessConflictingMapEntries() throws Exception
- {
- PropertyResolver.setValue("integerMap.class", this, AN_INTEGER, CONVERTER);
- assertThat(PropertyResolver.getValue("integerMap.class", this), is(AN_INTEGER));
- }
-
- /**
- * @throws Exception
- */
- @Test
- public void mapMethodExpressionasdf() throws Exception
- {
- HashMap<String, Integer> map = new HashMap<String, Integer>();
- PropertyResolver.setValue("class", map, 10, CONVERTER);
- Integer mySize = (Integer)PropertyResolver.getValue("class", map);
- assertEquals(mySize, new Integer(1));
- }
-
- /**
- * @throws Exception
- */
- @Test
public void mapWithDotLookup() throws Exception
{
Address address = new Address();
@@ -244,8 +217,7 @@ public class PropertyResolverTest extends WicketTestCase
assertNotNull(hm.get("address.test"));
PropertyResolver.setValue("addressMap[address.test].street", person, "wicket-street",
CONVERTER);
- String street = (String)PropertyResolver.getValue("addressMap[address.test].street",
- person);
+ String street = (String)PropertyResolver.getValue("addressMap[address.test].street", person);
assertEquals(street, "wicket-street");
}
@@ -774,73 +746,63 @@ public class PropertyResolverTest extends WicketTestCase
Object actual = converter.convert(date, Long.class);
assertEquals(date.getTime(), actual);
}
-
+
/**
* WICKET-5623 custom properties
*/
@Test
- public void custom()
- {
+ public void custom() {
Document document = new Document();
document.setType("type");
document.setProperty("string", "string");
-
+
Document nestedCustom = new Document();
nestedCustom.setProperty("string", "string2");
document.setProperty("nested", nestedCustom);
-
- PropertyResolver.setLocator(tester.getApplication(),
- new CachingPropertyLocator(new CustomGetAndSetLocator()));
-
+
+ PropertyResolver.setLocator(tester.getApplication(), new CachingPropertyLocator(new CustomGetAndSetLocator()));
+
assertEquals("type", PropertyResolver.getValue("type", document));
assertEquals("string", PropertyResolver.getValue("string", document));
assertEquals("string2", PropertyResolver.getValue("nested.string", document));
}
-
- class CustomGetAndSetLocator implements IPropertyLocator
- {
+
+ class CustomGetAndSetLocator implements IPropertyLocator {
private IPropertyLocator locator = new DefaultPropertyLocator();
-
+
@Override
- public IGetAndSet get(Class<?> clz, String exp)
- {
+ public IGetAndSet get(Class<?> clz, String exp) {
// first try default properties
IGetAndSet getAndSet = locator.get(clz, exp);
- if (getAndSet == null && Document.class.isAssignableFrom(clz))
- {
+ if (getAndSet == null && Document.class.isAssignableFrom(clz)) {
// fall back to document properties
getAndSet = new DocumentPropertyGetAndSet(exp);
}
return getAndSet;
}
-
- public class DocumentPropertyGetAndSet extends AbstractGetAndSet
- {
+
+ public class DocumentPropertyGetAndSet extends AbstractGetAndSet {
private String name;
- public DocumentPropertyGetAndSet(String name)
- {
+ public DocumentPropertyGetAndSet(String name) {
this.name = name;
}
@Override
- public Object getValue(Object object)
- {
- return ((Document)object).getProperty(name);
+ public Object getValue(Object object) {
+ return ((Document) object).getProperty(name);
}
@Override
- public Object newValue(Object object)
- {
+ public Object newValue(Object object) {
return new Document();
}
@Override
- public void setValue(Object object, Object value, PropertyResolverConverter converter)
- {
- ((Document)object).setProperty(name, value);
+ public void setValue(Object object, Object value, PropertyResolverConverter converter) {
+ ((Document) object).setProperty(name, value);
}
}
}