List of usage examples for java.lang IllegalArgumentException getMessage
public String getMessage()
From source file:com.moz.fiji.schema.tools.TestCreateTableTool.java
@Test public void testCreateHashedTableWithSplitKeys() throws Exception { final FijiTableLayout layout = FijiTableLayouts.getTableLayout(FijiTableLayouts.FOO_TEST_LEGACY); final File layoutFile = getTempLayoutFile(layout); final FijiURI tableURI = FijiURI.newBuilder(getFiji().getURI()).withTableName(layout.getName()).build(); try {//from w w w.ja v a 2 s .c om runTool(new CreateTableTool(), "--table=" + tableURI, "--layout=" + layoutFile, "--split-key-file=file://" + getRegionSplitKeyFile()); fail("Should throw IllegalArgumentException"); } catch (IllegalArgumentException iae) { assertTrue(iae.getMessage() .startsWith("Row key hashing is enabled for the table. Use --num-regions=N instead.")); } }
From source file:com.realdolmen.rdfleet.webmvc.controllers.rd.OrderCarController.java
@RequestMapping(value = "/{id}/order", method = RequestMethod.GET) public String getOrderNewCar(@PathVariable("id") Long id, Model model, @ModelAttribute("employeeCar") EmployeeCar employeeCar) { if (!canOrderNewCar()) return "redirect:/index"; Authentication auth = SecurityContextHolder.getContext().getAuthentication(); try {//from w ww. j a v a 2 s .co m employeeCar.setSelectedCar(carService.findByIdAndIsOrderable(id)); employeeCar.setCarOptions(new ArrayList<>()); model.addAttribute("functionalLevel", employeeService.getFunctionalLevelByEmail(auth.getName())); model.addAttribute("carOptions", carOptionService.findAllCarOptionsByTowingBracketPossibility( employeeCar.getSelectedCar().isTowingBracketPossibility())); } catch (IllegalArgumentException e) { model.addAttribute("error", e.getMessage()); } return "rd/car.order"; }
From source file:camelinaction.SpringSplitterStopOnExceptionABCTest.java
@Test public void testSplitStopOnException() throws Exception { MockEndpoint split = getMockEndpoint("mock:split"); // we expect 1 messages to be split since the 2nd message should fail split.expectedBodiesReceived("Camel rocks"); // and no combined aggregated message since we stop on exception MockEndpoint result = getMockEndpoint("mock:result"); result.expectedMessageCount(0);/*from w w w.java 2 s.c o m*/ // now send a message with an unknown letter (F) which forces an exception to occur try { template.sendBody("direct:start", "A,F,C"); fail("Should have thrown an exception"); } catch (CamelExecutionException e) { CamelExchangeException cause = assertIsInstanceOf(CamelExchangeException.class, e.getCause()); IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause()); assertEquals("Key not a known word F", iae.getMessage()); } assertMockEndpointsSatisfied(); }
From source file:com.realdolmen.rdfleet.webmvc.controllers.rd.OrderCarController.java
@RequestMapping(value = "/summary", method = RequestMethod.GET) public String getSummaryCar(@ModelAttribute("employeeCar") EmployeeCar employeeCar, @ModelAttribute("order") Order order, Model model) { if (!canOrderNewCar() || employeeCar == null) return "redirect:/index"; Authentication auth = SecurityContextHolder.getContext().getAuthentication(); try {/*from w w w . j a v a2 s. c o m*/ Order orderForEmployee = employeeService.createOrderForEmployee(auth.getName(), employeeCar); order.setAmountPaidByCompany(orderForEmployee.getAmountPaidByCompany()); order.setAmountPaidByEmployee(orderForEmployee.getAmountPaidByEmployee()); order.setOrderedCar(orderForEmployee.getOrderedCar()); model.addAttribute("functionalLevel", employeeService.getFunctionalLevelByEmail(auth.getName())); model.addAttribute("car", carService.findById(employeeCar.getSelectedCar().getId())); } catch (IllegalArgumentException e) { model.addAttribute("error", e.getMessage()); } return "rd/car.summary"; }
From source file:org.springframework.cloud.dataflow.rest.util.HttpClientConfigurerTests.java
/** * Basic test ensuring that an exception is thrown if the proxy * Uri is null.// w ww . j av a 2 s. c o m */ @Test public void testHttpClientWithNullProxyUri() throws Exception { final URI targetHost = new URI("http://test.com"); final HttpClientConfigurer builder = HttpClientConfigurer.create(targetHost); try { builder.withProxyCredentials(null, null, null); } catch (IllegalArgumentException e) { Assert.assertEquals("The proxyUri must not be null.", e.getMessage()); return; } fail("Expected an IllegalArgumentException to be thrown."); }
From source file:com.kitac.kinesissamples.consumer.Consumer.java
/** * Converts a byte array to a string object that is JSON format. *///from w w w . j a va2s.c om private String toJsonString(byte[] source) { String retVal; byte[] src; try { // Decode Base64 encoded string. src = Base64.getDecoder().decode(source); } catch (IllegalArgumentException e) { LOG.severe(e.getMessage()); src = null; } if (src != null) { try { retVal = new String(src, "UTF-8"); } catch (UnsupportedEncodingException ex) { Logger.getLogger(Consumer.class.getName()).log(Level.SEVERE, null, ex); retVal = new String(src); } } else { retVal = ""; } return retVal; }
From source file:com.itemanalysis.jmetrik.graph.histogram.HistogramPanel.java
private void processCommand() { try {/*w w w . j a va2 s . com*/ chartTitle = command.getFreeOption("title").getString(); chartSubtitle = command.getFreeOption("subtitle").getString(); if (command.getFreeOption("groupvar").hasValue()) { hasGroupingVariable = true; } xlabel = command.getFreeOption("variable").getString(); ylabel = ""; if (command.getSelectOneOption("yaxis").isValueSelected("freq")) { ylabel = "Frequency"; } else { ylabel = "Density"; } } catch (IllegalArgumentException ex) { logger.fatal(ex.getMessage(), ex); this.firePropertyChange("error", "", "Error - Check log for details."); } }
From source file:it.txt.ens.core.impl.test.BasicENSResourceTest.java
@Test public void testCreation() { System.out.println(//from www . ja v a 2 s.c om "Creation of a " + BasicENSResource.class.getSimpleName() + " instance with full constructor"); String host = "www.myhost.com"; String path = "myENSService"; String namespace = "this is my namespace"; String pattern = "this.is.my.ens.pattern.*"; ENSResource resource; try { resource = testCreation(host, path, namespace, pattern); testURI(resource); } catch (IllegalArgumentException e) { fail(e.getMessage()); e.printStackTrace(); } System.out.println("TEST SUCCEEDED"); System.out.println("-----------------------------------------------------------------------"); System.out.println( "Creation of a " + BasicENSResource.class.getSimpleName() + " instance with 3-params constructor"); host = "www.myhost.com"; namespace = "this is my second namespace"; pattern = "this.is.my.second.ens.pattern.*"; try { resource = testCreation(host, null, namespace, pattern); testURI(resource); } catch (IllegalArgumentException e) { fail(e.getMessage()); e.printStackTrace(); } System.out.println("TEST SUCCEEDED"); }
From source file:ch.systemsx.cisd.openbis.generic.shared.util.WebClientFilesUpdaterTest.java
@Test public final void testConstructor() { boolean fail = true; try {/*from w w w. j a va2 s. c o m*/ new WebClientFilesUpdater(null); } catch (final AssertionError e) { fail = false; } assertFalse(fail); new WebClientFilesUpdater(workingDirectory.getPath()); try { new WebClientFilesUpdater(workingDirectory.getPath(), "dummy"); fail("IllegalArgumentException expected."); } catch (final IllegalArgumentException ex) { assertEquals("Technology 'dummy' must be one of '[demo]'.", ex.getMessage()); } }
From source file:com.att.aro.core.cloud.aws.AwsRepository.java
private void constructRepo(String accessId, String secretKey, String region, String bucketName, ClientConfiguration config) {//www .ja v a2 s .com System.setProperty("java.net.useSystemProxies", "true"); if (isNotBlank(accessId) && isNotBlank(secretKey) && isNotBlank(region) && isNotBlank(bucketName)) { try { AWSCredentials creds = new BasicAWSCredentials(accessId, secretKey); Regions regions = Regions.fromName(region); this.bucketName = bucketName; s3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(creds)) .withRegion(regions).withClientConfiguration(config).build(); transferMgr = TransferManagerBuilder.standard().withS3Client(s3Client).build(); } catch (IllegalArgumentException ille) { LOGGER.error(ille.getMessage(), ille); } catch (Exception exp) { LOGGER.error(exp.getMessage(), exp); } } }