Added an option to exclude timing tests

This commit is contained in:
Trustin Lee 2009-03-09 19:03:48 +00:00
parent 832ed0c198
commit 0a72ffeacd
3 changed files with 56 additions and 0 deletions

View File

@ -34,6 +34,7 @@ import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
import org.jboss.netty.util.DummyHandler;
import org.jboss.netty.util.TimingTestUtil;
import org.junit.Test;
@ -48,6 +49,10 @@ public class NioClientSocketShutdownTimeTest {
@Test
public void testShutdownTime() throws Throwable {
if (!TimingTestUtil.isTimingTestEnabled()) {
return;
}
ServerSocketChannel serverSocket = ServerSocketChannel.open();
serverSocket.socket().bind(new InetSocketAddress(0));

View File

@ -37,6 +37,7 @@ import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jboss.netty.util.TimingTestUtil;
import org.junit.Test;
@ -51,6 +52,10 @@ public class NioServerSocketShutdownTimeTest {
@Test(timeout = 10000)
public void testSuccessfulBindAttempt() throws Exception {
if (!TimingTestUtil.isTimingTestEnabled()) {
return;
}
ServerBootstrap bootstrap = new ServerBootstrap(
new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),

View File

@ -0,0 +1,46 @@
/*
* JBoss, Home of Professional Open Source
*
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @author tags. See the COPYRIGHT.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.netty.util;
/**
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
* @version $Rev$, $Date$
*/
public final class TimingTestUtil {
private static final boolean ENABLED;
static {
String value = System.getProperty("exclude-timing-tests", "false");
ENABLED = !ConversionUtil.toBoolean(value);
System.out.println("Timing tests will be disabled as requested.");
}
public static boolean isTimingTestEnabled() {
return ENABLED;
}
private TimingTestUtil() {
// Unused
}
}