jmxutilstest.java

来自「一个搜索引擎,希望对大家有用」· Java 代码 · 共 66 行

JAVA
66
字号
/* JmxUtilsTest.java * * $Id: JmxUtilsTest.java,v 1.1 2005/12/07 22:26:23 stack-sf Exp $ * * Created Dec 7, 2005 * * Copyright (C) 2005 Internet Archive. * * This file is part of the Heritrix web crawler (crawler.archive.org). * * Heritrix is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * any later version. * * Heritrix is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with Heritrix; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package org.archive.util;import java.util.HashMap;import java.util.Iterator;import java.util.Map;import javax.management.openmbean.CompositeData;import javax.management.openmbean.CompositeDataSupport;import javax.management.openmbean.CompositeType;import javax.management.openmbean.OpenDataException;import junit.framework.TestCase;public class JmxUtilsTest extends TestCase {    public void testCreateCompositeType() throws OpenDataException {        Map m =  new HashMap();        m.put("0", new Long(0));        m.put("1", new Double(1));        m.put("2", "2");        CompositeType ct = JmxUtils.createCompositeType(m, "ct", "description");        testCompositeDataHasMapContent(ct, m);        // Now mess with the order.        Map n = new HashMap();        n.put("0", new Long(17));        n.put("2", "Some old string");        n.put("1", new Double(17.45));        testCompositeDataHasMapContent(ct, n);    }    private void testCompositeDataHasMapContent(final CompositeType ct,            final Map m)    throws OpenDataException {        CompositeData cd = new CompositeDataSupport(ct, m);        for (final Iterator i = m.keySet().iterator(); i.hasNext();) {            String key = (String)i.next();            assertTrue(cd.containsKey(key));            assertEquals(m.get(key), cd.get(key));        }    }}

⌨️ 快捷键说明

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