List of usage examples for java.lang IllegalArgumentException getMessage
public String getMessage()
From source file:net.sf.jooreports.openoffice.converter.OpenOfficeDocumentConverterTest.java
public void testUnsupportedConversion() throws IOException { DocumentFormat inputFormat = new DocumentFormat("XYZ", DocumentFamily.TEXT, "application/xyz", "xyz"); DocumentFormat outputFormat = new DocumentFormat("ABC", "application/abc", "abc"); try {// w ww. j ava 2 s. c o m getDocumentConverter().convert(getTestFile("unknown-type.xyz"), inputFormat, new File("unused"), outputFormat); fail("should throw exception"); } catch (IllegalArgumentException argumentException) { assertTrue(argumentException.getMessage().startsWith("unsupported conversion")); } }
From source file:ComboBoxDemo2.java
/** Formats and displays today's date. */ public void reformat() { Date today = new Date(); SimpleDateFormat formatter = new SimpleDateFormat(currentPattern); try {// w w w. ja va 2 s .c om String dateString = formatter.format(today); result.setForeground(Color.black); result.setText(dateString); } catch (IllegalArgumentException iae) { result.setForeground(Color.red); result.setText("Error: " + iae.getMessage()); } }
From source file:com.acc.storefront.interceptors.beforecontroller.SetLanguageBeforeControllerHandler.java
@Override public boolean beforeController(final HttpServletRequest request, final HttpServletResponse response, final HandlerMethod handler) { if (isGetMethod(request)) { final String languageIdentifier = request.getParameter(languageParameter); if (StringUtils.isNotBlank(languageIdentifier)) { try { final LanguageModel languageModel = languageResolver.getLanguage(languageIdentifier); commonI18NService.setCurrentLanguage(languageModel); } catch (final IllegalArgumentException ile) { LOG.warn("Can not set session language to [" + languageIdentifier + "]. " + ile.getMessage()); if (LOG.isDebugEnabled()) { LOG.debug("Exception setting the language", ile); }/*www . j a v a 2s . c o m*/ } } } return true; }
From source file:org.camelcookbook.ws.multipleoperations.OperationSpringTest.java
@Test public void testOperationInvalidOperationNameSpring() { try {//from w ww .j a v a2 s. co m Object response = template.requestBodyAndHeader(String.format( "cxf:http://localhost:%d/paymentServicev2?serviceClass=org.camelcookbook.ws.payment_service_v2.Payment", port1), "bogus", "operationName", "invalid"); fail("Should fail"); } catch (CamelExecutionException e) { IllegalArgumentException fault = assertIsInstanceOf(IllegalArgumentException.class, e.getCause()); log.info("reason = {}", fault.getMessage()); } }
From source file:org.cbioportal.session_service.service.internal.SessionServiceImpl.java
@Override public List<Session> getSessionsByQuery(String source, String type, String field, String value) throws SessionQueryInvalidException { try {/*from ww w . j a v a2s . c o m*/ return sessionRepository.findBySourceAndTypeAndQuery(source, type, field, value); } catch (IllegalArgumentException e) { throw new SessionQueryInvalidException(e.getMessage()); } catch (UncategorizedMongoDbException e) { throw new SessionQueryInvalidException(e.getMessage()); } }
From source file:org.impalaframework.extension.mvc.annotation.collector.RequestParameterArgumentCollectorTest.java
public void testGetArgumentMissingRequired() { Annotation annotation = getParamAnnotation(RequestParameterRequiredStringClass.class, "method1", String.class); RequestParameterArgumentCollector collector = new RequestParameterArgumentCollector( (RequestParam) annotation, String.class); expect(request.getParameter("param1")).andReturn(null); replayMocks();// w w w . j a v a 2 s . c o m try { collector.getArgument(request, implicitModel, typeConverter); fail(); } catch (IllegalArgumentException e) { assertEquals("Parameter 'param1' is required.", e.getMessage()); } verifyMocks(); }
From source file:org.elasticsearch.client.HeapBufferedAsyncResponseConsumerTests.java
public void testConfiguredBufferLimit() throws Exception { try {//from www . j ava 2 s . c o m new HeapBufferedAsyncResponseConsumer(randomIntBetween(Integer.MIN_VALUE, 0)); } catch (IllegalArgumentException e) { assertEquals("bufferLimit must be greater than 0", e.getMessage()); } try { new HeapBufferedAsyncResponseConsumer(0); } catch (IllegalArgumentException e) { assertEquals("bufferLimit must be greater than 0", e.getMessage()); } int bufferLimit = randomIntBetween(1, MAX_TEST_BUFFER_SIZE - 100); HeapBufferedAsyncResponseConsumer consumer = new HeapBufferedAsyncResponseConsumer(bufferLimit); bufferLimitTest(consumer, bufferLimit); }
From source file:framework.GlobalHelpers.java
private static Action findActionOnProduction(String className, String action) { // use reflectasm for fast relection try {/*w w w . j a v a2 s . c o m*/ Action cached = actionsCache.get(className, action); if (cached != null) { return cached; } else { Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className); MethodAccess access = MethodAccess.get(clazz); int index = access.getIndex(action); Method actionMethod = clazz.getDeclaredMethods()[index]; Action instance = new Action(action, getControllerInstance(clazz), actionMethod, access, index); actionsCache.put(className, action, instance); return instance; } } catch (IllegalArgumentException e) { actionsCache.put(className, action, new Action(className, action)); return null; } catch (ClassNotFoundException e) { actionsCache.put(className, action, new Action(className, action)); return null; } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:it.txt.ens.core.impl.test.BasicENSResourceTest.java
private ENSResource testCreation(String host, String path, String namespace, String pattern) { ENSResource resource = null;/* w w w. j av a 2 s . c o m*/ BasicENSResourceFactory factory = new BasicENSResourceFactory(); try { if (path == null) resource = factory.create(host, namespace, pattern); else resource = factory.create(host, path, namespace, pattern); assertEquals("Unexpected host", host, resource.getHost()); if (path == null) assertEquals("Unexpected path", ENSResource.DEFAULT_PATH, resource.getPath()); else if (path.startsWith("/")) assertEquals("Unexpected path", path, resource.getPath()); else assertEquals("Unexpected path", "/" + path, resource.getPath()); assertEquals("Unexpected namespace", namespace, resource.getNamespace()); assertEquals("Unexpected pattern", pattern, resource.getPattern()); } catch (IllegalArgumentException e) { fail(e.getMessage()); e.printStackTrace(); } catch (URIBuildingException e) { fail(e.getMessage()); e.printStackTrace(); } return resource; }
From source file:com.moz.fiji.schema.tools.TestCreateTableTool.java
@Test public void testCreateUnhashedTableWithNumRegions() throws Exception { final FijiTableLayout layout = FijiTableLayout.newLayout(FijiTableLayouts.getFooUnhashedTestLayout()); final File layoutFile = getTempLayoutFile(layout); final FijiURI tableURI = FijiURI.newBuilder(getFiji().getURI()).withTableName(layout.getName()).build(); try {/*from www.j av a2 s. co m*/ runTool(new CreateTableTool(), "--table=" + tableURI, "--layout=" + layoutFile, "--num-regions=4"); fail("Should throw InvalidLayoutException"); } catch (IllegalArgumentException iae) { assertTrue(iae.getMessage() .startsWith("May not use numRegions > 1 if row key hashing is disabled in the layout")); } }