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: **********************************************************************************/package org.sakaiproject.tool.assessment.test.integration.context;
021:
022: import org.springframework.test.*;
023:
024: import org.sakaiproject.tool.assessment.integration.context.*; //import org.sakaiproject.tool.assessment.integration.helper.ifc.*;
025: import org.sakaiproject.tool.assessment.test.integration.helper.ifc.TestAgentHelper;
026: import org.springframework.context.ConfigurableApplicationContext;
027: import org.springframework.context.support.ClassPathXmlApplicationContext;
028: import org.springframework.web.context.WebApplicationContext;
029: import org.springframework.web.context.support.WebApplicationContextUtils;
030: import org.springframework.web.context.support.XmlWebApplicationContext;
031: import org.sakaiproject.spring.SpringBeanLocator;
032: import org.springframework.context.support.StaticApplicationContext;
033: import org.springframework.context.support.FileSystemXmlApplicationContext;
034:
035: public class TestIntegrationContextFactory extends
036: AbstractTransactionalSpringContextTests {
037: private IntegrationContextFactory integrationContextFactory;
038:
039: public TestIntegrationContextFactory(String name) {
040: }
041:
042: protected void onSetUpInTransaction() throws Exception {
043: }
044:
045: protected String[] getConfigLocations() {
046:
047: String[] configLocations = {
048: "org/sakaiproject/spring/integrationContext.xml",
049: // "org/sakaiproject/spring/applicationContext.xml",
050: "org/sakaiproject/spring/BeanDefinitions.xml",
051: // "org/sakaiproject/config/shared_components.xml",
052: //gb
053: // "org/sakaiproject/spring/spring-beans-test.xml",
054: // "org/sakaiproject/spring/spring-hib-test.xml",
055: };
056:
057: return configLocations;
058: }
059:
060: public void testGetInstance() {
061: IntegrationContextFactory actualReturn = integrationContextFactory
062: .getInstance();
063: integrationContextFactory = actualReturn;
064: assertNotNull(actualReturn);
065: System.out.println("testGetInstance=" + actualReturn);
066: }
067:
068: public void testMethods() {
069: System.out.println("testMethods");
070: // first, we make sure that SpringBeanLocator can handle non-web context
071: int configLength = getConfigLocations().length;
072: String[] fileConfigs = new String[configLength];
073: for (int i = 0; i < configLength; i++) {
074: fileConfigs[i] = "**/" + getConfigLocations()[i];
075: }
076: FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(
077: fileConfigs);
078: SpringBeanLocator.setConfigurableApplicationContext(context);
079: TestIntCtxtFactoryMethods testMethods = new TestIntCtxtFactoryMethods(
080: integrationContextFactory);
081: System.out.println("testIsIntegrated");
082: testMethods.testIsIntegrated();
083: System.out.println("testGetAgentHelper");
084: testMethods.testGetAgentHelper();
085: System.out.println("testGetAuthzHelper");
086: testMethods.testGetAuthzHelper();
087: System.out.println("testGetGradebookHelper");
088: testMethods.testGetGradebookHelper();
089: System.out.println("testGetGradeBookServiceHelper");
090: testMethods.testGetGradeBookServiceHelper();
091: System.out.println("testGetPublishingTargetHelper");
092: testMethods.testGetPublishingTargetHelper();
093: }
094:
095: public static void main(String[] args) {
096: System.out.println("starting.");
097: TestIntegrationContextFactory test = new TestIntegrationContextFactory(
098: "Test Integration Context Factory");
099: try {
100: test.setUp(); // we test instance next, so we don't do it in setUp()
101: test.testGetInstance(); //must be run first
102: test.testMethods();
103: test.tearDown();
104: } catch (Exception ex) {
105: System.out.println("ex=" + ex);
106: ex.printStackTrace();
107: }
108: System.out.println("done.");
109: }
110:
111: }
|