package hirondelle.fish.test.doubles;
import java.io.FileNotFoundException;
import java.util.*;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
public class FakeServletConfig implements ServletConfig {
private static void main(String... aArgs) throws FileNotFoundException {
log("Starting.");
FakeServletConfig fake = new FakeServletConfig();
Enumeration names = fake.getInitParameterNames();
while( names.hasMoreElements() ){
Object name = names.nextElement();
String value = fake.getInitParameter(name.toString());
log(name + "=" + value);
}
log("Done.");
}
public static final String SERVLET_NAME = "Fake Testing Servlet";
public FakeServletConfig() throws FileNotFoundException {
fFakeServletContext = new FakeServletContext();
fInitParams = buildFakeData();
}
public String getInitParameter(String aParamName) {
return fInitParams.get(aParamName);
}
public Enumeration getInitParameterNames() {
return Collections.enumeration(fInitParams.keySet());
}
public ServletContext getServletContext() {
return fFakeServletContext;
}
public String getServletName() {
return SERVLET_NAME;
}
private Map<String, String> fInitParams;
private ServletContext fFakeServletContext;
private Map<String, String> buildFakeData(){
Map<String, String> result = new LinkedHashMap<String, String>();
result.put("Webmaster", "BLAH@BLAH.COM");
result.put("EmailInSeparateThread", "YES");
result.put("LoggingDirectory", "C:\\log\\fish\\");
result.put("LoggingLevels", "hirondelle.fish.level=FINE, hirondelle.web4j.level=FINE");
result.put("ImplicitMappingRemoveBasePackage", "hirondelle.fish");
result.put("TroubleTicketMailingList", "BLAH@BLAH.COM, BLAH@BLAH.COM");
result.put("MinimumIntervalBetweenTroubleTickets", "30");
result.put("PoorPerformanceThreshold", "20");
result.put("MaxHttpRequestSize", "51200");
result.put("MaxFileUploadRequestSize", "1048576");
result.put("MaxRequestParamValueSize", "51200");
result.put("SpamDetectionInFirewall", "OFF");
result.put("FullyValidateFileUploads", "ON");
result.put("CharacterEncoding", "UTF-8");
result.put("DefaultLocale", "en");
result.put("DefaultUserTimeZone", "UTC");
result.put("TimeZoneHint", "NONE");
result.put("DecimalStyle", "HALF_EVEN,2");
result.put("DecimalSeparator", "PERIOD");
result.put("BigDecimalDisplayFormat", "#,##0.00");
result.put("BooleanTrueDisplayFormat", "<input type='checkbox' name='blah' value='blah' checked readonly notab>");
result.put("BooleanFalseDisplayFormat", "<input type='checkbox' name='blah' value='blah' readonly notab>");
result.put("EmptyOrNullDisplayFormat", "-");
result.put("IntegerDisplayFormat", "#,###");
result.put("IgnorableParamValue", "");
result.put("IsSQLPrecompilationAttempted", "true");
result.put("MaxRows", "300");
result.put("FetchSize", "25");
result.put("HasAutoGeneratedKeys", "true");
result.put("ErrorCodeForDuplicateKey", "1062");
result.put("SqlFetcherDefaultTxIsolationLevel", "DATABASE_DEFAULT");
result.put("SqlEditorDefaultTxIsolationLevel", "DATABASE_DEFAULT");
result.put("ImplementationFor.hirondelle.web4j.database.ConnectionSource", "hirondelle.fish.test.doubles.FakeConnectionSrc");
result.put("DefaultDbConnectionString", "jdbc:mysql://localhost:3306/fish");
result.put("TranslationDbConnectionString", "jdbc:mysql://localhost:3306/fish_translation");
result.put("AccessControlDbConnectionString", "jdbc:mysql://localhost:3306/fish_access");
return result;
}
private static void log(Object aObject){
System.out.println(String.valueOf(aObject));
}
}