/* * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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 4313885 4926319 4927634 5032610 5032622 5049968 5059533 6223711 6277261 6269946 6288823 * @summary Basic tests of java.util.Scanner methods * @key randomness */ import java.util.*; import java.text.*; import java.io.*; import java.nio.*; import java.util.regex.*; import java.math.*; public class ScanTest { private static boolean failure = false; private static int failCount = 0; private static int NUM_SOURCE_TYPES = 2; public static void main(String[] args) throws Exception { Locale reservedLocale = Locale.getDefault(); String lang = reservedLocale.getLanguage(); try { if (!"en".equals(lang) && !"zh".equals(lang) && !"ko".equals(lang) && !"ja".equals(lang)) { //Before we have resource to improve the test to be ready for //arbitrary locale, force the default locale to be "English" //for now. Locale.setDefault(Locale.ENGLISH); } skipTest(); findInLineTest(); findWithinHorizonTest(); findInEmptyLineTest(); removeTest(); fromFileTest(); ioExceptionTest(); matchTest(); delimiterTest(); useLocaleTest(); closeTest(); cacheTest(); cacheTest2(); nonASCIITest(); resetTest(); for (int j=0; j\n]+"); sc.next(); String textOfRef = sc.next(); if (!textOfRef.equals(expected[i])) failCount++; } // Read some html tags using < and > as delimiters if (!sc.next().equals("/a")) failCount++; if (!sc.next().equals("b")) failCount++; // Scan some html tags using skip and next Pattern nonTagStart = Pattern.compile("[^<]+"); Pattern tag = Pattern.compile("<[^>]+?>"); Pattern spotAfterTag = Pattern.compile("(?<=>)"); String[] expected2 = { "", "

", "