001: /**********************************************************************************
002: * $URL: $
003: * $Id: $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the"License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: *
021: **********************************************************************************/package org.sakaiproject.tool.assessment.test.integration.context;
022:
023: import junit.framework.*;
024: import org.springframework.test.*;
025:
026: import org.sakaiproject.tool.assessment.integration.context.*;
027: import org.sakaiproject.tool.assessment.integration.helper.ifc.*;
028: import org.sakaiproject.tool.assessment.test.integration.helper.ifc.TestAgentHelper;
029: import org.sakaiproject.tool.assessment.test.integration.helper.ifc.TestGradebookHelper;
030: import org.sakaiproject.tool.assessment.test.integration.helper.ifc.TestPublishingTargetHelper;
031: import org.sakaiproject.tool.assessment.test.integration.helper.ifc.TestAuthzHelper;
032: import org.sakaiproject.tool.assessment.test.integration.helper.ifc.TestGradebookServiceHelper;
033: import org.springframework.context.ConfigurableApplicationContext;
034: import org.springframework.web.context.WebApplicationContext;
035:
036: public class TestIntCtxtFactoryMethods extends TestCase {
037: private IntegrationContextFactory integrationContextFactory = null;
038:
039: public TestIntCtxtFactoryMethods(IntegrationContextFactory factory) {
040: this .integrationContextFactory = factory;
041: }
042:
043: protected void setUp() throws Exception {
044: super .setUp();
045: }
046:
047: protected void tearDown() throws Exception {
048: super .tearDown();
049: }
050:
051: public void testGetAgentHelper() {
052: AgentHelper actualReturn = integrationContextFactory
053: .getAgentHelper();
054: System.out.println("testGetAgentHelper=" + actualReturn);
055: assertNotNull(actualReturn);
056: System.out.println(" *** testing agent helper methods");
057: TestAgentHelper testAgent = new TestAgentHelper(actualReturn);
058: System.out.println("testCreateAnonymous()");
059: testAgent.testCreateAnonymous();
060: System.out.println("testGetAgent()");
061: testAgent.testGetAgent();
062: System.out.println("testGetAgentString()");
063: testAgent.testGetAgentString();
064: System.out.println("testGetAgentString_RequestResponse()");
065: testAgent.testGetAgentString_RequestResponse();
066: System.out.println("testGetAnonymousId()");
067: testAgent.testGetAnonymousId();
068: System.out.println("testGetCurrentSiteId()");
069: testAgent.testGetCurrentSiteId();
070: System.out.println("testGetCurrentSiteIdFromExternalServlet()");
071: testAgent.testGetCurrentSiteIdFromExternalServlet();
072: System.out.println("testGetCurrentSiteName()");
073: testAgent.testGetCurrentSiteName();
074: System.out.println("testGetDisplayName()");
075: testAgent.testGetDisplayName();
076: System.out.println("testGetDisplayNameByAgentId()");
077: testAgent.testGetDisplayNameByAgentId();
078: System.out.println("testGetFirstName()");
079: testAgent.testGetFirstName();
080: System.out.println("testGetLastName()");
081: testAgent.testGetLastName();
082: System.out.println("testGetRole()");
083: testAgent.testGetRole();
084: System.out.println("testGetRoleForCurrentAgent()");
085: testAgent.testGetRoleForCurrentAgent();
086: System.out.println("testGetSiteName()");
087: testAgent.testGetSiteName();
088: System.out.println("testIsIntegratedEnvironment()");
089: testAgent.testIsIntegratedEnvironment();
090: System.out.println("testIsStandaloneEnvironment()");
091: testAgent.testIsStandaloneEnvironment();
092:
093: System.out
094: .println(" *** complete: testing agent helper methods");
095: }
096:
097: // test this first, it is used below
098: public void testIsIntegrated() {
099: boolean expectedReturn = false;
100: boolean actualReturn = integrationContextFactory.isIntegrated();
101: System.out
102: .println("verified: testIsIntegrated=" + actualReturn);
103: }
104:
105: public void testGetAuthzHelper() {
106: AuthzHelper actualReturn = integrationContextFactory
107: .getAuthzHelper();
108: assertNotNull(actualReturn);
109: System.out.println("testGetAuthzHelper=" + actualReturn);
110: System.out.println(" *** testing gradebook helper methods");
111: TestAuthzHelper testAuthz = new TestAuthzHelper(actualReturn,
112: integrationContextFactory.isIntegrated());
113: System.out.println("testCheckAuthorization()");
114: testAuthz.testCheckAuthorization();
115: System.out.println("testCheckMembership()");
116: testAuthz.testCheckMembership();
117: System.out.println("testCreateAuthorization()");
118: testAuthz.testCreateAuthorization();
119: System.out.println("testGetAssessments()");
120: testAuthz.testGetAssessments();
121: System.out.println("testGetAssessmentsByAgentAndFunction()");
122: testAuthz.testGetAssessmentsByAgentAndFunction();
123: System.out.println("testGetAuthorizationByAgentAndFunction()");
124: testAuthz.testGetAuthorizationByAgentAndFunction();
125: System.out
126: .println("testGetAuthorizationByFunctionAndQualifier()");
127: testAuthz.testGetAuthorizationByFunctionAndQualifier();
128: System.out.println("testGetAuthorizationToViewAssessments()");
129: testAuthz.testGetAuthorizationToViewAssessments();
130: System.out.println("testRemoveAuthorizationByQualifier()");
131: testAuthz.testRemoveAuthorizationByQualifier();
132: System.out.println("testIsAuthorized()");
133: testAuthz.testIsAuthorized();
134:
135: System.out
136: .println(" *** complete: testing gradebook helper methods");
137: }
138:
139: public void testGetGradeBookServiceHelper() {
140: GradebookServiceHelper actualReturn = integrationContextFactory
141: .getGradebookServiceHelper();
142: assertNotNull(actualReturn);
143: System.out.println("testGetGradeBookServiceHelper="
144: + actualReturn);
145: System.out
146: .println(" *** testing gradebook service helper methods");
147: TestGradebookServiceHelper testGBS = new TestGradebookServiceHelper(
148: actualReturn, integrationContextFactory.isIntegrated());
149: System.out
150: .println(" *** testing gradebook service helper methods");
151: System.out.println("testAddToGradebook");
152: testGBS.testAddToGradebook();
153: System.out.println("testGradebookExists");
154: testGBS.testGradebookExists();
155: System.out.println("testRemoveExternalAssessment");
156: testGBS.testRemoveExternalAssessment();
157: System.out.println("testUpdateExternalAssessmentScore");
158: testGBS.testUpdateExternalAssessmentScore();
159: System.out
160: .println(" *** complete: testing gradebook service helper methods");
161: }
162:
163: public void testGetGradebookHelper() {
164: GradebookHelper actualReturn = integrationContextFactory
165: .getGradebookHelper();
166: assertNotNull(actualReturn);
167: System.out.println("testGetGradebookHelper=" + actualReturn);
168: System.out.println(" *** testing gradebook helper methods");
169: TestGradebookHelper testGB = new TestGradebookHelper(
170: actualReturn, integrationContextFactory.isIntegrated());
171: testGB.testGetDefaultGradebookUId();
172: System.out.println("testGetDefaultGradebookUId()");
173: testGB.testGetGradebookUId();
174: System.out.println("testGetGradebookUId()");
175:
176: System.out
177: .println(" *** complete: testing gradebook helper methods");
178: }
179:
180: public void testGetPublishingTargetHelper() {
181: PublishingTargetHelper actualReturn = integrationContextFactory
182: .getPublishingTargetHelper();
183: assertNotNull(actualReturn);
184: System.out.println("testGetPublishingTargetHelper="
185: + actualReturn);
186: System.out.println("integrationContextFactory.isIntegrated()="
187: + integrationContextFactory.isIntegrated());
188: System.out.println(" *** testing publish helper methods");
189: TestPublishingTargetHelper test = new TestPublishingTargetHelper(
190: actualReturn, integrationContextFactory.isIntegrated());
191: System.out.println("testGetLog");
192: test.testGetLog();
193: System.out.println("testGetSiteService");
194: test.testGetSiteService();
195: System.out.println("testGetTargets");
196: test.testGetTargets();
197: System.out.println("testSetLog");
198: test.testSetLog();
199: System.out.println("testSetSiteService");
200: test.testSetSiteService();
201: System.out
202: .println(" *** complete: testing publish helper methods");
203: }
204:
205: }
|