001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.axis2.jaxws.lifecycle;
020:
021: import junit.framework.TestCase;
022: import org.apache.axis2.jaxws.registry.FactoryRegistry;
023: import org.apache.axis2.jaxws.resourceinjection.ResourceInjectionPortTypeImpl;
024: import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager;
025: import org.apache.axis2.jaxws.server.endpoint.lifecycle.factory.EndpointLifecycleManagerFactory;
026: import org.apache.axis2.jaxws.TestLogger;
027:
028: public class EndpointLifecycleTests extends TestCase {
029: Object endpointInstance = new ResourceInjectionPortTypeImpl();
030: Object badObject = new Object();
031:
032: public EndpointLifecycleTests() {
033: super ();
034: // TODO Auto-generated constructor stub
035: }
036:
037: /**
038: * @param arg0
039: */
040: public EndpointLifecycleTests(String arg0) {
041: super (arg0);
042: // TODO Auto-generated constructor stub
043: }
044:
045: public void testPostConstruct() {
046: TestLogger.logger.debug("------------------------------");
047: TestLogger.logger.debug("Test : " + getName());
048: try {
049: EndpointLifecycleManagerFactory elmf = (EndpointLifecycleManagerFactory) FactoryRegistry
050: .getFactory(EndpointLifecycleManagerFactory.class);
051: assertNotNull(elmf);
052: EndpointLifecycleManager elm = elmf
053: .createEndpointLifecycleManager(endpointInstance);
054: assertNotNull(elmf);
055: elm.invokePostConstruct();
056: TestLogger.logger.debug("------------------------------");
057: } catch (Exception e) {
058: fail(e.getMessage());
059: }
060: }
061:
062: public void testPreDestroy() {
063: TestLogger.logger.debug("------------------------------");
064: TestLogger.logger.debug("Test : " + getName());
065: try {
066: EndpointLifecycleManagerFactory elmf = (EndpointLifecycleManagerFactory) FactoryRegistry
067: .getFactory(EndpointLifecycleManagerFactory.class);
068: assertNotNull(elmf);
069: EndpointLifecycleManager elm = elmf
070: .createEndpointLifecycleManager(endpointInstance);
071: assertNotNull(elm);
072: elm.invokePreDestroy();
073: TestLogger.logger.debug("------------------------------");
074: } catch (Exception e) {
075: fail(e.getMessage());
076: }
077: }
078:
079: public void testBadPostConstruct() {
080: TestLogger.logger.debug("------------------------------");
081: TestLogger.logger.debug("Test : " + getName());
082: try {
083: EndpointLifecycleManagerFactory elmf = (EndpointLifecycleManagerFactory) FactoryRegistry
084: .getFactory(EndpointLifecycleManagerFactory.class);
085: assertNotNull(elmf);
086: EndpointLifecycleManager elm = elmf
087: .createEndpointLifecycleManager(badObject);
088: assertNotNull(elmf);
089: elm.invokePostConstruct();
090: TestLogger.logger.debug("------------------------------");
091: } catch (Exception e) {
092: fail(e.getMessage());
093: }
094: }
095:
096: public void testBadPreDestroy() {
097: TestLogger.logger.debug("------------------------------");
098: TestLogger.logger.debug("Test : " + getName());
099: try {
100: EndpointLifecycleManagerFactory elmf = (EndpointLifecycleManagerFactory) FactoryRegistry
101: .getFactory(EndpointLifecycleManagerFactory.class);
102: assertNotNull(elmf);
103: EndpointLifecycleManager elm = elmf
104: .createEndpointLifecycleManager(badObject);
105: assertNotNull(elm);
106: elm.invokePreDestroy();
107: TestLogger.logger.debug("------------------------------");
108: } catch (Exception e) {
109: fail(e.getMessage());
110: }
111: }
112: }
|