Example usage for java.lang IllegalArgumentException getMessage

List of usage examples for java.lang IllegalArgumentException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.xing.api.data.profile.CompanyTest.java

@Test
public void setNameThrowsIfLimitExited() throws Exception {
    Company company = new Company();
    try {//from ww  w  .j ava  2 s .  c  om
        company.name(leftPad("longName", Company.LIMIT_NAME + 1, '*'));
        fail();
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage())
                .isEqualTo("Argument Name too long. " + Company.LIMIT_NAME + " characters is the maximum.");
    }
}

From source file:com.xing.api.data.profile.CompanyTest.java

@Test
public void setTitleThrowsIfLimitExited() throws Exception {
    Company company = new Company();
    try {// www . j ava 2  s.co  m
        company.title(leftPad("longTitle", Company.LIMIT_TITLE + 1, '*'));
        fail();
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage())
                .isEqualTo("Argument Title too long. " + Company.LIMIT_TITLE + " characters is the maximum.");
    }
}

From source file:com.xing.api.data.profile.CompanyTest.java

@Test
public void setUrlThrowsIfLimitExited() throws Exception {
    Company company = new Company();
    try {//from  ww  w  .j  av a 2 s .co m
        company.url(leftPad("longUrl", Company.LIMIT_URL + 1, '*'));
        fail();
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage())
                .isEqualTo("Argument Url too long. " + Company.LIMIT_URL + " characters is the maximum.");
    }
}

From source file:com.xing.api.data.profile.CompanyTest.java

@Test
public void setDescriptionThrowsIfLimitExited() throws Exception {
    Company company = new Company();
    try {//from  ww w  .j ava  2  s. c om
        company.description(leftPad("longDescription", Company.LIMIT_DESCRIPTION + 1, '*'));
        fail();
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage()).isEqualTo(
                "Argument Description too long. " + Company.LIMIT_DESCRIPTION + " characters is the maximum.");
    }
}

From source file:de.zalando.spring.cloud.config.aws.kms.test.EncryptionCLI.java

@Override
public void run(final String... args) {
    try {/*from  w  w  w.j a v  a  2 s.  com*/
        checkArgument(args.length >= 3, "Too few arguments.");

        final String text = args[1];
        final AWSKMSClient kms = new AWSKMSClient();
        kms.setRegion(fromName(args[2]));

        switch (args[0]) {

        case "encrypt":
            checkArgument(args.length == 4, "Too few arguments.");
            System.out.println(new KmsTextEncryptor(kms, args[3]).encrypt(text));
            break;

        case "decrypt":
            System.out.println(new KmsTextEncryptor(kms, null).decrypt(text));
            break;

        default:

            break;
        }
    } catch (final IllegalArgumentException e) {
        System.out.println(e.getMessage() + " Usage:\n" //
                + "./run.sh encrypt 'plaintext' eu-west-1 ${kmsKeyId}\n" //
                + "./run.sh decrypt 'base64cipherText' eu-west-1");
    }
}

From source file:com.alfresco.orm.UpdateHelper.java

public void update(final AlfrescoContent alfrescoContent) throws ORMException {
    try {//from  w  w w. j a va  2 s  .  co m
        Map<QName, Serializable> properties = ORMUtil.getAlfrescoProperty(alfrescoContent);
        ORMUtil.saveProperties(alfrescoContent, properties, serviceRegistry.getNodeService(),
                restrictedPropertiesForUpdate);
        ORMUtil.executeCustomeMethodForProperty(alfrescoContent, beanFactory);
        ORMUtil.executeAssociation(alfrescoContent, beanFactory, serviceRegistry);
    } catch (IllegalArgumentException e) {
        throw new ORMException(e.getMessage(), e);
    } catch (SecurityException e) {
        throw new ORMException(e.getMessage(), e);
    } catch (IllegalAccessException e) {
        throw new ORMException(e.getMessage(), e);
    } catch (NoSuchMethodException e) {
        throw new ORMException(e.getMessage(), e);
    } catch (InvocationTargetException e) {
        throw new ORMException(e.getMessage(), e);
    } catch (InstantiationException e) {
        throw new ORMException(e.getMessage(), e);
    }
}

From source file:example.users.webservice.persistence.mock.UsersMockDao.java

private void initUsers() {
    Calendar calendar = new GregorianCalendar();
    calendar.setLenient(false);// w  ww .  j  av a 2  s. c om
    calendar.set(1984, 1, 23);
    try {
        User user1 = new User("Antonio", "Genovese", "Regist", calendar.getTime());
        calendar.set(1981, 6, 25);
        User user2 = new User("Gianluca", "Genovese", "Gianblues", calendar.getTime());
        calendar.set(2011, 7, 7);
        User user3 = new User("Gabriele", "Genovese", "Gaby", calendar.getTime());
        this.users.add(user1);
        this.users.add(user2);
        this.users.add(user3);
    } catch (IllegalArgumentException ex) {
        logger.error("Exception Calendar " + ex.getMessage());
    }

}

From source file:com.puppycrawl.tools.checkstyle.checks.indentation.CommentsIndentationCheckTest.java

@Test
public void testVisitToken() throws Exception {
    final CommentsIndentationCheck check = new CommentsIndentationCheck();
    DetailAST methodDef = new DetailAST();
    methodDef.setType(TokenTypes.METHOD_DEF);
    methodDef.setText("methodStub");
    try {//from  w  w  w . ja va 2s  .c  o m
        check.visitToken(methodDef);
        Assert.fail();
    } catch (IllegalArgumentException e) {
        final String msg = e.getMessage();
        Assert.assertEquals("Unexpected token type: methodStub", msg);
    }
}

From source file:ar.com.zauber.commons.web.proxy.impl.ValidateURLRequestMapperTest.java

/** @throws Exception on error */
public final void testNullArgument() throws Exception {
    final URLRequestMapper v = new ValidateURLRequestMapper(
            new InmutableURLRequestMapper(new InmutableURLResult(new URL("http://localhost"))));
    try {//from  w  w w . j av a  2  s.  co m
        v.getProxiedURLFromRequest(null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("request can't be null", e.getMessage());
    }
}

From source file:com.graphhopper.http.InfoServlet.java

@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    try {/*from w  ww. java 2 s. c  o  m*/
        writeInfos(req, res);
    } catch (IllegalArgumentException ex) {
        writeError(res, SC_BAD_REQUEST, ex.getMessage());
    } catch (Exception ex) {
        logger.error("Error while executing request: " + req.getQueryString(), ex);
        writeError(res, SC_INTERNAL_SERVER_ERROR, "Problem occured:" + ex.getMessage());
    }
}