Path: blob/master/test/jdk/java/util/Properties/CompatibilityTest.java
41149 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.ByteArrayOutputStream;24import java.io.IOException;25import java.util.Properties;26import org.testng.Assert;2728import org.testng.annotations.DataProvider;29import org.testng.annotations.Test;3031/*32* @test33* @bug 825235434* @run testng CompatibilityTest35* @summary Verify compatibility.36*/37public class CompatibilityTest {38@DataProvider(name = "entries")39public Object[][] getEntries() throws IOException {40return new Object[][]{41{8, 238923},42{1.1, 1.1},43{new Object(), "Value"},44{"Key", new Object()},45};46}4748/**49* Verifies that a ClassCastException is thrown as specified by the50* {@code storeToXML} method.51* @param key the key52* @param value the value53* @throws IOException54*/55@Test(dataProvider = "entries")56void testThrows(Object key, Object value) throws IOException {57Assert.assertThrows(ClassCastException.class, () -> storeToXML(key, value));58}5960void storeToXML(Object key, Object value) throws IOException {61ByteArrayOutputStream os = new ByteArrayOutputStream();62Properties pr = new Properties();63pr.put(key, value);64pr.storeToXML(os, "Test", "UTF-8");65}66}676869