151e2646dSJens Baumgart /* 2*5c5f7c6bSMatthias Sohn * Copyright (C) 2010, Google Inc. and others 351e2646dSJens Baumgart * 4*5c5f7c6bSMatthias Sohn * This program and the accompanying materials are made available under the 5*5c5f7c6bSMatthias Sohn * terms of the Eclipse Distribution License v. 1.0 which is available at 6*5c5f7c6bSMatthias Sohn * https://www.eclipse.org/org/documents/edl-v10.php. 751e2646dSJens Baumgart * 8*5c5f7c6bSMatthias Sohn * SPDX-License-Identifier: BSD-3-Clause 951e2646dSJens Baumgart */ 1051e2646dSJens Baumgart 1151e2646dSJens Baumgart package org.eclipse.jgit.junit.http; 1251e2646dSJens Baumgart 1351e2646dSJens Baumgart import java.util.Enumeration; 1451e2646dSJens Baumgart import java.util.HashMap; 1551e2646dSJens Baumgart import java.util.Iterator; 1651e2646dSJens Baumgart import java.util.Map; 1751e2646dSJens Baumgart 1851e2646dSJens Baumgart import javax.servlet.ServletConfig; 1951e2646dSJens Baumgart import javax.servlet.ServletContext; 2051e2646dSJens Baumgart 210b131b73SMatthias Sohn /** 220b131b73SMatthias Sohn * Mock ServletConfig 230b131b73SMatthias Sohn */ 2451e2646dSJens Baumgart public class MockServletConfig implements ServletConfig { 253b444863SDavid Pursehouse private final Map<String, String> parameters = new HashMap<>(); 2651e2646dSJens Baumgart 270b131b73SMatthias Sohn /** 280b131b73SMatthias Sohn * Set init parameter. 290b131b73SMatthias Sohn * 300b131b73SMatthias Sohn * @param name 310b131b73SMatthias Sohn * @param value 320b131b73SMatthias Sohn */ setInitParameter(String name, String value)3351e2646dSJens Baumgart public void setInitParameter(String name, String value) { 3451e2646dSJens Baumgart parameters.put(name, value); 3551e2646dSJens Baumgart } 3651e2646dSJens Baumgart 370b131b73SMatthias Sohn /** {@inheritDoc} */ 387ac182f4SDavid Pursehouse @Override getInitParameter(String name)3951e2646dSJens Baumgart public String getInitParameter(String name) { 4051e2646dSJens Baumgart return parameters.get(name); 4151e2646dSJens Baumgart } 4251e2646dSJens Baumgart 430b131b73SMatthias Sohn /** {@inheritDoc} */ 447ac182f4SDavid Pursehouse @Override getInitParameterNames()45cf8e0f34SDavid Pursehouse public Enumeration<String> getInitParameterNames() { 4651e2646dSJens Baumgart final Iterator<String> i = parameters.keySet().iterator(); 4751e2646dSJens Baumgart return new Enumeration<String>() { 487ac182f4SDavid Pursehouse @Override 4951e2646dSJens Baumgart public boolean hasMoreElements() { 5051e2646dSJens Baumgart return i.hasNext(); 5151e2646dSJens Baumgart } 5251e2646dSJens Baumgart 537ac182f4SDavid Pursehouse @Override 5451e2646dSJens Baumgart public String nextElement() { 5551e2646dSJens Baumgart return i.next(); 5651e2646dSJens Baumgart } 5751e2646dSJens Baumgart }; 5851e2646dSJens Baumgart } 5951e2646dSJens Baumgart 600b131b73SMatthias Sohn /** {@inheritDoc} */ 617ac182f4SDavid Pursehouse @Override 6251e2646dSJens Baumgart public String getServletName() { 6351e2646dSJens Baumgart return "MOCK_SERVLET"; 6451e2646dSJens Baumgart } 6551e2646dSJens Baumgart 660b131b73SMatthias Sohn /** {@inheritDoc} */ 677ac182f4SDavid Pursehouse @Override 6851e2646dSJens Baumgart public ServletContext getServletContext() { 6951e2646dSJens Baumgart return null; 7051e2646dSJens Baumgart } 7151e2646dSJens Baumgart } 72