Package com.puppycrawl.tools.checkstyle.api

Examples of com.puppycrawl.tools.checkstyle.api.AuditEvent


        logger.auditStarted(null);
        final LocalizedMessage message =
            new LocalizedMessage(1, 1,
                "messages.properties", "key", null, SeverityLevel.ERROR, null,
                this.getClass(), null);
        final AuditEvent ev = new AuditEvent(this, "Test.java", message);
        logger.addError(ev);
        logger.auditFinished(null);
        final String[] expectedLines = {
            "<error line=\"1\" column=\"1\" severity=\"error\" message=\"key\" source=\"com.puppycrawl.tools.checkstyle.XMLLoggerTest\"/>",
        };
View Full Code Here


        final XMLLogger logger = new XMLLogger(outStream, true);
        logger.auditStarted(null);
        final LocalizedMessage message =
            new LocalizedMessage(1, 1,
                "messages.properties", null, null, null, this.getClass(), null);
        final AuditEvent ev = new AuditEvent(this, "Test.java", message);
        logger.addException(ev, new TestThrowable());
        logger.auditFinished(null);
        final String[] expectedLines = {
            "&lt;exception&gt;",
            "&lt;![CDATA[",
View Full Code Here

                // Grab the severity from the rule configuration, use null as default value
                String configSeverity = getConfigAttribute( childConfig, null, "severity", null );

                // count rule violations
                long violations = 0;
                AuditEvent lastMatchedEvent = null;
                for ( List<AuditEvent> errors : results.getFiles().values() )
                {
                    for ( AuditEvent event : errors )
                    {
                        if ( matchRule( event, ruleName, fixedmessage, configSeverity ) )
View Full Code Here

    public void testListeners()
    {
        fireAuditStarted( null );

        AuditEvent event = new AuditEvent( this, "/source/path/file1", null );
        fireFileStarted( event );
        LocalizedMessage message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.INFO, null, getClass(), null );
        fireAddError( new AuditEvent( this, "/source/path/file1", message ) );
        fireFileFinished( event );

        event = new AuditEvent( this, "/source/path/file2", null );
        fireFileStarted( event );
        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.WARNING, null, getClass(), null );
        fireAddError( new AuditEvent( this, "/source/path/file2", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file2", message ) );
        fireFileFinished( event );

        event = new AuditEvent( this, "/source/path/file3", null );
        fireFileStarted( event );
        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.ERROR, null, getClass(), null );
        fireAddError( new AuditEvent( this, "/source/path/file3", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file3", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file3", message ) );
        fireFileFinished( event );

        event = new AuditEvent( this, "/source/path/file4", null );
        fireFileStarted( event );
        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.IGNORE, null, getClass(), null );
        fireAddError( new AuditEvent( this, "/source/path/file4", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file4", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file4", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file4", message ) );
        fireFileFinished( event );

        fireAuditFinished( null );

        CheckstyleCheckerListener listener = listenerMap.get( SeverityLevel.INFO );
View Full Code Here

    public void testResults()
    {
        Map<String, List<AuditEvent>> files = new HashMap<String, List<AuditEvent>>();

        LocalizedMessage message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.INFO, null, getClass(), null );
        AuditEvent event = new AuditEvent( this, "file1", message );
        files.put( "file1", Collections.singletonList( event ) );

        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.WARNING, null, getClass(), null );
        List<AuditEvent> events = new ArrayList<AuditEvent>();
        events.add( new AuditEvent( this, "file2", message ) );
        events.add( new AuditEvent( this, "file2", message ) );
        files.put( "file2", events );

        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.ERROR, null, getClass(), null );
        events = new ArrayList<AuditEvent>();
        events.add( new AuditEvent( this, "file3", message ) );
        events.add( new AuditEvent( this, "file3", message ) );
        events.add( new AuditEvent( this, "file3", message ) );
        files.put( "file3", events );

        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.IGNORE, null, getClass(), null );
        events = new ArrayList<AuditEvent>();
        events.add( new AuditEvent( this, "file4", message ) );
        events.add( new AuditEvent( this, "file4", message ) );
        events.add( new AuditEvent( this, "file4", message ) );
        events.add( new AuditEvent( this, "file4", message ) );
        files.put( "file4", events );

        results.setFiles( files );

        assertEquals( "test total files", 4, results.getFiles().size() );
View Full Code Here

                // Grab the severity from the rule configuration, use null as default value
                String configSeverity = getConfigAttribute( childConfig, null, "severity", null );

                // count rule violations
                long violations = 0;
                AuditEvent lastMatchedEvent = null;
                for ( List<AuditEvent> errors : results.getFiles().values() )
                {
                    for ( AuditEvent event : errors )
                    {
                        if ( matchRule( event, ruleName, fixedmessage, configSeverity ) )
View Full Code Here

    public void testListeners()
    {
        fireAuditStarted( null );

        AuditEvent event = new AuditEvent( this, "/source/path/file1", null );
        fireFileStarted( event );
        LocalizedMessage message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.INFO, null, getClass(), null );
        fireAddError( new AuditEvent( this, "/source/path/file1", message ) );
        fireFileFinished( event );

        event = new AuditEvent( this, "/source/path/file2", null );
        fireFileStarted( event );
        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.WARNING, null, getClass(), null );
        fireAddError( new AuditEvent( this, "/source/path/file2", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file2", message ) );
        fireFileFinished( event );

        event = new AuditEvent( this, "/source/path/file3", null );
        fireFileStarted( event );
        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.ERROR, null, getClass(), null );
        fireAddError( new AuditEvent( this, "/source/path/file3", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file3", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file3", message ) );
        fireFileFinished( event );

        event = new AuditEvent( this, "/source/path/file4", null );
        fireFileStarted( event );
        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.IGNORE, null, getClass(), null );
        fireAddError( new AuditEvent( this, "/source/path/file4", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file4", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file4", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file4", message ) );
        fireFileFinished( event );

        fireAuditFinished( null );

        CheckstyleCheckerListener listener = listenerMap.get( SeverityLevel.INFO );
View Full Code Here

    public void testListeners()
    {
        fireAuditStarted( null );

        AuditEvent event = new AuditEvent( this, "/source/path/file1", null );
        fireFileStarted( event );
        LocalizedMessage message =
            new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.INFO, null, getClass(), null );
        fireAddError( new AuditEvent( this, "/source/path/file1", message ) );
        fireFileFinished( event );

        event = new AuditEvent( this, "/source/path2/file2", null );
        fireFileStarted( event );
        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.WARNING, null, getClass(), null );
        fireAddError( new AuditEvent( this, "/source/path2/file2", message ) );
        fireAddError( new AuditEvent( this, "/source/path2/file2", message ) );
        fireFileFinished( event );

        event = new AuditEvent( this, "/source/path/file3", null );
        fireFileStarted( event );
        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.ERROR, null, getClass(), null );
        fireAddError( new AuditEvent( this, "/source/path/file3", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file3", message ) );
        fireAddError( new AuditEvent( this, "/source/path/file3", message ) );
        fireFileFinished( event );

        event = new AuditEvent( this, "/source/path2/file4", null );
        fireFileStarted( event );
        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.IGNORE, null, getClass(), null );
        fireAddError( new AuditEvent( this, "/source/path2/file4", message ) );
        fireAddError( new AuditEvent( this, "/source/path2/file4", message ) );
        fireAddError( new AuditEvent( this, "/source/path2/file4", message ) );
        fireAddError( new AuditEvent( this, "/source/path2/file4", message ) );
        fireFileFinished( event );

        fireAuditFinished( null );

        CheckstyleCheckerListener listener = listenerMap.get( SeverityLevel.INFO );
View Full Code Here

    public void testResults()
    {
        Map<String, List<AuditEvent>> files = new HashMap<String, List<AuditEvent>>();

        LocalizedMessage message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.INFO, null, getClass(), null );
        AuditEvent event = new AuditEvent( this, "file1", message );
        files.put( "file1", Collections.singletonList( event ) );

        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.WARNING, null, getClass(), null );
        List<AuditEvent> events = new ArrayList<AuditEvent>();
        events.add( new AuditEvent( this, "file2", message ) );
        events.add( new AuditEvent( this, "file2", message ) );
        files.put( "file2", events );

        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.ERROR, null, getClass(), null );
        events = new ArrayList<AuditEvent>();
        events.add( new AuditEvent( this, "file3", message ) );
        events.add( new AuditEvent( this, "file3", message ) );
        events.add( new AuditEvent( this, "file3", message ) );
        files.put( "file3", events );

        message = new LocalizedMessage( 0, 0, "", "", null, SeverityLevel.IGNORE, null, getClass(), null );
        events = new ArrayList<AuditEvent>();
        events.add( new AuditEvent( this, "file4", message ) );
        events.add( new AuditEvent( this, "file4", message ) );
        events.add( new AuditEvent( this, "file4", message ) );
        events.add( new AuditEvent( this, "file4", message ) );
        files.put( "file4", events );

        results.setFiles( files );

        assertEquals( "test total files", 4, results.getFiles().size() );
View Full Code Here

    }

    /** notify all listeners about the audit start */
    protected void fireAuditStarted()
    {
        final AuditEvent evt = new AuditEvent(this);
        final Iterator it = mListeners.iterator();
        while (it.hasNext()) {
            final AuditListener listener = (AuditListener) it.next();
            listener.auditStarted(evt);
        }
View Full Code Here

TOP

Related Classes of com.puppycrawl.tools.checkstyle.api.AuditEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.