001: /*
002: * $Id: ContextUtilTest.java 474191 2006-11-13 08:30:40Z mrdon $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts2.views.util;
022:
023: import junit.framework.TestCase;
024:
025: import org.apache.struts2.StrutsConstants;
026:
027: import com.opensymphony.xwork2.util.ValueStack;
028: import com.opensymphony.xwork2.util.ValueStackFactory;
029:
030: /**
031: * Test case for ContextUtil
032: *
033: */
034: public class ContextUtilTest extends TestCase {
035:
036: public void testAltSyntaxMethod1() throws Exception {
037: ValueStack stack = ValueStackFactory.getFactory()
038: .createValueStack();
039: stack.getContext().put("useAltSyntax", "true");
040:
041: ContextUtil.setAltSyntax("true");
042: assertTrue(ContextUtil.isUseAltSyntax(stack.getContext()));
043: }
044:
045: public void testAltSyntaxMethod2() throws Exception {
046: ValueStack stack = ValueStackFactory.getFactory()
047: .createValueStack();
048: stack.getContext().put("useAltSyntax", "false");
049:
050: ContextUtil.setAltSyntax("true");
051: assertTrue(ContextUtil.isUseAltSyntax(stack.getContext()));
052: }
053:
054: public void testAltSyntaxMethod3() throws Exception {
055: ValueStack stack = ValueStackFactory.getFactory()
056: .createValueStack();
057: stack.getContext().put("useAltSyntax", "true");
058:
059: ContextUtil.setAltSyntax("false");
060: assertTrue(ContextUtil.isUseAltSyntax(stack.getContext()));
061: }
062:
063: public void testAltSyntaxMethod4() throws Exception {
064: ValueStack stack = ValueStackFactory.getFactory()
065: .createValueStack();
066: stack.getContext().put("useAltSyntax", "false");
067:
068: ContextUtil.setAltSyntax("false");
069: assertFalse(ContextUtil.isUseAltSyntax(stack.getContext()));
070: }
071:
072: //========================================================
073:
074: public void testAltSyntaxMethod5() throws Exception {
075: ValueStack stack = ValueStackFactory.getFactory()
076: .createValueStack();
077: stack.getContext().put("useAltSyntax", Boolean.TRUE);
078:
079: ContextUtil.setAltSyntax("true");
080: assertTrue(ContextUtil.isUseAltSyntax(stack.getContext()));
081: }
082:
083: public void testAltSyntaxMethod6() throws Exception {
084: ValueStack stack = ValueStackFactory.getFactory()
085: .createValueStack();
086: stack.getContext().put("useAltSyntax", Boolean.FALSE);
087:
088: ContextUtil.setAltSyntax("true");
089: assertTrue(ContextUtil.isUseAltSyntax(stack.getContext()));
090: }
091:
092: public void testAltSyntaxMethod7() throws Exception {
093: ValueStack stack = ValueStackFactory.getFactory()
094: .createValueStack();
095: stack.getContext().put("useAltSyntax", Boolean.TRUE);
096:
097: ContextUtil.setAltSyntax("false");
098: assertTrue(ContextUtil.isUseAltSyntax(stack.getContext()));
099: }
100:
101: public void testAltSyntaxMethod8() throws Exception {
102: ValueStack stack = ValueStackFactory.getFactory()
103: .createValueStack();
104: stack.getContext().put("useAltSyntax", Boolean.FALSE);
105:
106: ContextUtil.setAltSyntax("false");
107: assertFalse(ContextUtil.isUseAltSyntax(stack.getContext()));
108: }
109:
110: // ==========================================
111: public void testAltSyntaxMethod9() throws Exception {
112: ValueStack stack = ValueStackFactory.getFactory()
113: .createValueStack();
114: stack.getContext().put("useAltSyntax", null);
115:
116: ContextUtil.setAltSyntax("true");
117: assertTrue(ContextUtil.isUseAltSyntax(stack.getContext()));
118: }
119: }
|