01: /*
02: * $Id: TestContextFactory.java 8083 2007-08-28 02:25:36Z aperepel $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.tck.jndi;
12:
13: import org.mule.tck.testmodels.fruit.Apple;
14: import org.mule.tck.testmodels.fruit.Banana;
15: import org.mule.tck.testmodels.fruit.Orange;
16:
17: import java.util.Hashtable;
18:
19: import javax.naming.Context;
20: import javax.naming.NamingException;
21:
22: /**
23: * Creates an in-memory context and populates it with test data.
24: */
25: public class TestContextFactory extends InMemoryContextFactory {
26: public Context getInitialContext() throws NamingException {
27: Context context = super .getInitialContext();
28: populateTestData(context);
29: return context;
30: }
31:
32: public Context getInitialContext(Hashtable environment)
33: throws NamingException {
34: Context context = super .getInitialContext(environment);
35: populateTestData(context);
36: return context;
37: }
38:
39: protected void populateTestData(Context context)
40: throws NamingException {
41: context.bind("fruit/apple", new Apple());
42: context.bind("fruit/banana", new Banana());
43: context.bind("fruit/orange", new Orange(new Integer(8),
44: new Double(10), "Florida Sunny"));
45: }
46: }
|