Java Examples for org.testng.SkipException

The following java examples will help you to understand the usage of org.testng.SkipException. These source code samples are taken from different open source projects.

Example 1
Project: assumeng-master  File: AssumptionListener.java View source code
@Override
public void beforeInvocation(IInvokedMethod invokedMethod, ITestResult result) {
    ITestNGMethod testNgMethod = result.getMethod();
    ConstructorOrMethod contructorOrMethod = testNgMethod.getConstructorOrMethod();
    Method method = contructorOrMethod.getMethod();
    if (method == null || !contructorOrMethod.getMethod().isAnnotationPresent(Assumption.class)) {
        return;
    }
    List<String> failedAssumptions = checkAssumptions(method, result);
    if (!failedAssumptions.isEmpty()) {
        throw new SkipException(format("Skipping [%s] because the %s assumption(s) do not hold.", contructorOrMethod.getName(), failedAssumptions));
    }
}
Example 2
Project: java-client-api-master  File: NoExecutorStartedPluginManagerIT.java View source code
@Test
public void getPluginsShouldReturnTheListOfInstalledPluginsForJenkins20() {
    if (jenkinsServer.getVersion().isLessThan("2.0")) {
        throw new SkipException("Not Version 2.0 (" + jenkinsServer.getVersion() + ")");
    }
    // TODO: The list of plugins is contained in the plugin.txt
    // which should be read and used as base of comparison.
    // instead of maintaining at two locations.
    //@formatter:off
    Plugin[] expectedPlugins = { createPlugin("token-macro", "1.12.1"), createPlugin("testng-plugin", "1.10"), createPlugin("job-dsl", "1.41"), createPlugin("junit", "1.10"), createPlugin("jacoco", "1.0.19"), createPlugin("config-file-provider", "2.10.0"), createPlugin("timestamper", "1.7.2"), createPlugin("credentials", "1.24"), createPlugin("throttle-concurrents", "1.9.0"), createPlugin("cloudbees-folder", "5.12") };
    //@formatter:on
    List<Plugin> plugins = pluginManager.getPlugins();
    for (Plugin plugin : plugins) {
        boolean found = false;
        for (int i = 0; i < expectedPlugins.length; i++) {
            if (plugin.getShortName().equals(expectedPlugins[i].getShortName()) && plugin.getVersion().equals(expectedPlugins[i].getVersion())) {
                found = true;
            }
        }
        assertThat(found).isTrue().as("Plugin shortName:{} version:{} couldn't be found.", plugin.getShortName(), plugin.getVersion());
    }
}
Example 3
Project: testng_samples-master  File: SeleniumFixture.java View source code
@BeforeMethod
public void ignoreInBrowser(Method m) {
    IgnoreInBrowser ignore = m.getAnnotation(IgnoreInBrowser.class);
    if (ignore != null) {
        String browser = ((RemoteWebDriver) driver).getCapabilities().getBrowserName();
        Browser[] ignoredBrowsers = ignore.value();
        for (Browser ignoredBrowser : ignoredBrowsers) {
            if (ignoredBrowser.name().toLowerCase().equals(browser)) {
                throw new SkipException("Ignored in browser " + browser);
            }
        }
    }
}
Example 4
Project: bootstrapium-master  File: TestListener.java View source code
@Override
public void onTestSkipped(ITestResult result) {
    logger.error(String.format("SKIP %s.%s", result.getTestClass().getName(), result.getMethod().getMethodName()));
    Throwable cause = result.getThrowable();
    if (cause != null && SkipException.class.isAssignableFrom(cause.getClass())) {
        logger.error(cause.getMessage());
    }
}
Example 5
Project: docker-java-master  File: CreateContainerCmdImplTest.java View source code
@SuppressWarnings("Duplicates")
@Test
public void createContainerWithShmPidsLimit() throws DockerException {
    final RemoteApiVersion apiVersion = getVersion(dockerClient);
    if (!apiVersion.isGreaterOrEqual(RemoteApiVersion.VERSION_1_23)) {
        throw new SkipException("API version should be >= 1.23");
    }
    HostConfig hostConfig = new HostConfig().withPidsLimit(2L);
    CreateContainerResponse container = dockerClient.createContainerCmd(BUSYBOX_IMAGE).withHostConfig(hostConfig).withCmd("true").exec();
    LOG.info("Created container {}", container.toString());
    assertThat(container.getId(), not(isEmptyString()));
    InspectContainerResponse inspectContainerResponse = dockerClient.inspectContainerCmd(container.getId()).exec();
    assertThat(inspectContainerResponse.getHostConfig().getPidsLimit(), is(hostConfig.getPidsLimit()));
}
Example 6
Project: Illarion-Java-master  File: YandexProviderTest.java View source code
@Test(enabled = false)
public void testGermanToEnglish() {
    if (provider == null) {
        throw new SkipException("Provider was not correctly prepared.");
    }
    String translation = provider.getTranslation("Hallo!", TranslationDirection.GermanToEnglish);
    assertEquals(translation, "Hello!", "Translation service is not yielding the expected result.");
}
Example 7
Project: incubator-brooklyn-master  File: SpecParameterUnwrappingTest.java View source code
@Test(dataProvider = "brooklynTypes")
public void testDepentantCatalogsInheritParameters(Class<? extends BrooklynObject> type) {
    if (type == ConfigLocationForTest.class) {
        //TODO
        throw new SkipException("Locations don't inherit parameters, should migrate to the type registry first");
    }
    addCatalogItems("brooklyn.catalog:", "  version: " + TEST_VERSION, "  items:", "  - id: paramItem", "    item:", "      type: " + type.getName(), "      brooklyn.parameters:", "      - simple", "  - id: " + SYMBOLIC_NAME, "    item:", "      type: paramItem:" + TEST_VERSION);
    CatalogItem<?, ?> item = catalog.getCatalogItem(SYMBOLIC_NAME, TEST_VERSION);
    AbstractBrooklynObjectSpec<?, ?> spec = createSpec(item);
    List<SpecParameter<?>> inputs = spec.getParameters();
    assertEquals(inputs.size(), 1);
    SpecParameter<?> firstInput = inputs.get(0);
    assertEquals(firstInput.getLabel(), "simple");
}
Example 8
Project: java-driver-master  File: SchemaRefreshDebouncerTest.java View source code
/**
     * Ensures that when multiple UPDATED schema_change events are received
     * on a control connection for for the same table within
     * {@link QueryOptions#getRefreshSchemaIntervalMillis()} that the schema refresh is debounced
     * and coalesced into a single schema refresh for that table only.
     *
     * @throws Exception
     * @jira_ticket JAVA-657
     * @since 2.0.11
     */
@Test(groups = "short")
public void should_debounce_and_coalesce_multiple_alter_events_on_same_table_into_refresh_table() throws Exception {
    if (ccm().getCassandraVersion().compareTo(VersionNumber.parse("2.2")) >= 0)
        throw new SkipException("Disabled in Cassandra 2.2+ because of CASSANDRA-9996");
    String keyspace = TestUtils.generateIdentifier("ks_");
    String table = "tbl1";
    String comment = "I am changing this table.";
    String columnName = "added_column";
    // Execute on session 2 which refreshes schema as part of processing responses.
    session2.execute(String.format(CREATE_KEYSPACE_SIMPLE_FORMAT, keyspace, 1));
    session2.execute(String.format("CREATE TABLE %s (k text PRIMARY KEY, t text, i int, f float)", keyspace + "." + table));
    reset(controlConnection);
    reset(listener);
    session().execute(String.format("ALTER TABLE %s.%s WITH comment = '%s'", keyspace, table, comment));
    session().execute(String.format("ALTER TABLE %s.%s ADD %s int", keyspace, table, columnName));
    ArgumentCaptor<TableMetadata> original = forClass(TableMetadata.class);
    ArgumentCaptor<TableMetadata> captor = forClass(TableMetadata.class);
    verify(listener, timeout(DEBOUNCE_TIME * 2).times(1)).onTableChanged(captor.capture(), original.capture());
    assertThat(captor.getValue()).hasName(table).isInKeyspace(keyspace).hasColumn(columnName).hasComment(comment);
    assertThat(original.getValue()).hasName(table).isInKeyspace(keyspace).hasNoColumn(columnName).doesNotHaveComment(comment);
    // Verify a refresh of the table was executed, but only once.
    verify(controlConnection, times(1)).refreshSchema(TABLE, keyspace, table, Collections.<String>emptyList());
    KeyspaceMetadata ksm = cluster2.getMetadata().getKeyspace(keyspace);
    assertThat(ksm).isNotNull();
    TableMetadata tm = ksm.getTable(table);
    assertThat(tm).hasName(table).isInKeyspace(keyspace).hasColumn(columnName).hasComment(comment);
}
Example 9
Project: jodconverter-master  File: ProcessManagerTest.java View source code
public void linuxProcessManager() throws Exception {
    if (!PlatformUtils.isLinux()) {
        throw new SkipException("LinuxProcessManager can only be tested on Linux");
    }
    ProcessManager processManager = new LinuxProcessManager();
    Process process = new ProcessBuilder("sleep", "5s").start();
    ProcessQuery query = new ProcessQuery("sleep", "5s");
    long pid = processManager.findPid(query);
    assertFalse(pid == ProcessManager.PID_NOT_FOUND);
    Integer javaPid = (Integer) ReflectionUtils.getPrivateField(process, "pid");
    assertEquals(pid, javaPid.longValue());
    processManager.kill(process, pid);
    assertEquals(processManager.findPid(query), ProcessManager.PID_NOT_FOUND);
}
Example 10
Project: jolokia-master  File: DiscoveryMulticastResponderTest.java View source code
@Test
public void simple() throws IOException, InterruptedException {
    System.out.println("=================================================");
    if (!NetworkUtil.isMulticastSupported()) {
        throw new SkipException("No multicast interface found, skipping test ");
    }
    AgentDetailsHolder holder = new TestAgentsDetailsHolder();
    DiscoveryMulticastResponder responder = new DiscoveryMulticastResponder(holder, new AllowAllRestrictor(), new LogHandler.StdoutLogHandler(true));
    responder.start();
    // Warming up
    Thread.sleep(1000);
    JolokiaDiscovery discovery = new JolokiaDiscovery("test", new LogHandler.StdoutLogHandler(true));
    try {
        List<JSONObject> msgs = discovery.lookupAgents();
        System.out.println("=================================================");
        if (msgs.size() == 0) {
            // We are retrying it with a longer timeout
            System.out.println("No answer received, trying now with 30s timeout");
            msgs = discovery.lookupAgentsWithTimeout(30000);
        }
        assertTrue(msgs.size() > 0);
    } catch (UnknownHostException exp) {
        throw new SkipException("Skipping test because no single multicast request could be send on any interface");
    } finally {
        responder.stop();
    }
}
Example 11
Project: keystone-master  File: SkipTestListener.java View source code
@Override
public void beforeInvocation(IInvokedMethod iim, ITestResult itr) {
    Method method = iim.getTestMethod().getConstructorOrMethod().getMethod();
    // Check if method is annotated with @SkipTest
    if (method.isAnnotationPresent(SkipTest.class)) {
        SkipTest skipAnnotation = method.getAnnotation(SkipTest.class);
        String httpExecutorName = HttpExecutor.create().getExecutorName();
        // Annotation connector parameter can be a regex like ".*"
        if (httpExecutorName.matches(skipAnnotation.connector())) {
            StringBuilder message = new StringBuilder();
            message.append(String.format("Skip test %s for connector %s", method.getName(), httpExecutorName));
            if (skipAnnotation.issue() > 0) {
                message.append(String.format(" due to issue %s", skipAnnotation.issue()));
            }
            if (!skipAnnotation.description().isEmpty()) {
                message.append(String.format(": %s", skipAnnotation.description()));
            }
            // Skip Test
            Logger.getLogger(getClass().getName()).warning(message.toString());
            throw new SkipException(message.toString());
        }
    }
}
Example 12
Project: neutron-master  File: SkipTestListener.java View source code
@Override
public void beforeInvocation(IInvokedMethod iim, ITestResult itr) {
    Method method = iim.getTestMethod().getConstructorOrMethod().getMethod();
    // Check if method is annotated with @SkipTest
    if (method.isAnnotationPresent(SkipTest.class)) {
        SkipTest skipAnnotation = method.getAnnotation(SkipTest.class);
        String httpExecutorName = HttpExecutor.create().getExecutorName();
        // Annotation connector parameter can be a regex like ".*"
        if (httpExecutorName.matches(skipAnnotation.connector())) {
            StringBuilder message = new StringBuilder();
            message.append(String.format("Skip test %s for connector %s", method.getName(), httpExecutorName));
            if (skipAnnotation.issue() > 0) {
                message.append(String.format(" due to issue %s", skipAnnotation.issue()));
            }
            if (!skipAnnotation.description().isEmpty()) {
                message.append(String.format(": %s", skipAnnotation.description()));
            }
            // Skip Test
            Logger.getLogger(getClass().getName()).warning(message.toString());
            throw new SkipException(message.toString());
        }
    }
}
Example 13
Project: openstack4j-master  File: SkipTestListener.java View source code
@Override
public void beforeInvocation(IInvokedMethod iim, ITestResult itr) {
    Method method = iim.getTestMethod().getConstructorOrMethod().getMethod();
    // Check if method is annotated with @SkipTest
    if (method.isAnnotationPresent(SkipTest.class)) {
        SkipTest skipAnnotation = method.getAnnotation(SkipTest.class);
        String httpExecutorName = HttpExecutor.create().getExecutorName();
        // Annotation connector parameter can be a regex like ".*"
        if (httpExecutorName.matches(skipAnnotation.connector())) {
            StringBuilder message = new StringBuilder();
            message.append(String.format("Skip test %s for connector %s", method.getName(), httpExecutorName));
            if (skipAnnotation.issue() > 0) {
                message.append(String.format(" due to issue %s", skipAnnotation.issue()));
            }
            if (!skipAnnotation.description().isEmpty()) {
                message.append(String.format(": %s", skipAnnotation.description()));
            }
            // Skip Test
            Logger.getLogger(getClass().getName()).warning(message.toString());
            throw new SkipException(message.toString());
        }
    }
}
Example 14
Project: WAAT-master  File: WebDriverScriptRunnerHelper.java View source code
@Override
public void startDriver() {
    String os = System.getProperty("os.name").toLowerCase();
    logger.info("Starting WebDriver on OS: " + os + " for browser: " + browser.name());
    if (browser.equals(BROWSER.firefox)) {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        instantiateFireFoxDriver(capabilities);
    } else if (browser.equals(BROWSER.iehta)) {
        if (!os.contains("win")) {
            throw new SkipException("Skipping this test as Internet Explorer browser is NOT available on " + os);
        }
        driver = new InternetExplorerDriver();
        driver.get(BASE_URL);
    } else if (browser.equals(BROWSER.chrome)) {
        driver = new ChromeDriver();
        driver.get(BASE_URL);
    }
    logger.info("Driver started: " + browser.name());
    logger.info("Page title: " + driver.getTitle());
}
Example 15
Project: web-test-framework-master  File: DriverManagerListenerMockTest.java View source code
/**
   *
   * @return
   */
@DataProvider(parallel = true)
public Object[][] getData() {
    Object[][] series = new Object[5][2];
    series[0][0] = new DriverContextForTest();
    series[0][1] = new SkipException("Skip me");
    series[1][0] = new DriverContextForTest();
    series[2][0] = new DriverContextForTest();
    series[3][0] = new DriverContextForTest();
    series[4][0] = new DriverContextForTest();
    return series;
}
Example 16
Project: web-test-master  File: WebDriverUtilsTest.java View source code
@Test
public void saveScreenshotChromeTest() {
    if (System.getProperty("webdriver.chrome.driver") == null) {
        throw new SkipException("The path to the driver executable (webdriver.chrome.driver) is not set");
    }
    WebDriverFactory wdf = new WebDriverFactory("chrome");
    WebDriver wd = wdf.createDriver(new DesiredCapabilities());
    wd.get("http://google.com");
    File screenshotFile = WebDriverUtils.saveScreenshot(wd, getScreenshotName("chrome"));
    wd.quit();
    assertThat(screenshotFile.exists(), equalTo(true));
    if (Boolean.parseBoolean(System.getProperty("org.uncommons.reportng.escape-output", "true"))) {
        Reporter.log("Screenshot: " + screenshotFile.getAbsolutePath());
    } else {
        Reporter.log("<a href=\"file:///" + screenshotFile.getAbsolutePath() + "\">Screenshot</a>");
    }
}
Example 17
Project: react-streams-master  File: PublisherVerification.java View source code
@Override
@Test
public void optional_spec104_mustSignalOnErrorWhenFails() throws Throwable {
    try {
        whenHasErrorPublisherTest(new PublisherTestRun<T>() {

            @Override
            public void run(final Publisher<T> pub) throws InterruptedException {
                final Latch onErrorlatch = new Latch(env);
                final Latch onSubscribeLatch = new Latch(env);
                pub.subscribe(new TestEnvironment.TestSubscriber<T>(env) {

                    @Override
                    public void onSubscribe(Subscription subs) {
                        onSubscribeLatch.assertOpen("Only one onSubscribe call expected");
                        onSubscribeLatch.close();
                    }

                    @Override
                    public void onError(Throwable cause) {
                        onSubscribeLatch.assertClosed("onSubscribe should be called prior to onError always");
                        onErrorlatch.assertOpen(String.format("Error-state Publisher %s called `onError` twice on new Subscriber", pub));
                        onErrorlatch.close();
                    }
                });
                onSubscribeLatch.expectClose("Should have received onSubscribe");
                onErrorlatch.expectClose(String.format("Error-state Publisher %s did not call `onError` on new Subscriber", pub));
                env.verifyNoAsyncErrors();
            }
        });
    } catch (SkipException se) {
        throw se;
    } catch (Throwable ex) {
        throw new RuntimeException(String.format("Publisher threw exception (%s) instead of signalling error via onError!", ex.getMessage()), ex);
    }
}
Example 18
Project: reactive-streams-jvm-master  File: PublisherVerification.java View source code
@Override
@Test
public void optional_spec104_mustSignalOnErrorWhenFails() throws Throwable {
    try {
        whenHasErrorPublisherTest(new PublisherTestRun<T>() {

            @Override
            public void run(final Publisher<T> pub) throws InterruptedException {
                final Latch onErrorlatch = new Latch(env);
                final Latch onSubscribeLatch = new Latch(env);
                pub.subscribe(new TestEnvironment.TestSubscriber<T>(env) {

                    @Override
                    public void onSubscribe(Subscription subs) {
                        onSubscribeLatch.assertOpen("Only one onSubscribe call expected");
                        onSubscribeLatch.close();
                    }

                    @Override
                    public void onError(Throwable cause) {
                        onSubscribeLatch.assertClosed("onSubscribe should be called prior to onError always");
                        onErrorlatch.assertOpen(String.format("Error-state Publisher %s called `onError` twice on new Subscriber", pub));
                        onErrorlatch.close();
                    }
                });
                onSubscribeLatch.expectClose("Should have received onSubscribe");
                onErrorlatch.expectClose(String.format("Error-state Publisher %s did not call `onError` on new Subscriber", pub));
                env.verifyNoAsyncErrors();
            }
        });
    } catch (SkipException se) {
        throw se;
    } catch (Throwable ex) {
        throw new RuntimeException(String.format("Publisher threw exception (%s) instead of signalling error via onError!", ex.getMessage()), ex);
    }
}
Example 19
Project: CMake-runner-plugin-master  File: OutputRedirectProcessorTest.java View source code
@Test
public void testWrap() throws Throwable {
    getBuildType().addConfigParameter(new SimpleParameter(OutputRedirectProcessor.ENABLE_STDERR_REDIRECT_CONFIG_PARAMETER, "true"));
    addRunParameter(SimpleRunnerConstants.USE_CUSTOM_SCRIPT, "true");
    if (SystemInfo.isWindows) {
        addRunParameter(SimpleRunnerConstants.SCRIPT_CONTENT, "ECHO ON\r\n" + "ECHO \"StdOut\"\r\n" + "ECHO \"StdErr\" 1>&2\r\n");
    } else if (SystemInfo.isUnix) {
        addRunParameter(SimpleRunnerConstants.SCRIPT_CONTENT, "echo \"StdOut\"\n" + "echo \"StdErr\" 1>&2\n");
    } else {
        throw new SkipException("Unsupported OS");
    }
    assertBuildLogContains("StdOut NORMAL", "StdErr NORMAL");
}
Example 20
Project: irma_future_id-master  File: JavaSecVerifierTest.java View source code
@Test
public void testVerificationNoError() throws IOException {
    final String hostName = "www.google.com";
    TlsClientProtocol handler;
    try {
        // open connection
        Socket socket = new Socket(hostName, 443);
        assertTrue(socket.isConnected());
        // connect client
        DefaultTlsClientImpl c = new DefaultTlsClientImpl(hostName);
        handler = new TlsClientProtocol(socket.getInputStream(), socket.getOutputStream());
        handler.connect(c);
    } catch (Exception ex) {
        throw new SkipException("Unable to create TLS client.");
    }
}
Example 21
Project: jodconverter.bak-master  File: ProcessManagerTest.java View source code
public void linuxProcessManager() throws Exception {
    if (!PlatformUtils.isLinux()) {
        throw new SkipException("LinuxProcessManager can only be tested on Linux");
    }
    ProcessManager processManager = new LinuxProcessManager();
    Process process = new ProcessBuilder("sleep", "5s").start();
    ProcessQuery query = new ProcessQuery("sleep", "5s");
    long pid = processManager.findPid(query);
    assertFalse(pid == ProcessManager.PID_UNKNOWN);
    Integer javaPid = (Integer) ReflectionUtils.getPrivateField(process, "pid");
    assertEquals(pid, javaPid.longValue());
    processManager.kill(process, pid);
    assertEquals(processManager.findPid(query), ProcessManager.PID_UNKNOWN);
}
Example 22
Project: open-ecard-master  File: JavaSecVerifierTest.java View source code
@Test
public void testVerificationNoError() throws IOException {
    final String hostName = "github.com";
    TlsClientProtocol handler;
    DefaultTlsClientImpl c;
    try {
        // open connection
        Socket socket = new Socket(hostName, 443);
        assertTrue(socket.isConnected());
        assertTrue(socket.isBound());
        assertFalse(socket.isClosed());
        // connect client
        c = new DefaultTlsClientImpl(hostName);
        SecureRandom sr = ReusableSecureRandom.getInstance();
        handler = new TlsClientProtocol(socket.getInputStream(), socket.getOutputStream(), sr);
    } catch (Exception ex) {
        throw new SkipException("Unable to create TLS client.");
    }
    // do TLS handshake
    handler.connect(c);
    handler.close();
}
Example 23
Project: cloudbreak-master  File: AbstractCloudbreakIntegrationTest.java View source code
@BeforeClass
public void checkContextParameters(ITestContext testContext) {
    itContext = suiteContext.getItContext(testContext.getSuite().getName());
    if (itContext.getContextParam(CloudbreakITContextConstants.SKIP_REMAINING_SUITETEST_AFTER_ONE_FAILED, Boolean.class) && !CollectionUtils.isEmpty(itContext.getContextParam(CloudbreakITContextConstants.FAILED_TESTS, List.class))) {
        throw new SkipException("Suite contains failed tests, the remaining tests will be skipped.");
    }
    cloudbreakClient = itContext.getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class);
    Assert.assertNotNull(cloudbreakClient, "CloudbreakClient cannot be null.");
}
Example 24
Project: gerrit-rest-java-client-master  File: RealServerTest.java View source code
@DataProvider(name = "LoginData")
public Object[][] getData() throws Exception {
    URL url = this.getClass().getResource("testhosts.json");
    if (url == null) {
        String message = "File 'src/test/resources/com/urswolfer/gerrit/client/rest/testhosts.json' not found.\n" + "Not running any " + getClass().getSimpleName() + " tests.\n" + "Create the json file with following content: '[[\"http://gerrit\", null, null], [\"http://host2\", \"user\", \"pw\"]]'.";
        throw new SkipException(message);
    }
    File file = new File(url.toURI());
    return new Gson().fromJson(new FileReader(file), Object[][].class);
}
Example 25
Project: jclouds-master  File: GoGridLiveTestDisabled.java View source code
/**
    * Tests common load balancer operations. Also verifies IP services and job services.
    */
@Test(enabled = true)
public void testLoadBalancerLifecycle() {
    int lbCountBeforeTest = api.getLoadBalancerServices().getLoadBalancerList().size();
    final String nameOfLoadBalancer = "LoadBalancer" + String.valueOf(new Date().getTime()).substring(6);
    loadBalancersToDeleteAfterTest.add(nameOfLoadBalancer);
    Set<Ip> availableIps = api.getIpServices().getUnassignedPublicIpList();
    if (availableIps.size() < 4)
        throw new SkipException("Not enough available IPs (4 needed) to run the test");
    Iterator<Ip> ipIterator = availableIps.iterator();
    Ip vip = ipIterator.next();
    Ip realIp1 = ipIterator.next();
    Ip realIp2 = ipIterator.next();
    Ip realIp3 = ipIterator.next();
    AddLoadBalancerOptions options = new AddLoadBalancerOptions.Builder().create(LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SOURCE_ADDRESS);
    LoadBalancer createdLoadBalancer = api.getLoadBalancerServices().addLoadBalancer(nameOfLoadBalancer, IpPortPair.builder().ip(vip).port(80).build(), Arrays.asList(IpPortPair.builder().ip(realIp1).port(80).build(), IpPortPair.builder().ip(realIp2).port(80).build()), options);
    assertNotNull(createdLoadBalancer);
    assert loadBalancerLatestJobCompleted.apply(createdLoadBalancer);
    // get load balancer by name
    Set<LoadBalancer> response = api.getLoadBalancerServices().getLoadBalancersByName(nameOfLoadBalancer);
    assert response.size() == 1;
    createdLoadBalancer = Iterables.getOnlyElement(response);
    assertNotNull(createdLoadBalancer.getRealIpList());
    assertEquals(createdLoadBalancer.getRealIpList().size(), 2);
    assertNotNull(createdLoadBalancer.getVirtualIp());
    assertEquals(createdLoadBalancer.getVirtualIp().getIp().getIp(), vip.getIp());
    LoadBalancer editedLoadBalancer = api.getLoadBalancerServices().editLoadBalancerNamed(nameOfLoadBalancer, Arrays.asList(IpPortPair.builder().ip(realIp3).port(8181).build()));
    assert loadBalancerLatestJobCompleted.apply(editedLoadBalancer);
    assertNotNull(editedLoadBalancer.getRealIpList());
    assertEquals(editedLoadBalancer.getRealIpList().size(), 1);
    assertEquals(Iterables.getOnlyElement(editedLoadBalancer.getRealIpList()).getIp().getIp(), realIp3.getIp());
    int lbCountAfterAddingOneServer = api.getLoadBalancerServices().getLoadBalancerList().size();
    assert lbCountAfterAddingOneServer == lbCountBeforeTest + 1 : "There should be +1 increase in the number of load balancers since the test started";
    // delete the load balancer
    api.getLoadBalancerServices().deleteByName(nameOfLoadBalancer);
    Set<Job> jobs = api.getJobServices().getJobsForObjectName(nameOfLoadBalancer);
    assert "DeleteLoadBalancer".equals(Iterables.getLast(jobs).getCommand().getName());
    assert loadBalancerLatestJobCompleted.apply(createdLoadBalancer);
    int lbCountAfterDeletingTheServer = api.getLoadBalancerServices().getLoadBalancerList().size();
    assert lbCountAfterDeletingTheServer == lbCountBeforeTest : "There should be the same # of load balancers as since the test started";
}
Example 26
Project: reactor-core-master  File: FluxBlackboxProcessorVerification.java View source code
@Override
public void required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber() throws Throwable {
    try {
        super.required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber();
    } catch (Throwable t) {
        if (t.getMessage() != null && t.getMessage().contains("did not drop reference to test subscriber")) {
            throw new SkipException("todo", t);
        } else {
            throw t;
        }
    }
}
Example 27
Project: s3proxy-master  File: JcloudsS3ClientLiveTest.java View source code
@Override
@Test
public void testPublicWriteOnObject() throws InterruptedException, ExecutionException, TimeoutException, IOException {
    try {
        super.testPublicWriteOnObject();
        Fail.failBecauseExceptionWasNotThrown(AWSResponseException.class);
    } catch (AWSResponseException are) {
        assertThat(are.getError().getCode()).isEqualTo("NotImplemented");
        throw new SkipException("public-read-write-acl not supported", are);
    }
}
Example 28
Project: YubiHSM-java-api-master  File: AEADCmdTest.java View source code
@Test
public void testGenerateAEADBlocked() throws Exception {
    DefaultArtifactVersion minVersion = new DefaultArtifactVersion("1.0.4");
    DefaultArtifactVersion curVersion = new DefaultArtifactVersion(hsm.getInfo().getVersion());
    if (curVersion.compareTo(minVersion) == -1) {
        throw new SkipException("This test requires firmware 1.0.4 or later");
    }
    try {
        byte[] secretBA = Utils.hexToByteArray("ec1c263a5d9bd270db0b19b18ca5396b");
        hsm.generateAEAD(nonce, 0x00000002, secretBA);
    } catch (YubiHSMCommandFailedException e) {
        assertEquals("Command YSM_AEAD_GENERATE failed: YSM_FUNCTION_DISABLED", e.getMessage());
    }
}
Example 29
Project: ca-apm-fieldpack-mongodb-master  File: ClusterProbeTest.java View source code
@Test
public void testJson() throws Exception {
    if (!TestUtil.configuredToRun(RUN_CLUSTER_TEST)) {
        throw new SkipException(String.format("%s property not set", RUN_CLUSTER_TEST));
    }
    for (Properties testProps : testPropList) {
        Collector collector = new Collector(testProps);
        final String host = testProps.getProperty(Collector.DB_HOST_PROP);
        final int port = Integer.parseInt(testProps.getProperty(Collector.DB_PORT_PROP));
        String json = collector.makeMetrics(collector.getMongoData(host, port)).toString();
        try {
            JsonParser p = Json.createParser(new StringReader(json));
            while (p.hasNext()) {
                p.next();
            }
            p.close();
        } catch (Exception ex) {
            fail("JSON parse exception", ex);
        }
    }
}
Example 30
Project: gatk-master  File: LibDrmaaQueueTest.java View source code
@Test(dependsOnMethods = { "testDrmaa" })
public void testSubmitEcho() throws Exception {
    if (!queueTestRunModeIsSet) {
        throw new SkipException("Skipping testSubmitEcho because we are in pipeline test dry run mode");
    }
    if (implementation.contains("LSF")) {
        System.err.println("    *********************************************************");
        System.err.println("   ***********************************************************");
        System.err.println("   ****                                                   ****");
        System.err.println("  ****  Skipping LibDrmaaQueueTest.testSubmitEcho()        ****");
        System.err.println("  ****     Are you using the dotkit .combined_LSF_SGE?     ****");
        System.err.println("   ****                                                   ****");
        System.err.println("   ***********************************************************");
        System.err.println("    *********************************************************");
        throw new SkipException("Skipping testSubmitEcho because correct DRMAA implementation not found");
    }
    Memory error = new Memory(LibDrmaa.DRMAA_ERROR_STRING_BUFFER);
    int errnum;
    File outFile = tryCreateNetworkTempFile("LibDrmaaQueueTest.out");
    errnum = LibDrmaa.drmaa_init(null, error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
    if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
        Assert.fail(String.format("Could not initialize the DRMAA library: %s", error.getString(0)));
    try {
        PointerByReference jtRef = new PointerByReference();
        Pointer jt;
        Memory jobIdMem = new Memory(LibDrmaa.DRMAA_JOBNAME_BUFFER);
        String jobId;
        IntByReference remotePs = new IntByReference();
        IntByReference stat = new IntByReference();
        PointerByReference rusage = new PointerByReference();
        errnum = LibDrmaa.drmaa_allocate_job_template(jtRef, error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
            Assert.fail(String.format("Could not create job template: %s", error.getString(0)));
        jt = jtRef.getValue();
        errnum = LibDrmaa.drmaa_set_attribute(jt, LibDrmaa.DRMAA_REMOTE_COMMAND, "sh", error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
            Assert.fail(String.format("Could not set attribute \"%s\": %s", LibDrmaa.DRMAA_REMOTE_COMMAND, error.getString(0)));
        errnum = LibDrmaa.drmaa_set_attribute(jt, LibDrmaa.DRMAA_OUTPUT_PATH, ":" + outFile.getAbsolutePath(), error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
            Assert.fail(String.format("Could not set attribute \"%s\": %s", LibDrmaa.DRMAA_OUTPUT_PATH, error.getString(0)));
        errnum = LibDrmaa.drmaa_set_attribute(jt, LibDrmaa.DRMAA_JOIN_FILES, "y", error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
            Assert.fail(String.format("Could not set attribute \"%s\": %s", LibDrmaa.DRMAA_JOIN_FILES, error.getString(0)));
        StringArray args = new StringArray(new String[] { "-c", "echo \"Hello world.\"" });
        errnum = LibDrmaa.drmaa_set_vector_attribute(jt, LibDrmaa.DRMAA_V_ARGV, args, error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
            Assert.fail(String.format("Could not set attribute \"%s\": %s", LibDrmaa.DRMAA_V_ARGV, error.getString(0)));
        errnum = LibDrmaa.drmaa_run_job(jobIdMem, LibDrmaa.DRMAA_JOBNAME_BUFFER_LEN, jt, error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
            Assert.fail(String.format("Could not submit job: %s", error.getString(0)));
        jobId = jobIdMem.getString(0);
        System.out.println(String.format("Job id %s", jobId));
        errnum = LibDrmaa.drmaa_delete_job_template(jt, error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
            Assert.fail(String.format("Could not delete job template: %s", error.getString(0)));
        System.out.println("Waiting for job to run: " + jobId);
        remotePs.setValue(LibDrmaa.DRMAA_PS.DRMAA_PS_QUEUED_ACTIVE);
        List<Integer> runningStatuses = Arrays.asList(LibDrmaa.DRMAA_PS.DRMAA_PS_QUEUED_ACTIVE, LibDrmaa.DRMAA_PS.DRMAA_PS_RUNNING);
        while (runningStatuses.contains(remotePs.getValue())) {
            Thread.sleep(30 * 1000L);
            errnum = LibDrmaa.drmaa_job_ps(jobId, remotePs, error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
            if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
                Assert.fail(String.format("Could not get status for jobId %s: %s", jobId, error.getString(0)));
        }
        Assert.assertEquals(remotePs.getValue(), LibDrmaa.DRMAA_PS.DRMAA_PS_DONE, "Job status is not DONE.");
        errnum = LibDrmaa.drmaa_wait(jobId, Pointer.NULL, new NativeLong(0), stat, LibDrmaa.DRMAA_TIMEOUT_NO_WAIT, rusage, error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
            Assert.fail(String.format("Wait failed for jobId %s: %s", jobId, error.getString(0)));
        IntByReference exited = new IntByReference();
        IntByReference exitStatus = new IntByReference();
        IntByReference signaled = new IntByReference();
        Memory signal = new Memory(LibDrmaa.DRMAA_SIGNAL_BUFFER);
        IntByReference coreDumped = new IntByReference();
        IntByReference aborted = new IntByReference();
        errnum = LibDrmaa.drmaa_wifexited(exited, stat.getValue(), error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
            Assert.fail(String.format("Exit check failed for jobId %s: %s", jobId, error.getString(0)));
        Assert.assertTrue(exited.getValue() != 0, String.format("Job did not exit cleanly: %s", jobId));
        errnum = LibDrmaa.drmaa_wexitstatus(exitStatus, stat.getValue(), error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
            Assert.fail(String.format("Exit status failed for jobId %s: %s", jobId, error.getString(0)));
        Assert.assertEquals(exitStatus.getValue(), 0, String.format("Exit status for jobId %s is non-zero", jobId));
        errnum = LibDrmaa.drmaa_wifsignaled(signaled, stat.getValue(), error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
            Assert.fail(String.format("Signaled check failed for jobId %s: %s", jobId, error.getString(0)));
        if (signaled.getValue() != 0) {
            errnum = LibDrmaa.drmaa_wtermsig(signal, LibDrmaa.DRMAA_SIGNAL_BUFFER_LEN, stat.getValue(), error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
            if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
                Assert.fail(String.format("Signal lookup failed for jobId %s: %s", jobId, error.getString(0)));
            errnum = LibDrmaa.drmaa_wcoredump(coreDumped, stat.getValue(), error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
            if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
                Assert.fail(String.format("Core dump check failed for jobId %s: %s", jobId, error.getString(0)));
            Assert.fail(String.format("JobId %s exited with signal %s and core dump flag %d", jobId, signal.getString(0), coreDumped.getValue()));
        }
        errnum = LibDrmaa.drmaa_wifaborted(aborted, stat.getValue(), error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
            Assert.fail(String.format("Aborted check failed for jobId %s: %s", jobId, error.getString(0)));
        Assert.assertTrue(aborted.getValue() == 0, String.format("Job was aborted: %s", jobId));
    } finally {
        if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS) {
            LibDrmaa.drmaa_exit(error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
        } else {
            errnum = LibDrmaa.drmaa_exit(error, LibDrmaa.DRMAA_ERROR_STRING_BUFFER_LEN);
            if (errnum != LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_SUCCESS)
                Assert.fail(String.format("Could not shut down the DRMAA library: %s", error.getString(0)));
        }
    }
    Assert.assertTrue(FileUtils.waitFor(outFile, 120), "File not found: " + outFile.getAbsolutePath());
    System.out.println("--- output ---");
    System.out.println(FileUtils.readFileToString(outFile));
    System.out.println("--- output ---");
    Assert.assertTrue(outFile.delete(), "Unable to delete " + outFile.getAbsolutePath());
    System.out.println("Validating that we reached the end of the test without exit.");
}
Example 31
Project: jboss-marshalling-master  File: SimpleMarshallerTests.java View source code
@Test
public void testSerializableEmptyWriteObjectDefaultReadObject() throws Throwable {
    final TestSerializableEmptyWriteObjectDefaultReadObject serializable = new TestSerializableEmptyWriteObjectDefaultReadObject();
    runReadWriteTest(new ReadWriteTest() {

        public void runWrite(final Marshaller marshaller) throws Throwable {
            if (!(marshaller instanceof RiverMarshaller)) {
                throw new SkipException("Test not relevant for " + marshaller);
            }
            marshaller.writeObject(serializable);
        }

        public void runRead(final Unmarshaller unmarshaller) throws Throwable {
            TestSerializableEmptyWriteObjectDefaultReadObject o = unmarshaller.readObject(TestSerializableEmptyWriteObjectDefaultReadObject.class);
            assertEquals(serializable.sixth, o.sixth);
            assertEquals(0.0, o.seventh);
            assertEOF(unmarshaller);
        }
    });
}
Example 32
Project: jtrade-master  File: TestIBMarketFeed.java View source code
@Test()
public void testIBMarketFeedTickListener() throws Exception {
    final List<Tick> ticks = new ArrayList<Tick>();
    IBMarketFeed marketFeed = new IBMarketFeed();
    try {
        marketFeed.connect();
        marketFeed.addTickListener(symbol, new TickListener() {

            @Override
            public void onTick(Tick tick) {
                ticks.add(tick);
            }
        }, false, null);
        marketFeed.addTickListener(new TickListener() {

            @Override
            public void onTick(Tick tick) {
                ticks.add(tick);
            }
        });
        assertEquals(marketFeed.isConnected(), true);
        long start = System.currentTimeMillis();
        try {
            while (marketFeed.isConnected() && ticks.isEmpty()) {
                Thread.sleep(10);
                if (System.currentTimeMillis() - start > 70000) {
                    throw new SkipException("Test timed out waiting for marketdata");
                }
            }
        } catch (InterruptedException e) {
        }
        assertEquals(ticks.get(0), ticks.get(1));
        assertEquals(ticks.get(ticks.size() - 1), marketFeed.getLastTick(symbol));
        assertEquals(symbol, ticks.get(0).getSymbol());
        assertTrue(ticks.get(0).getAsk() > 0);
        assertTrue(ticks.get(0).getAskSize() > 0);
        assertTrue(ticks.get(0).getBid() > 0);
        assertTrue(ticks.get(0).getBidSize() > 0);
        marketFeed.removeAllListeners();
    } finally {
        marketFeed.disconnect();
    }
}
Example 33
Project: legacy-jclouds-master  File: GoGridLiveTestDisabled.java View source code
/**
    * Tests common load balancer operations. Also verifies IP services and job services.
    */
@Test(enabled = true)
public void testLoadBalancerLifecycle() {
    int lbCountBeforeTest = api.getLoadBalancerServices().getLoadBalancerList().size();
    final String nameOfLoadBalancer = "LoadBalancer" + String.valueOf(new Date().getTime()).substring(6);
    loadBalancersToDeleteAfterTest.add(nameOfLoadBalancer);
    Set<Ip> availableIps = api.getIpServices().getUnassignedPublicIpList();
    if (availableIps.size() < 4)
        throw new SkipException("Not enough available IPs (4 needed) to run the test");
    Iterator<Ip> ipIterator = availableIps.iterator();
    Ip vip = ipIterator.next();
    Ip realIp1 = ipIterator.next();
    Ip realIp2 = ipIterator.next();
    Ip realIp3 = ipIterator.next();
    AddLoadBalancerOptions options = new AddLoadBalancerOptions.Builder().create(LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SOURCE_ADDRESS);
    LoadBalancer createdLoadBalancer = api.getLoadBalancerServices().addLoadBalancer(nameOfLoadBalancer, IpPortPair.builder().ip(vip).port(80).build(), Arrays.asList(IpPortPair.builder().ip(realIp1).port(80).build(), IpPortPair.builder().ip(realIp2).port(80).build()), options);
    assertNotNull(createdLoadBalancer);
    assert loadBalancerLatestJobCompleted.apply(createdLoadBalancer);
    // get load balancer by name
    Set<LoadBalancer> response = api.getLoadBalancerServices().getLoadBalancersByName(nameOfLoadBalancer);
    assert (response.size() == 1);
    createdLoadBalancer = Iterables.getOnlyElement(response);
    assertNotNull(createdLoadBalancer.getRealIpList());
    assertEquals(createdLoadBalancer.getRealIpList().size(), 2);
    assertNotNull(createdLoadBalancer.getVirtualIp());
    assertEquals(createdLoadBalancer.getVirtualIp().getIp().getIp(), vip.getIp());
    LoadBalancer editedLoadBalancer = api.getLoadBalancerServices().editLoadBalancerNamed(nameOfLoadBalancer, Arrays.asList(IpPortPair.builder().ip(realIp3).port(8181).build()));
    assert loadBalancerLatestJobCompleted.apply(editedLoadBalancer);
    assertNotNull(editedLoadBalancer.getRealIpList());
    assertEquals(editedLoadBalancer.getRealIpList().size(), 1);
    assertEquals(Iterables.getOnlyElement(editedLoadBalancer.getRealIpList()).getIp().getIp(), realIp3.getIp());
    int lbCountAfterAddingOneServer = api.getLoadBalancerServices().getLoadBalancerList().size();
    assert lbCountAfterAddingOneServer == lbCountBeforeTest + 1 : "There should be +1 increase in the number of load balancers since the test started";
    // delete the load balancer
    api.getLoadBalancerServices().deleteByName(nameOfLoadBalancer);
    Set<Job> jobs = api.getJobServices().getJobsForObjectName(nameOfLoadBalancer);
    assert ("DeleteLoadBalancer".equals(Iterables.getLast(jobs).getCommand().getName()));
    assert loadBalancerLatestJobCompleted.apply(createdLoadBalancer);
    int lbCountAfterDeletingTheServer = api.getLoadBalancerServices().getLoadBalancerList().size();
    assert lbCountAfterDeletingTheServer == lbCountBeforeTest : "There should be the same # of load balancers as since the test started";
}
Example 34
Project: product-ml-master  File: ExternalDataset1DigitRecognitionTestCase.java View source code
@BeforeClass(alwaysRun = true)
public void initTest() throws MLIntegrationBaseTestException, MLHttpClientException, IOException, JSONException {
    super.init();
    mlHttpclient = getMLHttpClient();
    String version = "1.0";
    File file = new File(mlHttpclient.getResourceAbsolutePath(MLIntegrationTestConstants.DIGIT_RECOGNITION_DATASET_SAMPLE));
    if (!file.exists()) {
        throw new SkipException("Skipping the tests because the dataset file is not available at: " + file.getAbsolutePath());
    }
    int datasetId = createDataset(MLIntegrationTestConstants.DATASET_NAME_DIGITS, version, MLIntegrationTestConstants.DIGIT_RECOGNITION_DATASET_SAMPLE);
    versionSetId = getVersionSetId(datasetId, version);
    isDatasetProcessed(versionSetId, MLIntegrationTestConstants.THREAD_SLEEP_TIME_LARGE, 1000);
    projectId = createProject(MLIntegrationTestConstants.PROJECT_NAME_DIGITS, MLIntegrationTestConstants.DATASET_NAME_DIGITS);
}
Example 35
Project: arquillian-core-master  File: Arquillian.java View source code
public void run(final IHookCallBack callback, final ITestResult testResult) {
    verifyTestRunnerAdaptorHasBeenSet();
    TestResult result;
    try {
        result = deployableTest.get().test(new TestMethodExecutor() {

            public void invoke(Object... parameters) throws Throwable {
                /*
                *  The parameters are stored in the InvocationHandler, so we can't set them on the test result directly.
                *  Copy the Arquillian found parameters to the InvocationHandlers parameters
                */
                copyParameters(parameters, callback.getParameters());
                callback.runTestMethod(testResult);
                // Parameters can be contextual, so extract information
                swapWithClassNames(callback.getParameters());
                testResult.setParameters(callback.getParameters());
                if (testResult.getThrowable() != null) {
                    throw testResult.getThrowable();
                }
            }

            private void copyParameters(Object[] source, Object[] target) {
                for (int i = 0; i < source.length; i++) {
                    if (source[i] != null) {
                        target[i] = source[i];
                    }
                }
            }

            private void swapWithClassNames(Object[] source) {
                // clear parameters. they can be contextual and might fail TestNG during the report writing.
                for (int i = 0; source != null && i < source.length; i++) {
                    Object parameter = source[i];
                    if (parameter != null) {
                        source[i] = parameter.toString();
                    } else {
                        source[i] = "null";
                    }
                }
            }

            public Method getMethod() {
                return testResult.getMethod().getMethod();
            }

            public Object getInstance() {
                return Arquillian.this;
            }
        });
        Throwable throwable = result.getThrowable();
        if (throwable != null) {
            if (result.getStatus() == Status.SKIPPED) {
                if (throwable instanceof SkippedTestExecutionException) {
                    result.setThrowable(new SkipException(throwable.getMessage()));
                }
            }
            testResult.setThrowable(result.getThrowable());
        }
        // calculate test end time. this is overwritten in the testng invoker..
        testResult.setEndMillis((result.getStart() - result.getEnd()) + testResult.getStartMillis());
    } catch (Exception e) {
        testResult.setThrowable(e);
    }
}
Example 36
Project: lsql-master  File: SqlStatementTest.java View source code
@Test()
public void listLiteralQueryParameterEmptyArray() {
    boolean skipTest = lSql.getDialect() instanceof PostgresDialect;
    if (skipTest) {
        throw new SkipException("empty list literal not support");
    }
    setup();
    List<Row> rows;
    AbstractSqlStatement<RowQuery> statement = lSql.executeQuery("select * from person where" + " age in (/*ages=*/ 11, 12, 13 /**/) " + "and 1 = /*param=*/ 1 /**/;");
    // API Version 2, empty
    rows = statement.query("ages", ListLiteralQueryParameter.of(), "param", 1).toList();
    assertEquals(rows.size(), 0);
}
Example 37
Project: OpenIDM-master  File: FileUtilTest.java View source code
/*
    mkfile 1k text1k.txt
    mkfile 8k text8k.txt
    mkfile 96k text96k.txt
    mkfile 1m text1m.txt
    mkfile 10m text10m.txt
     */
@BeforeClass
public void beforeClass() throws Exception {
    if (null == FileUtilTest.class.getResource("/text1k.txt") || null == FileUtilTest.class.getResource("/text8k.txt") || null == FileUtilTest.class.getResource("/text96k.txt") || null == FileUtilTest.class.getResource("/text1m.txt") || null == FileUtilTest.class.getResource("/text10m.txt")) {
        throw new SkipException("Skipping FileUtil test because the missing test files.");
    }
}
Example 38
Project: openjdk-master  File: LogGeneratedClassesTest.java View source code
@Test
public void testDumpDirNotWritable() throws IOException {
    if (!Files.getFileStore(Paths.get(".")).supportsFileAttributeView(PosixFileAttributeView.class)) {
        // No easy way to setup readonly directory without POSIX
        // We would like to skip the test with a cause with
        //     throw new SkipException("Posix not supported");
        // but jtreg will report failure so we just pass the test
        // which we can look at if jtreg changed its behavior
        System.out.println("WARNING: POSIX is not supported. Skipping testDumpDirNotWritable test.");
        return;
    }
    Files.createDirectory(Paths.get("readOnly"), asFileAttribute(fromString("r-xr-xr-x")));
    try {
        if (isWriteableDirectory(Paths.get("readOnly"))) {
            // Skipping the test: it's allowed to write into read-only directory
            // (e.g. current user is super user).
            System.out.println("WARNING: readOnly directory is writeable. Skipping testDumpDirNotWritable test.");
            return;
        }
        TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), "-cp", ".", "-Djdk.internal.lambda.dumpProxyClasses=readOnly", "-Djava.security.manager", "com.example.TestLambda");
        assertEquals(tr.testOutput.stream().filter( s -> s.startsWith("WARNING")).peek( s -> assertTrue(s.contains("not writable"))).count(), 1, "only show error once");
        tr.assertZero("Should still return 0");
    } finally {
        TestUtil.removeAll(Paths.get("readOnly"));
    }
}
Example 39
Project: teamcity-vmware-plugin-master  File: VmwareCloudIntegrationTest.java View source code
public void validate_objects_on_client_creation() throws MalformedURLException, RemoteException {
    throw new SkipException("TODO: Add validation");
/*    FakeModel.instance().removeFolder("cf");
    recreateClient();
    assertNotNull(myClient.getErrorInfo());
    assertEquals(wrapWithArraySymbols(VMWareCloudErrorInfoFactory.noSuchFolder("cf").getMessage()),
                 myClient.getErrorInfo().getMessage());
    FakeModel.instance().addFolder("cf");

    FakeModel.instance().removeResourcePool("rp");
    recreateClient();
    assertNotNull(myClient.getErrorInfo());
    assertEquals(wrapWithArraySymbols(VMWareCloudErrorInfoFactory.noSuchResourcePool("rp").getMessage()),
                 myClient.getErrorInfo().getMessage());
    FakeModel.instance().addResourcePool("rp");

    FakeModel.instance().removeVM("image1");
    recreateClient();
    assertNotNull(myClient.getErrorInfo());
    assertEquals(wrapWithArraySymbols(VMWareCloudErrorInfoFactory.noSuchVM("image1").getMessage()),
                 myClient.getErrorInfo().getMessage());
    FakeModel.instance().addVM("image1");

    FakeModel.instance().removeVM("image2");
    recreateClient();
    assertNotNull(myClient.getErrorInfo());
    assertEquals(wrapWithArraySymbols(VMWareCloudErrorInfoFactory.noSuchVM("image2").getMessage()),
                 myClient.getErrorInfo().getMessage());
    FakeModel.instance().addVM("image2");*/
}
Example 40
Project: webui-framework-master  File: BugzillaTestNGListener.java View source code
protected void lookupBugAndSkipIfOpen(String bugId) {
    BzChecker.bzState state;
    String summary;
    boolean isBugOpen;
    try {
        state = bzChecker.getBugState(bugId);
        summary = bzChecker.getBugField(bugId, "summary").toString();
        isBugOpen = bzChecker.isBugOpen(bugId);
    } catch (XmlRpcException xre) {
        log.log(Level.WARNING, "Could not determine the state of Bugzilla bug " + bugId + ". Assuming test needs to be run.", xre);
        return;
    }
    // throw a skip exception when the bug is open
    if (isBugOpen) {
        //add bug to list of blockers
        blockingBugs.add(bugId);
        throw new SkipException("This test is blocked by " + state.toString() + " Bugzilla bug '" + summary + "'.  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
    } else
        log.log(Level.INFO, "This test was previously blocked by " + state.toString() + " Bugzilla bug '" + summary + "'.  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
}
Example 41
Project: liblevenshtein-java-master  File: SerializerTest.java View source code
@SuppressWarnings("checkstyle:illegalcatch")
private Object[][] buildParams() {
    try {
        final AbstractSerializer[] serializers = { new ProtobufSerializer(), new BytecodeSerializer(), new PlainTextSerializer(true), new PlainTextSerializer(false) };
        final SortedDawg dictionary = buildDictionary();
        final int[] maxDistances = { 0, 2, Integer.MAX_VALUE };
        final boolean[] includeDistances = { true, false };
        final Algorithm[] algorithms = Algorithm.values();
        final List<Object[]> provider = new ArrayList<>(serializers.length * maxDistances.length * algorithms.length);
        for (final AbstractSerializer serializer : serializers) {
            serializer.fileSystem(fs);
            for (final int maxDistance : maxDistances) {
                for (final boolean includeDistance : includeDistances) {
                    for (final Algorithm algorithm : algorithms) {
                        final Transducer<?, ?> transducer = (Transducer<?, ?>) (Object) new TransducerBuilder().dictionary(dictionary).algorithm(algorithm).defaultMaxDistance(maxDistance).includeDistance(includeDistance).build();
                        provider.add(new Object[] { serializer, dictionary, transducer });
                    }
                }
            }
        }
        return provider.toArray(new Object[0][0]);
    } catch (final Throwable thrown) {
        final String message = "Failed to build @DataProvider [serializerParams]";
        log.error(message, thrown);
        throw new SkipException(message, thrown);
    }
}
Example 42
Project: openicf-master  File: AccountAttributeTest.java View source code
/**
     * check behaviour of {@link AccountAttribute#PASSWD_FORCE_CHANGE}
     * attribute.
     *
     * If it is true, the user should change her password on the next login,
     * thus the "new password:" prompt signalizes this fact.
     */
@Test
public void testResetPassword() {
    if (getConnection().isNis()) {
        // Workaround: skipping. TODO Solaris NIS scripts in connector
        // doesn't support forcing password change on Solaris NIS.
        logger.info("skipping test 'testResetPassword' for Solaris NIS configuration.");
        throw new SkipException("Skipping test 'testResetPassword' for Solaris NIS configuration.");
    }
    final Pair<String, String> credentials = createResetPasswordUser(true);
    final String username = credentials.first;
    final String password = credentials.second;
    try {
        // check if user exists
        String loginsCmd = (!getConnection().isNis()) ? "logins -oxma -l " + username : "ypmatch \"" + username + "\" passwd";
        String out = getConnection().executeCommand(loginsCmd);
        assertTrue(out.contains(username), "user " + username + " is missing, buffer: <" + out + ">");
        try {
            getFacade().authenticate(ObjectClass.ACCOUNT, username, new GuardedString(password.toCharArray()), null);
            fail("expected to wait for 'new password:' prompt failed.");
        } catch (ConnectorException ex) {
            if (!ex.getMessage().contains("New Password:")) {
                fail("expected to wait for 'new password:' prompt failed with exception: " + ex.getMessage());
            } else {
                logger.ok("test testResetPassword passed");
            }
        }
    } finally {
        getFacade().delete(ObjectClass.ACCOUNT, new Uid(username), null);
    }
}
Example 43
Project: diqube-master  File: AbstractDiqubeIntegrationTest.java View source code
/**
   * @throws SkipException
   *           If we cannot identify PIDs on this system.
   */
private void validatePidAvailable(Method testMethod) throws SkipException {
    // start an arbitrary process and check if we can get the PID of it.
    ProcessBuilder pb = new ProcessBuilder("java", "-version");
    try {
        Process p = pb.start();
        ProcessPidUtil.getPid(p);
        p.destroyForcibly();
    // if no exception: we found a PID, so we're fine.
    } catch (IOExceptionIllegalStateException |  e) {
        throw new SkipException("Skipping test method, because this system cannot identify the PID of sub-processes: " + testMethod.toString());
    }
}
Example 44
Project: mysql-binlog-connector-java-master  File: BinaryLogClientIntegrationTest.java View source code
@Test
public void testFSP() throws Exception {
    try {
        master.execute(new Callback<Statement>() {

            @Override
            public void execute(Statement statement) throws SQLException {
                statement.execute("create table fsp_check (column_ datetime(0))");
            }
        });
    } catch (SQLSyntaxErrorException e) {
        throw new SkipException("MySQL < 5.6.4+");
    }
    assertEquals(writeAndCaptureRow("datetime(0)", "'1989-03-21 01:02:03.777777'"), new Serializable[] { generateTime(1989, 3, 21, 1, 2, 4, 0) });
    assertEquals(writeAndCaptureRow("datetime(1)", "'1989-03-21 01:02:03.777777'"), new Serializable[] { generateTime(1989, 3, 21, 1, 2, 3, 800) });
    assertEquals(writeAndCaptureRow("datetime(2)", "'1989-03-21 01:02:03.777777'"), new Serializable[] { generateTime(1989, 3, 21, 1, 2, 3, 780) });
    assertEquals(writeAndCaptureRow("datetime(3)", "'1989-03-21 01:02:03.777777'"), new Serializable[] { generateTime(1989, 3, 21, 1, 2, 3, 778) });
    assertEquals(writeAndCaptureRow("datetime(3)", "'1989-03-21 01:02:03.777'"), new Serializable[] { generateTime(1989, 3, 21, 1, 2, 3, 777) });
    assertEquals(writeAndCaptureRow("datetime(4)", "'1989-03-21 01:02:03.777777'"), new Serializable[] { generateTime(1989, 3, 21, 1, 2, 3, 777) });
    assertEquals(writeAndCaptureRow("datetime(5)", "'1989-03-21 01:02:03.777777'"), new Serializable[] { generateTime(1989, 3, 21, 1, 2, 3, 777) });
    assertEquals(writeAndCaptureRow("datetime(6)", "'1989-03-21 01:02:03.777777'"), new Serializable[] { generateTime(1989, 3, 21, 1, 2, 3, 777) });
}
Example 45
Project: presto-master  File: TestPrestoS3FileSystem.java View source code
@Test
public void testCreateWithStagingDirectorySymlink() throws Exception {
    java.nio.file.Path tmpdir = Paths.get(StandardSystemProperty.JAVA_IO_TMPDIR.value());
    java.nio.file.Path staging = Files.createTempDirectory(tmpdir, "staging");
    java.nio.file.Path link = Paths.get(staging + ".symlink");
    try {
        try {
            Files.createSymbolicLink(link, staging);
        } catch (UnsupportedOperationException e) {
            throw new SkipException("Filesystem does not support symlinks", e);
        }
        try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) {
            MockAmazonS3 s3 = new MockAmazonS3();
            Configuration conf = new Configuration();
            conf.set(PrestoS3FileSystem.S3_STAGING_DIRECTORY, link.toString());
            fs.initialize(new URI("s3n://test-bucket/"), conf);
            fs.setS3Client(s3);
            FSDataOutputStream stream = fs.create(new Path("s3n://test-bucket/test"));
            stream.close();
            assertTrue(Files.exists(link));
        }
    } finally {
        deleteRecursively(link.toFile());
        deleteRecursively(staging.toFile());
    }
}
Example 46
Project: incubator-atlas-master  File: TestUtils.java View source code
public static void skipForGremlin3EnabledGraphDb() throws SkipException {
    //ATLAS-1579 Currently, some tests are skipped for titan1 backened. As these tests are hard coded to use Gremlin2. See ATLAS-1579, ATLAS-1591 once it is fixed, please remove it.
    if (TestUtils.getGraph().getSupportedGremlinVersion() == GremlinVersion.THREE) {
        throw new SkipException("This test requires Gremlin2. Skipping test ");
    }
}
Example 47
Project: libbio-formats-java-master  File: FormatReaderTest.java View source code
/**
   * @testng.test groups = "all fast automated"
   */
public void testConsistentReader() {
    if (config == null)
        throw new SkipException("No config tree");
    String testName = "testConsistentReader";
    if (!initFile())
        result(testName, false, "initFile");
    String format = config.getReader();
    IFormatReader r = reader;
    if (r instanceof ImageReader) {
        r = ((ImageReader) r).getReader();
    } else if (r instanceof ReaderWrapper) {
        try {
            r = ((ReaderWrapper) r).unwrap();
        } catch (FormatException e) {
        } catch (IOException e) {
        }
    }
    String realFormat = TestTools.shortClassName(r);
    result(testName, realFormat.equals(format), realFormat);
}
Example 48
Project: Prendamigo-master  File: Invoker.java View source code
private void handleConfigurationFailure(Throwable ite, ITestNGMethod tm, ITestResult testResult, IConfigurationAnnotation annotation, ITestNGMethod currentTestMethod, Object instance, XmlSuite suite) {
    Throwable cause = ite.getCause() != null ? ite.getCause() : ite;
    if (SkipException.class.isAssignableFrom(cause.getClass())) {
        SkipException skipEx = (SkipException) cause;
        if (skipEx.isSkip()) {
            testResult.setThrowable(skipEx);
            handleConfigurationSkip(tm, testResult, annotation, currentTestMethod, instance, suite);
            return;
        }
    }
    Utils.log("", 3, "Failed to invoke @Configuration method " + tm.getRealClass().getName() + "." + tm.getMethodName() + ":" + cause.getMessage());
    handleException(cause, tm, testResult, 1);
    runConfigurationListeners(testResult);
    //
    if (null != annotation) {
        recordConfigurationInvocationFailed(tm, testResult.getTestClass(), annotation, currentTestMethod, instance, suite);
    }
}
Example 49
Project: richfaces-qa-master  File: AbstractWebDriverTest.java View source code
/**
     * Opens the tested page. If templates is not empty nor null, it appends url parameter with templates.
     */
@BeforeMethod(alwaysRun = true, dependsOnMethods = "configure")
public void loadPage() {
    if (driver == null) {
        throw new SkipException("webDriver isn't initialized");
    }
    // delete session
    driver.manage().deleteAllCookies();
    // move mouse to upper left corner of window so it will not stay over tested component
    moveMouseToUpperLeftCorner();
    // try to load the page
    for (int i = 0; i < 3; i++) {
        openPageWithCurrentConfiguration();
        // check page is correctlu loaded or repeat
        if (checkPageIsLoadedCorrectly()) {
            break;
        }
    }
    driverType = DriverType.getCurrentType(driver);
    // resize browser window to 1280x1024 or full screen
    driver.manage().window().setSize(new Dimension(1920, 1080));
}
Example 50
Project: bioformats-master  File: FormatReaderTest.java View source code
@Test(groups = { "all", "fast", "automated" })
public void testConsistentReader() {
    if (config == null)
        throw new SkipException("No config tree");
    String testName = "testConsistentReader";
    if (!initFile())
        result(testName, false, "initFile");
    String format = config.getReader();
    IFormatReader r = reader;
    if (r instanceof ImageReader) {
        r = ((ImageReader) r).getReader();
    } else if (r instanceof ReaderWrapper) {
        try {
            r = ((ReaderWrapper) r).unwrap();
        } catch (FormatException e) {
        } catch (IOException e) {
        }
    }
    String realFormat = TestTools.shortClassName(r);
    result(testName, realFormat.equals(format), realFormat);
}
Example 51
Project: powermock-master  File: SomeClass.java View source code
public void throwSkipException() {
    throw new SkipException("Skip test");
}
Example 52
Project: pitest-master  File: Skips.java View source code
@org.testng.annotations.Test()
public void skip() {
    throw new SkipException("skipping");
}
Example 53
Project: TestNG-master  File: SkipAndExpectedSampleTest.java View source code
@Test(expectedExceptions = NullPointerException.class)
public void a2() {
    throw new SkipException("test");
}
Example 54
Project: elasticsearch-river-mongodb-master  File: RiverTokuMXTestAbstract.java View source code
@BeforeClass
protected void checkEnvironment() {
    if (!tokuIsSupported()) {
        throw new SkipException("Skipping tests because running tests on environment not supported by TokuMX.");
    }
}
Example 55
Project: infinispan-master  File: FailAllTestNGHook.java View source code
@Override
public void run(IHookCallBack iHookCallBack, ITestResult iTestResult) {
    iHookCallBack.runTestMethod(iTestResult);
    throw new SkipException("Induced failure");
}
Example 56
Project: extentreports-java-master  File: ListenerTests.java View source code
@Test(expectedExceptions = SkipException.class, groups = "skip")
public void skipTest() {
    try {
        Thread.sleep(2000);
    } catch (Exception e) {
    }
    throw new SkipException("Intentionally skipped test.");
}
Example 57
Project: maven-surefire-master  File: SkipExceptionReportTest.java View source code
@Test
public void testSkipException() {
    throw new SkipException("Skip test");
}
Example 58
Project: surefire-master  File: SkipExceptionReportTest.java View source code
@Test
public void testSkipException() {
    throw new SkipException("Skip test");
}
Example 59
Project: eurocarbdb-master  File: ReferenceTest.java View source code
// private Reference gs1;
@Test
public void coreReferenceDataExists() {
    super.setup();
    int i = getEntityManager().countAll(Reference.class);
    System.out.println("total references in data store = " + i);
    // if ( i == 0 )
    //     throw new SkipException();
    super.teardown();
}
Example 60
Project: jclouds-labs-openstack-master  File: CloudNetworksUKNetworkApiLiveTest.java View source code
@Override
public void testBulkCreateNetwork() {
    throw new SkipException("unsupported functionality");
}
Example 61
Project: quasar-firebase-master  File: FirebaseTest.java View source code
@BeforeMethod
public void verify() {
    if (ref == null) {
        throw new SkipException("Firebase reference not set");
    }
}
Example 62
Project: spring-integration-java-dsl-master  File: PollablePublisherIntegrationFlowVerification.java View source code
@Override
public void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws Throwable {
    throw new SkipException("The Spring Integration Publisher supports " + "'TheSameElementsInTheSameSequenceToAllOfItsSubscribers' only in case of 'PublishSubscribeChannel' " + "and unbounded (Long.MAX_VALUE) request(n).");
}
Example 63
Project: vaadin-for-heroku-master  File: SessionTest.java View source code
@BeforeClass
protected void checkEnvironment() {
    if (!memcachedAvailable()) {
        throw new SkipException("Skipping tests because memcached was not available.");
    } else {
        driver = new SharedDriver();
        page = new SessionTestPage(driver);
        startServers();
    }
}
Example 64
Project: JFramework-master  File: BaseTest.java View source code
public <T> T skipIfNull(T reference, Object errorMessage) {
    if (reference == null) {
        throw new SkipException(errorMessage.toString());
    }
    return reference;
}
Example 65
Project: sonar-java-master  File: TestNGListenerTest.java View source code
@org.testng.annotations.Test
public void test() {
    throw new org.testng.SkipException("Skip me");
}
Example 66
Project: falcon-master  File: LogMoverTest.java View source code
@BeforeClass
public void checkEnvironment() throws Exception {
    if (MerlinConstants.IS_SECURE) {
        throw new SkipException("Skipping tests because LogMover Functionality is not Supported on secure mode.");
    }
}
Example 67
Project: reportng-master  File: ReportNGUtils.java View source code
public boolean hasSkipException(ITestResult result) {
    return result.getThrowable() instanceof SkipException;
}
Example 68
Project: rhq-master  File: SecurityModuleOptionsTest.java View source code
@BeforeTest
public void checkServerVersion() {
    if (System.getProperty("as7.version").equals("6.1.0.Alpha")) {
        // This version has issues with Security Modules
        throw new SkipException("This test does not run on 6.1.0.Alpha");
    }
}