diff options
author | lana <none@none> | 2013-10-25 10:39:13 -0700 |
---|---|---|
committer | lana <none@none> | 2013-10-25 10:39:13 -0700 |
commit | 1492287786f2f20c945859b927c66358751c0f8e (patch) | |
tree | 156f552bed21656d7776f5a70e229ee7b86515d5 /test/javax | |
parent | a1f7f2b01d84ad0ffaecfa1a6a504abea065a041 (diff) | |
parent | 602fee2588f67fb0d8efc1ee78e3b209e6d1ebe2 (diff) |
Merge
Diffstat (limited to 'test/javax')
12 files changed, 253 insertions, 83 deletions
diff --git a/test/javax/management/monitor/CounterMonitorThresholdTest.java b/test/javax/management/monitor/CounterMonitorThresholdTest.java index a1f93d8c4..b56d314af 100644 --- a/test/javax/management/monitor/CounterMonitorThresholdTest.java +++ b/test/javax/management/monitor/CounterMonitorThresholdTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 6229368 + * @bug 6229368 8025207 * @summary Wrong threshold value in CounterMonitor with offset and modulus. * @author Luis-Miguel Alventosa * @run clean CounterMonitorThresholdTest @@ -144,16 +144,14 @@ public class CounterMonitorThresholdTest { for (int i = 0; i < counter.length; i++) { mbean.setCounter(counter[i]); System.out.println("\nCounter = " + mbean.getCounter()); - Thread.sleep(300); - Integer derivedGaugeValue = (Integer) cm.getDerivedGauge(name); - System.out.println("Derived Gauge = " + derivedGaugeValue); - if (derivedGaugeValue.intValue() != derivedGauge[i]) { - System.out.println("Wrong derived gauge! Current value = " + - derivedGaugeValue + " Expected value = " + derivedGauge[i]); - System.out.println("\nStop monitoring..."); - cm.stop(); - throw new IllegalArgumentException("wrong derived gauge"); - } + Integer derivedGaugeValue; + // either pass or test timeout (killed by test harness) + // see 8025207 + do { + Thread.sleep(150); + derivedGaugeValue = (Integer) cm.getDerivedGauge(name); + } while (derivedGaugeValue.intValue() != derivedGauge[i]); + Number thresholdValue = cm.getThreshold(name); System.out.println("Threshold = " + thresholdValue); if (thresholdValue.intValue() != threshold[i]) { @@ -163,7 +161,6 @@ public class CounterMonitorThresholdTest { cm.stop(); throw new IllegalArgumentException("wrong threshold"); } - Thread.sleep(300); } // Stop the monitor diff --git a/test/javax/management/monitor/NullAttributeValueTest.java b/test/javax/management/monitor/NullAttributeValueTest.java index e1661186a..01ab275fa 100644 --- a/test/javax/management/monitor/NullAttributeValueTest.java +++ b/test/javax/management/monitor/NullAttributeValueTest.java @@ -23,11 +23,12 @@ /* * @test - * @bug 6200031 + * @bug 6200031 8025206 * @summary Test that the counter/gauge/string monitors emit a * jmx.monitor.error.type notification when the attribute * being monitored returns a null value. * @author Luis-Miguel Alventosa + * @author Shanliang JIANG * @run clean NullAttributeValueTest * @run build NullAttributeValueTest * @run main NullAttributeValueTest @@ -39,7 +40,7 @@ import javax.management.monitor.*; public class NullAttributeValueTest implements NotificationListener { // Flag to notify that a message has been received - private boolean messageReceived = false; + private volatile boolean messageReceived = false; // MBean class public class ObservedObject implements ObservedObjectMBean { @@ -83,7 +84,6 @@ public class NullAttributeValueTest implements NotificationListener { * Update the counter and check for notifications */ public int counterMonitorNotification() throws Exception { - CounterMonitor counterMonitor = null; try { MBeanServer server = MBeanServerFactory.newMBeanServer(); @@ -134,31 +134,17 @@ public class NullAttributeValueTest implements NotificationListener { echo(">>> START the CounterMonitor"); counterMonitor.start(); - // Wait for granularity period (multiplied by 2 for sure) - // - Thread.sleep(granularityperiod * 2); - - // Check if notification was received - // - if (messageReceived) { - echo("\tOK: CounterMonitor notification received"); - } else { - echo("\tKO: CounterMonitor notification missed or not emitted"); - return 1; - } + return checkReceived(granularityperiod, "CounterMonitor"); } finally { if (counterMonitor != null) counterMonitor.stop(); } - - return 0; } /** * Update the gauge and check for notifications */ public int gaugeMonitorNotification() throws Exception { - GaugeMonitor gaugeMonitor = null; try { MBeanServer server = MBeanServerFactory.newMBeanServer(); @@ -212,31 +198,17 @@ public class NullAttributeValueTest implements NotificationListener { echo(">>> START the GaugeMonitor"); gaugeMonitor.start(); - // Wait for granularity period (multiplied by 2 for sure) - // - Thread.sleep(granularityperiod * 2); - - // Check if notification was received - // - if (messageReceived) { - echo("\tOK: GaugeMonitor notification received"); - } else { - echo("\tKO: GaugeMonitor notification missed or not emitted"); - return 1; - } + return checkReceived(granularityperiod, "GaugeMonitor"); } finally { if (gaugeMonitor != null) gaugeMonitor.stop(); } - - return 0; } /** * Update the string and check for notifications */ public int stringMonitorNotification() throws Exception { - StringMonitor stringMonitor = null; try { MBeanServer server = MBeanServerFactory.newMBeanServer(); @@ -289,24 +261,11 @@ public class NullAttributeValueTest implements NotificationListener { echo(">>> START the StringMonitor"); stringMonitor.start(); - // Wait for granularity period (multiplied by 2 for sure) - // - Thread.sleep(granularityperiod * 2); - - // Check if notification was received - // - if (messageReceived) { - echo("\tOK: StringMonitor notification received"); - } else { - echo("\tKO: StringMonitor notification missed or not emitted"); - return 1; - } + return checkReceived(granularityperiod, "StringMonitor"); } finally { if (stringMonitor != null) stringMonitor.stop(); } - - return 0; } /** @@ -326,6 +285,21 @@ public class NullAttributeValueTest implements NotificationListener { return error; } + private int checkReceived(long granularityperiod, String caller) throws InterruptedException { + int i = 100; + do { + Thread.sleep(granularityperiod); + } while (!messageReceived && i-- > 0); + + if (messageReceived) { + echo("\tOK: " + caller + " notification received"); + } else { + echo("\tKO: " + caller + " notification missed or not emitted"); + } + + return messageReceived ? 0 : 1; + } + /* * Print message */ diff --git a/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java b/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java index 1ada5fb3b..42bed8570 100644 --- a/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java +++ b/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4940957 + * @bug 4940957 8025205 * @summary Tests behaviour when connections break * @author Eamonn McManus * @run clean BrokenConnectionTest @@ -485,14 +485,13 @@ public class BrokenConnectionTest { } if (thisok) { System.out.println("Waiting for failure notif"); - long deadline = System.currentTimeMillis() + 5000; - while (failureListener.count < 1 - && System.currentTimeMillis() < deadline) - Thread.sleep(500); - if (failureListener.count < 1) { - System.out.println("Did not get failure notif!"); - thisok = false; - } else if (failureListener.count > 1) { + // pass or test timeout. see 8025205 + do { + Thread.sleep(100); + } while (failureListener.count < 1); + + Thread.sleep(1000); // if more notif coming ... + if (failureListener.count > 1) { System.out.println("Got too many failure notifs: " + failureListener.count); thisok = false; diff --git a/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java b/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java index 854a211a7..9bd9a741c 100644 --- a/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java +++ b/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4886838 4886830 + * @bug 4886838 4886830 8025204 * @summary Tests that idle timeouts happen at appropriate times * @author Eamonn McManus * @run clean IdleTimeoutTest @@ -278,19 +278,11 @@ public class IdleTimeoutTest { } System.out.println("Waiting for id list to drop ours"); - deadline = System.currentTimeMillis() + timeout*2 + 10000; - while (true) { - ids = Arrays.asList(server.getConnectionIds()); - if (!ids.contains(connId) - || System.currentTimeMillis() >= deadline) - break; - Thread.sleep(500); - } - if (ids.contains(connId)) { - System.out.println("Client id still in list after " + - "deadline: " + ids); - return false; - } + // pass or timed out by test harness - see 8025204 + do { + Thread.sleep(100); + ids = Arrays.asList(server.getConnectionIds()); + } while (ids.contains(connId)); conn.getDefaultDomain(); if (connId.equals(client.getConnectionId())) { diff --git a/test/javax/management/remote/mandatory/loading/MissingClassTest.java b/test/javax/management/remote/mandatory/loading/MissingClassTest.java index e70d0adfe..98eead895 100644 --- a/test/javax/management/remote/mandatory/loading/MissingClassTest.java +++ b/test/javax/management/remote/mandatory/loading/MissingClassTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4915825 4921009 4934965 4977469 + * @bug 4915825 4921009 4934965 4977469 8019584 * @summary Tests behavior when client or server gets object of unknown class * @author Eamonn McManus * @run clean MissingClassTest SingleClassLoader diff --git a/test/javax/xml/jaxp/validation/8015092/XPathWhiteSpaceTest.java b/test/javax/xml/jaxp/validation/8015092/XPathWhiteSpaceTest.java new file mode 100644 index 000000000..c4c4fa2ae --- /dev/null +++ b/test/javax/xml/jaxp/validation/8015092/XPathWhiteSpaceTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013, 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 8015092 + * @summary whitespace within patterns in Selector XPath expression is accepted + * @run main/othervm XPathWhiteSpaceTest + */ + +import java.io.*; +import javax.xml.XMLConstants; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import org.xml.sax.SAXException; + +/** + * http://www.w3.org/TR/xmlschema-1/#coss-identity-constraint + * For readability, whitespace may be used in selector XPath expressions even though + * not explicitly allowed by the grammar: + * whitespace may be freely added within patterns before or after any token. + * + * @author huizhe.wang@oracle.com + */ +public class XPathWhiteSpaceTest { + static final String XSDFILE = "idJ029.xsd"; + + public static void main(String[] args) throws Exception { + try{ + SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = schemaFactory.newSchema(new File(System.getProperty("test.src", "."), XSDFILE)); + } catch (SAXException e) { + throw new RuntimeException(e.getMessage()); + } + + + } + +} diff --git a/test/javax/xml/jaxp/validation/8015092/idIxpns.xsd b/test/javax/xml/jaxp/validation/8015092/idIxpns.xsd new file mode 100644 index 000000000..941695faf --- /dev/null +++ b/test/javax/xml/jaxp/validation/8015092/idIxpns.xsd @@ -0,0 +1,12 @@ +<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="xpns.org" xmlns:xpns="xpns.org">
+ <xsd:element name="xsid" type="xsd:string"/>
+ <xsd:element name="xiid">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="xiid2" type="xsd:string" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="val" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
diff --git a/test/javax/xml/jaxp/validation/8015092/idIxpns1.xsd b/test/javax/xml/jaxp/validation/8015092/idIxpns1.xsd new file mode 100644 index 000000000..d0ff89a78 --- /dev/null +++ b/test/javax/xml/jaxp/validation/8015092/idIxpns1.xsd @@ -0,0 +1,12 @@ +<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="xpns1.org" xmlns:xpns="xpns1.org">
+ <xsd:element name="xsid" type="xsd:string"/>
+ <xsd:element name="xiid">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="xiid2" type="xsd:string" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="val" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
diff --git a/test/javax/xml/jaxp/validation/8015092/idJ029.xsd b/test/javax/xml/jaxp/validation/8015092/idJ029.xsd new file mode 100644 index 000000000..9b83e2958 --- /dev/null +++ b/test/javax/xml/jaxp/validation/8015092/idJ029.xsd @@ -0,0 +1,21 @@ +<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xpns="xpns.org" xmlns:xpns1="xpns1.org" xmlns:xpns2="xpns2.org" xmlns:imp="importNS">
+ <xsd:import namespace="importNS" schemaLocation="idJimp.xsd"/>
+ <xsd:import namespace="xpns.org" schemaLocation="idIxpns.xsd"/>
+ <xsd:import namespace="xpns1.org" schemaLocation="idIxpns1.xsd"/>
+ <xsd:element name="root">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="tid" maxOccurs="unbounded"/>
+ <xsd:element ref="imp:iid1" maxOccurs="unbounded"/>
+ <xsd:element ref="imp:sid" maxOccurs="unbounded"/>
+ <xsd:element ref="xpns:xiid" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:unique id="foo123" name="uid">
+ <xsd:selector xpath=".//tid"/>
+ <xsd:field xpath=". //."/>
+ </xsd:unique>
+ </xsd:element>
+ <xsd:element name="tid" type="xsd:string"/>
+</xsd:schema>
diff --git a/test/javax/xml/jaxp/validation/8015092/idJimp.xsd b/test/javax/xml/jaxp/validation/8015092/idJimp.xsd new file mode 100644 index 000000000..c2b966af9 --- /dev/null +++ b/test/javax/xml/jaxp/validation/8015092/idJimp.xsd @@ -0,0 +1,11 @@ +<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="importNS" xmlns:imp="importNS">
+ <xsd:element name="sid" type="xsd:string"/>
+ <xsd:element name="iid1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="iid2" type="xsd:string" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
diff --git a/test/javax/xml/jaxp/validation/8015243/AnyURITest.java b/test/javax/xml/jaxp/validation/8015243/AnyURITest.java new file mode 100644 index 000000000..437610c45 --- /dev/null +++ b/test/javax/xml/jaxp/validation/8015243/AnyURITest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013, 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 8015243 + * @summary verifies that illegal URI such as // is rejected + * @run main/othervm AnyURITest + */ + +import java.io.*; +import javax.xml.XMLConstants; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import org.xml.sax.SAXException; + +/** + * Similar to java.net.URI, allow empty authority prior to non-empty + * path, query component or fragment identifier + * + * @author huizhe.wang@oracle.com + */ +public class AnyURITest { + static final String XSDFILE = "anyURI_b006.xsd"; + + public static void main(String[] args) throws Exception { + try{ + SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = schemaFactory.newSchema(new File(System.getProperty("test.src", "."), XSDFILE)); + throw new RuntimeException("Illegal URI // should be rejected."); + } catch (SAXException e) { + //expected: + //Enumeration value '//' is not in the value space of the base type, anyURI. + } + + + } + +} diff --git a/test/javax/xml/jaxp/validation/8015243/anyURI_b006.xsd b/test/javax/xml/jaxp/validation/8015243/anyURI_b006.xsd new file mode 100644 index 000000000..ba131d943 --- /dev/null +++ b/test/javax/xml/jaxp/validation/8015243/anyURI_b006.xsd @@ -0,0 +1,32 @@ +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:element name="root"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element ref="foo"/> + <xsd:element ref="bar"/> + </xsd:choice> + </xsd:complexType> + </xsd:element> + + <xsd:element type="xsd:anyURI" name="foo"></xsd:element> + <xsd:element type="st" name="bar"></xsd:element> + + <xsd:simpleType name="st"> + <xsd:restriction base="xsd:anyURI"> + <xsd:enumeration value="/"/> + <xsd:enumeration value="//"/> + <xsd:enumeration value="///"/> + <xsd:enumeration value="//a\\b"/> + <xsd:enumeration value="\"/> + <xsd:enumeration value="\\"/> + <xsd:enumeration value="\\\"/> + <xsd:enumeration value="\\/"/> + <xsd:enumeration value="\\a\b"/> + <xsd:enumeration value="\a\b"/> + <xsd:enumeration value="/a\b"/> + <xsd:enumeration value="..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\a"/> + </xsd:restriction> + </xsd:simpleType> + +</xsd:schema> |