URL xml = getResource("xml/naming/testBindings.xml");
JNDIBindings bindings = (JNDIBindings)unmarshaller.unmarshal(xml.openStream(), schemaBinding);
JNDIBinding[] values = bindings.getBindings();
assertTrue("There are 5 bindings("+values.length+")", values.length == 5);
JNDIBinding key1 = values[0];
assertTrue("values[0] name is ctx1/key1", key1.getName().equals("ctx1/key1"));
assertTrue("values[0] is string of value1", key1.getText().equals("value1"));
JNDIBinding userHome = values[1];
assertTrue("values[1] name is ctx1/user.home", userHome.getName().equals("ctx1/user.home"));
String p = System.getProperty("user.home");
assertTrue("values[1] is property ${user.home}", userHome.getText().equals(p));
// Test binding from a text to URL based on the type attribute PropertyEditor
JNDIBinding jbossHome = values[2];
assertTrue("values[2] name is ctx1/key2", jbossHome.getName().equals("ctx1/key2"));
assertTrue("values[2] is http://www.jboss.org",
jbossHome.getText().equals("http://www.jboss.org"));
assertTrue("values[2] type is java.net.URL",
jbossHome.getType().equals("java.net.URL"));
Object value2 = jbossHome.getValue();
assertTrue("values[2] value is URL(http://www.jboss.org)",
value2.equals(new URL("http://www.jboss.org")));
// Test a binding from an xml fragment from a foreign namespace.
JNDIBinding properties = values[3];
Object value = properties.getValue();
assertTrue("values[3] name is ctx2/key1", properties.getName().equals("ctx2/key1"));
assertTrue("values[3] is java.util.Properties", value instanceof Properties);
Properties props = (Properties) value;
assertTrue("Properties(key1) == value1", props.getProperty("key1").equals("value1"));
assertTrue("Properties(key2) == value2", props.getProperty("key2").equals("value2"));
// Test binding from a text to InetAddress based on the editor attribute PropertyEditor
JNDIBinding host = values[4];
assertTrue("values[4] name is hosts/localhost", host.getName().equals("hosts/localhost"));
assertTrue(host.isTrim());
assertTrue("values[4] text is 127.0.0.1",
host.getText().equals("127.0.0.1"));
assertTrue("values[4] editor is org.jboss.util.propertyeditor.InetAddressEditor",
host.getEditor().equals("org.jboss.util.propertyeditor.InetAddressEditor"));
Object value4 = host.getValue();
InetAddress hostValue = (InetAddress) value4;
InetAddress localhost = InetAddress.getByName("127.0.0.1");
assertTrue("values[4] value is InetAddress(127.0.0.1)",
hostValue.getHostAddress().equals(localhost.getHostAddress()));
}