# HG changeset patch # User Jiri Vanek # Date 1384339240 -3600 # Node ID e139942101a960466aa5eb9b6dddfecaa5b6b719 # Parent 7d2759e4bc980f8c8623bf3473650b1a242b4ddf Backported and adapted test-extension to silence stdout/err of itw when run from junit diff -r 7d2759e4bc98 -r e139942101a9 ChangeLog --- a/ChangeLog Wed Nov 13 11:15:18 2013 +0100 +++ b/ChangeLog Wed Nov 13 11:40:40 2013 +0100 @@ -1,3 +1,13 @@ +2013-11-13 Jiri Vanek + + Added test-extension to silence stdout/err of itw when run from junit + * tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java: now extends NoStdOutErrTest + * tests/netx/unit/net/sourceforge/jnlp/ParserBasic.java: same + * tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java: same + * tests/test-extensions/net/sourceforge/jnlp/util/logging/NoStdOutErrTest.java: + new class with (disableStds) BeforeClass method and (restoreStds) AfterClass + method which are responsible for redirecting all itw messages from extending test. + 2013-11-13 Jiri Vanek Enabled access to manifests' attributes from JNLPFile class diff -r 7d2759e4bc98 -r e139942101a9 tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java --- a/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java Wed Nov 13 11:15:18 2013 +0100 +++ b/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java Wed Nov 13 11:40:40 2013 +0100 @@ -46,11 +46,12 @@ import net.sourceforge.jnlp.JNLPFile.Match; import net.sourceforge.jnlp.annotations.Bug; import net.sourceforge.jnlp.mock.MockJNLPFile; +import net.sourceforge.jnlp.util.logging.NoStdOutErrTest; import org.junit.Assert; import org.junit.Test; -public class JNLPFileTest { +public class JNLPFileTest extends NoStdOutErrTest{ Locale jvmLocale = new Locale("en", "CA", "utf8"); MockJNLPFile file = new MockJNLPFile(jvmLocale); diff -r 7d2759e4bc98 -r e139942101a9 tests/netx/unit/net/sourceforge/jnlp/ParserBasic.java --- a/tests/netx/unit/net/sourceforge/jnlp/ParserBasic.java Wed Nov 13 11:15:18 2013 +0100 +++ b/tests/netx/unit/net/sourceforge/jnlp/ParserBasic.java Wed Nov 13 11:40:40 2013 +0100 @@ -37,20 +37,17 @@ package net.sourceforge.jnlp; -import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.List; -import net.sourceforge.jnlp.runtime.CodeBaseClassLoaderTest; import net.sourceforge.jnlp.mock.DummyJNLPFile; +import net.sourceforge.jnlp.util.logging.NoStdOutErrTest; -import org.junit.After; import org.junit.Assert; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; /** Test that the parser works with basic jnlp files */ -public class ParserBasic { +public class ParserBasic extends NoStdOutErrTest{ private static Node root; private static Parser parser; diff -r 7d2759e4bc98 -r e139942101a9 tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java --- a/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java Wed Nov 13 11:15:18 2013 +0100 +++ b/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java Wed Nov 13 11:40:40 2013 +0100 @@ -62,10 +62,11 @@ import net.sourceforge.jnlp.Version; import net.sourceforge.jnlp.cache.UpdatePolicy; import net.sourceforge.jnlp.util.StreamUtils; +import net.sourceforge.jnlp.util.logging.NoStdOutErrTest; import org.junit.Test; -public class JNLPClassLoaderTest { +public class JNLPClassLoaderTest extends NoStdOutErrTest{ /* Get the open file-descriptor count for the process. * Note that this is specific to Unix-like operating systems. diff -r 7d2759e4bc98 -r e139942101a9 tests/test-extensions/net/sourceforge/jnlp/util/logging/NoStdOutErrTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-extensions/net/sourceforge/jnlp/util/logging/NoStdOutErrTest.java Wed Nov 13 11:40:40 2013 +0100 @@ -0,0 +1,74 @@ +/* +Copyright (C) 2011-2012 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 2. + +IcedTea 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 for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + */ +package net.sourceforge.jnlp.util.logging; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import java.io.*; +import java.lang.*; + +public class NoStdOutErrTest { + + private static PrintStream origOut; + private static PrintStream origErr; + private static ByteArrayOutputStream nwOut; + private static ByteArrayOutputStream nwErr; + + + @BeforeClass + public static void disableStds() throws Exception { + nwOut = new ByteArrayOutputStream(); + origOut = System.out; + nwErr = new ByteArrayOutputStream(); + origErr = System.err; + System.setOut(new PrintStream(nwOut)); + System.setErr(new PrintStream(nwErr)); + } + + @AfterClass + public static void restoreStds() throws Exception { + System.setOut(new PrintStream(origOut)); + System.setErr(new PrintStream(origErr)); + } + + + + +}