--- /dev/null 2017-02-06 10:30:55.634050603 +0300 +++ new/functional/FxmlTests/src/test/fxmltests/app/staticPropertyLoadApp.java.excluded 2017-02-10 15:02:05.553501982 +0300 @@ -0,0 +1,2781 @@ +// https://bugs.openjdk.java.net/browse/INTJDK-7624138 +/* + * Copyright (c) 2014, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ +package test.fxmltests.app; + +import javafx.fxml.LoadListener; +import com.sun.javafx.fxml.ParseTraceElement; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.css.CssMetaData; +import javafx.css.Styleable; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.fxml.FXMLLoader; +import javafx.fxml.JavaFXBuilderFactory; +import javafx.fxml.LoadException; +import javafx.scene.Group; + + +import javafx.scene.Node; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.Labeled; +import javafx.scene.control.ListView; +import javafx.scene.control.Menu; +import javafx.scene.control.MenuBar; +import javafx.scene.control.MenuItem; +import javafx.scene.control.RadioButton; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.ToggleGroup; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.input.KeyCombination; +import javafx.scene.layout.*; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Font; +import javafx.scene.text.Text; +import javafx.util.Callback; +import javafx.util.Pair; + +import test.javaclient.shared.BasicButtonChooserApp; +import test.javaclient.shared.PageWithSlots; +import test.javaclient.shared.TestNode; +import test.javaclient.shared.Utils; + +public class staticPropertyLoadApp extends BasicButtonChooserApp { + + public static final String RESOURCE_BASE = "/test/fxmltests/resources/"; + public static final String staticPropertyResourcePath = RESOURCE_BASE + "static-property.fxml"; + public static final String hashmapResourcePath = RESOURCE_BASE + "hashmap.fxml"; + public static final String customClassLoadResourcePath = RESOURCE_BASE + "include.fxml"; + public static final String factoryResourcePath = RESOURCE_BASE + "factory.fxml"; + public static final String builderResourcePath = RESOURCE_BASE + "builder.fxml"; + public static final String propertyElementsResourcePath = RESOURCE_BASE + "propertyElements.fxml"; + public static final String referenceResourcePath = RESOURCE_BASE + "reference.fxml"; + public static final String copyResourcePath = RESOURCE_BASE + "fxcopy.fxml"; + public static final String propertySetterResourcePath = RESOURCE_BASE + "propertySetter.fxml"; + public static final String roListResourcePath = RESOURCE_BASE + "rolist.fxml"; + public static final String roMapResourcePath = RESOURCE_BASE + "romap.fxml"; + public static final String defaultPropertyResourcePath = RESOURCE_BASE + "defaultProperty.fxml"; + public static final String fxdefineResourcePath = RESOURCE_BASE + "fxdefine.fxml"; + public static final String fxdefine2ResourcePath = RESOURCE_BASE + "fxdefine2.fxml"; + public static final String namespaceBindingResourcePath = RESOURCE_BASE + "namespaceBinding.fxml"; + public static final String staticPropertiesResourcePath = RESOURCE_BASE + "static-properties.fxml"; + public static final String rootMethodEventHandlerResourcePath = RESOURCE_BASE + "rootMethodEventHandler.fxml"; + public static final String scriptEventHandlerResourcePath = RESOURCE_BASE + "scriptEventHandler.fxml"; + public static final String scriptResourcePath = RESOURCE_BASE + "script.fxml"; + public static final String menuitemResourcePath = RESOURCE_BASE + "menuitem.fxml"; + public static final String resourceResourcePath = RESOURCE_BASE + "resourcefxml.fxml"; + public static final String splitpanebugResourcePath = RESOURCE_BASE + "vt1.fxml"; + public static final String throw1ResourcePath = RESOURCE_BASE + "throw1.fxml"; + public static final String throw2ResourcePath = RESOURCE_BASE + "throw2.fxml"; + public static final String rt19133ResourcePath = RESOURCE_BASE + "rt19133.fxml"; + + public static enum Pages { + staticProperty,HashMap,customClassAndInclude,factory,simple, + propertyElements,reference,copy,prSetter,roList,roMap, + defaultProperty,fxdefine,namespaceBinding,staticProperties,rootMethodEventHandler, + scriptEventHandler,script,menuItem,resources1,resources2,namespace, + splitpanebug,charset, loadExceptions, + slotDefaultLabeled, slotDefaultListview, slotDefaultMenu, slotDefaultMenuBar, + slotDefaultScrollpane, slotDefaultTabpane, slotDefaultTableView, + slotDefaultTextinput, slotDefaultTitledpane, slotDefaultTreeview, + slotDefaultImageview, slotDefaultPane, slotControllerFactory, + specificSignatureMethod, loadfontSlot, scenebuilderSlot, + scenebuilderNoRoot, references2, apConstraints, coerce, listviewItems, listenerNullArg, + gridapplet, csspath, errorFXML, colorValueOF, escapeCharacter, collectionEventsHandlers, + noArgControllerMethod, overloadedControllerMethod, customIDProperty, unknownCustomType, + baseControllerProperty, relativeStylesheet, FXMLLoaderAPI, fullyQualifiedNames, importPI, + beanInstantiation, valueOf, root, fxId, fxController, noDefaultController, lateRoot, + lateController, variableResolution, externalScript + + } + + public staticPropertyLoadApp() { + super(800, 600, "LoadFXML", false); + } + + Rectangle retRec = new Rectangle(10,10){{setFill(Color.GREEN);}}; + Rectangle redRectangle = new Rectangle(10,10){{setFill(Color.RED);}}; + + abstract private class TestNodeWithIOExceptionProcessing extends TestNode { + + abstract protected Node impl_drawNode() throws IOException; + protected String impl_getPathToResource() { return null; }; + protected URL resource = null; + protected File f = null; + + @Override + public Node drawNode() { + Node result = redRectangle; + + VBox vb = null; + + if (null != impl_getPathToResource()) { + resource = getClass().getResource(impl_getPathToResource()); + if (null != resource && null != (f = new File(resource.getFile()))) { + System.out.println("loading " + f.getPath()); + } else { + String tmpMsg = "resource file error. [" + impl_getPathToResource() + "]"; + System.out.println(tmpMsg); + reportGetterFailure(tmpMsg); + return result; + } + } + try { + result = impl_drawNode(); + } catch (IOException ex) { + reportGetterFailure("TestNodeWithIOExceptionProcessing: IOException"); + Logger.getLogger(staticPropertyLoadApp.class.getName()).log(Level.SEVERE, null, ex); + } catch (Exception ex) { + reportGetterFailure("TestNodeWithIOExceptionProcessing: Exception"); + Logger.getLogger(staticPropertyLoadApp.class.getName()).log(Level.SEVERE, null, ex); + } + return result; + } + } + + private class slotStaticProperty extends TestNodeWithIOExceptionProcessing { + @Override + protected String impl_getPathToResource() { + return staticPropertyResourcePath; + } + @Override + public Node impl_drawNode() throws IOException { + Node uplevelNode = null; + try { + uplevelNode = FXMLLoader.load(resource); + } catch (Exception e) { + System.out.println("message: " + e.getMessage()); + reportGetterFailure("message: " + e.getMessage()); + } + return uplevelNode; + } + } + + private class hashmaptest extends TestNodeWithIOExceptionProcessing { + + HashMap hm = null; + String value1; + String value2; + + @Override + protected String impl_getPathToResource() { + return hashmapResourcePath; + } + + @Override + public Node impl_drawNode() throws IOException { + + try { + hm = FXMLLoader.load(resource); + value1 = (String) hm.get("foo"); + value2 = (String) hm.get("bar"); + } catch (Exception e) { + System.out.println("message: " + e.getMessage()); + reportGetterFailure("exception thrown."); + } + if (value1.equals("123") && value2.equals("456")) { + return retRec; + } else { + reportGetterFailure("failed."); + return redRectangle; + } + } + } + + CustomClass cc; + private class customClassLoadSlot extends TestNodeWithIOExceptionProcessing { + + @Override + protected String impl_getPathToResource() { + return customClassLoadResourcePath; + } + + @Override + public Node impl_drawNode() throws IOException { + FXMLLoader fxmlLoader = new FXMLLoader(); + + InputStream is = null; + try { + fxmlLoader.setLocation(resource); + is = resource.openStream(); + cc = (CustomClass) fxmlLoader.load(is); + } catch (Exception e) { + System.out.println("message: " + e.getMessage()); + e.printStackTrace(); + reportGetterFailure("exception thrown."); + } finally { + is.close(); + } + +// System.out.println(" includes: " + fxmlLoader.getIncludes()); + System.out.println("cc.getFld(): " + cc.getFld()); + + if (cc.getFld().equals("fine!")) { + return retRec; + } else { + reportGetterFailure("failed."); + return redRectangle; + } + } + } + + private class factorySlot extends TestNodeWithIOExceptionProcessing { + + ObservableList ss = FXCollections.observableArrayList(); + + @Override + protected String impl_getPathToResource() { + return factoryResourcePath; + } + + @Override + public Node impl_drawNode() throws IOException { + try { + ss = FXMLLoader.load(resource); + } catch (Exception e) { + System.out.println("message: " + e.getMessage()); + reportGetterFailure("exception thrown."); + } + if (ss.get(0).equals("A") && ss.get(1).equals("B") && ss.get(2).equals("C")) { + return retRec; + } else { + reportGetterFailure("failed."); + return redRectangle; + } + } + } + + private class simpleSlot extends TestNodeWithIOExceptionProcessing { + + Color color = Color.ALICEBLUE; + + @Override + protected String impl_getPathToResource() { + return builderResourcePath; + } + + @Override + public Node impl_drawNode() throws IOException { + InputStream is = null; + try { + FXMLLoader fxmlLoader2 = new FXMLLoader(); + is = resource.openStream(); + ClassLoader defaultClassLoader = fxmlLoader2.getClassLoader(); + + fxmlLoader2.setBuilderFactory(new JavaFXBuilderFactory(defaultClassLoader)); + color = (Color) fxmlLoader2.load(is); // see RT-18091 + } catch (Exception e) { + e.printStackTrace(); + System.out.println("message: " + e.getMessage()); + reportGetterFailure("exception thrown."); + } finally { + is.close(); + } + System.out.println("color: " + color); + if (color.equals(Color.color(1., 0., 0.))) { + return retRec; + } else { + reportGetterFailure("failed."); + return redRectangle; + } + } + } + + private class propertyElementsSlot extends TestNodeWithIOExceptionProcessing { + + Label label; + + @Override + protected String impl_getPathToResource() { + return propertyElementsResourcePath; + } + + @Override + public Node impl_drawNode() { + try { + label = FXMLLoader.load(resource); + } catch (Exception e) { + System.out.println("message: " + e.getMessage()); + reportGetterFailure("exception thrown."); + } + if (label.getText().equals("label")) { + return label; + } else { + reportGetterFailure("failed."); + return redRectangle; + } + } + } + + private class referenceSlot extends TestNodeWithIOExceptionProcessing { + + List