|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.tasklist.usertasks.ics; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeEvent; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.io.Writer; import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import junit.framework.*; import org.netbeans.modules.tasklist.client.Suggestion; import org.netbeans.modules.tasklist.client.SuggestionPriority; import org.netbeans.modules.tasklist.providers.SuggestionProvider; import org.netbeans.modules.tasklist.usertasks.UserTask; import org.netbeans.modules.tasklist.usertasks.ics.parser.*; import org.openide.ErrorManager; import org.openide.nodes.Node; import org.openide.util.NbBundle; /** * Tests for the IcsReader * * @author Tim Lebedkov */ public class IcsReaderTest extends TestCase { public IcsReaderTest(java.lang.String testName) { super(testName); } public static Test suite() { TestSuite suite = new TestSuite(IcsReaderTest.class); return suite; } public void testReader() throws IOException { String s = readIcs("\r\n"); assertEquals(s, "\r\n"); s = readIcs( "A:01234567\r\n" + " 0123456789\r\n" + "\t01234567890\r\n" ); assertEquals("A:01234567012345678901234567890\r\n", s); } public void testReader2() throws IOException { String s = readIcs2("\r\n"); assertEquals(s, "\r\n"); s = readIcs2( "A:01234567\r\n" + " 0123456789\r\n" + "\t01234567890\r\n" ); assertEquals("A:01234567012345678901234567890\r\n", s); } private String readIcs(String fn) throws IOException { Reader r = new IcsReader(new StringReader(fn)); StringBuffer sb = new StringBuffer(); while (true) { int c = r.read(); if (c == -1) return sb.toString(); sb.append((char) c); } } private String readIcs2(String fn) throws IOException { Reader r = new IcsReader(new StringReader(fn)); StringBuffer sb = new StringBuffer(); char[] buffer = new char[10]; while (true) { int n = r.read(buffer); if (n == -1) return sb.toString(); sb.append(buffer, 0, n); } } public static void main(String[] p) { try { new IcsReaderTest("IcsReader").testReader(); } catch (Exception e) { e.printStackTrace(); } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.