@Test public void testTapParserException4() { exception = new ParserException("Null", new NullPointerException()); // NOPMD assertNotNull(exception); assertEquals(exception.getMessage(), "Null"); assertTrue(exception.getCause() instanceof NullPointerException); }
public static void work(BufferedReader ir) { TestParser testParser = new TestParser(); try { PushbackReader r = new PushbackReader(ir, 1024); Parser parser = new Parser(new Lexer(r)); Node syntaxTree = parser.parse(); syntaxTree.apply(testParser); } catch (LexerException e) { System.out.println(e.getMessage() + "."); } catch (ParserException e) { System.out.println(e.getMessage() + "."); } catch (IOException e) { System.out.println(e.getMessage() + "."); System.exit(1); } }
@Override public void run() { final Collection<cgCache> caches; try { caches = doImport(); importStepHandler.sendMessage( importStepHandler.obtainMessage( IMPORT_STEP_STORE_CACHES, R.string.gpx_import_storing, caches.size())); cgSearch search = storeParsedCaches(caches); Log.i(Settings.tag, "Imported successfully " + caches.size() + " caches."); importStepHandler.sendMessage( importStepHandler.obtainMessage( IMPORT_STEP_FINISHED, cgeoapplication.getCount(search), 0, search)); } catch (IOException e) { Log.i(Settings.tag, "Importing caches failed - error reading data: " + e.getMessage()); importStepHandler.sendMessage( importStepHandler.obtainMessage( IMPORT_STEP_FINISHED_WITH_ERROR, R.string.gpx_import_error_io, 0, e.getLocalizedMessage())); } catch (ParserException e) { Log.i(Settings.tag, "Importing caches failed - data format error" + e.getMessage()); importStepHandler.sendMessage( importStepHandler.obtainMessage( IMPORT_STEP_FINISHED_WITH_ERROR, R.string.gpx_import_error_parser, 0, e.getLocalizedMessage())); } catch (CancellationException e) { Log.i(Settings.tag, "Importing caches canceled"); importStepHandler.sendMessage(importStepHandler.obtainMessage(IMPORT_STEP_CANCELED)); } catch (Exception e) { Log.e(Settings.tag, "Importing caches failed - unknown error: ", e); importStepHandler.sendMessage( importStepHandler.obtainMessage( IMPORT_STEP_FINISHED_WITH_ERROR, R.string.gpx_import_error_unexpected, 0, e.getLocalizedMessage())); } }
@Test public void testTapParserException2() { exception = new ParserException("Error parsing document"); assertNotNull(exception); assertEquals(exception.getMessage(), "Error parsing document"); }