Path: blob/master/test/jdk/javax/xml/crypto/dsig/LogParameters.java
41152 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 jdk.test.lib.hexdump.HexPrinter;2425import java.io.ByteArrayOutputStream;26import java.util.logging.*;2728/**29* @test30* @bug 824790731* @library /test/lib32* @modules java.xml.crypto/com.sun.org.slf4j.internal33*/34public class LogParameters {35public static void main(String[] args) {3637ByteArrayOutputStream bout = new ByteArrayOutputStream();38Logger.getLogger(String.class.getName()).setLevel(Level.ALL);39Handler h = new StreamHandler(bout, new SimpleFormatter());40h.setLevel(Level.ALL);41Logger.getLogger(String.class.getName()).addHandler(h);4243com.sun.org.slf4j.internal.Logger log =44com.sun.org.slf4j.internal.LoggerFactory.getLogger(String.class);45log.debug("I have {} {}s.", 10, "apple");4647h.flush();4849byte[] data = bout.toByteArray();50String s = new String(data);51if (!s.contains("LogParameters main")52|| !s.contains("FINE: I have 10 apples.")) {53HexPrinter.simple().format(data);54throw new RuntimeException("Unexpected log output: " + s);55}56}57}585960