当前位置: 首页>>代码示例>>Java>>正文


Java NbTestCase类代码示例

本文整理汇总了Java中org.netbeans.junit.NbTestCase的典型用法代码示例。如果您正苦于以下问题:Java NbTestCase类的具体用法?Java NbTestCase怎么用?Java NbTestCase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NbTestCase类属于org.netbeans.junit包,在下文中一共展示了NbTestCase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeScratchDir

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
/**Copied from org.netbeans.api.project.
 * Create a scratch directory for tests.
 * Will be in /tmp or whatever, and will be empty.
 * If you just need a java.io.File use clearWorkDir + getWorkDir.
 */
public static FileObject makeScratchDir(NbTestCase test) throws IOException {
    test.clearWorkDir();
    File root = test.getWorkDir();
    assert root.isDirectory() && root.list().length == 0;
    FileObject fo = FileUtil.toFileObject(root);
    if (fo != null) {
        // Presumably using masterfs.
        return fo;
    } else {
        // For the benefit of those not using masterfs.
        LocalFileSystem lfs = new LocalFileSystem();
        try {
            lfs.setRootDirectory(root);
        } catch (PropertyVetoException e) {
            assert false : e;
        }
        Repository.getDefault().addFileSystem(lfs);
        return lfs.getRoot();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:UnitUtilities.java

示例2: makeScratchDir

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
/**Copied from org.netbeans.api.project.
 * Create a scratch directory for tests.
 * Will be in /tmp or whatever, and will be empty.
 * If you just need a java.io.File use clearWorkDir + getWorkDir.
 */
@SuppressWarnings("deprecation")
public static FileObject makeScratchDir(NbTestCase test) throws IOException {
    test.clearWorkDir();
    File root = test.getWorkDir();
    assert root.isDirectory() && root.list().length == 0;
    FileObject fo = FileUtil.toFileObject(root);
    if (fo != null) {
        // Presumably using masterfs.
        return fo;
    } else {
        // For the benefit of those not using masterfs.
        LocalFileSystem lfs = new LocalFileSystem();
        try {
            lfs.setRootDirectory(root);
        } catch (PropertyVetoException e) {
            assert false : e;
        }
        Repository.getDefault().addFileSystem(lfs);
        return lfs.getRoot();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:CommentHandlerServiceTest.java

示例3: makeScratchDir

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
/**Copied from org.netbeans.api.project.
 * Create a scratch directory for tests.
 * Will be in /tmp or whatever, and will be empty.
 * If you just need a java.io.File use clearWorkDir + getWorkDir.
 */
public static FileObject makeScratchDir(NbTestCase test) throws IOException {
    test.clearWorkDir();
    File root = test.getWorkDir();        
    assert root.isDirectory() && root.list().length == 0;
    File cacheFolder = new File (root, "cache"); //NOI18N
    cacheFolder.mkdirs();
    IndexUtil.setCacheFolder(cacheFolder);
    FileObject fo = FileUtil.toFileObject(root);
    if (fo != null) {
        // Presumably using masterfs.
        return fo;
    } else {
        // For the benefit of those not using masterfs.
        LocalFileSystem lfs = new LocalFileSystem();
        try {
            lfs.setRootDirectory(root);
        } catch (PropertyVetoException e) {
            assert false : e;
        }
        Repository.getDefault().addFileSystem(lfs);
        return lfs.getRoot();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:APIIsSelfContainedTest.java

示例4: makeScratchDir

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
/**
 * Create a scratch directory for tests.
 * Will be in /tmp or whatever, and will be empty.
 * If you just need a java.io.File use clearWorkDir + getWorkDir.
 */
public static FileObject makeScratchDir(NbTestCase test) throws IOException {
    test.clearWorkDir();
    File root = test.getWorkDir();
    assert root.isDirectory() : root;
    assert root.list().length == 0 : Arrays.toString(root.list());
    MockLookup.init(); // URLMapper asks for default lookup
    FileObject fo = FileUtil.toFileObject(root);
    Assert.assertNotNull(
            "No FileObject for " + root + " found.\n" +
            "Maybe you need ${openide/masterfs.dir}/modules/org-netbeans-modules-masterfs.jar\n" +
            "in test.unit.run.cp.extra, or make sure Lookups.metaInfServices is included in Lookup.default, so that\n" +
            "Lookup.default<URLMapper>=" + Lookup.getDefault().lookupAll(URLMapper.class) + " includes MasterURLMapper\n" +
            "e.g. by using TestUtil.setLookup(Object[]) rather than TestUtil.setLookup(Lookup).",
            fo);
    return fo;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:TestUtil.java

示例5: testInsertAtZero

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
public void testInsertAtZero() throws Exception {
    RandomTestContainer container = createContainer();
    RandomTestContainer.Context context = container.context();

    Position pos0 = DocumentContentTesting.createPosition(context, 0);
    container.runChecks(context);
    DocumentContentTesting.insert(context, 0, "ahoj cau");
    Position pos1 = DocumentContentTesting.createPosition(context, 1);
    Position pos3 = DocumentContentTesting.createPosition(context, 3);
    container.runChecks(context);
    DocumentContentTesting.remove(context, 0, 4);
    container.runChecks(context);
    DocumentContentTesting.insert(context, 0, "next");
    NbTestCase.assertEquals(0, pos1.getOffset());
    container.runChecks(context);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:EditorDocumentContentTest.java

示例6: testBasicFailUndo0

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
public void testBasicFailUndo0() throws Exception {
    StableCompoundEdit cEdit = new StableCompoundEdit();
    TestEdit e0 = new TestEdit(true);
    TestEdit e1 = new TestEdit();
    cEdit.addEdit(e0);
    cEdit.addEdit(e1);
    NbTestCase.assertFalse("Not ended yet", cEdit.canUndo());
    NbTestCase.assertFalse("Not ended yet", cEdit.canRedo());
    cEdit.end();
    NbTestCase.assertTrue("Expected undoable", cEdit.canUndo());
    NbTestCase.assertFalse("Expected non-redoable", cEdit.canRedo());
    
    try {
        cEdit.undo();
        fail("Was expecting CannotUndoException exception.");
    } catch (CannotUndoException ex) {
        // Expected
    }
    NbTestCase.assertTrue("Expected undoable", cEdit.canUndo());
    NbTestCase.assertFalse("Expected non-redoable", cEdit.canRedo());
    NbTestCase.assertTrue("Expected undoable", e0.canUndo());
    NbTestCase.assertFalse("Expected non-redoable", e0.canRedo());
    NbTestCase.assertTrue("Expected undoable", e1.canUndo());
    NbTestCase.assertFalse("Expected non-redoable", e1.canRedo());
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:StableCompoundEditTest.java

示例7: testBasicFailUndo1

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
public void testBasicFailUndo1() throws Exception {
    StableCompoundEdit cEdit = new StableCompoundEdit();
    TestEdit e0 = new TestEdit();
    TestEdit e1 = new TestEdit(true);
    cEdit.addEdit(e0);
    cEdit.addEdit(e1);
    NbTestCase.assertFalse("Not ended yet", cEdit.canUndo());
    NbTestCase.assertFalse("Not ended yet", cEdit.canRedo());
    cEdit.end();
    NbTestCase.assertTrue("Expected undoable", cEdit.canUndo());
    NbTestCase.assertFalse("Expected non-redoable", cEdit.canRedo());
    
    try {
        cEdit.undo();
        fail("Was expecting CannotUndoException exception.");
    } catch (CannotUndoException ex) {
        // Expected
    }
    NbTestCase.assertTrue("Expected undoable", cEdit.canUndo());
    NbTestCase.assertFalse("Expected non-redoable", cEdit.canRedo());
    NbTestCase.assertTrue("Expected undoable", e0.canUndo());
    NbTestCase.assertFalse("Expected non-redoable", e0.canRedo());
    NbTestCase.assertTrue("Expected undoable", e1.canUndo());
    NbTestCase.assertFalse("Expected non-redoable", e1.canRedo());
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:StableCompoundEditTest.java

示例8: finish

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
public void finish() throws Exception {
    if (input == null) {
        if (!outputFile.createNewFile()) {
            NbTestCase.fail("Cannot create file " + outputFile);
        }
        FileWriter fw = new FileWriter(outputFile);
        try {
            fw.write(output.toString());
        } finally {
            fw.close();
        }
        NbTestCase.fail("Created tokens dump file " + outputFile + "\nPlease re-run the test.");

    } else {
        if (inputIndex < input.length()) {
            NbTestCase.fail("Some text left unread:" + input.substring(inputIndex));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:TokenDumpCheck.java

示例9: logProperties

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
public static void logProperties(NbTestCase testCase) {
    testCase.log("");
    testCase.log("-----------------------------------------------------------");
    testCase.log("|  SETUP PROPERTIES:                                      |");
    testCase.log("-----------------------------------------------------------");
    testCase.log(EXCLUDE_PLUGINS + "=" + System.getProperty(EXCLUDE_PLUGINS));
    testCase.log(INCLUDE_PLUGINS + "=" + System.getProperty(INCLUDE_PLUGINS));
    testCase.log(DISABLE_DEFAULT_UC + "=" + System.getProperty(DISABLE_DEFAULT_UC));
    testCase.log(ADDITIONAL_UC + "=" + System.getProperty(ADDITIONAL_UC));
    testCase.log("-----------------------------------------------------------");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:OperationUtils.java

示例10: logRegisteredUCs

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
public static void logRegisteredUCs(boolean onlyEnabled, NbTestCase testCase) {
    List<UpdateUnitProvider> providers = UpdateUnitProviderImpl.getUpdateUnitProviders(onlyEnabled);
    testCase.log("");
    testCase.log("-----------------------------------------------------------");
    testCase.log("|  CURRENTLY REGISTERED UPDATE CENTERS:                   |");
    testCase.log("-----------------------------------------------------------");
    for (UpdateUnitProvider provider : providers) {
        testCase.log(provider.getProviderURL().toString() + "[" + provider.getCategory().toString() + "]");
    }
    testCase.log("-----------------------------------------------------------");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:OperationUtils.java

示例11: testAllSessionsClosed

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
public void testAllSessionsClosed() {        
    //open source
    Node beanNode = new Node(new SourcePackagesNode(Utilities.testProjectName), "examples.advanced|MemoryView.java"); //NOI18N
    new OpenAction().perform(beanNode); // NOI18N
    EditorOperator eo = new EditorOperator("MemoryView.java");
    try {
        eo.clickMouse(50,50,1);
    } catch (Throwable t) {
        System.err.println(t.getMessage());
    }
    new EventTool().waitNoEvent(1000);
    //place breakpoint
    Utilities.toggleBreakpoint(eo, 104);
    //start debugging
    new DebugJavaFileAction().perform(beanNode);
    //wait for breakpoint
    Utilities.waitStatusText("Thread main stopped at MemoryView.java:104");
    List<? extends JPDADebugger> list = DebuggerManager
            .getDebuggerManager()
            .getCurrentSession()
            .lookup(null, JPDADebugger.class);
    JPDADebugger debugger = list.get(0);
    WeakReference<? extends JPDADebugger> debuggerRef = new WeakReference(debugger);

    //finish debugging
    Utilities.endAllSessions();
    //close sources
    eo.close();
    //nulling all temporary variables which could hold some references to debugger
    list = null;
    debugger = null;
    System.gc();
    try {
        NbTestCase.assertGC("All the debugging sessions were not correctly closed", debuggerRef);
    } catch (OutOfMemoryError u) {
        System.out.println(u.getMessage());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:CloseSessionsTest.java

示例12: process

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (!roundEnv.processingOver()) {
        for (Element e : roundEnv.getElementsAnnotatedWith(RandomlyFails.class)) {
            Element typeEl = e.getKind() == ElementKind.METHOD ? e.getEnclosingElement() : e;
            TypeMirror nbTestCaseType = processingEnv.getElementUtils().
                    getTypeElement(NbTestCase.class.getName()).asType();
            if (!processingEnv.getTypeUtils().isAssignable(typeEl.asType(), nbTestCaseType)) {
                processingEnv.getMessager().printMessage(Kind.ERROR, "@RandomlyFails must be used on NbTestCase subclasses", e);
            }
        }
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:RandomlyFailsProcessor.java

示例13: assertGC

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
/**
 * Asserts that the object can be garbage collected.
 * It suspends event queue thread to assure that OutOfMemoryError is not
 * thrown in it instead of the current thread.
 * @param text the text to show when test fails.
 * @param ref the referent to object that should be GCed
 * @see NbTestCase#assertGC(java.lang.String, java.lang.ref.Reference)
 */
static void assertGC(String text, Reference<?> ref) {
    final Object LOCK = new Object();
    blockEQ(LOCK);
    try {
        NbTestCase.assertGC(text, ref);
    } finally {
        // Resume EQ:
        synchronized (LOCK) {
            LOCK.notifyAll();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:EQFriendlyGC.java

示例14: getTestFile

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
protected FileObject getTestFile(String relFilePath) {
    File wholeInputFile = new File(getDataDir(), relFilePath);
    if (!wholeInputFile.exists()) {
        NbTestCase.fail("File " + wholeInputFile + " not found.");
    }
    FileObject fo = FileUtil.toFileObject(wholeInputFile);
    assertNotNull(fo);

    return fo;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:CslTestBase.java

示例15: getHints

import org.netbeans.junit.NbTestCase; //导入依赖的package包/类
protected ComputedHints getHints(NbTestCase test, Rule hint, String relFilePath, FileObject fileObject, String caretLine) throws Exception {
    ComputedHints hints = computeHints(test, hint, relFilePath, fileObject, caretLine, ChangeOffsetType.NONE);

    if (checkAllHintOffsets()) {
        // Run alternate hint computation AFTER the real computation above since we will destroy the document...
        Logger.global.addHandler(new Handler() {
            @Override
            public void publish(LogRecord record) {
                if (record.getThrown() != null) {
                    StringWriter sw = new StringWriter();
                    record.getThrown().printStackTrace(new PrintWriter(sw));
                    fail("Encountered error: " + sw.toString());
                }
            }

            @Override
            public void flush() {
            }

            @Override
            public void close() throws SecurityException {
            }

        });
        for (ChangeOffsetType type : new ChangeOffsetType[] { ChangeOffsetType.OUTSIDE, ChangeOffsetType.OVERLAP }) {
            computeHints(test, hint, relFilePath, fileObject, caretLine, type);
        }
    }

    return hints;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:CslTestBase.java


注:本文中的org.netbeans.junit.NbTestCase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。