001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 004 * 005 * This program and the accompanying materials are dual-licensed under 006 * either the terms of the Eclipse Public License v1.0 as published by 007 * the Eclipse Foundation 008 * 009 * or (per the licensee's choosing) 010 * 011 * under the terms of the GNU Lesser General Public License version 2.1 012 * as published by the Free Software Foundation. 013 */ 014package ch.qos.logback.classic.util; 015 016import java.util.Hashtable; 017 018import javax.naming.Context; 019import javax.naming.NamingException; 020import javax.naming.spi.InitialContextFactory; 021 022public class MockInitialContextFactory implements InitialContextFactory { 023 static MockInitialContext mic; 024 025 static { 026 System.out.println("MockInitialContextFactory static called"); 027 initialize(); 028 } 029 030 public static void initialize() { 031 try { 032 mic = new MockInitialContext(); 033 } catch (NamingException e) { 034 e.printStackTrace(); 035 } 036 } 037 038 public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException { 039 return mic; 040 } 041 042 public static MockInitialContext getContext() { 043 return mic; 044 } 045 046}