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.hp.mqm.clt.SettingsTest.java

@Test
public void testSettings_empty() throws IOException, URISyntaxException {
    Settings settings = new Settings();
    try {/*from  w w  w  . jav a 2 s  .co m*/
        settings.load(null);
        Assert.fail();
    } catch (IllegalArgumentException e) {
        Assert.assertEquals("Can not read the default configuration file: config.properties", e.getMessage());
    }
    Assert.assertNull(settings.getServer());
    Assert.assertNull(settings.getSharedspace());
    Assert.assertNull(settings.getWorkspace());
    Assert.assertNull(settings.getUser());
    Assert.assertNull(settings.getProxyHost());
    Assert.assertNull(settings.getProxyPort());
    Assert.assertNull(settings.getProxyUser());

    settings.setDefaultConfigFilenameProvider(new TestDefaultConfigFilenameProvider());
    settings.load(null);
    Assert.assertEquals("http://localhost:8282/qcbin", settings.getServer());
    Assert.assertEquals(Integer.valueOf(1011), settings.getSharedspace());
    Assert.assertEquals(Integer.valueOf(1012), settings.getWorkspace());
    Assert.assertEquals("user", settings.getUser());
    Assert.assertEquals("some.proxy.hpe.com", settings.getProxyHost());
    Assert.assertNull(settings.getProxyPort());
    Assert.assertEquals("proxyuser", settings.getProxyUser());
}

From source file:com.ngdata.sep.impl.SepModelImpl.java

@Override
public boolean removeSubscriptionSilent(String name) throws IOException {
    ReplicationAdmin replicationAdmin = new ReplicationAdmin(hbaseConf);
    try {/*  w  w w  .j  av  a2s.  c  om*/
        String internalName = toInternalSubscriptionName(name);
        if (!replicationAdmin.listPeers().containsKey(internalName)) {
            log.error("Requested to remove a subscription which does not exist, skipping silently: '" + name
                    + "'");
            return false;
        } else {
            try {
                replicationAdmin.removePeer(internalName);
            } catch (IllegalArgumentException e) {
                if (e.getMessage().equals("Cannot remove inexisting peer")) { // see ReplicationZookeeper
                    return false;
                }
                throw e;
            } catch (Exception e) {
                // HBase 0.95+ throws at least one extra exception: ReplicationException which we convert into IOException
                throw new IOException(e);
            }
        }
        String basePath = baseZkPath + "/" + internalName;
        try {
            ZkUtil.deleteNode(zk, basePath + "/hbaseid");
            for (String child : zk.getChildren(basePath + "/rs", false)) {
                ZkUtil.deleteNode(zk, basePath + "/rs/" + child);
            }
            ZkUtil.deleteNode(zk, basePath + "/rs");
            ZkUtil.deleteNode(zk, basePath);
        } catch (InterruptedException ie) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(ie);
        } catch (KeeperException ke) {
            log.error("Cleanup in zookeeper failed on " + basePath, ke);
        }
        return true;
    } finally {
        Closer.close(replicationAdmin);
    }
}

From source file:net.dv8tion.jda.core.handle.MessageUpdateHandler.java

private Long handleDefaultMessage(JSONObject content) {
    Message message;/*from  w ww.  jav a  2  s.c  o  m*/
    try {
        message = api.getEntityBuilder().createMessage(content);
    } catch (IllegalArgumentException e) {
        switch (e.getMessage()) {
        case EntityBuilder.MISSING_CHANNEL: {
            final long channelId = content.getLong("channel_id");
            api.getEventCache().cache(EventCache.Type.CHANNEL, channelId,
                    () -> handle(responseNumber, allContent));
            EventCache.LOG
                    .debug("Received a message update for a channel that JDA does not currently have cached");
            return null;
        }
        case EntityBuilder.MISSING_USER: {
            final long authorId = content.getJSONObject("author").getLong("id");
            api.getEventCache().cache(EventCache.Type.USER, authorId, () -> handle(responseNumber, allContent));
            EventCache.LOG
                    .debug("Received a message update for a user that JDA does not currently have cached");
            return null;
        }
        default:
            throw e;
        }
    }

    switch (message.getChannelType()) {
    case TEXT: {
        TextChannel channel = message.getTextChannel();
        if (api.getGuildLock().isLocked(channel.getGuild().getIdLong())) {
            return channel.getGuild().getIdLong();
        }
        api.getEventManager().handle(new GuildMessageUpdateEvent(api, responseNumber, message));
        break;
    }
    case PRIVATE: {
        api.getEventManager().handle(new PrivateMessageUpdateEvent(api, responseNumber, message));
    }
    case GROUP: {
        api.getEventManager().handle(new GroupMessageUpdateEvent(api, responseNumber, message));
        break;
    }

    default:
        WebSocketClient.LOG
                .warn("Received a MESSAGE_UPDATE with a unknown MessageChannel ChannelType. JSON: " + content);
        return null;
    }

    //Combo event
    api.getEventManager().handle(new MessageUpdateEvent(api, responseNumber, message));
    return null;
}

From source file:net.sf.jooreports.openoffice.converter.OpenOfficeDocumentConverterTest.java

public void testNullArgumentWithStreams() {
    DocumentFormat inputFormat = new DocumentFormat("XYZ", "application/xyz", "xyz");
    DocumentFormat outputFormat = new DocumentFormat("ABC", "application/abc", "abc");

    InputStream inputStream = new ByteArrayInputStream(new byte[0]);
    OutputStream outputStream = new ByteArrayOutputStream();

    try {/*from  w  w w  .  j av  a  2s. c o m*/
        getDocumentConverter().convert(null, inputFormat, outputStream, outputFormat);
        fail("should throw exception");
    } catch (IllegalArgumentException argumentException) {
        assertEquals("inputStream is null", argumentException.getMessage());
    }

    try {
        getDocumentConverter().convert(inputStream, null, outputStream, outputFormat);
        fail("should throw exception");
    } catch (IllegalArgumentException argumentException) {
        assertEquals("inputFormat is null", argumentException.getMessage());
    }

    try {
        getDocumentConverter().convert(inputStream, inputFormat, null, outputFormat);
        fail("should throw exception");
    } catch (IllegalArgumentException argumentException) {
        assertEquals("outputStream is null", argumentException.getMessage());
    }

    try {
        getDocumentConverter().convert(inputStream, inputFormat, outputStream, null);
        fail("should throw exception");
    } catch (IllegalArgumentException argumentException) {
        assertEquals("outputFormat is null", argumentException.getMessage());
    }
}

From source file:com.netflix.spinnaker.halyard.deploy.config.v1.ConfigParser.java

public <T> T read(Path path, Class<T> tClass) {
    try {//from   w  w w .  ja v  a  2 s.  co  m
        InputStream is = new FileInputStream(path.toFile());
        Object obj = yamlParser.load(is);
        return objectMapper.convertValue(obj, tClass);
    } catch (IllegalArgumentException e) {
        throw new HalException(new ProblemBuilder(Problem.Severity.FATAL,
                "Failed to load " + tClass.getSimpleName() + " config: " + e.getMessage()).build());
    } catch (FileNotFoundException e) {
        throw new HalException(new ProblemBuilder(Problem.Severity.FATAL,
                "Failed to find " + tClass.getSimpleName() + " config: " + e.getMessage()).build());
    }
}

From source file:com.microsoft.rest.ValidatorTests.java

@Test
public void validateList() throws Exception {
    ListWrapper body = new ListWrapper();
    try {//from   w ww.jav a2  s  . co m
        body.list = null;
        Validator.validate(body); // fail
        fail();
    } catch (IllegalArgumentException ex) {
        Assert.assertTrue(ex.getMessage().contains("list is required"));
    }
    body.list = new ArrayList<StringWrapper>();
    Validator.validate(body); // pass
    StringWrapper wrapper = new StringWrapper();
    wrapper.value = "valid";
    body.list.add(wrapper);
    Validator.validate(body); // pass
    body.list.add(null);
    Validator.validate(body); // pass
    body.list.add(new StringWrapper());
    try {
        Validator.validate(body); // fail
        fail();
    } catch (IllegalArgumentException ex) {
        Assert.assertTrue(ex.getMessage().contains("list.value is required"));
    }
}

From source file:com.microsoft.rest.ValidatorTests.java

@Test
public void validateMap() throws Exception {
    MapWrapper body = new MapWrapper();
    try {//from w  w  w  . ja  v  a2 s.  com
        body.map = null;
        Validator.validate(body); // fail
        fail();
    } catch (IllegalArgumentException ex) {
        Assert.assertTrue(ex.getMessage().contains("map is required"));
    }
    body.map = new HashMap<LocalDate, StringWrapper>();
    Validator.validate(body); // pass
    StringWrapper wrapper = new StringWrapper();
    wrapper.value = "valid";
    body.map.put(new LocalDate(1, 2, 3), wrapper);
    Validator.validate(body); // pass
    body.map.put(new LocalDate(1, 2, 3), null);
    Validator.validate(body); // pass
    body.map.put(new LocalDate(1, 2, 3), new StringWrapper());
    try {
        Validator.validate(body); // fail
        fail();
    } catch (IllegalArgumentException ex) {
        Assert.assertTrue(ex.getMessage().contains("map.value is required"));
    }
}

From source file:nz.net.catalyst.mobile.dds.CapabilitySerivceControllerTest.java

@Test
public void testMissingUserAgent() throws Exception {
    HashMap<String, String> headers = new HashMap<String, String>();
    headers.put("user-agent-missing",
            "Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaE71-1/100.07.57; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413");
    String headersStr = mapper.writeValueAsString(headers);

    try {/* ww w . j av a  2s . c om*/
        csController.getCapabilities(headersStr, new String[] { "model_name" });
        fail("exception expected");
    } catch (IllegalArgumentException e) {
        assertEquals("required http header 'user-agent' is missing", e.getMessage());
        MockHttpServletResponse response = new MockHttpServletResponse();
        csController.handleParseProblems(e, response);
        assertEquals(400, response.getStatus());
    }

}

From source file:org.springframework.cloud.dataflow.rest.client.DataflowTemplateTests.java

@Test
public void testDataFlowTemplateContructorWithNullUri() throws URISyntaxException {

    try {//from www .  j a va2 s  .  c om
        new DataFlowTemplate(null);
    } catch (IllegalArgumentException e) {
        assertEquals("The provided baseURI must not be null.", e.getMessage());
        return;
    }

    fail("Expected an IllegalArgumentException to be thrown.");
}

From source file:org.obiba.onyx.core.service.impl.DefaultAppointmentManagementServiceImplTest.java

@Test
public void testInitializeNoInputDirectoryString() {
    try {//  w w  w.  jav a  2s . com
        appointmentServiceImpl.initialize();
        fail("Should get IllegalArgumentException.");
    } catch (IllegalArgumentException e) {
        Assert.assertEquals("DefaultAppointmentManagementServiceImpl: InputDirectory should not be null",
                e.getMessage());
    }
}