1 /*
2 * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3 * the spring framework, http://el4j.sf.net
4 * Copyright (C) 2006 by ELCA Informatique SA, Av. de la Harpe 22-24,
5 * 1000 Lausanne, Switzerland, http://www.elca.ch
6 *
7 * EL4J is published under the GNU Lesser General Public License (LGPL)
8 * Version 2.1. See http://www.gnu.org/licenses/
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * For alternative licensing, please contact info@elca.ch
16 */
17 package ch.elca.el4j.tests.core.implicitcontextpassing;
18
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import ch.elca.el4j.core.contextpassing.AbstractImplicitContextPasser;
23
24 /**
25 * This is the test implicit context passer A with different kinds of data.
26 *
27 * @svnLink $Revision: 3875 $;$Date: 2009-08-04 14:35:53 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/tests/core/core_implicit_context_passing_test/src/test/java/ch/elca/el4j/tests/core/implicitcontextpassing/ImplicitContextPasserImplA.java $
28 *
29 * @author David Stefan (DST)
30 */
31
32 public class ImplicitContextPasserImplA extends AbstractImplicitContextPasser
33 implements ImplicitContextPassTester {
34
35 /**
36 * Test data.
37 */
38 private Object m_testData = null;
39
40 /**
41 * Received data.
42 */
43 private Object m_receivedData = null;
44
45 /**
46 * Set which data to use.
47 *
48 * @param option
49 * Kind of data to use
50 */
51 public void setDataToUse(int option) {
52 List<Object> temp;
53 switch (option) {
54 case RESET:
55 m_testData = null;
56 m_receivedData = null;
57 break;
58 case NULL_TEST:
59 m_testData = null;
60 break;
61 case STRING_TEST:
62 m_testData = "This is my test data string";
63 break;
64 case INT_TEST:
65 m_testData = Integer.MIN_VALUE;
66 break;
67 case FLOAT_TEST:
68 m_testData = Float.MAX_VALUE;
69 break;
70 case DOUBLE_TEST:
71 m_testData = Double.NEGATIVE_INFINITY;
72 break;
73 case LIST_TEST:
74 temp = new ArrayList<Object>();
75 temp.add("");
76 temp.add("bar");
77 temp.add(Double.NaN);
78 m_testData = temp;
79 break;
80 case NULL_LIST_TEST:
81 temp = new ArrayList<Object>();
82 m_testData = temp;
83 break;
84 default:
85 throw new RuntimeException("Type of test not supported");
86 }
87 }
88
89 /**
90 * {@inheritDoc}
91 */
92 public Object getImplicitlyPassedContext() {
93 return m_testData;
94 }
95
96 /**
97 * {@inheritDoc}
98 */
99 public void pushImplicitlyPassedContext(Object context) {
100 if (context != null) {
101 m_receivedData = context;
102 }
103 }
104
105 /**
106 * {@inheritDoc}
107 */
108 public Object getReceivedData() {
109 return m_receivedData;
110 }
111
112 /**
113 * {@inheritDoc}
114 */
115 public Object getTestData() {
116 return m_testData;
117 }
118 }