/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2014-2017 <mickael.jeanroy@gmail.com>
 *
 * 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 com.github.mjeanroy.junit.servers.servers;

import java.net.URI;

import javax.servlet.ServletContext;

import com.github.mjeanroy.junit.servers.servers.configuration.AbstractConfiguration;

/**
 * Specification of embedded server.
 *
 * <p>
 *
 * An embedded server:
 * <ul>
 *   <li>Can be started, stopped or restarted.</li>
 *   <li>Must provide port that can be used to query resources.</li>
 * </ul>
 *
 * @param <T> The type of configuration used by the embedded server implementation.
 */
public interface EmbeddedServer<T extends AbstractConfiguration> {

	/**
	 * Start embedded server.
	 * If server is already started, this method should do nothing.
	 */
	void start();

	/**
	 * Stop embedded server.
	 * If server is already stopped, this method should do nothing.
	 */
	void stop();

	/**
	 * Restart embedded server.
	 */
	void restart();

	/**
	 * Return server configuration.
	 *
	 * @return Configuration.
	 */
	T getConfiguration();

	/**
	 * Check if embedded server is started.
	 *
	 * @return {@code true} if embedded server is started, {@code false} otherwise.
	 */
	boolean isStarted();

	/**
	 * Get the protocol scheme ({@code "http"}, {@code "https"}).
	 *
	 * @return Protocol scheme.
	 */
	String getScheme();

	/**
	 * Get the host, should be {@code "localhost"}, unless specific configuration.
	 *
	 * @return The server hostname.
	 */
	String getHost();

	/**
	 * Get port used by embedded server.
	 *
	 * <p>
	 *
	 * Note that:
	 * <ul>
	 *   <li>If the server is not started, the returned port should be the one set in the configuration.</li>
	 *   <li>Otherwise, the "real" port should be returned (the port used by the embedded server)</li>
	 * </ul>
	 *
	 * @return Port.
	 */
	int getPort();

	/**
	 * Get server context path.
	 *
	 * @return Server context path.
	 */
	String getPath();

	/**
	 * Get URL to query embedded server.
	 *
	 * @return URL.
	 */
	String getUrl();

	/**
	 * The URL object.
	 *
	 * @return URL.
	 */
	URI getUri();

	/**
	 * Get servlet context used within container.
	 * If container is not a servlet container, this method should return null.
	 *
	 * @return Servlet Cntext from container.
	 */
	ServletContext getServletContext();
}

@@ -2946,103 +2946,573 @@
 %09 * 
-@return Server context path.%0A%09 */%0A%09String getPath();%0A%0A%09/**%0A%09 * Get URL to query embedded server
+%3Cp%3E%0A%09 *%0A%09 * It is not guaranteed that the returned server path here is URL encoded. If you need to query%0A%09 * embedded server, use %7B@link #getUrl()%7D or %7B@link #getUri()%7D.%0A%09 *%0A%09 * @return Server context path.%0A%09 */%0A%09String getPath();%0A%0A%09/**%0A%09 * Get URL to query embedded server.%0A%09 *%0A%09 * %3Cp%3E%0A%09 *%0A%09 * Implementations %3Cstrong%3Emust%3C/strong%3E return a valid URL: for example, it means that the context path must be%0A%09 * URL encoded if it contains illegal characters (such as space for example). Usually, this method should%0A%09 * return the result of %7B@link #getUri()#toString()%7D
 .%0A%09 

add missing methods to EmbeddedServer