// Path: src/main/java/jp/eisbahn/oauth2/server/fetcher/accesstoken/AccessTokenFetcher.java
// public static class FetchResult {
// 
// 	private String token;
// 	private Map<String, String> params;
// 
// 	/**
// 	 * This constructor initializes like both parameters become a null value.
// 	 */
// 	public FetchResult() {
// 		this(null, null);
// 	}
// 
// 	/**
// 	 * This constructor initializes with the specified argument values.
// 	 * @param token The access token string.
// 	 * @param params Other parameters.
// 	 */
// 	public FetchResult(String token, Map<String, String> params) {
// 		super();
// 		this.token = token;
// 		this.params = params;
// 	}
// 
// 	/**
// 	 * Set the access token.
// 	 * @param token The token string.
// 	 */
// 	public void setToken(String token) {
// 		this.token = token;
// 	}
// 
// 	/**
// 	 * Retrieve the access token.
// 	 * @return The token string.
// 	 */
// 	public String getToken() {
// 		return token;
// 	}
// 
// 	/**
// 	 * Set other parameters.
// 	 * @param params The other parameter map object.
// 	 */
// 	public void setParams(Map<String, String> params) {
// 		this.params = params;
// 	}
// 
// 	/**
// 	 * Retrieve the other parameters.
// 	 * @return The other parameter map object.
// 	 */
// 	public Map<String, String> getParams() {
// 		return params;
// 	}
// 
// }
// 
// Path: src/main/java/jp/eisbahn/oauth2/server/fetcher/accesstoken/impl/AuthHeader.java
// public class AuthHeader implements AccessTokenFetcher {
// 
// 	private static final String HEADER_AUTHORIZATION = "Authorization";
// 	private static final Pattern REGEXP_AUTHORIZATION =
// 			Pattern.compile("^\\s*(OAuth|Bearer)\\s+([^\\s\\,]*)");
// 	private static final Pattern REGEXP_TRIM = Pattern.compile("^\\s*,\\s*");
// 	private static final Pattern REGEXP_DIV_COMMA = Pattern.compile(",\\s*");
// 
// 	/**
// 	 * Return whether an access token is included in the Authorization
// 	 * request header.
// 	 * 
// 	 * @param request The request object.
// 	 * @return If the header value has an access token, this result is true.
// 	 */
// 	@Override
// 	public boolean match(Request request) {
// 		String header = request.getHeader(HEADER_AUTHORIZATION);
// 		return (header != null)
// 			&& (Pattern.matches("^\\s*(OAuth|Bearer)(.*)$", header));
// 	}
// 
// 	/**
// 	 * Fetch an access token from an Authorization request header and return it.
// 	 * This method must be called when a result of the match() method is true
// 	 * only.
// 	 * 
// 	 * @param request The request object.
// 	 * @return the fetched access token.
// 	 */
// 	@Override
// 	public FetchResult fetch(Request request) {
// 		String header = request.getHeader(HEADER_AUTHORIZATION);
// 		Matcher matcher = REGEXP_AUTHORIZATION.matcher(header);
// 		if (!matcher.find()) {
// 			throw new IllegalStateException(
// 				"parse() method was called when match() result was false.");
// 		}
// 		String token = matcher.group(2);
// 		Map<String, String> params = new HashMap<String, String>();
// 		int end = matcher.end();
// 		if (header.length() != end) {
// 			header = header.substring(end);
// 			header = REGEXP_TRIM.matcher(header).replaceFirst("");
// 			String[] expList = REGEXP_DIV_COMMA.split(header);
// 			for (String exp : expList) {
// 				String[] keyValue = exp.split("=", 2);
// 				String value = keyValue[1].replaceFirst("^\"", "");
// 				value = value.replaceFirst("\"$", "");
// 				params.put(keyValue[0], Util.decodeParam(value));
// 			}
// 		}
// 		return new FetchResult(token, params);
// 	}
// 
// }
// 
// Path: src/main/java/jp/eisbahn/oauth2/server/models/Request.java
// public interface Request {
// 
// 	/**
// 	 * Retrieve the parameter value specified by the parameter name
// 	 * from the request.
// 	 * @param name The parameter name.
// 	 * @return The value against the name.
// 	 */
// 	public String getParameter(String name);
// 
// 	/**
// 	 * Retrieve all parameter names and values from the request as a Map instance.
// 	 * @return  The map instance which has all parameter names and values.
// 	 */
// 	public Map<String, String> getParameterMap();
// 	
// 	/**
// 	 * Retrieve the request header value from the request.
// 	 * @param name The header's name.
// 	 * @return The value against the name.
// 	 */
// 	public String getHeader(String name);
// 
// }


import static org.junit.Assert.*;
import static org.easymock.EasyMock.*;
import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import jp.eisbahn.oauth2.server.fetcher.accesstoken.AccessTokenFetcher.FetchResult;
import jp.eisbahn.oauth2.server.fetcher.accesstoken.impl.AuthHeader;
import jp.eisbahn.oauth2.server.models.Request;
		verify(req);

		req = createRequestMock("oauth token1");
		assertFalse(target.match(req));
		verify(req);

		req = createRequestMock("Bearer token1");
		assertTrue(target.match(req));
		verify(req);

		req = createRequestMock("Bearer");
		assertTrue(target.match(req));
		verify(req);

		req = createRequestMock(" Bearer token1");
		assertTrue(target.match(req));
		verify(req);

		req = createRequestMock("Beare token1");
		assertFalse(target.match(req));
		verify(req);

		req = createRequestMock("bearer token1");
		assertFalse(target.match(req));
		verify(req);
	}

	@Test
	public void testParse() throws Exception {
		Request req;
// Path: src/main/java/jp/eisbahn/oauth2/server/fetcher/accesstoken/AccessTokenFetcher.java
// public static class FetchResult {
// 
// 	private String token;
// 	private Map<String, String> params;
// 
// 	/**
// 	 * This constructor initializes like both parameters become a null value.
// 	 */
// 	public FetchResult() {
// 		this(null, null);
// 	}
// 
// 	/**
// 	 * This constructor initializes with the specified argument values.
// 	 * @param token The access token string.
// 	 * @param params Other parameters.
// 	 */
// 	public FetchResult(String token, Map<String, String> params) {
// 		super();
// 		this.token = token;
// 		this.params = params;
// 	}
// 
// 	/**
// 	 * Set the access token.
// 	 * @param token The token string.
// 	 */
// 	public void setToken(String token) {
// 		this.token = token;
// 	}
// 
// 	/**
// 	 * Retrieve the access token.
// 	 * @return The token string.
// 	 */
// 	public String getToken() {
// 		return token;
// 	}
// 
// 	/**
// 	 * Set other parameters.
// 	 * @param params The other parameter map object.
// 	 */
// 	public void setParams(Map<String, String> params) {
// 		this.params = params;
// 	}
// 
// 	/**
// 	 * Retrieve the other parameters.
// 	 * @return The other parameter map object.
// 	 */
// 	public Map<String, String> getParams() {
// 		return params;
// 	}
// 
// }
// 
// Path: src/main/java/jp/eisbahn/oauth2/server/fetcher/accesstoken/impl/AuthHeader.java
// public class AuthHeader implements AccessTokenFetcher {
// 
// 	private static final String HEADER_AUTHORIZATION = "Authorization";
// 	private static final Pattern REGEXP_AUTHORIZATION =
// 			Pattern.compile("^\\s*(OAuth|Bearer)\\s+([^\\s\\,]*)");
// 	private static final Pattern REGEXP_TRIM = Pattern.compile("^\\s*,\\s*");
// 	private static final Pattern REGEXP_DIV_COMMA = Pattern.compile(",\\s*");
// 
// 	/**
// 	 * Return whether an access token is included in the Authorization
// 	 * request header.
// 	 * 
// 	 * @param request The request object.
// 	 * @return If the header value has an access token, this result is true.
// 	 */
// 	@Override
// 	public boolean match(Request request) {
// 		String header = request.getHeader(HEADER_AUTHORIZATION);
// 		return (header != null)
// 			&& (Pattern.matches("^\\s*(OAuth|Bearer)(.*)$", header));
// 	}
// 
// 	/**
// 	 * Fetch an access token from an Authorization request header and return it.
// 	 * This method must be called when a result of the match() method is true
// 	 * only.
// 	 * 
// 	 * @param request The request object.
// 	 * @return the fetched access token.
// 	 */
// 	@Override
// 	public FetchResult fetch(Request request) {
// 		String header = request.getHeader(HEADER_AUTHORIZATION);
// 		Matcher matcher = REGEXP_AUTHORIZATION.matcher(header);
// 		if (!matcher.find()) {
// 			throw new IllegalStateException(
// 				"parse() method was called when match() result was false.");
// 		}
// 		String token = matcher.group(2);
// 		Map<String, String> params = new HashMap<String, String>();
// 		int end = matcher.end();
// 		if (header.length() != end) {
// 			header = header.substring(end);
// 			header = REGEXP_TRIM.matcher(header).replaceFirst("");
// 			String[] expList = REGEXP_DIV_COMMA.split(header);
// 			for (String exp : expList) {
// 				String[] keyValue = exp.split("=", 2);
// 				String value = keyValue[1].replaceFirst("^\"", "");
// 				value = value.replaceFirst("\"$", "");
// 				params.put(keyValue[0], Util.decodeParam(value));
// 			}
// 		}
// 		return new FetchResult(token, params);
// 	}
// 
// }
// 
// Path: src/main/java/jp/eisbahn/oauth2/server/models/Request.java
// public interface Request {
// 
// 	/**
// 	 * Retrieve the parameter value specified by the parameter name
// 	 * from the request.
// 	 * @param name The parameter name.
// 	 * @return The value against the name.
// 	 */
// 	public String getParameter(String name);
// 
// 	/**
// 	 * Retrieve all parameter names and values from the request as a Map instance.
// 	 * @return  The map instance which has all parameter names and values.
// 	 */
// 	public Map<String, String> getParameterMap();
// 	
// 	/**
// 	 * Retrieve the request header value from the request.
// 	 * @param name The header's name.
// 	 * @return The value against the name.
// 	 */
// 	public String getHeader(String name);
// 
// }


// Path: src/test/java/jp/eisbahn/oauth2/server/fetcher/accesstoken/impl/AuthHeaderTest.java
import static org.junit.Assert.*;
import static org.easymock.EasyMock.*;
import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import jp.eisbahn.oauth2.server.fetcher.accesstoken.AccessTokenFetcher.FetchResult;
import jp.eisbahn.oauth2.server.fetcher.accesstoken.impl.AuthHeader;
import jp.eisbahn.oauth2.server.models.Request;

		verify(req);

		req = createRequestMock("oauth token1");
		assertFalse(target.match(req));
		verify(req);

		req = createRequestMock("Bearer token1");
		assertTrue(target.match(req));
		verify(req);

		req = createRequestMock("Bearer");
		assertTrue(target.match(req));
		verify(req);

		req = createRequestMock(" Bearer token1");
		assertTrue(target.match(req));
		verify(req);

		req = createRequestMock("Beare token1");
		assertFalse(target.match(req));
		verify(req);

		req = createRequestMock("bearer token1");
		assertFalse(target.match(req));
		verify(req);
	}

	@Test
	public void testParse() throws Exception {
		Request req;
		FetchResult parseResult;