use of org.junit.AssumptionViolatedException in project hazelcast by hazelcast.
the class OperatingSystemMetricSetTest method assumeOperatingSystemMXBeanType.
private void assumeOperatingSystemMXBeanType(String expected) {
OperatingSystemMXBean bean = ManagementFactory.getOperatingSystemMXBean();
try {
Class<?> expectedInterface = Class.forName(expected);
assumeTrue(expectedInterface.isAssignableFrom(bean.getClass()));
} catch (ClassNotFoundException e) {
throw new AssumptionViolatedException("MXBean interface " + expected + " was not found");
}
}
use of org.junit.AssumptionViolatedException in project hazelcast by hazelcast.
the class AbstractPbeReplacerTest method assumeAlgorithmsSupported.
protected void assumeAlgorithmsSupported(String secretKeyFactory, String cipher) {
try {
SecretKeyFactory.getInstance(secretKeyFactory);
Cipher.getInstance(cipher);
} catch (Exception e) {
throw new AssumptionViolatedException("Skipping - Unsupported algorithm", e);
}
}
use of org.junit.AssumptionViolatedException in project brave by openzipkin.
the class ITSpringRabbit method startRabbit.
@BeforeClass
public static void startRabbit() {
if ("true".equals(System.getProperty("docker.skip"))) {
throw new AssumptionViolatedException("Skipping startup of docker " + IMAGE);
}
try {
LOGGER.info("Starting docker image " + IMAGE);
rabbit = new RabbitMQContainer(IMAGE);
rabbit.start();
} catch (Throwable e) {
throw new AssumptionViolatedException("Couldn't start docker image " + IMAGE + ": " + e.getMessage(), e);
}
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(rabbit.getContainerIpAddress(), rabbit.getMappedPort(RABBIT_PORT));
try {
RabbitAdmin amqpAdmin = new RabbitAdmin(connectionFactory);
amqpAdmin.declareExchange(exchange);
amqpAdmin.declareQueue(queue);
amqpAdmin.declareBinding(binding);
amqpAdmin.declareExchange(exchange_batch);
amqpAdmin.declareQueue(queue_batch);
amqpAdmin.declareBinding(binding_batch);
amqpAdmin.declareExchange(exchange_request_reply);
amqpAdmin.declareQueue(queue_request);
amqpAdmin.declareQueue(queue_reply);
amqpAdmin.declareBinding(binding_request);
amqpAdmin.declareBinding(binding_reply);
} finally {
connectionFactory.destroy();
}
}
use of org.junit.AssumptionViolatedException in project acceptance-test-harness by jenkinsci.
the class PluginManager method installPlugins.
/**
* Installs specified plugins.
*
* @deprecated Please be encouraged to use {@link WithPlugins} annotations to statically declare
* the required plugins you need. If you really do need to install plugins in the middle
* of a test, as opposed to be in the beginning, then this is the right method.
* <p/>
* The deprecation marker is to call attention to {@link WithPlugins}. This method
* is not really deprecated.
* @return Always false.
*/
@Deprecated
public boolean installPlugins(final PluginSpec... specs) throws UnableToResolveDependencies, IOException {
final Map<String, String> candidates = getMapShortNamesVersion(specs);
if (!updated) {
checkForUpdates();
}
if (uploadPlugins) {
LOGGER.warning("Installing plugins by direct upload. Better to use the default MockUpdateCenter.");
// First check to see whether we need to do anything.
// If not, do not consider transitive dependencies of the requested plugins,
// which might force updates (and thus restarts) even though we already have
// a sufficiently new version of the requested plugin.
boolean someChangeRequired = false;
for (PluginSpec spec : specs) {
if (installationStatus(spec) != InstallationStatus.UP_TO_DATE) {
someChangeRequired = true;
break;
}
}
if (!someChangeRequired) {
return false;
}
List<PluginMetadata> pluginToBeInstalled = ucmd.get(jenkins).transitiveDependenciesOf(jenkins, Arrays.asList(specs));
for (PluginMetadata newPlugin : pluginToBeInstalled) {
final String name = newPlugin.getName();
String requiredVersion = candidates.get(name);
String availableVersion = newPlugin.getVersion();
if (requiredVersion == null) {
// a dependency
requiredVersion = availableVersion;
}
final String currentSpec = StringUtils.isNotEmpty(requiredVersion) ? name + "@" + requiredVersion : name;
InstallationStatus status = installationStatus(currentSpec);
if (status != InstallationStatus.UP_TO_DATE) {
if (new VersionNumber(requiredVersion).compareTo(new VersionNumber(availableVersion)) > 0) {
throw new AssumptionViolatedException(name + " has version " + availableVersion + " but " + requiredVersion + " was requested");
}
try {
newPlugin.uploadTo(jenkins, injector, availableVersion);
} catch (ArtifactResolutionException x) {
throw new UnableToResolveDependencies(x);
}
}
}
} else {
// JENKINS-50790 It seems that this page takes too much time to load when running in the new ci.jenkins.io
try {
driver.manage().timeouts().pageLoadTimeout(time.seconds(240), TimeUnit.MILLISECONDS);
visit("available");
} finally {
driver.manage().timeouts().pageLoadTimeout(time.seconds(FallbackConfig.PAGE_LOAD_TIMEOUT), TimeUnit.MILLISECONDS);
}
// End JENKINS-50790
final ArrayList<PluginSpec> update = new ArrayList<>();
for (final PluginSpec n : specs) {
switch(installationStatus(n)) {
case NOT_INSTALLED:
tickPluginToInstall(n);
break;
case OUTDATED:
update.add(n);
break;
case UP_TO_DATE:
// Nothing to do
break;
default:
assert false : "Unreachable";
}
}
clickButton("Install");
// Plugins that are already installed in older version will be updated
System.out.println("Plugins to be updated: " + update);
if (!update.isEmpty()) {
// Updates tab
visit("");
for (PluginSpec n : update) {
tickPluginToInstall(n);
}
clickButton("Download now and install after restart");
}
}
// Jenkins will be restarted if necessary
boolean hasBeenRestarted = new UpdateCenter(jenkins).waitForInstallationToComplete(specs);
if (!hasBeenRestarted && specs.length > 0 && jenkins.getVersion().isNewerThan(new VersionNumber("2.188"))) {
jenkins.getLogger("all").waitForLogged(Pattern.compile("Completed installation of .*"), 1000);
}
return false;
}
use of org.junit.AssumptionViolatedException in project acceptance-test-harness by jenkinsci.
the class PluginManager method tickPluginToInstall.
private void tickPluginToInstall(PluginSpec spec) {
String name = spec.getName();
WebElement filterBox = find(By.id("filter-box"));
filterBox.clear();
filterBox.sendKeys(name);
// the target plugin web element becomes stale due to the dynamic behaviour of the plugin
// manager UI which ends up with StaleElementReferenceException.
// This is re-trying until the element can be properly checked.
waitFor().withTimeout(10, TimeUnit.SECONDS).until(() -> {
try {
check(find(by.xpath("//input[starts-with(@name,'plugin.%s.')]", name)));
} catch (NoSuchElementException | StaleElementReferenceException e) {
return false;
}
return true;
});
final VersionNumber requiredVersion = spec.getVersionNumber();
if (requiredVersion != null) {
final VersionNumber availableVersion = getAvailableVersionForPlugin(name);
if (availableVersion.isOlderThan(requiredVersion)) {
throw new AssumptionViolatedException(String.format("Version '%s' of '%s' is required, but available version is '%s'", requiredVersion, name, availableVersion));
}
}
}
Aggregations