本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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>();
}