All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mattressframework.test.mock.MockHttpEntityReader Maven / Gradle / Ivy

/*
 * Copyright 2007-2008, Josh Devins.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.mattressframework.test.mock;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

import org.mattressframework.api.HttpEntityReader;
import org.mattressframework.api.http.Header;
import org.mattressframework.api.http.MediaType;

/**
 * A mock {@link HttpEntityReader} allowing testing of other framework elements
 * easily. Allows setting of the entity to be returned from
 * {@link #readFrom(Class, MediaType, Map, InputStream)}.
 * 
 * @author Josh Devins ([email protected])
 */
public class MockHttpEntityReader extends MockProvider implements
        HttpEntityReader {

    private Object entity;

    public Object readFrom(final Class type, final MediaType mediaType,
            final Map httpHeaders,
            final InputStream entityStream) throws IOException {

        return entity;
    }

    public void setEntity(final Object entity) {
        this.entity = entity;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy