StarImportTest.java revision 857
766N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 766N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 766N/A * This code is free software; you can redistribute it and/or modify it 766N/A * under the terms of the GNU General Public License version 2 only, as 766N/A * published by the Free Software Foundation. 766N/A * This code is distributed in the hope that it will be useful, but WITHOUT 766N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 766N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 766N/A * version 2 for more details (a copy is included in the LICENSE file that 766N/A * accompanied this code). 766N/A * You should have received a copy of the GNU General Public License version 766N/A * 2 along with this work; if not, write to the Free Software Foundation, 766N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 766N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 766N/A * or visit www.oracle.com if you need additional information or have any 766N/A * @summary Basher for star-import scopes 766N/A * Select a random element from an array of choices. 766N/A * Write a message to stderr. 766N/A * Write a message to stderr, and dump a scope. 766N/A * Write an error message to stderr. 766N/A /** Class to encapsulate a test run. */ 766N/A * Setup env by creating pseudo-random collection of names, packages and classes. 766N/A * Set up a random number of names. 766N/A * Set up a package containing a random number of member elements. 766N/A// log("setup: created " + c1); 766N/A// log("setup: created " + c2); 766N/A// log("package " + p, p.members_field); 766N/A * Set up a class containing a random number of member elements. 766N/A// log("setup: created " + c); 766N/A// log("setup: created " + ic); 766N/A * Create a star-import scope and a model therof, from the packages and 766N/A * classes created by setupPackages and setupClasses. 766N/A * @throws Exception for fatal errors, such as from reflection 766N/A // if StarImportScope exists, use it, otherwise, for testing legacy code, 766N/A // fall back on ImportScope 766N/A// log("importAll", members); 766N/A // The following lines are taken from MemberEnter.importAll, 766N/A // before the use of StarImportScope.importAll. 766N/A// log("star-import scope", starImportScope); 766N/A * The core of the test. In a random order, move nested classes from 766N/A * the package in which they created to the class which should own them. 766N/A // select a random nested class to move from package to class 766N/A // remove from star import model 766N/A // owner should be a package 766N/A// log(sym + " owner: " + sym.owner, sym.owner.members()); 766N/A// log("outer: " + outerName + " " + outer); 766N/A // rename and insert into class 766N/A// log(sym.name + "(" + sym + ") removed from reference model"); 766N/A * Check the contents of a scope 766N/A // First, check all entries in scope are in map 766N/A // Second, check all entries in map are in scope