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
18 package ch.elca.el4j.tests.core.implicitcontextpassing;
19
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import ch.elca.el4j.core.contextpassing.AbstractImplicitContextPasser;
24
25 //Checkstyle: MagicNumber off
26
27 /**
28 * This is the test implicit context passer B with data different to those in
29 * ImplicitContextPasserImplA.
30 *
31 * @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/ImplicitContextPasserImplB.java $
32 *
33 * @author David Stefan (DST)
34 */
35
36 public class ImplicitContextPasserImplB extends AbstractImplicitContextPasser
37 implements ImplicitContextPassTester {
38
39 /**
40 * Test data.
41 */
42 private Object m_testData = null;
43
44 /**
45 * Received data.
46 */
47 private Object m_receivedData = null;
48
49 /**
50 * {@inheritDoc}
51 */
52 public void setDataToUse(int option) {
53 List<Object> temp;
54 switch (option) {
55 case RESET:
56 m_testData = null;
57 m_receivedData = null;
58 break;
59 case NULL_TEST:
60 m_testData = null;
61 break;
62 case STRING_TEST:
63 m_testData
64 = "This is another test data string, that is different";
65 break;
66 case INT_TEST:
67 m_testData = Integer.MAX_VALUE;
68 break;
69 case FLOAT_TEST:
70 m_testData = Float.MIN_VALUE;
71 break;
72 case DOUBLE_TEST:
73 m_testData = Double.POSITIVE_INFINITY;
74 break;
75 case LIST_TEST:
76 temp = new ArrayList<Object>();
77 temp.add(new ArrayList<String>().add("bar"));
78 temp.add(13);
79 temp.add("ralca");
80 m_testData = temp;
81 break;
82 case NULL_LIST_TEST:
83 temp = new ArrayList<Object>();
84 m_testData = temp;
85 break;
86 default:
87 throw new RuntimeException("Type of test not supported");
88 }
89 }
90
91 /**
92 * {@inheritDoc}
93 */
94 public Object getImplicitlyPassedContext() {
95 return m_testData;
96 }
97
98 /**
99 * {@inheritDoc}
100 */
101 public void pushImplicitlyPassedContext(Object context) {
102 if (context != null) {
103 m_receivedData = context;
104 }
105 }
106
107 /**
108 * {@inheritDoc}
109 */
110 public Object getReceivedData() {
111 return m_receivedData;
112 }
113
114 /**
115 * {@inheritDoc}
116 */
117 public Object getTestData() {
118 return m_testData;
119 }
120 }
121 //Checkstyle: MagicNumber on