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.integration.helper.ifc.*;
025: import org.sakaiproject.service.framework.log.*;
026: import org.sakaiproject.site.*;
027:
028: import java.util.*;
029: import org.springframework.beans.factory.NoSuchBeanDefinitionException;
030:
031: public class TestPublishingTargetHelper extends TestCase {
032: private PublishingTargetHelper publishingTargetHelper = null;
033: private boolean isIntegrated;
034:
035: public TestPublishingTargetHelper(PublishingTargetHelper helper,
036: boolean integrated) {
037: this .publishingTargetHelper = helper;
038: this .isIntegrated = integrated;
039: assertNotNull(publishingTargetHelper);
040:
041: }
042:
043: protected void setUp() throws Exception {
044: super .setUp();
045: /**@todo verify the constructors*/
046: publishingTargetHelper = null;
047: }
048:
049: protected void tearDown() throws Exception {
050: publishingTargetHelper = null;
051: super .tearDown();
052: }
053:
054: public void testGetLog() {
055: Logger actualReturn = null;
056: boolean unimplemented = false;
057: try {
058: actualReturn = publishingTargetHelper.getLog();
059: } catch (NoSuchBeanDefinitionException nb) {
060: unimplemented = false; // we hit service to lookup bean in unit test
061:
062: } catch (java.lang.UnsupportedOperationException ex) {
063: unimplemented = true;
064: }
065:
066: if (isStandalone()) {
067: assertTrue(unimplemented);
068: }
069: if (this .isIntegrated()) {
070: assertFalse(unimplemented);
071: }
072: }
073:
074: public void testGetSiteService() {
075: SiteService actualReturn = null;
076: boolean unimplemented = false;
077: try {
078: actualReturn = publishingTargetHelper.getSiteService();
079: } catch (NoSuchBeanDefinitionException nb) {
080: unimplemented = false; // we hit service to lookup bean in unit test
081:
082: } catch (java.lang.UnsupportedOperationException ex) {
083: unimplemented = true;
084: }
085:
086: if (isStandalone()) {
087: assertTrue(unimplemented);
088: }
089: if (this .isIntegrated()) {
090: assertFalse(unimplemented);
091: }
092: }
093:
094: public void testGetTargets() {
095: HashMap actualReturn = publishingTargetHelper.getTargets();
096: int actualSize = actualReturn.size();
097: this .assertFalse(actualSize == 0);
098: }
099:
100: public void testSetLog() {
101: Logger log = null;
102:
103: boolean unimplemented = false;
104: boolean success = true;
105: try {
106: publishingTargetHelper.setLog(log);
107: } catch (java.lang.UnsupportedOperationException ex) {
108: unimplemented = true;
109: } catch (Exception ex2) {
110: success = false;
111: }
112:
113: if (isStandalone()) {
114: assertTrue(unimplemented);
115: }
116: if (this .isIntegrated()) {
117: assertTrue(success);
118: }
119:
120: }
121:
122: public void testSetSiteService() {
123: SiteService siteService = null;
124:
125: boolean unimplemented = false;
126: boolean success = true;
127: try {
128: publishingTargetHelper.setSiteService(siteService);
129: } catch (java.lang.UnsupportedOperationException ex) {
130: unimplemented = true;
131: } catch (Exception ex2) {
132: success = false;
133: }
134:
135: if (isStandalone()) {
136: assertTrue(unimplemented);
137: }
138: if (this .isIntegrated()) {
139: assertTrue(success);
140: }
141:
142: }
143:
144: public boolean isIntegrated() {
145: return isIntegrated;
146: }
147:
148: public boolean isStandalone() {
149: return !isIntegrated;
150: }
151: }
|