Example usage for java.lang AssertionError getMessage

List of usage examples for java.lang AssertionError getMessage

Introduction

In this page you can find the example usage for java.lang AssertionError getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:easycare.cuke.steps.PasswordSteps.java

/**
 * Trying to change the password using an invalid password.
 * <ol>/* ww w.j av  a  2s  .  c o  m*/
 * <li>Fills in <strong>Password</strong> and <strong>Confirm
 * Password</strong> fields with an invalid password</li>
 * <li>Checks the message "<strong>Passwords match</strong>" is displayed</li>
 * <li>Clicks on the <strong>Continue</strong> button</li>
 * <li>Checks the message
 * "<strong>Password does not meet the requirements</strong>" is displayed</li>
 * </ol>
 */
@Given("^I enter an invalid password it should fail" + NO_CONFIRM_STRING + "$")
public void iEnterInvalidPassword(String isConfirmationRequired) throws Exception {
    String[] invalidPasswords = { "Ecoblu1", "easycare@123", "PasswOrd" };
    for (String password : invalidPasswords) {
        try {
            changePassword(password, password, isConfirmationRequired);
            this.commonSteps.iShouldSee(this.messageSource.getMessage("password.change.fail"));
            this.commonSteps.clickButton("Continue");
            this.commonSteps.iShouldSee(this.messageSource.getMessage("password.change.fail"));
        } catch (AssertionError e) {
            throw new AssertionError("Error when validating password " + password + ": " + e.getMessage());
        }
    }
}

From source file:org.cloudifysource.quality.iTests.test.cli.cloudify.cloud.services.byon.ByonCloudService.java

public void cleanCronTasks() {
    String command = "crontab -r";

    String[] hosts = this.getMachines();
    for (String host : hosts) {
        try {//from  w ww  .j  a v a  2  s  .  com
            LogUtils.log("Removing scheduled task from " + host);
            LogUtils.log(
                    SSHUtils.runCommand(host, AbstractTestSupport.OPERATION_TIMEOUT, command, user, password));
        } catch (AssertionError e) {
            LogUtils.log("Failed to clean cron tasks on host " + host + " .Reason --> " + e.getMessage());
        }
    }

}

From source file:org.cloudifysource.quality.iTests.test.cli.cloudify.cloud.services.byon.ByonCloudService.java

private void killAllJavaOnAllHosts() {

    String command = "killall -9 java";
    if (sudo) {/*w w  w  .  j  a v a 2  s .c o  m*/
        command = "sudo " + command;
    }

    String[] hosts = this.getMachines();
    for (String host : hosts) {
        try {
            LogUtils.log("Trying to kill: " + host);
            LogUtils.log(
                    SSHUtils.runCommand(host, AbstractTestSupport.OPERATION_TIMEOUT, command, user, password));
        } catch (AssertionError e) {
            LogUtils.log("Failed to kill java processes on host " + host + " .Reason --> " + e.getMessage());
        }
    }
}

From source file:org.openspaces.itest.archive.ArchiveContainerTest.java

/**
 * Tests archiver with configurer (wrong template)
 *///w ww  . jav  a  2 s  .  co  m
@Test
public void testWrongTemplateConfigurer() throws Exception {
    try {
        configurerTest(TestTemplate.WRONG_TEMPLATE);
        Assert.fail("Expected exception");
    } catch (AssertionError e) {
        Assert.assertEquals("expected:<5> but was:<0>", e.getMessage());
    }
}

From source file:org.openspaces.itest.archive.ArchiveContainerTest.java

/**
 * Tests archiver with wrong template (processed = true)
 *//*from www  .j ava  2s.c  o m*/
@Test() //GS-11380
public void testWrongTemplateXmlAnnotation() throws InterruptedException {
    // see @Archive(batchSize=2) annotation and atomic=true in MockArchiveContainer
    final int expectedBatchSize = 2;
    try {
        xmlTest(TEST_WRONG_TEMPLATE_ANNOTATION_XML, expectedBatchSize);
        Assert.fail("Expected exception");
    } catch (AssertionError e) {
        Assert.assertEquals("expected:<5> but was:<0>", e.getMessage());
    }
}

From source file:net.cpollet.jixture.asserts.TestJixtureAssert.java

@Test
public void isNotEmptyThrowsExceptionWhenAssertFails() {
    // GIVEN/*from   ww  w.j  av a 2 s .c  om*/
    Mockito.when(unitDao.getAll(User.class)).thenReturn(Collections.<User>emptyList());

    // WHEN + THEN
    try {
        JixtureAssert.assertThat(User.class).isNotEmpty();
    } catch (AssertionError e) {
        assertThat(e.getMessage()).isEqualTo("Expected at least 1 rows but got only 0");
        return;
    }

    Assert.fail("AssertionError expected but not thrown");
}

From source file:net.cpollet.jixture.asserts.TestJixtureAssert.java

@Test
public void isEmptyThrowsExceptionWhenAssertFails() {
    // GIVEN/*from   w  w  w  . ja va 2  s . co  m*/
    User user1 = new User();
    user1.setUsername("username 1");

    Mockito.when(unitDao.getAll(User.class)).thenReturn(Arrays.asList(user1));

    // WHEN + THEN
    try {
        JixtureAssert.assertThat(User.class).isEmpty();
    } catch (AssertionError e) {
        assertThat(e.getMessage()).isEqualTo("Expected at most 0 rows but got 1");
        return;
    }

    Assert.fail("AssertionError expected but not thrown");
}

From source file:net.cpollet.jixture.asserts.TestJixtureAssert.java

@Test
public void rowsCountIsAtLeastThrowsExceptionWhenAssertFails() {
    // GIVEN//from  w  w  w . j a v  a  2  s. co  m
    User user1 = new User();
    user1.setUsername("username 1");

    Mockito.when(unitDao.getAll(User.class)).thenReturn(Arrays.asList(user1));

    // WHEN + THEN
    try {
        JixtureAssert.assertThat(User.class).rowsCountIsAtLeast(2);
    } catch (AssertionError e) {
        assertThat(e.getMessage()).isEqualTo("Expected at least 2 rows but got only 1");

        return;
    }

    Assert.fail("AssertionError expected but not thrown");
}

From source file:net.cpollet.jixture.asserts.TestJixtureAssert.java

@Test
public void rowsCountIsAtMostThrowsExceptionWhenAssertFails() {
    // GIVEN//from w  ww. ja  va2s .com
    User user1 = new User();
    user1.setUsername("username 1");

    Mockito.when(unitDao.getAll(User.class)).thenReturn(Arrays.asList(user1));

    // WHEN + THEN
    try {
        JixtureAssert.assertThat(User.class).rowsCountIsAtMost(0);
    } catch (AssertionError e) {
        assertThat(e.getMessage()).isEqualTo("Expected at most 0 rows but got 1");

        return;
    }

    Assert.fail("AssertionError expected but not thrown");
}

From source file:net.cpollet.jixture.asserts.TestJixtureAssert.java

@Test
public void rowsCountIsExactlyThrowsExceptionWhenNotEnoughRows() {
    // GIVEN//from  www  .j  a  v a 2  s .co m
    User user1 = new User();
    user1.setUsername("username 1");

    Mockito.when(unitDao.getAll(User.class)).thenReturn(Arrays.asList(user1));

    // WHEN + THEN
    try {
        JixtureAssert.assertThat(User.class).rowsCountIsExactly(2);
    } catch (AssertionError e) {
        assertThat(e.getMessage()).isEqualTo("Expected at least 2 rows but got only 1");

        return;
    }

    Assert.fail("AssertionError expected but not thrown");
}