/** * Make sure special characters are serialized properly. * * @throws Exception... */ public void testSerializeRegexErrorParserSpecialCharacters() throws Exception { final String TESTING_ID = "org.eclipse.cdt.core.test.regexerrorparser"; final String TESTING_NAME = "<>\"'\\& Error Parser"; final String TESTING_REGEX = "Pattern-<>\"'\\&"; final String ALL_IDS = ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserAvailableIds()); { // Create error parser with the same id as in eclipse registry RegexErrorParser regexErrorParser = new RegexErrorParser(TESTING_ID, TESTING_NAME); regexErrorParser.addPattern( new RegexErrorPattern( TESTING_REGEX, "line-<>\"'\\&", "file-<>\"'\\&", "description-<>\"'\\&", null, IMarkerGenerator.SEVERITY_WARNING, false)); // Add to available parsers ErrorParserExtensionManager.setUserDefinedErrorParsersInternal( new IErrorParserNamed[] {regexErrorParser}); assertNotNull(ErrorParserManager.getErrorParserCopy(TESTING_ID)); // And serialize in persistent storage ErrorParserExtensionManager.serializeUserDefinedErrorParsers(); } { // Re-load from persistent storage and check it out ErrorParserExtensionManager.loadUserDefinedErrorParsers(); String all = ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserAvailableIds()); assertTrue(all.contains(TESTING_ID)); IErrorParser errorParser = ErrorParserManager.getErrorParserCopy(TESTING_ID); assertNotNull(errorParser); assertTrue(errorParser instanceof RegexErrorParser); RegexErrorParser regexErrorParser = (RegexErrorParser) errorParser; assertEquals(TESTING_ID, regexErrorParser.getId()); assertEquals(TESTING_NAME, regexErrorParser.getName()); RegexErrorPattern[] errorPatterns = regexErrorParser.getPatterns(); assertEquals(1, errorPatterns.length); assertEquals(TESTING_REGEX, errorPatterns[0].getPattern()); } }
/** * Test serialization of user defined error parsers. * * @throws Exception... */ public void testSerializeErrorParser() throws Exception { final String TESTING_ID = "org.eclipse.cdt.core.test.errorparser"; final String TESTING_NAME = "An error parser"; { // Create error parser IErrorParser errorParser = new GASErrorParser(); // Add to available parsers ErrorParserExtensionManager.setUserDefinedErrorParsersInternal( new IErrorParserNamed[] { new ErrorParserNamedWrapper(TESTING_ID, TESTING_NAME, errorParser) }); assertNotNull(ErrorParserManager.getErrorParserCopy(TESTING_ID)); assertEquals(TESTING_NAME, ErrorParserManager.getErrorParserCopy(TESTING_ID).getName()); // Serialize in persistent storage ErrorParserExtensionManager.serializeUserDefinedErrorParsers(); } { // Remove from available parsers ErrorParserExtensionManager.setUserDefinedErrorParsersInternal(null); assertNull(ErrorParserManager.getErrorParserCopy(TESTING_ID)); } { // Re-load from persistent storage and check it out ErrorParserExtensionManager.loadUserDefinedErrorParsers(); IErrorParserNamed errorParser = ErrorParserManager.getErrorParserCopy(TESTING_ID); assertNotNull(errorParser); assertEquals(TESTING_NAME, errorParser.getName()); assertTrue(errorParser instanceof ErrorParserNamedWrapper); assertTrue( ((ErrorParserNamedWrapper) errorParser).getErrorParser() instanceof GASErrorParser); } { // Remove from available parsers as clean-up ErrorParserExtensionManager.setUserDefinedErrorParsersInternal(null); assertNull(ErrorParserManager.getErrorParserCopy(TESTING_ID)); } }
/** * Check that default parser IDs are stored properly. * * @throws Exception... */ public void testSerializeDefaultErrorParserIds() throws Exception { final String[] testingDefaultErrorParserIds = { "org.eclipse.cdt.core.test.errorparser0", "org.eclipse.cdt.core.test.errorparser1", "org.eclipse.cdt.core.test.errorparser2", }; final String TESTING_IDS = ErrorParserManager.toDelimitedString(testingDefaultErrorParserIds); final String DEFAULT_IDS = ErrorParserManager.toDelimitedString(ErrorParserManager.getDefaultErrorParserIds()); { // setDefaultErrorParserIds ErrorParserExtensionManager.setDefaultErrorParserIdsInternal(testingDefaultErrorParserIds); String[] defaultErrorParserIds = ErrorParserManager.getDefaultErrorParserIds(); assertNotNull(defaultErrorParserIds); assertEquals(TESTING_IDS, ErrorParserManager.toDelimitedString(defaultErrorParserIds)); // serialize them ErrorParserExtensionManager.serializeDefaultErrorParserIds(); } { // Remove from internal list ErrorParserExtensionManager.setDefaultErrorParserIdsInternal(null); assertEquals( DEFAULT_IDS, ErrorParserManager.toDelimitedString(ErrorParserManager.getDefaultErrorParserIds())); } { // Re-load from persistent storage and check it out ErrorParserExtensionManager.loadDefaultErrorParserIds(); String[] defaultErrorParserIds = ErrorParserManager.getDefaultErrorParserIds(); assertNotNull(defaultErrorParserIds); assertEquals(TESTING_IDS, ErrorParserManager.toDelimitedString(defaultErrorParserIds)); } { // Reset IDs and serialize ErrorParserExtensionManager.setDefaultErrorParserIdsInternal(null); ErrorParserExtensionManager.serializeDefaultErrorParserIds(); // Check that default IDs are loaded ErrorParserExtensionManager.loadDefaultErrorParserIds(); String[] defaultErrorParserIds = ErrorParserManager.getDefaultErrorParserIds(); assertNotNull(defaultErrorParserIds); assertEquals(DEFAULT_IDS, ErrorParserManager.toDelimitedString(defaultErrorParserIds)); } }