⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlpropertiestest.java

📁 基于Jabber协议的即时消息服务器
💻 JAVA
字号:
/** * $RCSfile$ * $Revision * $Date: 2004-11-11 18:06:45 -0800 (Thu, 11 Nov 2004) $ * * Copyright (C) 1999-2004 Jive Software. All rights reserved. * * This software is the proprietary information of Jive Software. Use is subject to license terms. */package org.jivesoftware.util;import junit.framework.TestCase;import java.io.ByteArrayInputStream;import java.util.Iterator;public class XMLPropertiesTest extends TestCase {    public void testAttributes() throws Exception {        String xml = "<root><foo></foo></root>";        XMLProperties props = new XMLProperties(new ByteArrayInputStream(xml.getBytes()));        assertNull(props.getAttribute("foo","bar"));        xml = "<root><foo bar=\"test123\"></foo></root>";        props = new XMLProperties(new ByteArrayInputStream(xml.getBytes()));        assertEquals(props.getAttribute("foo","bar"), "test123");    }    public void testGetProperty() throws Exception {        XMLProperties props = new XMLProperties(                "./resources/org/jivesoftware/util/XMLProperties.test01.xml");        assertEquals("123", props.getProperty("foo.bar"));        assertEquals("456", props.getProperty("foo.bar.baz"));        assertNull(props.getProperty("foo"));        assertNull(props.getProperty("nothing.something"));    }    public void testGetChildPropertiesIterator() throws Exception {        XMLProperties props = new XMLProperties(                "./resources/org/jivesoftware/util/XMLProperties.test02.xml");        String[] names = {"a","b","c","d"};        String[] values = {"1","2","3","4"};        String[] children = props.getChildrenProperties("foo.bar");        for (int i=0; i<children.length; i++) {            String prop = children[i];            assertEquals(names[i], prop);            String value = props.getProperty("foo.bar." + prop);            assertEquals(values[i], value);            i++;        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -