/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4417152 4481572 6248930 6725399 6884800
* @summary Test Channels basic functionality
*/
public class Basic {
message = "ascii data for a test";
encoding = "ISO-8859-1";
test();
message = "\ucafe\ubabe\ucafe\ubabe\ucafe\ubabe";
encoding = "UTF-8";
test();
}
static void failNpeExpected() {
throw new RuntimeException("Did not get the expected NullPointerException.");
}
//Test if methods of Channels throw NPE with null argument(s)
try {
} catch (NullPointerException npe) {}
try {
} catch (NullPointerException npe) {}
try {
try {
public void close() throws IOException { }
public boolean isOpen() { return true; }
};
public void close() {}
public boolean isOpen() { return true; }
};
try {
-1);
} catch (NullPointerException npe) {}
try {
} catch (NullPointerException npe) {}
try {
} catch (NullPointerException npe) {}
try {
} catch (NullPointerException npe) {}
try {
} catch (NullPointerException npe) {}
try {
-1);
} catch (NullPointerException npe) {}
try {
} catch (NullPointerException npe) {}
try {
} catch (NullPointerException npe) {}
try {
} catch (NullPointerException npe) {}
try {
} catch (NullPointerException npe) {}
try {
} catch (NullPointerException npe) {}
try {
} finally {
}
}
byte bb[] = new byte[messageSize];
int bytesRead = 0;
int totalRead = 0;
while (bytesRead != -1) {
}
for (int i=0; i<ITERATIONS; i++) {
throw new RuntimeException("Test failed");
}
}
for (int i=0; i<limit; i++)
}
for (int i=0; i<ITERATIONS; i++)
}
byte bb[] = new byte[messageSize];
int bytesRead = 0;
int totalRead = 0;
while (bytesRead != -1) {
throw new RuntimeException("available not useful or not maximally useful");
}
throw new RuntimeException("available() should return 0 at EOF");
for (int i=0; i<ITERATIONS; i++) {
throw new RuntimeException("Test failed");
}
}
for (int i=0; i<ITERATIONS; i++)
}
int bytesRead = 0;
int totalRead = 0;
while (bytesRead != -1) {
}
for (int i=0; i<ITERATIONS; i++) {
throw new RuntimeException("Test failed");
}
}
// Causes BufferOverflowException if bug 4481572 is present.
byte data[] = new byte[9000];
int bytesRead = 1;
int totalRead = 0;
while (bytesRead > 0) {
}
}
char data[] = new char[40];
for (int i=0; i<ITERATIONS; i++)
w.flush();
w.close();
}
char data[] = new char[messageSize];
int totalRead = 0;
int charsRead = 0;
while (totalRead < messageSize) {
}
for (int i=0; i<ITERATIONS; i++) {
throw new RuntimeException("Test failed");
}
r.close();
}
}
super(file);
}
}
super(file);
}
}