testpriority.java

来自「Java的面向对象数据库系统的源代码」· Java 代码 · 共 70 行

JAVA
70
字号
/* * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. * * This software is open source. * See the bottom of this file for the licence. * * $Id: TestPriority.java,v 1.1 2003/07/07 10:30:30 per_nyfelt Exp $ */package test.dom4j.rule;import junit.framework.Test;import junit.framework.TestCase;import junit.framework.TestSuite;import junit.textui.TestRunner;import org.dom4j.DocumentFactory;import org.dom4j.rule.Pattern;/** Tests the priority behaviour of Pattern.  *  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>  * @version $Revision: 1.1 $  */public class TestPriority extends TestCase{    public TestPriority(String name) {        super( name );    }    public static void main(String[] args) {        TestRunner.run( suite() );    }    public static Test suite() {        return new TestSuite( TestPriority.class );    }    public void testNameNode() throws Exception {        testPriority( "foo", 0 );    }    public void testQNameNode() throws Exception {        //testPriority( "foo:bar", 0 );    }    public void testFilter() throws Exception {        testPriority( "foo[@id='123']", 0.5 );    }    public void testURI() throws Exception {        testPriority( "foo:*", -0.25);    }    public void testAnyNode() throws Exception {        testPriority( "*", -0.5 );    }    protected void testPriority(String expr, double priority) throws Exception {        System.out.println( "parsing: " + expr );        Pattern pattern = DocumentFactory.getInstance().createPattern( expr );        double d = pattern.getPriority();        System.out.println( "expr: " + expr + " has priority: " + d );        System.out.println( "pattern: " + pattern );        assertEquals( "expr: " + expr, new Double(priority), new Double(d) );    }}

⌨️ 快捷键说明

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