001/****************************************************************
002 * Licensed to the Apache Software Foundation (ASF) under one   *
003 * or more contributor license agreements.  See the NOTICE file *
004 * distributed with this work for additional information        *
005 * regarding copyright ownership.  The ASF licenses this file   *
006 * to you under the Apache License, Version 2.0 (the            *
007 * "License"); you may not use this file except in compliance   *
008 * with the License.  You may obtain a copy of the License at   *
009 *                                                              *
010 *   http://www.apache.org/licenses/LICENSE-2.0                 *
011 *                                                              *
012 * Unless required by applicable law or agreed to in writing,   *
013 * software distributed under the License is distributed on an  *
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
015 * KIND, either express or implied.  See the License for the    *
016 * specific language governing permissions and limitations      *
017 * under the License.                                           *
018 ****************************************************************/
019
020package org.apache.james.mpt.api;
021
022import org.apache.james.mpt.host.ExternalHostSystem;
023
024/**
025 * <p>Host system under test.</p>
026 * <p>
027 * This interface encapsulates the interaction between the server
028 * under test and the test framework. MPT can be used to test components
029 * without the need to serve the protocol though a socket by creating a 
030 * suitable implementation of this interface.
031 * </p>
032 * @see ExternalHostSystem  ExternalHostSystem (a <code>HostSystem</code> for servers
033 * running independently)
034 * @see Session Session (supports multiple connection to the host system)
035 */
036public interface HostSystem extends SessionFactory {
037
038    /**
039     * Add a user for testing.
040     * 
041     * @param user
042     *            user name
043     * @param password
044     *            user password
045     * @throws Exception
046     */
047    boolean addUser(String user, String password) throws Exception;
048
049    /**
050     * Creates a new session for functional testing.
051     * 
052     * @return <code>Session</code>, not null
053     * @throws Exception
054     */
055    Session newSession(Continuation continuation) throws Exception;
056
057    void beforeTests() throws Exception;
058
059    void afterTests() throws Exception;
060
061    void beforeTest() throws Exception;
062
063    void afterTest() throws Exception;
064
065}