Skip to content

Commit

Permalink
SEAMCONFIG-49 Support fields of the class Properties: replacing and m…
Browse files Browse the repository at this point in the history
…odifying (regression from seam 2)
  • Loading branch information
ge0ffrey committed Jul 20, 2011
1 parent ce5fbb7 commit 6cec73d
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
Expand Up @@ -24,6 +24,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.SortedMap;
import java.util.TreeMap;

Expand Down Expand Up @@ -70,6 +71,10 @@ public MapFieldSet(Property<Object> field, List<EntryXmlItem> items) {

keyType = TypeReader.readClassFromType(parameterizedType.getActualTypeArguments()[0]);
valueType = TypeReader.readClassFromType(parameterizedType.getActualTypeArguments()[1]);
} else if (type == Properties.class) {
collectionType = Properties.class;
keyType = TypeReader.readClassFromType(String.class);
valueType = TypeReader.readClassFromType(String.class);
} else {
throw new RuntimeException("Could not determine element type for map " + field.getDeclaringClass().getName() + "." + field.getName());
}
Expand Down
@@ -0,0 +1,26 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed 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.jboss.seam.config.xml.test.fieldset;

import java.util.Properties;

public class PropertiesFieldValue {

public Properties properties1;

public Properties properties2;
}
@@ -0,0 +1,42 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed 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.jboss.seam.config.xml.test.fieldset;

import junit.framework.Assert;
import org.jboss.seam.config.xml.test.AbstractXMLTest;
import org.junit.Test;

public class SetPropertiesFieldValueBeanTest extends AbstractXMLTest {

@Override
protected String getXmlFileName() {
return "properties-set-field-value-beans.xml";
}

@Test
public void propertiesSetFieldValue() {
PropertiesFieldValue x = getReference(PropertiesFieldValue.class);
Assert.assertTrue(x.properties1.size() == 2);
Assert.assertTrue(x.properties2.size() == 2);

Assert.assertTrue(x.properties1.get("1").equals("hello"));
Assert.assertTrue(x.properties1.get("2").equals("world"));
Assert.assertTrue(x.properties2.get("key1").equals("Value 1"));
Assert.assertTrue(x.properties2.get("key2").equals("Value 2"));

}
}
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="urn:java:ee"
xmlns:test="urn:java:org.jboss.seam.config.xml.test.fieldset">
<test:PropertiesFieldValue>
<replaces/>
<test:properties1>
<entry>
<key>1</key>
<value>hello</value>
</entry>
<entry>
<key>2</key>
<value>world</value>
</entry>
</test:properties1>
<test:properties2>
<e>
<k>key1</k>
<v>Value 1</v>
</e>
<e>
<k>key2</k>
<v>Value 2</v>
</e>
</test:properties2>

</test:PropertiesFieldValue>

</beans>

0 comments on commit 6cec73d

Please sign in to comment.