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.helper.ifc;
022:
023: import junit.framework.*;
024: import org.sakaiproject.tool.assessment.data.dao.assessment.*;
025: import org.sakaiproject.tool.assessment.data.ifc.grading.*;
026: import org.sakaiproject.tool.assessment.integration.helper.ifc.GradebookServiceHelper;
027: import org.sakaiproject.spring.SpringBeanLocator;
028: import org.springframework.context.ConfigurableApplicationContext;
029: import org.springframework.web.context.WebApplicationContext;
030: import org.springframework.beans.factory.NoSuchBeanDefinitionException;
031:
032: public class TestGradebookServiceHelper extends TestCase {
033: private GradebookServiceHelper gradebookServiceHelper = null;
034:
035: private boolean integrated;
036: private WebApplicationContext context;
037:
038: public TestGradebookServiceHelper(GradebookServiceHelper helper,
039: boolean integrated) {
040: this .gradebookServiceHelper = helper;
041: this .integrated = integrated;
042: this .context = context;
043: assertNotNull(gradebookServiceHelper);
044: }
045:
046: protected void setUp() throws Exception {
047: super .setUp();
048: /**@todo verify the constructors*/
049: gradebookServiceHelper = null;
050: }
051:
052: protected void tearDown() throws Exception {
053: gradebookServiceHelper = null;
054: super .tearDown();
055: }
056:
057: public void testAddToGradebook() {
058: boolean success = false;
059:
060: try {
061: PublishedAssessmentData publishedAssessment = null;
062: boolean expectedReturn = false;
063: // should fail (false) with null, so success shoudl be false
064: boolean actualReturn = gradebookServiceHelper
065: .addToGradebook(publishedAssessment);
066: assertEquals("return value", expectedReturn, actualReturn);
067: success = true;
068: } catch (Exception ex) {
069: System.out.println("testAddToGradebook " + ex);
070: }
071: assertFalse(success);
072: }
073:
074: public void testGradebookExists() {
075: // standalone will always return false, for integrated use non-existent
076: String gradebookUId = "bogusGB";
077: boolean expectedReturn = false;
078: boolean actualReturn = false;
079: // for nowwe bypass for integrated, 'cause we need to fake up web ctxt.
080: if (this .isStandalone()) {
081: actualReturn = gradebookServiceHelper
082: .gradebookExists(gradebookUId);
083: }
084: assertEquals("return value", expectedReturn, actualReturn);
085: }
086:
087: public void testRemoveExternalAssessment() {
088:
089: boolean success = false;
090: try {
091: String gradebookUId = null;
092: String publishedAssessmentId = null;
093: gradebookServiceHelper.removeExternalAssessment(
094: gradebookUId, publishedAssessmentId);
095: success = true;
096: } catch (NoSuchBeanDefinitionException nb) {
097: success = true; // unit test, calling sb locator, so we call success
098: System.out.println("unit test hitting locator");
099: } catch (Exception ex) {
100: System.out.println("testRemoveExternalAssessment " + ex);
101: }
102: assertTrue(success);
103: }
104:
105: public void testUpdateExternalAssessmentScore() {
106: boolean success = false;
107:
108: try {
109: AssessmentGradingIfc ag = null;
110: gradebookServiceHelper.updateExternalAssessmentScore(ag);
111: success = true;
112: } catch (NoSuchBeanDefinitionException nb) {
113: success = true; // unit test, calling sb locator, so we call success
114: System.out.println("unit test hitting locator");
115: } catch (Exception ex) {
116: System.out.println("testUpdateExternalAssessmentScore "
117: + ex);
118: }
119: assertTrue(success);
120: }
121:
122: public boolean isIntegrated() {
123: return integrated;
124: }
125:
126: public boolean isStandalone() {
127: return !integrated;
128: }
129:
130: }
|