io.blitz.mock.MockLog.java Source code

Java tutorial

Introduction

Here is the source code for io.blitz.mock.MockLog.java

Source

/*
 * The MIT License
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package io.blitz.mock;

import java.util.ArrayList;
import java.util.List;
import org.apache.maven.plugin.logging.Log;

/**
 * Mocks the maven Log so we can test the log response too.
 * @author ghermeto
 */
public class MockLog implements Log {

    private List<String> debugMessages;

    private List<String> infoMessages;

    private List<String> errorMessages;

    private List<String> warnMessages;

    public MockLog() {
        infoMessages = new ArrayList<String>();
        warnMessages = new ArrayList<String>();
        debugMessages = new ArrayList<String>();
        errorMessages = new ArrayList<String>();
    }

    public boolean isDebugEnabled() {
        throw new UnsupportedOperationException("Not supported.");
    }

    public void debug(CharSequence cs) {
        debugMessages.add(cs.toString());
    }

    public void debug(CharSequence cs, Throwable thrwbl) {
        throw new UnsupportedOperationException("Not supported.");
    }

    public void debug(Throwable thrwbl) {
        debugMessages.add(thrwbl.getMessage());
    }

    public boolean isInfoEnabled() {
        throw new UnsupportedOperationException("Not supported.");
    }

    public void info(CharSequence cs) {
        infoMessages.add(cs.toString());
    }

    public void info(CharSequence cs, Throwable thrwbl) {
        throw new UnsupportedOperationException("Not supported.");
    }

    public void info(Throwable thrwbl) {
        infoMessages.add(thrwbl.getMessage());
    }

    public boolean isWarnEnabled() {
        throw new UnsupportedOperationException("Not supported.");
    }

    public void warn(CharSequence cs) {
        warnMessages.add(cs.toString());
    }

    public void warn(CharSequence cs, Throwable thrwbl) {
        throw new UnsupportedOperationException("Not supported.");
    }

    public void warn(Throwable thrwbl) {
        warnMessages.add(thrwbl.getMessage());
    }

    public boolean isErrorEnabled() {
        throw new UnsupportedOperationException("Not supported.");
    }

    public void error(CharSequence cs) {
        errorMessages.add(cs.toString());
    }

    public void error(CharSequence cs, Throwable thrwbl) {
        throw new UnsupportedOperationException("Not supported.");
    }

    public void error(Throwable thrwbl) {
        errorMessages.add(thrwbl.getMessage());
    }

    public List<String> getDebugMessages() {
        return debugMessages;
    }

    public List<String> getErrorMessages() {
        return errorMessages;
    }

    public List<String> getInfoMessages() {
        return infoMessages;
    }

    public List<String> getWarnMessages() {
        return warnMessages;
    }
}