2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to you under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.shale.test.mock;
19  
20  import java.util.HashMap;
21  import java.util.Iterator;
22  import java.util.Map;
23  
24  import javax.faces.lifecycle.Lifecycle;
25  import javax.faces.lifecycle.LifecycleFactory;
26  
27  /***
28   * <p>Mock implementation of <code>LifecycleFactory</code>.</p>
29   *
30   * $Id$
31   */
32  
33  public class MockLifecycleFactory extends LifecycleFactory {
34  
35  
36      // ------------------------------------------------------------ Constructors
37  
38  
39      /***
40       * <p>Return a default instance.</p>
41       */
42      public MockLifecycleFactory() {
43  
44          lifecycles = new HashMap();
45          lifecycles.put(LifecycleFactory.DEFAULT_LIFECYCLE, new MockLifecycle());
46  
47      }
48  
49  
50      // ----------------------------------------------------- Mock Object Methods
51  
52  
53      // ------------------------------------------------------ Instance Variables
54  
55  
56      /***
57       * <p>The set of Lifecycle instances registered with us.</p>
58       */
59      private Map lifecycles = null;
60  
61  
62      // ------------------------------------------------ LifecycleFactory Methods
63  
64  
65      /*** {@inheritDoc} */
66      public void addLifecycle(String lifecycleId, Lifecycle lifecycle) {
67  
68          lifecycles.put(lifecycleId, lifecycle);
69  
70      }
71  
72  
73      /*** {@inheritDoc} */
74      public Lifecycle getLifecycle(String lifecycleId) {
75  
76          return (Lifecycle) lifecycles.get(lifecycleId);
77  
78      }
79  
80  
81      /*** {@inheritDoc} */
82      public Iterator getLifecycleIds() {
83  
84          return lifecycles.keySet().iterator();
85  
86      }
87  
88  
89  }