当前位置: 首页>>代码示例>>Java>>正文


Java Assume.assumeNoException方法代码示例

本文整理汇总了Java中org.junit.Assume.assumeNoException方法的典型用法代码示例。如果您正苦于以下问题:Java Assume.assumeNoException方法的具体用法?Java Assume.assumeNoException怎么用?Java Assume.assumeNoException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.junit.Assume的用法示例。


在下文中一共展示了Assume.assumeNoException方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: spyOnNameService

import org.junit.Assume; //导入方法依赖的package包/类
/**
 * Spy on the Java DNS infrastructure.
 * This likely only works on Sun-derived JDKs, but uses JUnit's
 * Assume functionality so that any tests using it are skipped on
 * incompatible JDKs.
 */
private NameService spyOnNameService() {
  try {
    Field f = InetAddress.class.getDeclaredField("nameServices");
    f.setAccessible(true);
    Assume.assumeNotNull(f);
    @SuppressWarnings("unchecked")
    List<NameService> nsList = (List<NameService>) f.get(null);

    NameService ns = nsList.get(0);
    Log log = LogFactory.getLog("NameServiceSpy");
    
    ns = Mockito.mock(NameService.class,
        new GenericTestUtils.DelegateAnswer(log, ns));
    nsList.set(0, ns);
    return ns;
  } catch (Throwable t) {
    LOG.info("Unable to spy on DNS. Skipping test.", t);
    // In case the JDK we're testing on doesn't work like Sun's, just
    // skip the test.
    Assume.assumeNoException(t);
    throw new RuntimeException(t);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:TestDFSClientFailover.java

示例2: testVoteSending

import org.junit.Assume; //导入方法依赖的package包/类
@Test
public void testVoteSending() throws Exception {
    try {
        /* Open up connection to Votifier */
        Socket socket = new Socket("127.0.0.1", 8192);

        InputStream is = socket.getInputStream();
        OutputStream os = socket.getOutputStream();

        /* Read Votifier packet and grab challenge token */
        String in = new BufferedReader(new InputStreamReader(is)).readLine();
        String[] votifierIn = in.split(" ");
        Assert.assertEquals("Incorrect Votifier data!", 3, votifierIn.length);
        Assert.assertEquals("Votifier signature mismatch", "VOTIFIER", votifierIn[0]);
        String challengeToken = votifierIn[2];

        /* Create vote object */
        Votifier2.Vote vote = Votifier2.newVoteObject(TEST_VOTER_NAME, TEST_SERVICE_NAME);
        byte[] message = Votifier2.encodeMessage(vote, challengeToken, TEST_SERVER_KEY);

        /* Send vote object */
        os.write(message);
        os.flush();

        /* Read status */
        in = new BufferedReader(new InputStreamReader(is)).readLine();
        JSONObject result = new JSONObject(in);
        Assert.assertEquals("Votifier status was not 'ok'! Data: " + result, "ok", result.get("status"));

        /* Close connection */
        os.close();
        socket.close();
    } catch(SocketException e){
        /* Skip test */
        Assume.assumeNoException(e);
    }
}
 
开发者ID:mikroskeem,项目名称:votifier2-java,代码行数:38,代码来源:Votifier2Test.java

示例3: getInputStream

import org.junit.Assume; //导入方法依赖的package包/类
@Override
protected InputStream getInputStream() {
    try {
        return new URL("http://xmlns.com/foaf/spec/index.rdf").openStream();
    } catch (IOException e) {
        Assume.assumeNoException(e);
        return null;
    }
}
 
开发者ID:ansell,项目名称:rdf4j-schema-generator,代码行数:10,代码来源:FoafSchemaTest.java

示例4: checkAvailability

import org.junit.Assume; //导入方法依赖的package包/类
@BeforeClass
public static void checkAvailability() {
	try {
		new Rsa();
	} catch (WolfCryptException e) {
		if (e.getError() == WolfCryptError.NOT_COMPILED_IN)
			System.out.println("Rsa test skipped: " + e.getError());
		Assume.assumeNoException(e);
	}
}
 
开发者ID:wolfSSL,项目名称:wolfcrypt-jni,代码行数:11,代码来源:RsaTest.java

示例5: checkAvailability

import org.junit.Assume; //导入方法依赖的package包/类
@BeforeClass
public static void checkAvailability() {
	try {
		new Hmac();
	} catch (WolfCryptException e) {
		if (e.getError() == WolfCryptError.NOT_COMPILED_IN)
			System.out.println("Hmac test skipped: " + e.getError());
		Assume.assumeNoException(e);
	}
}
 
开发者ID:wolfSSL,项目名称:wolfcrypt-jni,代码行数:11,代码来源:HmacTest.java

示例6: checkAvailability

import org.junit.Assume; //导入方法依赖的package包/类
@BeforeClass
public static void checkAvailability() {
	try {
		new Aes();
	} catch (WolfCryptException e) {
		if (e.getError() == WolfCryptError.NOT_COMPILED_IN)
			System.out.println("Aes test skipped: " + e.getError());
		Assume.assumeNoException(e);
	}
}
 
开发者ID:wolfSSL,项目名称:wolfcrypt-jni,代码行数:11,代码来源:AesTest.java

示例7: checkAvailability

import org.junit.Assume; //导入方法依赖的package包/类
@BeforeClass
public static void checkAvailability() {
	try {
		new Dh();
	} catch (WolfCryptException e) {
		if (e.getError() == WolfCryptError.NOT_COMPILED_IN)
			System.out.println("Dh test skipped: " + e.getError());
		Assume.assumeNoException(e);
	}
}
 
开发者ID:wolfSSL,项目名称:wolfcrypt-jni,代码行数:11,代码来源:DhTest.java

示例8: checkAvailability

import org.junit.Assume; //导入方法依赖的package包/类
@BeforeClass
public static void checkAvailability() {
	try {
		new Des3();
	} catch (WolfCryptException e) {
		if (e.getError() == WolfCryptError.NOT_COMPILED_IN)
			System.out.println("Des3 test skipped: " + e.getError());
		Assume.assumeNoException(e);
	}
}
 
开发者ID:wolfSSL,项目名称:wolfcrypt-jni,代码行数:11,代码来源:Des3Test.java

示例9: checkAvailability

import org.junit.Assume; //导入方法依赖的package包/类
@BeforeClass
public static void checkAvailability() {
	try {
		new Ecc();
	} catch (WolfCryptException e) {
		if (e.getError() == WolfCryptError.NOT_COMPILED_IN)
			System.out.println("Ecc test skipped: " + e.getError());
		Assume.assumeNoException(e);
	}
}
 
开发者ID:wolfSSL,项目名称:wolfcrypt-jni,代码行数:11,代码来源:EccTest.java

示例10: CheckGraalInvariants

import org.junit.Assume; //导入方法依赖的package包/类
public CheckGraalInvariants() {
    try {
        Class.forName("java.lang.management.ManagementFactory");
    } catch (ClassNotFoundException ex) {
        Assume.assumeNoException("cannot run without java.management JDK9 module", ex);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:CheckGraalInvariants.java

示例11: GraalOSRLockTest

import org.junit.Assume; //导入方法依赖的package包/类
public GraalOSRLockTest() {
    try {
        Class.forName("java.lang.management.ManagementFactory");
    } catch (ClassNotFoundException ex) {
        Assume.assumeNoException("cannot check for monitors without java.management JDK9 module", ex);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:GraalOSRLockTest.java

示例12: checkCapabilities

import org.junit.Assume; //导入方法依赖的package包/类
@Before
public void checkCapabilities() {
    try {
        ThreadMXBean threadMXBean = Management.getThreadMXBean();
        Assume.assumeTrue("skipping management interface test", threadMXBean.isCurrentThreadCpuTimeSupported());
    } catch (LinkageError err) {
        Assume.assumeNoException("Cannot run without java.management JDK9 module", err);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:TimerKeyTest.java

示例13: compact

import org.junit.Assume; //导入方法依赖的package包/类
@Override
public List<Path> compact(CompactionThroughputController throughputController, User user)
    throws IOException {
  try {
    isInCompact = true;
    synchronized (this) {
      this.wait();
    }
  } catch (InterruptedException e) {
    Assume.assumeNoException(e);
  }
  return new ArrayList<Path>();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:TestCompaction.java


注:本文中的org.junit.Assume.assumeNoException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。