testjar.java
来自「MoMEUnit是一个单元测试的J2ME的应用程序xUnit架构实例。这是来自J」· Java 代码 · 共 140 行
JAVA
140 行
package org.momeunit.ant.taskdefs;import org.apache.tools.ant.Task;import org.apache.tools.ant.types.FileSet;import org.apache.tools.ant.types.ZipFileSet;import org.momeunit.ant.core.Utility;/** * MoMEUnit nested tag intended to specify files of jar archive to be scanned for * test cases and to be included in resulting test J2ME application. Extends * {@link ZipFileSet}. Adds if/unless functionality. Implements * {@link TestElement}. * * @author Sergio Morozov * @version 1.1.2 */public class TestJar extends ZipFileSet implements TestElement{ private static final String TEST_TYPE = "class"; private String pattern = null; private boolean onlyTests = true; private String ifProp = null; private String unlessProp = null; /* * (non-Javadoc) * * @see org.momeunit.ant.taskdefs.TestElement#getPattern() */ public String getPattern() { return this.pattern; } /* * (non-Javadoc) * * @see org.momeunit.ant.taskdefs.TestElement#setPattern(java.lang.String) */ public void setPattern(String pattern) { Utility.assertNotEmpty(pattern, "pattern", "testjar"); this.pattern = pattern; } /* * (non-Javadoc) * * @see org.momeunit.ant.taskdefs.TestElement#getFileSet() */ public FileSet getFileSet() { Utility.assertRequiredAttribute(getSrc(getProject()), "src", "testjar"); return this; } /* * * * @see org.momeunit.ant.taskdefs.TestElement#getType() */ public String getType() { return TEST_TYPE; } /** * Always returns <code>true</code>. * * @see org.momeunit.ant.taskdefs.TestElement#containsClasses() * @since 1.1.2 */ public boolean containsClasses() { return true; } /* * (non-Javadoc) * * @see org.momeunit.ant.taskdefs.TestElement#isOnlyTests() */ public boolean isOnlyTests() { return this.onlyTests; } /* * (non-Javadoc) * * @see org.momeunit.ant.taskdefs.TestElement#setOnlyTests(boolean) */ public void setOnlyTests(boolean onlyTests) { this.onlyTests = onlyTests; } /** * Sets name of property to be set to allow this element. * * @param ifProp * name of property to be set to allow this element. * @since 1.1 */ public void setIf(String ifProp) { Utility.assertNotEmpty(ifProp, "if", "testjar"); this.ifProp = ifProp; } /** * Sets name of property to be unset to allow this element. * * @param unlessProp * name of property to be unset to allow this element. * @since 1.1 */ public void setUnless(String unlessProp) { Utility.assertNotEmpty(unlessProp, "unless", "testjar"); this.unlessProp = unlessProp; } /* * (non-Javadoc) * * @see org.momeunit.ant.taskdefs.TestElement#shouldUse(org.apache.tools.ant.Task) */ public boolean shouldUse(Task task) { return (ifProp == null || task.getProject().getProperty(ifProp) != null) && (unlessProp == null || task.getProject().getProperty(unlessProp) == null); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?