01: /* Copyright 2002 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal;
07:
08: import junit.framework.*;
09: import org.jasig.portal.UPFileSpec;
10: import org.jasig.portal.PortalException;
11:
12: public class UPFileSpecTest extends TestCase {
13:
14: String tagValue;
15: String methodValue;
16: String methodNodeIdValue;
17: String targetNodeIdValue;
18: String manual_uPFile;
19:
20: public UPFileSpecTest(String name) {
21: super (name);
22: }
23:
24: protected void setUp() {
25: tagValue = "someTagValue";
26: methodValue = UPFileSpec.RENDER_URL_ELEMENT;
27: methodNodeIdValue = "renderNodeIdValue";
28: targetNodeIdValue = "someTargetValue";
29:
30: manual_uPFile = UPFileSpec.TAG_URL_ELEMENT
31: + UPFileSpec.PORTAL_URL_SEPARATOR + tagValue
32: + UPFileSpec.PORTAL_URL_SEPARATOR + methodValue
33: + UPFileSpec.PORTAL_URL_SEPARATOR + methodNodeIdValue
34: + UPFileSpec.PORTAL_URL_SEPARATOR
35: + UPFileSpec.TARGET_URL_ELEMENT
36: + UPFileSpec.PORTAL_URL_SEPARATOR + targetNodeIdValue
37: + UPFileSpec.PORTAL_URL_SEPARATOR
38: + UPFileSpec.PORTAL_URL_SUFFIX;
39:
40: }
41:
42: public void testCombinedBuild() throws PortalException {
43: String uPFile = UPFileSpec.buildUPFile(tagValue,
44: UPFileSpec.RENDER_METHOD, methodNodeIdValue,
45: targetNodeIdValue, null);
46: assertEquals(uPFile, manual_uPFile);
47: }
48:
49: public void testIncrementalBuild() throws PortalException {
50: UPFileSpec upf = new UPFileSpec();
51: upf.setTagId(tagValue);
52: upf.setMethod(UPFileSpec.RENDER_METHOD);
53: upf.setMethodNodeId(methodNodeIdValue);
54: upf.setTargetNodeId(targetNodeIdValue);
55: String uPFile = upf.getUPFile();
56: assertEquals(uPFile, manual_uPFile);
57: }
58:
59: public void testParsing() {
60: UPFileSpec fs = new UPFileSpec(manual_uPFile);
61: assertEquals(tagValue, fs.getTagId());
62: assertEquals(methodValue, fs.getMethod());
63: assertEquals(methodNodeIdValue, fs.getMethodNodeId());
64: assertEquals(targetNodeIdValue, fs.getTargetNodeId());
65: }
66:
67: }
|