001: package com.sun.portal.samples.asc.tests;
002:
003: import java.util.HashMap;
004: import java.util.Map;
005:
006: /**
007: * U4: Client requests processing of container action
008: * URL: provider=AJAXTableContainer&action=process&editMode=async&container.targetProvider=channelName&container.channelAction=minimize
009: * Request: XMLHttpRequest
010: * success/failure: JSON message
011: * @author gregz
012: *
013: */
014: public class TestUseCase4 extends AJAXTestCase {
015:
016: public void testU4Minimize() {
017: try {
018: int response;
019: String expected;
020:
021: // minimize default channel
022: response = processAction(Configuration.defaultChannel,
023: "minimize");
024: assertEquals(200, response);
025: expected = "Success.js";
026: compareExpected(expected);
027:
028: // verify channel was minimized
029: response = getDesktop();
030: assertEquals(200, response);
031: expected = Configuration.defaultChannel
032: + "-minimizedChannel.html";
033: compareExpected(expected);
034:
035: // normalize default channel
036: response = processAction(Configuration.defaultChannel,
037: "maximize");
038: assertEquals(200, response);
039: expected = "Success.js";
040: compareExpected(expected);
041:
042: // verify channel was normalized
043: response = getDesktop();
044: assertEquals(200, response);
045: expected = Configuration.defaultChannel
046: + "-normalFromMinimized.html";
047: compareExpected(expected);
048:
049: } catch (Exception e) {
050: TestUtils.fail(this , e);
051: }
052: }
053:
054: public void testU4Maximize() {
055: try {
056: int response;
057: String expected;
058:
059: // maximize default channel
060: response = processAction(Configuration.defaultChannel,
061: "truemaximize");
062: assertEquals(200, response);
063: expected = "Success.js";
064: compareExpected(expected);
065:
066: // verify channel was maximized
067: response = getDesktop();
068: assertEquals(200, response);
069: expected = Configuration.defaultChannel
070: + "-maximizedChannel.html";
071: compareExpected(expected);
072:
073: // normalize default channel
074: response = processAction(Configuration.defaultChannel,
075: "maximize");
076: assertEquals(200, response);
077: expected = "Success.js";
078: compareExpected(expected);
079:
080: // verify channel was normalized
081: response = getDesktop();
082: assertEquals(200, response);
083: expected = Configuration.defaultChannel
084: + "-normalFromMaximized.html";
085: compareExpected(expected);
086:
087: } catch (Exception e) {
088: TestUtils.fail(this , e);
089: }
090: }
091:
092: /*
093: public void testU4Remove() {
094: try {
095: int response;
096: String expected, unexpected;
097:
098: // remove default channel
099: response = processAction(Configuration.channel, "remove");
100: assertEquals(200, response);
101: expected = "Success.js";
102: compareExpected(expected);
103:
104: // verify channel was removed
105: response = getDesktop();
106: assertEquals(200, response);
107: unexpected = "DesktopNormal.html";
108: compareUnexpected(unexpected);
109:
110: // TODO add removed channel
111:
112: // verify was added back
113: response = getDesktop();
114: assertEquals(200, response);
115: expected = "DesktopNormal.html";
116: compareExpected(expected);
117:
118: } catch (Exception e) {
119: TestUtils.fail(this, e);
120: }
121:
122:
123: }
124:
125: */
126: public void testU4Failure() {
127: try {
128: processAction("UnknownChannel", "minimize");
129: String expected = "DesktopError.js";
130: compareExpected(expected);
131: } catch (Exception e) {
132: TestUtils.fail(this , e);
133: }
134: }
135:
136: private int processAction(String channelName, String action)
137: throws Exception {
138:
139: String provider = Configuration.defaultContainer;
140:
141: Map p = new HashMap();
142: p.put("provider", provider);
143: p.put("action", "process");
144: p.put(provider + ".channelAction", action);
145: p.put(provider + ".targetProvider", channelName);
146: p.put("editMode", "async");
147:
148: return asyncGet(p);
149:
150: }
151:
152: }
|