001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.harmony.luni.tests.java.io;
019:
020: import java.io.StringBufferInputStream;
021:
022: @SuppressWarnings("deprecation")
023: public class StringBufferInputStreamTest extends
024: junit.framework.TestCase {
025:
026: StringBufferInputStream sbis;
027:
028: /**
029: * @tests java.io.StringBufferInputStream#StringBufferInputStream(java.lang.String)
030: */
031: public void test_ConstructorLjava_lang_String() {
032: // Test for method java.io.StringBufferInputStream(java.lang.String)
033: }
034:
035: /**
036: * @tests java.io.StringBufferInputStream#available()
037: */
038: public void test_available() {
039: // Test for method int java.io.StringBufferInputStream.available()
040: assertEquals("Returned incorrect number of available bytes",
041: 11, sbis.available());
042: }
043:
044: /**
045: * @tests java.io.StringBufferInputStream#read()
046: */
047: public void test_read() {
048: // Test for method int java.io.StringBufferInputStream.read()
049: byte[] buf = new byte[5];
050: sbis.skip(6);
051: sbis.read(buf, 0, 5);
052: assertEquals("Returned incorrect chars", "World", new String(
053: buf));
054: }
055:
056: /**
057: * @tests java.io.StringBufferInputStream#read(byte[], int, int)
058: */
059: public void test_read$BII() {
060: // Test for method int java.io.StringBufferInputStream.read(byte [],
061: // int, int)
062: assertEquals("Read returned incorrect char", 'H', sbis.read());
063: }
064:
065: /**
066: * @tests java.io.StringBufferInputStream#reset()
067: */
068: public void test_reset() {
069: // Test for method void java.io.StringBufferInputStream.reset()
070: long s = sbis.skip(6);
071: assertEquals("Unable to skip correct umber of chars", 6, s);
072: sbis.reset();
073: assertEquals("Failed to reset", 'H', sbis.read());
074: }
075:
076: /**
077: * @tests java.io.StringBufferInputStream#skip(long)
078: */
079: public void test_skipJ() {
080: // Test for method long java.io.StringBufferInputStream.skip(long)
081: long s = sbis.skip(6);
082: assertEquals("Unable to skip correct umber of chars", 6, s);
083: assertEquals("Skip positioned at incorrect char", 'W', sbis
084: .read());
085: }
086:
087: /**
088: * Sets up the fixture, for example, open a network connection. This method
089: * is called before a test is executed.
090: */
091: protected void setUp() {
092: sbis = new StringBufferInputStream("Hello World");
093: }
094:
095: /**
096: * Tears down the fixture, for example, close a network connection. This
097: * method is called after a test is executed.
098: */
099: protected void tearDown() {
100: }
101: }
|