transport-udt tests should run only when provider class can be loaded and initialized
This commit is contained in:
parent
318328bb06
commit
a91887cda7
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2013 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.netty.channel.udt.nio;
|
||||
|
||||
import static org.junit.Assume.*;
|
||||
import io.netty.channel.udt.util.UnitHelp;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import com.barchart.udt.SocketUDT;
|
||||
|
||||
/**
|
||||
* Base for UDT tests.
|
||||
*/
|
||||
public abstract class AbstractUdtTest {
|
||||
|
||||
/**
|
||||
* UDT test assumptions.
|
||||
*/
|
||||
@BeforeClass
|
||||
public static void assumeConditions(){
|
||||
assumeTrue(UnitHelp.canLoadAndInitClass("com.barchart.udt.SocketUDT"));
|
||||
}
|
||||
|
||||
}
|
@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NioUdtByteAcceptorChannelTest {
|
||||
public class NioUdtByteAcceptorChannelTest extends AbstractUdtTest {
|
||||
|
||||
protected static final Logger log = LoggerFactory.getLogger(NioUdtByteAcceptorChannelTest.class);
|
||||
|
||||
|
@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NioUdtByteConnectorChannelTest {
|
||||
public class NioUdtByteConnectorChannelTest extends AbstractUdtTest {
|
||||
|
||||
protected static final Logger log = LoggerFactory.getLogger(NioUdtByteAcceptorChannelTest.class);
|
||||
|
||||
|
@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NioUdtByteRendezvousChannelTest {
|
||||
public class NioUdtByteRendezvousChannelTest extends AbstractUdtTest {
|
||||
|
||||
protected static final Logger log = LoggerFactory.getLogger(NioUdtByteAcceptorChannelTest.class);
|
||||
|
||||
|
@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NioUdtMessageAcceptorChannelTest {
|
||||
public class NioUdtMessageAcceptorChannelTest extends AbstractUdtTest {
|
||||
|
||||
protected static final Logger log = LoggerFactory.getLogger(NioUdtByteAcceptorChannelTest.class);
|
||||
|
||||
|
@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NioUdtMessageConnectorChannelTest {
|
||||
public class NioUdtMessageConnectorChannelTest extends AbstractUdtTest {
|
||||
|
||||
protected static final Logger log = LoggerFactory.getLogger(NioUdtByteAcceptorChannelTest.class);
|
||||
|
||||
|
@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NioUdtMessageRendezvousChannelTest {
|
||||
public class NioUdtMessageRendezvousChannelTest extends AbstractUdtTest {
|
||||
|
||||
protected static final Logger log = LoggerFactory.getLogger(NioUdtByteAcceptorChannelTest.class);
|
||||
|
||||
|
@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NioUdtProviderTest {
|
||||
public class NioUdtProviderTest extends AbstractUdtTest {
|
||||
|
||||
protected static final Logger log = LoggerFactory.getLogger(NioUdtProviderTest.class);
|
||||
|
||||
|
@ -40,6 +40,20 @@ public final class UnitHelp {
|
||||
private static final Logger log = LoggerFactory.getLogger(UnitHelp.class);
|
||||
private static final Pattern SPACES = Pattern.compile("\\s+");
|
||||
|
||||
/**
|
||||
* Verify class loading with class initialization.
|
||||
*/
|
||||
public static boolean canLoadAndInitClass(String name) {
|
||||
try{
|
||||
Class.forName(name, true, UnitHelp.class.getClassLoader());
|
||||
log.info("Class load and init success.");
|
||||
return true;
|
||||
} catch(Throwable e){
|
||||
log.warn("Class load or init failure.", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zero out buffer.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user