use of org.junit.AssumptionViolatedException in project junit4 by junit-team.
the class TempFolderRuleTest method getPosixFilePermissions.
private Set<String> getPosixFilePermissions(File root) {
try {
Class<?> pathClass = Class.forName("java.nio.file.Path");
Object linkOptionArray = Array.newInstance(Class.forName("java.nio.file.LinkOption"), 0);
Class<?> filesClass = Class.forName("java.nio.file.Files");
Object path = File.class.getDeclaredMethod("toPath").invoke(root);
Method posixFilePermissionsMethod = filesClass.getDeclaredMethod("getPosixFilePermissions", pathClass, linkOptionArray.getClass());
Set<?> permissions = (Set<?>) posixFilePermissionsMethod.invoke(null, path, linkOptionArray);
SortedSet<String> convertedPermissions = new TreeSet<String>();
for (Object item : permissions) {
convertedPermissions.add(item.toString());
}
return convertedPermissions;
} catch (Exception e) {
throw new AssumptionViolatedException("Test requires at least Java 1.7", e);
}
}
use of org.junit.AssumptionViolatedException in project zuul by Netflix.
the class SourceAddressChannelHandlerTest method ipv6AddressScopeNameRemoved.
@Test
public void ipv6AddressScopeNameRemoved() throws Exception {
List<NetworkInterface> nics = Collections.list(NetworkInterface.getNetworkInterfaces());
Assume.assumeTrue("No network interfaces", !nics.isEmpty());
List<Throwable> failures = new ArrayList<>();
for (NetworkInterface nic : nics) {
Inet6Address address;
try {
address = Inet6Address.getByAddress("localhost", new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, nic);
} catch (UnknownHostException e) {
// skip, the nic doesn't match
failures.add(e);
continue;
}
assertTrue(address.toString(), address.toString().contains("%"));
String addressString = SourceAddressChannelHandler.getHostAddress(new InetSocketAddress(address, 8080));
assertEquals("0:0:0:0:0:0:0:1", addressString);
return;
}
AssumptionViolatedException failure = new AssumptionViolatedException("No Compatible Nics were found");
failures.forEach(failure::addSuppressed);
throw failure;
}
use of org.junit.AssumptionViolatedException in project Java-Tutorial by gpcodervn.
the class CustomSuite method run.
@Override
public void run(RunNotifier notifier) {
System.out.println("Executing run()");
// Add Listener. This will register our JUnit Listener.
notifier.addListener(new ExecutionListener());
// Get each test notifier
EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription());
try {
// In order capture testRunStarted method
// at the very beginning of the test run, we will add below code.
// Invoke here the run testRunStarted() method
notifier.fireTestRunStarted(getDescription());
Statement statement = classBlock(notifier);
statement.evaluate();
} catch (AssumptionViolatedException e) {
testNotifier.fireTestIgnored();
} catch (StoppedByUserException e) {
throw e;
} catch (Throwable e) {
testNotifier.addFailure(e);
}
}
use of org.junit.AssumptionViolatedException in project Java-Tutorial by gpcodervn.
the class CustomBlockJUnit4ClassRunner method run.
@Override
public void run(RunNotifier notifier) {
System.out.println("Executing run()");
// Add Listener. This will register our JUnit Listener.
notifier.addListener(new ExecutionListener());
// Get each test notifier
EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription());
try {
// In order capture testRunStarted method
// at the very beginning of the test run, we will add below code.
// Invoke here the run testRunStarted() method
notifier.fireTestRunStarted(getDescription());
Statement statement = classBlock(notifier);
statement.evaluate();
} catch (AssumptionViolatedException e) {
testNotifier.fireTestIgnored();
} catch (StoppedByUserException e) {
throw e;
} catch (Throwable e) {
testNotifier.addFailure(e);
}
}
Aggregations