List of usage examples for java.lang IllegalArgumentException getMessage
public String getMessage()
From source file:com.yeahmobi.yunit.DbUnitTestExecutionListenerPrepareTests.java
@Test public void shouldFailIfDatasetLoaderCannotBeCreated() throws Exception { addBean("dbUnitDatabaseConnection", this.databaseConnection); ExtendedTestContextManager testContextManager = new ExtendedTestContextManager( NonCreatableDataSetLoader.class); try {//w w w . jav a2s . co m testContextManager.prepareTestInstance(); } catch (IllegalArgumentException e) { assertEquals("Unable to create data set loader instance for class " + "com.yeahmobi.yunit.DbUnitTestExecutionListenerPrepareTests$" + "AbstractCustomDataSetLoader", e.getMessage()); } }
From source file:it.geosolutions.opensdi2.configurations.ConfigurationTest.java
/** * Check if the scopeID is well extracted from the path *//*from w ww.j a v a 2 s. co m*/ @Test public void scopeIDTest() { MockHttpServletRequest req = new MockHttpServletRequest(); MockModule mm = new MockModule(); req.setPathInfo("moduleid/instanceid"); assertEquals("moduleid", mm.getScopeIDTest(req)); req.setPathInfo("moduleid/instanceid/aother/path/parts"); assertEquals("moduleid", mm.getScopeIDTest(req)); req.setPathInfo("moduleid/instanceid/"); assertEquals("moduleid", mm.getScopeIDTest(req)); req.setPathInfo("/moduleid/instanceid/"); assertEquals("moduleid", mm.getScopeIDTest(req)); req.setPathInfo("/moduleid/instanceid/other/path/parts/"); assertEquals("moduleid", mm.getScopeIDTest(req)); req.setPathInfo("/////moduleid/instanceid/other/path/parts/"); assertEquals("moduleid", mm.getScopeIDTest(req)); boolean exceptionOccurred = false; req.setPathInfo(""); try { mm.getScopeIDTest(req); } catch (IllegalArgumentException ise) { assertEquals("no scopeID is found after all the possible attemps... this should never happen...", ise.getMessage()); exceptionOccurred = true; } if (!exceptionOccurred) { fail(); } exceptionOccurred = false; req.setPathInfo("///"); try { mm.getScopeIDTest(req); } catch (IllegalArgumentException ise) { assertEquals("no scopeID is found... this should never happen...", ise.getMessage()); exceptionOccurred = true; } if (!exceptionOccurred) { fail(); } }
From source file:com.thoughtworks.go.service.ConfigRepositoryTest.java
@Test public void shouldThrowExceptionIfRevisionNotFound() throws Exception { configRepo.checkin(goConfigRevision("v1", "md5-1")); try {/*from w w w . ja va 2 s. c o m*/ configRepo.configChangesFor("md5-1", "md5-not-found"); fail("Should have failed"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("There is no config version corresponding to md5: 'md5-not-found'")); } try { configRepo.configChangesFor("md5-not-found", "md5-1"); fail("Should have failed"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("There is no config version corresponding to md5: 'md5-not-found'")); } }
From source file:com.twitter.hraven.datasource.AppVersionService.java
/** * Returns the list of distinct versions for the given application * sorted in reverse chronological order * * @param cluster//from w w w . ja v a 2 s.c om * @param user * @param appId * @return the list of versions sorted in reverse chronological order * (the list will be empty if no versions are found) * @throws IOException */ public List<VersionInfo> getDistinctVersions(String cluster, String user, String appId) throws IOException { Get get = new Get(getRowKey(cluster, user, appId)); List<VersionInfo> versions = Lists.newArrayList(); Long ts = 0L; Result r = this.versionsTable.get(get); if (r != null && !r.isEmpty()) { for (KeyValue kv : r.list()) { ts = 0L; try { ts = Bytes.toLong(kv.getValue()); versions.add(new VersionInfo(Bytes.toString(kv.getQualifier()), ts)); } catch (IllegalArgumentException e1) { // Bytes.toLong may throw IllegalArgumentException, although unlikely. LOG.error( "Caught conversion error while converting timestamp to long value " + e1.getMessage()); // rethrow the exception in order to propagate it throw e1; } } } if (versions.size() > 0) { Collections.sort(versions); } return versions; }
From source file:com.github.springtestdbunit.DbUnitTestExecutionListenerPrepareTests.java
@Test public void shouldFailIfDatasetLoaderCannotBeCreated() throws Exception { addBean("dbUnitDatabaseConnection", this.databaseConnection); ExtendedTestContextManager testContextManager = new ExtendedTestContextManager( NonCreatableDataSetLoader.class); try {//from www . java 2 s . c om testContextManager.prepareTestInstance(); } catch (IllegalArgumentException e) { assertEquals("Unable to create data set loader instance for class " + "com.github.springtestdbunit.DbUnitTestExecutionListenerPrepareTests$" + "AbstractCustomDataSetLoader", e.getMessage()); } }
From source file:com.nec.harvest.controller.KoguchiController.java
/** * Load koguchi page with parameters organization code and current date * //www. j a va 2 s .co m * @param orgCode * Organization code on request path * @param monthly * Current business day on request path * @param model * Model to update and return to view * @param businessDay * Business day on session * @param orgCodeFromSession * Organization code on session * @return Logic page view */ @RequestMapping(value = "/{orgCode}/{monthly}", method = RequestMethod.GET) public String render(@SessionAttribute(Constants.SESS_ORGANIZATION_CODE) String userOrgCode, @SessionAttribute(Constants.SESS_BUSINESS_DAY) Date businessDay, @PathVariable String proGNo, @PathVariable String orgCode, @PathVariable @DateTimeFormat(pattern = "yyyyMM") Date monthly, final Model model) { logger.info("Koguchi page view rendering..."); // model.addAttribute(PRINTABLE, true); model.addAttribute(PROCESSING_MONTH, monthly); try { // Get petty cash data List<PettyCash> pettyCashes = pettyCashService.findByOrgCodeAndBusinessDay(userOrgCode, monthly); model.addAttribute(PETTY_CASH_LIST, pettyCashes); if (pettyCashes == null || pettyCashes.size() == 0) { model.addAttribute(ERROR, false); model.addAttribute(ERROR_MESSAGE, MessageHelper.get(MsgConstants.CM_QRY_M01)); } } catch (IllegalArgumentException ex) { logger.warn(ex.getMessage()); } catch (ServiceException ex) { logger.error(ex.getMessage(), ex); // ??????????? model.addAttribute(ERROR, true); model.addAttribute(ERROR_MESSAGE, getSystemError()); return getViewName(); } try { // Check next and previous month is available Date previousMonth = DateUtil.monthsToSubtract(businessDay, 12); Date nextMonth = DateUtil.monthsToSubtract(businessDay, 1); if (monthly.compareTo(previousMonth) > 0) { model.addAttribute(PREVIOUS_MONTH, DateUtil.monthsToSubtract(monthly, 1)); } if (monthly.compareTo(nextMonth) <= 0) { model.addAttribute(NEXT_MONTH, DateUtil.monthsToAdd(monthly, 1)); } } catch (IllegalArgumentException ex) { logger.warn(ex.getMessage()); } try { // Get small category data List<SmallCategory> smallCategories = smallCategoryService.findAll(); model.addAttribute(SMALL_CATEGORY_LIST, smallCategories); } catch (IllegalArgumentException ex) { logger.warn(ex.getMessage()); } catch (ServiceException ex) { logger.error(ex.getMessage(), ex); // ??????????? model.addAttribute(ERROR, true); model.addAttribute(ERROR_MESSAGE, getSystemError()); return getViewName(); } try { // Get default total amount Organization orgObj = organizationService.findByOrgCode(orgCode); if (logger.isDebugEnabled()) { logger.debug("Organization: {}", orgObj.toString()); } logger.info("Total amount of all montly: {}", orgObj.getAmountOfToltal()); String amount = getTotalAmountOfMonth(monthly, orgObj); logger.info("Total amount of processing monthly: {}", amount); model.addAttribute(DEFAULT_SETTING_AMOUNT, amount); } catch (IllegalArgumentException ex) { logger.warn(ex.getMessage()); } catch (ServiceException | TooManyObjectsException ex) { logger.error(ex.getMessage(), ex); // ??????????? model.addAttribute(ERROR, true); model.addAttribute(ERROR_MESSAGE, getSystemError()); return getViewName(); } // Check and set editable page pageEditable(monthly, businessDay, model); logger.info("Koguchi page view rendered!"); return getViewName(); }
From source file:com.nec.harvest.controller.KounyuController.java
/** * This function will mapping without path variables default render * // www. j a v a 2 s .c om * @param userOrgCode * @param businessDay * @param orgCode * @param month * @param model * @return */ @RequestMapping(value = "/{orgCode}/{monthly}", method = RequestMethod.GET) public String render(@SessionAttribute(Constants.SESS_ORGANIZATION_CODE) String userOrgCode, @SessionAttribute(Constants.SESS_BUSINESS_DAY) Date businessDay, @PathVariable String orgCode, @PathVariable @DateTimeFormat(pattern = "yyyyMM") Date monthly, final Model model) { logger.info("Get a organization based on organization's code..."); // model.addAttribute(PAGE_VIEW, "kounyu"); model.addAttribute(PROCESSING_MONTH, monthly); model.addAttribute(ACTUAL_MAXIMUM_DAYS_OF_MONTH, DateUtil.getActualMaximumOfMonth(monthly)); try { // Check empty value on next month String nextMontly = BusinessDayHelper.getNextMonthly(monthly, DateFormat.DATE_WITHOUT_DAY); if (!purchaseService.checkEmptyPurchase(userOrgCode, nextMontly)) { nextMontly = null; } model.addAttribute(NEXT_MONTH, nextMontly); // Check empty value on prev month String previousMonthly = BusinessDayHelper.getPreviousMonthly(monthly, DateFormat.DATE_WITHOUT_DAY); if (!purchaseService.checkEmptyPurchase(userOrgCode, previousMonthly)) { previousMonthly = null; } model.addAttribute(PREVIOUS_MONTH, previousMonthly); } catch (IllegalArgumentException ex) { // } catch (ServiceException ex) { logger.error(ex.getMessage(), ex); // ??????????? model.addAttribute(ERROR_MESSAGE, getSystemError()); model.addAttribute(ERROR, true); return getViewName(); } // Check and set editable page Date getSudoDate = null; try { Tighten tighten = tightenService.findByClassifyAndMonth("1"); getSudoDate = DateFormatUtil.parse(tighten.getGetSudo(), DateFormat.DATE_WITHOUT_DAY); model.addAttribute(EDITABLE, monthly.after(getSudoDate)); } catch (ObjectNotFoundException ex) { logger.warn(ex.getMessage()); getSudoDate = DateUtil.monthsToSubtract(businessDay, 3); model.addAttribute(EDITABLE, monthly.after(getSudoDate)); } catch (IllegalArgumentException | NullPointerException | ParseException ex) { logger.warn(ex.getMessage()); model.addAttribute(EDITABLE, Boolean.FALSE); } catch (TooManyObjectsException | ServiceException ex) { logger.error(ex.getMessage(), ex); // ??????????? model.addAttribute(ERROR_MESSAGE, getSystemError()); model.addAttribute(ERROR, true); return getViewName(); } Map<String, PurchaseBean> listPurchaseData = null; List<PurchaseBean> listPurchaseHeader = null; try { // Get purchase header String getSudo = DateFormatUtil.format(monthly, DateFormat.DATE_WITHOUT_DAY); listPurchaseHeader = purchaseService.findByOrgCodeAndMonthAndSQL(orgCode, getSudo, SqlConstants.SQL_FIND_PURCHASE_DATA_HEADER_BY_ORGCODE_AND_MONTH); // Get purchase report Data listPurchaseData = purchaseService.findByOrgCodeAndMonth(orgCode, getSudo, SqlConstants.SQL_FIND_PURCHASE_DATA_BY_ORGCODE_AND_MONTH); } catch (IllegalArgumentException | ObjectNotFoundException ex) { logger.warn(ex.getMessage()); model.addAttribute(ERROR_MESSAGE, MessageHelper.get(MsgConstants.CM_QRY_M01)); model.addAttribute(ERROR, true); model.addAttribute(EDITABLE, Boolean.FALSE); } catch (ServiceException ex) { logger.error(ex.getMessage(), ex); // ??????????? model.addAttribute(ERROR_MESSAGE, getSystemError()); model.addAttribute(ERROR, true); return getViewName(); } model.addAttribute(LIST_KOUNYU_HEADER_BEAN, listPurchaseHeader); model.addAttribute(LIST_KOUNYU_DATA_BEAN, listPurchaseData); return getViewName(); }
From source file:ca.ualberta.physics.cssdp.catalogue.service.CatalogueService.java
public ServiceResponse<Project> find(String projectExternalKey) { ServiceResponse<Project> sr = new ServiceResponse<Project>(); try {// w w w. j a va 2s .com Mnemonic externalKey = new Mnemonic(projectExternalKey); Project project = projectDao.find(externalKey); sr.setPayload(project); } catch (IllegalArgumentException e) { sr.error(e.getMessage()); } return sr; }
From source file:$.DeviceTypeServiceImpl.java
@Path("/device/download") @GET/*from w w w . j a va 2 s . c om*/ @Produces("application/zip") public Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType) { try { ZipArchive zipFile = createDownloadFile(APIUtil.getAuthenticatedUser(), deviceName, sketchType); Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile())); response.status(Response.Status.OK); response.type("application/zip"); response.header("Content-Disposition", "attachment; filename=\"" + zipFile.getFileName() + "\""); Response resp = response.build(); zipFile.getZipFile().delete(); return resp; } catch (IllegalArgumentException ex) { return Response.status(400).entity(ex.getMessage()).build();//bad request } catch (DeviceManagementException ex) { log.error(ex.getMessage(), ex); return Response.status(500).entity(ex.getMessage()).build(); } catch (JWTClientException ex) { log.error(ex.getMessage(), ex); return Response.status(500).entity(ex.getMessage()).build(); } catch (APIManagerException ex) { log.error(ex.getMessage(), ex); return Response.status(500).entity(ex.getMessage()).build(); } catch (IOException ex) { log.error(ex.getMessage(), ex); return Response.status(500).entity(ex.getMessage()).build(); } catch (UserStoreException ex) { log.error(ex.getMessage(), ex); return Response.status(500).entity(ex.getMessage()).build(); } }