List of usage examples for java.lang RuntimeException getMessage
public String getMessage()
From source file:com.legstar.codegen.CodeGenMakeTest.java
/** * Check controls on input make file tag <cixstarget>. * @throws IOException if file cannot be read */// w w w . j a va 2 s .co m public void testCodeGenMakeNoTargetTag() throws IOException { File tempMakeFile = File.createTempFile("test-temp", "xml"); /* Create a temporary make file */ BufferedWriter out; out = new BufferedWriter(new FileWriter(tempMakeFile)); out.write("<somethingElse/>"); out.close(); CodeGenMake codeGenMake = new CodeGenMake(); codeGenMake.setModelName("modelName"); codeGenMake.setModel("model"); codeGenMake.setCodeGenMakeFileName(tempMakeFile.getPath()); try { codeGenMake.execute(); } catch (RuntimeException e) { assertEquals("Empty or invalid code generation make file", e.getMessage()); } }
From source file:ccc.plugins.multipart.apache.MultipartFormTest.java
/** * Test.//w w w. ja v a2 s . c o m */ public void testNonMultipartRequestIsRejected() { // ARRANGE // ACT try { new MultipartForm("UTF-8", 1, "text/plain", new ByteArrayInputStream(new byte[] { 1 })); fail(); // ASSERT } catch (final RuntimeException e) { assertEquals("Not a multipart.", e.getMessage()); } }
From source file:dk.dbc.opensearch.datadock.DatadockManager.java
/** * The update method constitutes the main workflow of the DatadockManager: * upon being called, it will:/*w w w. j ava 2 s. c o m*/ * * 1) check if there are any jobs waiting for execution and * a) continue on to 2), or * b) request the harvester for another 100 jobs * 2) loop while there are still jobs to execute, and * 3) check if the job has a workflow (i.e. there exists plugins to process it), and * a) submit it for execution with the {@link DatadockPool}, or * b) log a warning that the job could not be processed * 4) remove the job from the jobs waiting for execution, and * 5) call the {@link DatadockPool#checkJobs()} which will block until all jobs have finished and * 6) return the number of submitted jobs * * @throws HarvesterIOException * @throws HarvesterInvalidStatusChangeException * @throws InterruptedException */ public int update(int maxToHarvest) throws HarvesterIOException, HarvesterInvalidStatusChangeException, InterruptedException, ConfigurationException { log.trace("DatadockManager update called"); // Check if there are any registered jobs ready for docking // if not... new jobs are requested from the harvester if (registeredJobs.isEmpty()) { log.trace("no more jobs. requesting new jobs from the harvester"); registeredJobs = this.harvester.getJobs(maxToHarvest); } log.debug("DatadockManager.update: Size of registeredJobs: " + registeredJobs.size()); int jobs_submitted = 0; while (registeredJobs.size() > 0 && !shutdownRequested) { log.trace(String.format("processing job: %s", registeredJobs.get(0).getIdentifier())); try { TaskInfo job = registeredJobs.get(0); if (hasWorkflow(job)) { pool.submit(job.getIdentifier()); registeredJobs.remove(0); ++jobs_submitted; log.debug(String.format("submitted job: '%s'", job)); } else { log.warn(String.format( "Jobs for submitter, format \"%s,%s\" has no workflow from plugins and will henceforth be rejected.", job.getSubmitter(), job.getFormat())); registeredJobs.remove(0); } } catch (RuntimeException re) { String error = "Runtime exception caught " + re.getMessage(); log.error(error, re); } } //checking for finished jobs in the pool pool.checkJobs(); return jobs_submitted; }
From source file:org.openwms.core.configuration.file.ApplicationPreferenceTest.java
/** * Just test to validate the given XML file against the schema declaration. If the XML file is not compliant with the schema, the test * will fail./* w ww .j a v a2 s . c o m*/ * * @throws Exception any error */ @Test public void testReadPreferences() throws Exception { SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(ResourceUtils.getFile("classpath:preferences.xsd")); // Schema schema = schemaFactory.newSchema(new // URL("http://www.openwms.org/schema/preferences.xsd")); JAXBContext ctx = JAXBContext.newInstance("org.openwms.core.configuration.file"); Unmarshaller unmarshaller = ctx.createUnmarshaller(); unmarshaller.setSchema(schema); unmarshaller.setEventHandler(new ValidationEventHandler() { @Override public boolean handleEvent(ValidationEvent event) { RuntimeException ex = new RuntimeException(event.getMessage(), event.getLinkedException()); LOGGER.error(ex.getMessage()); throw ex; } }); Preferences prefs = Preferences.class.cast(unmarshaller .unmarshal(ResourceUtils.getFile("classpath:org/openwms/core/configuration/file/preferences.xml"))); for (AbstractPreference pref : prefs.getApplications()) { LOGGER.info(pref.toString()); } for (AbstractPreference pref : prefs.getModules()) { LOGGER.info(pref.toString()); } for (AbstractPreference pref : prefs.getUsers()) { LOGGER.info(pref.toString()); } }
From source file:io.redlink.sdk.DataConcurrencyTest.java
@Test @Concurrent(count = 5)// ww w .j a v a2 s.co m @Repeating(repetition = 20) public void testConcurrently() throws IOException, RDFHandlerException, InterruptedException { try { Model model = new TreeModel(); // create random triples for (int i = 0; i < rnd.nextInt(100) + 1; i++) { model.add(new StatementImpl(randomURI(), randomURI(), randomObject())); } log.debug("created {} random triples", model.size()); redlink.importDataset(model, TEST_DATASET); Model exported = redlink.exportDataset(TEST_DATASET); Assert.assertFalse(exported.isEmpty()); for (Statement stmt : model) { Assert.assertTrue("triple " + stmt + " not contained in exported data", exported.contains(stmt)); } for (Resource r : model.subjects()) { redlink.deleteResource(r.stringValue(), TEST_DATASET); } Model deleted = redlink.exportDataset(TEST_DATASET); for (Statement stmt : model) { Assert.assertFalse("triple " + stmt + " still contained in exported data", deleted.contains(stmt)); } } catch (RuntimeException ex) { log.error("exception: ", ex); Assert.fail(ex.getMessage()); } }
From source file:com.marklogic.contentpump.SplitDelimitedTextReader.java
@SuppressWarnings("unchecked") @Override/*ww w. j av a 2s . co m*/ public boolean nextKeyValue() throws IOException, InterruptedException { if (parser == null || pos >= end || parserIterator == null) { return false; } try { if (!parserIterator.hasNext()) { bytesRead = fileLen; return false; } String[] values = getLine(); pos += getBytesCountFromLine(values); if (values.length != fields.length) { setSkipKey(0, 0, "number of fields does not match number of columns"); return true; } docBuilder.newDoc(); for (int i = 0; i < fields.length; i++) { // skip empty column in header generated by trailing delimiter if (fields[i].equals("")) continue; if (!generateId && uriId == i) { if (setKey(values[i], 0, 0, true)) { return true; } } try { docBuilder.put(fields[i], values[i]); } catch (Exception e) { setSkipKey(0, 0, e.getMessage()); return true; } } docBuilder.build(); if (generateId) { if (setKey(idGen.incrementAndGet(), 0, 0, true)) { return true; } } if (value instanceof Text) { ((Text) value).set(docBuilder.getDoc()); } else { ((Text) ((ContentWithFileNameWritable<VALUEIN>) value).getValue()).set(docBuilder.getDoc()); } } catch (RuntimeException ex) { if (ex.getMessage().contains("invalid char between encapsulated token and delimiter")) { setSkipKey(0, 0, "invalid char between encapsulated token and delimiter"); // hasNext() will always be true here since this exception is caught if (parserIterator.hasNext()) { // consume the rest fields of this line parserIterator.next(); } } else { throw ex; } } return true; }
From source file:net.shirayu.android.WlanLogin.MyHttpClient.java
public HttpResponse execute(HttpUriRequest request) throws IOException, ClientProtocolException { stop_auth = false;//from w ww . j a v a2s . c om try { return client.execute(request); } catch (RuntimeException ex) { throw new ClientProtocolException(ex.getMessage()); } }
From source file:net.shirayu.android.WlanLogin.MyHttpClient.java
public HttpResponse execute(HttpHost target, HttpRequest request) throws IOException, ClientProtocolException { stop_auth = false;//from ww w. j av a 2 s . c o m try { return client.execute(target, request); } catch (RuntimeException ex) { throw new ClientProtocolException(ex.getMessage()); } }
From source file:de.micromata.genome.gwiki.scheduler_1_0.chronos.spi.GWikiSchedClassJobDefinition.java
@Override public FutureJob getInstance() { return GWikiWeb.get().runInPluginContext(new CallableX<FutureJob, RuntimeException>() { @Override//from w w w . j a va 2 s.c o m public FutureJob call() throws RuntimeException { try { Class c = Thread.currentThread().getContextClassLoader().loadClass(classNameToStart); Object o = c.newInstance(); mapProperties(o); if (o instanceof FutureJob) { return (FutureJob) o; } else if (o instanceof GWikiSchedulerJob) { return new GWikiSchedJobAdapter((GWikiSchedulerJob) o); } else { throw new RuntimeException("Unknown job type to create: " + o.getClass()); } } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { throw new RuntimeException("Failure loading class in ClassJobDefinition: " + ex.getMessage(), ex); } } }); }
From source file:net.shirayu.android.WlanLogin.MyHttpClient.java
public HttpResponse execute(HttpUriRequest request, HttpContext context) throws IOException, ClientProtocolException { stop_auth = false;/* w ww .ja v a2 s. com*/ try { return client.execute(request, context); } catch (RuntimeException ex) { throw new ClientProtocolException(ex.getMessage()); } }