View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.tck.jndi;
8   
9   import org.mule.tck.testmodels.fruit.Apple;
10  import org.mule.tck.testmodels.fruit.Banana;
11  import org.mule.tck.testmodels.fruit.Orange;
12  
13  import java.util.Hashtable;
14  
15  import javax.naming.Context;
16  import javax.naming.NamingException;
17  
18  /**
19   * Creates an in-memory context and populates it with test data.
20   */
21  public class TestContextFactory extends InMemoryContextFactory
22  {
23      public Context getInitialContext() throws NamingException
24      {
25          Context context = super.getInitialContext();
26          populateTestData(context);
27          return context;
28      }
29  
30      public Context getInitialContext(Hashtable environment) throws NamingException
31      {
32          Context context = super.getInitialContext(environment);
33          populateTestData(context);
34          return context;
35      }
36      
37      protected void populateTestData(Context context) throws NamingException
38      {
39          context.bind("fruit/apple", new Apple());
40          context.bind("fruit/banana", new Banana());
41          context.bind("fruit/orange", new Orange(new Integer(8), new Double(10), "Florida Sunny"));
42      }
43  }