0001: /**
0002: * Licensed to the Apache Software Foundation (ASF) under one or more
0003: * contributor license agreements. See the NOTICE file distributed with
0004: * this work for additional information regarding copyright ownership.
0005: * The ASF licenses this file to You under the Apache License, Version 2.0
0006: * (the "License"); you may not use this file except in compliance with
0007: * the License. You may obtain a copy of the License at
0008: *
0009: * http://www.apache.org/licenses/LICENSE-2.0
0010: *
0011: * Unless required by applicable law or agreed to in writing, software
0012: * distributed under the License is distributed on an "AS IS" BASIS,
0013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014: * See the License for the specific language governing permissions and
0015: * limitations under the License.
0016: */package org.apache.openejb.config;
0017:
0018: import junit.framework.TestCase;
0019: import org.apache.openejb.assembler.classic.Assembler;
0020: import org.apache.openejb.assembler.classic.CallbackInfo;
0021: import org.apache.openejb.assembler.classic.EjbJarInfo;
0022: import org.apache.openejb.assembler.classic.EjbLocalReferenceInfo;
0023: import org.apache.openejb.assembler.classic.EjbReferenceInfo;
0024: import org.apache.openejb.assembler.classic.EnvEntryInfo;
0025: import org.apache.openejb.assembler.classic.HandlerChainInfo;
0026: import org.apache.openejb.assembler.classic.HandlerInfo;
0027: import org.apache.openejb.assembler.classic.InitMethodInfo;
0028: import org.apache.openejb.assembler.classic.InjectionInfo;
0029: import org.apache.openejb.assembler.classic.JndiEncInfo;
0030: import org.apache.openejb.assembler.classic.NamedMethodInfo;
0031: import org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo;
0032: import org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo;
0033: import org.apache.openejb.assembler.classic.PortRefInfo;
0034: import org.apache.openejb.assembler.classic.ProxyFactoryInfo;
0035: import org.apache.openejb.assembler.classic.ReferenceLocationInfo;
0036: import org.apache.openejb.assembler.classic.RemoveMethodInfo;
0037: import org.apache.openejb.assembler.classic.ResourceEnvReferenceInfo;
0038: import org.apache.openejb.assembler.classic.ResourceReferenceInfo;
0039: import org.apache.openejb.assembler.classic.SecurityRoleReferenceInfo;
0040: import org.apache.openejb.assembler.classic.SecurityServiceInfo;
0041: import org.apache.openejb.assembler.classic.ServiceReferenceInfo;
0042: import org.apache.openejb.assembler.classic.StatefulBeanInfo;
0043: import org.apache.openejb.assembler.classic.StatefulSessionContainerInfo;
0044: import org.apache.openejb.assembler.classic.TransactionServiceInfo;
0045: import org.apache.openejb.jee.EjbJar;
0046: import org.apache.openejb.jee.StatefulBean;
0047:
0048: import javax.annotation.PostConstruct;
0049: import javax.annotation.PreDestroy;
0050: import javax.annotation.Resource;
0051: import javax.annotation.security.DeclareRoles;
0052: import javax.annotation.security.RolesAllowed;
0053: import javax.annotation.security.RunAs;
0054: import javax.ejb.CreateException;
0055: import javax.ejb.EJB;
0056: import javax.ejb.EJBHome;
0057: import javax.ejb.EJBLocalHome;
0058: import javax.ejb.EJBLocalObject;
0059: import javax.ejb.EJBObject;
0060: import javax.ejb.Init;
0061: import javax.ejb.Local;
0062: import javax.ejb.LocalHome;
0063: import javax.ejb.PostActivate;
0064: import javax.ejb.PrePassivate;
0065: import javax.ejb.Remote;
0066: import javax.ejb.RemoteHome;
0067: import javax.ejb.Remove;
0068: import javax.ejb.Timeout;
0069: import javax.ejb.Timer;
0070: import javax.ejb.TransactionAttribute;
0071: import javax.ejb.TransactionAttributeType;
0072: import javax.ejb.TransactionManagement;
0073: import javax.ejb.TransactionManagementType;
0074: import javax.interceptor.AroundInvoke;
0075: import javax.interceptor.InvocationContext;
0076: import javax.jms.Topic;
0077: import javax.sql.DataSource;
0078: import java.rmi.RemoteException;
0079: import java.util.List;
0080: import java.util.ListIterator;
0081:
0082: /**
0083: * @version $Rev$ $Date$
0084: */
0085: public class InheritenceTest extends TestCase {
0086:
0087: public void test() throws Exception {
0088: Assembler assembler = new Assembler();
0089: ConfigurationFactory config = new ConfigurationFactory();
0090:
0091: assembler.createProxyFactory(config
0092: .configureService(ProxyFactoryInfo.class));
0093: assembler.createTransactionManager(config
0094: .configureService(TransactionServiceInfo.class));
0095: assembler.createSecurityService(config
0096: .configureService(SecurityServiceInfo.class));
0097: assembler.createContainer(config
0098: .configureService(StatefulSessionContainerInfo.class));
0099:
0100: EjbJar ejbJar = new EjbJar();
0101: ejbJar.addEnterpriseBean(new StatefulBean(Color.class));
0102: ejbJar.addEnterpriseBean(new StatefulBean(Red.class));
0103: EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
0104:
0105: StatefulBeanInfo expected = (StatefulBeanInfo) ejbJarInfo.enterpriseBeans
0106: .get(0);
0107: StatefulBeanInfo actual = (StatefulBeanInfo) ejbJarInfo.enterpriseBeans
0108: .get(1);
0109:
0110: assertEquals("transactionType", expected.transactionType,
0111: actual.transactionType);
0112: assertEquals("runAs", expected.runAs, actual.runAs);
0113:
0114: assertEquals("businessLocal", expected.businessLocal,
0115: actual.businessLocal);
0116: assertEquals("businessRemote", expected.businessRemote,
0117: actual.businessRemote);
0118: assertEquals("local", expected.local, actual.local);
0119: assertEquals("localHome", expected.localHome, actual.localHome);
0120: assertEquals("remote", expected.remote, actual.remote);
0121: assertEquals("home", expected.home, actual.home);
0122:
0123: assertEquals("timeout", expected.timeoutMethod,
0124: actual.timeoutMethod);
0125:
0126: assertCallbackInfos("postActivate", expected.postActivate,
0127: actual.postActivate);
0128: assertCallbackInfos("prePassivate", expected.prePassivate,
0129: actual.prePassivate);
0130:
0131: assertCallbackInfos("postConstruct", expected.postConstruct,
0132: actual.postConstruct);
0133: assertCallbackInfos("preDestroy", expected.preDestroy,
0134: actual.preDestroy);
0135: assertCallbackInfos("preDestroy", expected.aroundInvoke,
0136: actual.aroundInvoke);
0137:
0138: assertRemoveMethodInfos("removeMethods",
0139: expected.removeMethods, actual.removeMethods);
0140: assertInitMethodInfos("initMethods", expected.initMethods,
0141: actual.initMethods);
0142:
0143: assertSecurityRoleReferenceInfos("securityRoleReferences",
0144: expected.securityRoleReferences,
0145: actual.securityRoleReferences);
0146:
0147: assertEquals("jndiEnc", expected.jndiEnc, actual.jndiEnc);
0148: }
0149:
0150: @Local
0151: public static interface ColorLocal {
0152: }
0153:
0154: @Remote
0155: public static interface ColorRemote {
0156: }
0157:
0158: public static interface ColorLocal2 {
0159: }
0160:
0161: public static interface ColorRemote2 {
0162: }
0163:
0164: public static interface ColorEjbHome extends EJBHome {
0165: ColorEjbObject create() throws CreateException, RemoteException;
0166: }
0167:
0168: public static interface ColorEjbObject extends EJBObject {
0169: }
0170:
0171: public static interface ColorEjbLocalHome extends EJBLocalHome {
0172: ColorEjbLocalObject create() throws CreateException;
0173: }
0174:
0175: public static interface ColorEjbLocalObject extends EJBLocalObject {
0176: }
0177:
0178: @EJB(name="colorClassEjb",beanInterface=ColorLocal.class)
0179: @Resource(name="colorClassResource",type=DataSource.class)
0180: @RolesAllowed({"ColorManager"})
0181: @DeclareRoles({"ColorGuy","ColorGal"})
0182: @RunAs("ColorManager")
0183: @TransactionManagement(TransactionManagementType.BEAN)
0184: @TransactionAttribute(TransactionAttributeType.MANDATORY)
0185: @Local({ColorLocal2.class})
0186: @Remote({ColorRemote2.class})
0187: @LocalHome(ColorEjbLocalHome.class)
0188: @RemoteHome(ColorEjbHome.class)
0189: public static class Color implements ColorLocal, ColorRemote {
0190:
0191: @EJB
0192: private ColorRemote colorFieldEjb;
0193:
0194: @Resource
0195: private DataSource colorFieldResource;
0196:
0197: @Resource
0198: private Topic colorFieldResourceEnv;
0199:
0200: public void methodOne() {
0201: }
0202:
0203: public void methodTwo() {
0204: }
0205:
0206: public void methodThree() {
0207: }
0208:
0209: public void methodFour() {
0210: }
0211:
0212: @Timeout
0213: public void colorTimeout(Timer timer) {
0214: }
0215:
0216: @AroundInvoke
0217: public Object invoke(InvocationContext context)
0218: throws Exception {
0219: return null;
0220: }
0221:
0222: @PostConstruct
0223: private void colorPostConstruct() {
0224:
0225: }
0226:
0227: @PreDestroy
0228: private void colorPreDestroy() {
0229: }
0230:
0231: @Init
0232: public void colorInit() {
0233: }
0234:
0235: @Remove
0236: public void colorRemove() {
0237:
0238: }
0239:
0240: @PrePassivate
0241: public void colorPrePassivate() {
0242: }
0243:
0244: @PostActivate
0245: public void colorPostActivate() {
0246:
0247: }
0248: }
0249:
0250: public static class Red extends Color {
0251: }
0252:
0253: // ------------------------------------------------------------------------------------------------------
0254: //
0255: // Assert methods
0256: //
0257: // ------------------------------------------------------------------------------------------------------
0258:
0259: public static void assertEquals(String m, JndiEncInfo a,
0260: JndiEncInfo b) {
0261: assertTrue(m, equals(a, b));
0262: }
0263:
0264: public static boolean equals(JndiEncInfo a, JndiEncInfo b) {
0265: if (a == null && b == null)
0266: return true;
0267: if (a == null || b == null)
0268: return false;
0269:
0270: if (!equalsEnvEntryInfos(a.envEntries, b.envEntries))
0271: return false;
0272: if (!equalsEjbReferenceInfos(a.ejbReferences, b.ejbReferences))
0273: return false;
0274: if (!equalsEjbLocalReferenceInfos(a.ejbLocalReferences,
0275: b.ejbLocalReferences))
0276: return false;
0277: if (!equalsResourceReferenceInfos(a.resourceRefs,
0278: b.resourceRefs))
0279: return false;
0280: if (!equalsPersistenceUnitReferenceInfos(a.persistenceUnitRefs,
0281: b.persistenceUnitRefs))
0282: return false;
0283: if (!equalsPersistenceContextReferenceInfos(
0284: a.persistenceContextRefs, b.persistenceContextRefs))
0285: return false;
0286: if (!equalsResourceEnvReferenceInfos(a.resourceEnvRefs,
0287: b.resourceEnvRefs))
0288: return false;
0289: if (!equalsServiceReferenceInfos(a.serviceRefs, b.serviceRefs))
0290: return false;
0291:
0292: return true;
0293: }
0294:
0295: // -- ReferenceLocationInfo --------------------------------//
0296:
0297: public static void assertReferenceLocationInfos(String s,
0298: List<ReferenceLocationInfo> expected,
0299: List<ReferenceLocationInfo> actual) {
0300: assertTrue(s, equalsReferenceLocationInfos(expected, actual));
0301: }
0302:
0303: public static boolean equalsReferenceLocationInfos(
0304: List<ReferenceLocationInfo> expected,
0305: List<ReferenceLocationInfo> actual) {
0306: return new ReferenceLocationInfoComparator().compare(expected,
0307: actual);
0308: }
0309:
0310: public static class ReferenceLocationInfoComparator extends
0311: ListComparator<ReferenceLocationInfo> {
0312: public boolean compare(ReferenceLocationInfo a,
0313: ReferenceLocationInfo b) {
0314: return InheritenceTest.equals(a, b);
0315: }
0316: }
0317:
0318: public static void assertEquals(String m, ReferenceLocationInfo a,
0319: ReferenceLocationInfo b) {
0320: assertTrue(m, equals(a, b));
0321: }
0322:
0323: public static boolean equals(ReferenceLocationInfo a,
0324: ReferenceLocationInfo b) {
0325: if (a == null && b == null)
0326: return true;
0327: if (a == null || b == null)
0328: return false;
0329:
0330: if (a.jndiName != null ? !a.jndiName.equals(b.jndiName)
0331: : b.jndiName != null)
0332: return false;
0333: if (a.jndiProviderId != null ? !a.jndiProviderId
0334: .equals(b.jndiProviderId) : b.jndiProviderId != null)
0335: return false;
0336:
0337: return true;
0338: }
0339:
0340: // -- EnvEntryInfo --------------------------------//
0341:
0342: public static void assertEnvEntryInfos(String s,
0343: List<EnvEntryInfo> expected, List<EnvEntryInfo> actual) {
0344: assertTrue(s, equalsEnvEntryInfos(expected, actual));
0345: }
0346:
0347: public static boolean equalsEnvEntryInfos(
0348: List<EnvEntryInfo> expected, List<EnvEntryInfo> actual) {
0349: return new EnvEntryInfoComparator().compare(expected, actual);
0350: }
0351:
0352: public static class EnvEntryInfoComparator extends
0353: ListComparator<EnvEntryInfo> {
0354: public boolean compare(EnvEntryInfo a, EnvEntryInfo b) {
0355: return InheritenceTest.equals(a, b);
0356: }
0357: }
0358:
0359: public static void assertEquals(String m, EnvEntryInfo a,
0360: EnvEntryInfo b) {
0361: assertTrue(m, equals(a, b));
0362: }
0363:
0364: public static boolean equals(EnvEntryInfo a, EnvEntryInfo b) {
0365: if (a == null && b == null)
0366: return true;
0367: if (a == null || b == null)
0368: return false;
0369:
0370: if (a.name != null ? !a.name.equals(b.name) : b.name != null)
0371: return false;
0372: if (a.type != null ? !a.type.equals(b.type) : b.type != null)
0373: return false;
0374: if (a.value != null ? !a.value.equals(b.value)
0375: : b.value != null)
0376: return false;
0377: if (!equals(a.location, b.location))
0378: return false;
0379: if (!equalsInjectionInfos(a.targets, b.targets))
0380: return false;
0381:
0382: return true;
0383: }
0384:
0385: // -- InjectionInfo --------------------------------//
0386:
0387: public static void assertInjectionInfos(String s,
0388: List<InjectionInfo> expected, List<InjectionInfo> actual) {
0389: assertTrue(s, equalsInjectionInfos(expected, actual));
0390: }
0391:
0392: public static boolean equalsInjectionInfos(
0393: List<InjectionInfo> expected, List<InjectionInfo> actual) {
0394: return new InjectionInfoComparator().compare(expected, actual);
0395: }
0396:
0397: public static class InjectionInfoComparator extends
0398: ListComparator<InjectionInfo> {
0399: public boolean compare(InjectionInfo a, InjectionInfo b) {
0400: return InheritenceTest.equals(a, b);
0401: }
0402: }
0403:
0404: public static void assertEquals(String s, InjectionInfo a,
0405: InjectionInfo b) {
0406: assertTrue(s, equals(a, b));
0407: }
0408:
0409: public static boolean equals(InjectionInfo a, InjectionInfo b) {
0410: if (a == null && b == null)
0411: return true;
0412: if (a == null || b == null)
0413: return false;
0414:
0415: if (a.propertyName != null ? !a.propertyName
0416: .equals(b.propertyName) : b.propertyName != null)
0417: return false;
0418: if (a.className != null ? !a.className.equals(b.className)
0419: : b.className != null)
0420: return false;
0421:
0422: return true;
0423: }
0424:
0425: // -- EjbReferenceInfo --------------------------------//
0426:
0427: public static void assertEjbReferenceInfos(String s,
0428: List<EjbReferenceInfo> expected,
0429: List<EjbReferenceInfo> actual) {
0430: assertTrue(s, equalsEjbReferenceInfos(expected, actual));
0431: }
0432:
0433: public static boolean equalsEjbReferenceInfos(
0434: List<EjbReferenceInfo> expected,
0435: List<EjbReferenceInfo> actual) {
0436: return new EjbReferenceInfoComparator().compare(expected,
0437: actual);
0438: }
0439:
0440: public static class EjbReferenceInfoComparator extends
0441: ListComparator<EjbReferenceInfo> {
0442: public boolean compare(EjbReferenceInfo a, EjbReferenceInfo b) {
0443: return InheritenceTest.equals(a, b);
0444: }
0445: }
0446:
0447: public static void assertEquals(String m, EjbReferenceInfo a,
0448: EjbReferenceInfo b) {
0449: assertTrue(m, equals(a, b));
0450: }
0451:
0452: public static boolean equals(EjbReferenceInfo a, EjbReferenceInfo b) {
0453: if (a == null && b == null)
0454: return true;
0455: if (a == null || b == null)
0456: return false;
0457:
0458: if (a.referenceName != null ? !a.referenceName
0459: .equals(b.referenceName) : b.referenceName != null)
0460: return false;
0461: if (a.homeType != null ? !a.homeType.equals(b.homeType)
0462: : b.homeType != null)
0463: return false;
0464: if (a.interfaceType != null ? !a.interfaceType
0465: .equals(b.interfaceType) : b.interfaceType != null)
0466: return false;
0467: if (a.ejbDeploymentId != null ? !a.ejbDeploymentId
0468: .equals(b.ejbDeploymentId) : b.ejbDeploymentId != null)
0469: return false;
0470: if (a.link != null ? !a.link.equals(b.link) : b.link != null)
0471: return false;
0472: if (a.externalReference != b.externalReference)
0473: return false;
0474: if (!equals(a.location, b.location))
0475: return false;
0476: if (!equalsInjectionInfos(a.targets, b.targets))
0477: return false;
0478:
0479: return true;
0480: }
0481:
0482: // -- EjbLocalReferenceInfo --------------------------------//
0483:
0484: public static void assertEjbLocalReferenceInfos(String s,
0485: List<EjbLocalReferenceInfo> expected,
0486: List<EjbLocalReferenceInfo> actual) {
0487: assertTrue(s, equalsEjbLocalReferenceInfos(expected, actual));
0488: }
0489:
0490: public static boolean equalsEjbLocalReferenceInfos(
0491: List<EjbLocalReferenceInfo> expected,
0492: List<EjbLocalReferenceInfo> actual) {
0493: return new EjbLocalReferenceInfoComparator().compare(expected,
0494: actual);
0495: }
0496:
0497: public static class EjbLocalReferenceInfoComparator extends
0498: ListComparator<EjbLocalReferenceInfo> {
0499: public boolean compare(EjbLocalReferenceInfo a,
0500: EjbLocalReferenceInfo b) {
0501: return InheritenceTest.equals(a, b);
0502: }
0503: }
0504:
0505: // -- ResourceReferenceInfo --------------------------------//
0506:
0507: public static void assertResourceReferenceInfos(String s,
0508: List<ResourceReferenceInfo> expected,
0509: List<ResourceReferenceInfo> actual) {
0510: assertTrue(s, equalsResourceReferenceInfos(expected, actual));
0511: }
0512:
0513: public static boolean equalsResourceReferenceInfos(
0514: List<ResourceReferenceInfo> expected,
0515: List<ResourceReferenceInfo> actual) {
0516: return new ResourceReferenceInfoComparator().compare(expected,
0517: actual);
0518: }
0519:
0520: public static class ResourceReferenceInfoComparator extends
0521: ListComparator<ResourceReferenceInfo> {
0522: public boolean compare(ResourceReferenceInfo a,
0523: ResourceReferenceInfo b) {
0524: return InheritenceTest.equals(a, b);
0525: }
0526: }
0527:
0528: public static void assertEquals(String m, ResourceReferenceInfo a,
0529: ResourceReferenceInfo b) {
0530: assertTrue(m, equals(a, b));
0531: }
0532:
0533: public static boolean equals(ResourceReferenceInfo a,
0534: ResourceReferenceInfo b) {
0535: if (a == null && b == null)
0536: return true;
0537: if (a == null || b == null)
0538: return false;
0539:
0540: if (a.referenceName != null ? !a.referenceName
0541: .equals(b.referenceName) : b.referenceName != null)
0542: return false;
0543: if (a.referenceType != null ? !a.referenceType
0544: .equals(b.referenceType) : b.referenceType != null)
0545: return false;
0546: if (a.referenceAuth != null ? !a.referenceAuth
0547: .equals(b.referenceAuth) : b.referenceAuth != null)
0548: return false;
0549: if (a.resourceID != null ? !a.resourceID.equals(b.resourceID)
0550: : b.resourceID != null)
0551: return false;
0552: if (a.properties != null ? !a.properties.equals(b.properties)
0553: : b.properties != null)
0554: return false;
0555: if (!equals(a.location, b.location))
0556: return false;
0557: if (!equalsInjectionInfos(a.targets, b.targets))
0558: return false;
0559:
0560: return true;
0561: }
0562:
0563: // -- PersistenceUnitReferenceInfo --------------------------------//
0564:
0565: public static void assertPersistenceUnitReferenceInfos(String s,
0566: List<PersistenceUnitReferenceInfo> expected,
0567: List<PersistenceUnitReferenceInfo> actual) {
0568: assertTrue(s, equalsPersistenceUnitReferenceInfos(expected,
0569: actual));
0570: }
0571:
0572: public static boolean equalsPersistenceUnitReferenceInfos(
0573: List<PersistenceUnitReferenceInfo> expected,
0574: List<PersistenceUnitReferenceInfo> actual) {
0575: return new PersistenceUnitReferenceInfoComparator().compare(
0576: expected, actual);
0577: }
0578:
0579: public static class PersistenceUnitReferenceInfoComparator extends
0580: ListComparator<PersistenceUnitReferenceInfo> {
0581: public boolean compare(PersistenceUnitReferenceInfo a,
0582: PersistenceUnitReferenceInfo b) {
0583: return InheritenceTest.equals(a, b);
0584: }
0585: }
0586:
0587: public static void assertEquals(String m,
0588: PersistenceUnitReferenceInfo a,
0589: PersistenceUnitReferenceInfo b) {
0590: assertTrue(m, equals(a, b));
0591: }
0592:
0593: public static boolean equals(PersistenceUnitReferenceInfo a,
0594: PersistenceUnitReferenceInfo b) {
0595: if (a == null && b == null)
0596: return true;
0597: if (a == null || b == null)
0598: return false;
0599:
0600: if (a.referenceName != null ? !a.referenceName
0601: .equals(b.referenceName) : b.referenceName != null)
0602: return false;
0603: if (a.persistenceUnitName != null ? !a.persistenceUnitName
0604: .equals(b.persistenceUnitName)
0605: : b.persistenceUnitName != null)
0606: return false;
0607: if (a.unitId != null ? !a.unitId.equals(b.unitId)
0608: : b.unitId != null)
0609: return false;
0610: if (!equals(a.location, b.location))
0611: return false;
0612: if (!equalsInjectionInfos(a.targets, b.targets))
0613: return false;
0614:
0615: return true;
0616: }
0617:
0618: // -- PersistenceContextReferenceInfo --------------------------------//
0619:
0620: public static void assertPersistenceContextReferenceInfos(String s,
0621: List<PersistenceContextReferenceInfo> expected,
0622: List<PersistenceContextReferenceInfo> actual) {
0623: assertTrue(s, equalsPersistenceContextReferenceInfos(expected,
0624: actual));
0625: }
0626:
0627: public static boolean equalsPersistenceContextReferenceInfos(
0628: List<PersistenceContextReferenceInfo> expected,
0629: List<PersistenceContextReferenceInfo> actual) {
0630: return new PersistenceContextReferenceInfoComparator().compare(
0631: expected, actual);
0632: }
0633:
0634: public static class PersistenceContextReferenceInfoComparator
0635: extends ListComparator<PersistenceContextReferenceInfo> {
0636: public boolean compare(PersistenceContextReferenceInfo a,
0637: PersistenceContextReferenceInfo b) {
0638: return InheritenceTest.equals(a, b);
0639: }
0640: }
0641:
0642: public static void assertEquals(String m,
0643: PersistenceContextReferenceInfo a,
0644: PersistenceContextReferenceInfo b) {
0645: assertTrue(m, equals(a, b));
0646: }
0647:
0648: public static boolean equals(PersistenceContextReferenceInfo a,
0649: PersistenceContextReferenceInfo b) {
0650: if (a == null && b == null)
0651: return true;
0652: if (a == null || b == null)
0653: return false;
0654:
0655: if (a.referenceName != null ? !a.referenceName
0656: .equals(b.referenceName) : b.referenceName != null)
0657: return false;
0658: if (a.persistenceUnitName != null ? !a.persistenceUnitName
0659: .equals(b.persistenceUnitName)
0660: : b.persistenceUnitName != null)
0661: return false;
0662: if (a.unitId != null ? !a.unitId.equals(b.unitId)
0663: : b.unitId != null)
0664: return false;
0665: if (a.extended != b.extended)
0666: return false;
0667: if (a.properties != null ? !a.properties.equals(b.properties)
0668: : b.properties != null)
0669: return false;
0670: if (!equals(a.location, b.location))
0671: return false;
0672: if (!equalsInjectionInfos(a.targets, b.targets))
0673: return false;
0674:
0675: return true;
0676: }
0677:
0678: // -- ResourceEnvReferenceInfo --------------------------------//
0679:
0680: public static void assertResourceEnvReferenceInfos(String s,
0681: List<ResourceEnvReferenceInfo> expected,
0682: List<ResourceEnvReferenceInfo> actual) {
0683: assertTrue(s, equalsResourceEnvReferenceInfos(expected, actual));
0684: }
0685:
0686: public static boolean equalsResourceEnvReferenceInfos(
0687: List<ResourceEnvReferenceInfo> expected,
0688: List<ResourceEnvReferenceInfo> actual) {
0689: return new ResourceEnvReferenceInfoComparator().compare(
0690: expected, actual);
0691: }
0692:
0693: public static class ResourceEnvReferenceInfoComparator extends
0694: ListComparator<ResourceEnvReferenceInfo> {
0695: public boolean compare(ResourceEnvReferenceInfo a,
0696: ResourceEnvReferenceInfo b) {
0697: return InheritenceTest.equals(a, b);
0698: }
0699: }
0700:
0701: public static void assertEquals(String m,
0702: ResourceEnvReferenceInfo a, ResourceEnvReferenceInfo b) {
0703: assertTrue(m, equals(a, b));
0704: }
0705:
0706: public static boolean equals(ResourceEnvReferenceInfo a,
0707: ResourceEnvReferenceInfo b) {
0708: if (a == null && b == null)
0709: return true;
0710: if (a == null || b == null)
0711: return false;
0712:
0713: if (a.resourceEnvRefName != null ? !a.resourceEnvRefName
0714: .equals(b.resourceEnvRefName)
0715: : b.resourceEnvRefName != null)
0716: return false;
0717: if (a.resourceEnvRefType != null ? !a.resourceEnvRefType
0718: .equals(b.resourceEnvRefType)
0719: : b.resourceEnvRefType != null)
0720: return false;
0721: if (a.mappedName != null ? !a.mappedName.equals(b.mappedName)
0722: : b.mappedName != null)
0723: return false;
0724: if (a.resourceID != null ? !a.resourceID.equals(b.resourceID)
0725: : b.resourceID != null)
0726: return false;
0727: if (!equals(a.location, b.location))
0728: return false;
0729: if (!equalsInjectionInfos(a.targets, b.targets))
0730: return false;
0731:
0732: return true;
0733: }
0734:
0735: // -- ServiceReferenceInfo --------------------------------//
0736:
0737: public static void assertServiceReferenceInfos(String s,
0738: List<ServiceReferenceInfo> expected,
0739: List<ServiceReferenceInfo> actual) {
0740: assertTrue(s, equalsServiceReferenceInfos(expected, actual));
0741: }
0742:
0743: public static boolean equalsServiceReferenceInfos(
0744: List<ServiceReferenceInfo> expected,
0745: List<ServiceReferenceInfo> actual) {
0746: return new ServiceReferenceInfoComparator().compare(expected,
0747: actual);
0748: }
0749:
0750: public static class ServiceReferenceInfoComparator extends
0751: ListComparator<ServiceReferenceInfo> {
0752: public boolean compare(ServiceReferenceInfo a,
0753: ServiceReferenceInfo b) {
0754: return InheritenceTest.equals(a, b);
0755: }
0756: }
0757:
0758: public static void assertEquals(String m, ServiceReferenceInfo a,
0759: ServiceReferenceInfo b) {
0760: assertTrue(m, equals(a, b));
0761: }
0762:
0763: public static boolean equals(ServiceReferenceInfo a,
0764: ServiceReferenceInfo b) {
0765: if (a == null && b == null)
0766: return true;
0767: if (a == null || b == null)
0768: return false;
0769:
0770: if (a.referenceName != null ? !a.referenceName
0771: .equals(b.referenceName) : b.referenceName != null)
0772: return false;
0773: if (a.serviceQName != null ? !a.serviceQName
0774: .equals(b.serviceQName) : b.serviceQName != null)
0775: return false;
0776: if (a.serviceType != null ? !a.serviceType
0777: .equals(b.serviceType) : b.serviceType != null)
0778: return false;
0779: if (a.portQName != null ? !a.portQName.equals(b.portQName)
0780: : b.portQName != null)
0781: return false;
0782: if (a.referenceType != null ? !a.referenceType
0783: .equals(b.referenceType) : b.referenceType != null)
0784: return false;
0785: if (a.wsdlFile != null ? !a.wsdlFile.equals(b.wsdlFile)
0786: : b.wsdlFile != null)
0787: return false;
0788: if (a.jaxrpcMappingFile != null ? !a.jaxrpcMappingFile
0789: .equals(b.jaxrpcMappingFile)
0790: : b.jaxrpcMappingFile != null)
0791: return false;
0792: if (a.id != null ? !a.id.equals(b.id) : b.id != null)
0793: return false;
0794: if (!equalsHandlerChainInfos(a.handlerChains, b.handlerChains))
0795: return false;
0796: if (!equalsPortRefInfos(a.portRefs, b.portRefs))
0797: return false;
0798: if (!equals(a.location, b.location))
0799: return false;
0800: if (!equalsInjectionInfos(a.targets, b.targets))
0801: return false;
0802:
0803: return true;
0804: }
0805:
0806: // -- HandlerChainInfo --------------------------------//
0807:
0808: public static void assertHandlerChainInfos(String s,
0809: List<HandlerChainInfo> expected,
0810: List<HandlerChainInfo> actual) {
0811: assertTrue(s, equalsHandlerChainInfos(expected, actual));
0812: }
0813:
0814: public static boolean equalsHandlerChainInfos(
0815: List<HandlerChainInfo> expected,
0816: List<HandlerChainInfo> actual) {
0817: return new HandlerChainInfoComparator().compare(expected,
0818: actual);
0819: }
0820:
0821: public static class HandlerChainInfoComparator extends
0822: ListComparator<HandlerChainInfo> {
0823: public boolean compare(HandlerChainInfo a, HandlerChainInfo b) {
0824: return InheritenceTest.equals(a, b);
0825: }
0826: }
0827:
0828: public static void assertEquals(String s, HandlerChainInfo a,
0829: HandlerChainInfo b) {
0830: assertTrue(s, equals(a, b));
0831: }
0832:
0833: public static boolean equals(HandlerChainInfo a, HandlerChainInfo b) {
0834: if (a == null && b == null)
0835: return true;
0836: if (a == null || b == null)
0837: return false;
0838:
0839: if (a.serviceNamePattern != null ? !a.serviceNamePattern
0840: .equals(b.serviceNamePattern)
0841: : b.serviceNamePattern != null)
0842: return false;
0843: if (a.portNamePattern != null ? !a.portNamePattern
0844: .equals(b.portNamePattern) : b.portNamePattern != null)
0845: return false;
0846: if (a.protocolBindings != null ? !a.protocolBindings
0847: .equals(b.protocolBindings)
0848: : b.protocolBindings != null)
0849: return false;
0850: if (!equalsHandlerInfos(a.handlers, b.handlers))
0851: return false;
0852:
0853: return true;
0854: }
0855:
0856: // -- HandlerInfo --------------------------------//
0857:
0858: public static void assertHandlerInfos(String s,
0859: List<HandlerInfo> expected, List<HandlerInfo> actual) {
0860: assertTrue(s, equalsHandlerInfos(expected, actual));
0861: }
0862:
0863: public static boolean equalsHandlerInfos(
0864: List<HandlerInfo> expected, List<HandlerInfo> actual) {
0865: return new HandlerInfoComparator().compare(expected, actual);
0866: }
0867:
0868: public static class HandlerInfoComparator extends
0869: ListComparator<HandlerInfo> {
0870: public boolean compare(HandlerInfo a, HandlerInfo b) {
0871: return InheritenceTest.equals(a, b);
0872: }
0873: }
0874:
0875: public static void assertEquals(String s, HandlerInfo a,
0876: HandlerInfo b) {
0877: assertTrue(s, equals(a, b));
0878: }
0879:
0880: public static boolean equals(HandlerInfo a, HandlerInfo b) {
0881: if (a == null && b == null)
0882: return true;
0883: if (a == null || b == null)
0884: return false;
0885:
0886: if (a.handlerClass != null ? !a.handlerClass
0887: .equals(b.handlerClass) : b.handlerClass != null)
0888: return false;
0889: if (a.handlerName != null ? !a.handlerName
0890: .equals(b.handlerName) : b.handlerName != null)
0891: return false;
0892: if (a.initParams != null ? !a.initParams.equals(b.initParams)
0893: : b.initParams != null)
0894: return false;
0895: if (a.soapHeaders != null ? !a.soapHeaders
0896: .equals(b.soapHeaders) : b.soapHeaders != null)
0897: return false;
0898: if (a.soapRoles != null ? !a.soapRoles.equals(b.soapRoles)
0899: : b.soapRoles != null)
0900: return false;
0901:
0902: return true;
0903: }
0904:
0905: // -- PortRefInfo --------------------------------//
0906:
0907: public static void assertPortRefInfos(String s,
0908: List<PortRefInfo> expected, List<PortRefInfo> actual) {
0909: assertTrue(s, equalsPortRefInfos(expected, actual));
0910: }
0911:
0912: public static boolean equalsPortRefInfos(
0913: List<PortRefInfo> expected, List<PortRefInfo> actual) {
0914: return new PortRefInfoComparator().compare(expected, actual);
0915: }
0916:
0917: public static class PortRefInfoComparator extends
0918: ListComparator<PortRefInfo> {
0919: public boolean compare(PortRefInfo a, PortRefInfo b) {
0920: return InheritenceTest.equals(a, b);
0921: }
0922: }
0923:
0924: public static void assertEquals(String s, PortRefInfo a,
0925: PortRefInfo b) {
0926: assertTrue(s, equals(a, b));
0927: }
0928:
0929: public static boolean equals(PortRefInfo a, PortRefInfo b) {
0930: if (a == null && b == null)
0931: return true;
0932: if (a == null || b == null)
0933: return false;
0934:
0935: if (a.qname != null ? !a.qname.equals(b.qname)
0936: : b.qname != null)
0937: return false;
0938: if (a.serviceEndpointInterface != null ? !a.serviceEndpointInterface
0939: .equals(b.serviceEndpointInterface)
0940: : b.serviceEndpointInterface != null)
0941: return false;
0942: if (a.properties != null ? !a.properties.equals(b.properties)
0943: : b.properties != null)
0944: return false;
0945: if (a.enableMtom != b.enableMtom)
0946: return false;
0947:
0948: return true;
0949: }
0950:
0951: // -- CallbackInfo --------------------------------//
0952:
0953: public static void assertCallbackInfos(String s,
0954: List<CallbackInfo> expected, List<CallbackInfo> actual) {
0955: assertTrue(s, equalsCallbackInfos(expected, actual));
0956: }
0957:
0958: public static boolean equalsCallbackInfos(
0959: List<CallbackInfo> expected, List<CallbackInfo> actual) {
0960: return new CallbackInfoComparator().compare(expected, actual);
0961: }
0962:
0963: public static class CallbackInfoComparator extends
0964: ListComparator<CallbackInfo> {
0965: public boolean compare(CallbackInfo a, CallbackInfo b) {
0966: return InheritenceTest.equals(a, b);
0967: }
0968: }
0969:
0970: public static void assertEquals(String m, CallbackInfo a,
0971: CallbackInfo b) {
0972: assertTrue(m, equals(a, b));
0973: }
0974:
0975: public static boolean equals(CallbackInfo a, CallbackInfo b) {
0976: if (a == null && b == null)
0977: return true;
0978: if (a == null || b == null)
0979: return false;
0980: if (a.className != null ? !a.className.equals(b.className)
0981: : b.className != null)
0982: return false;
0983: if (a.method != null ? !a.method.equals(b.method)
0984: : b.method != null)
0985: return false;
0986: return true;
0987: }
0988:
0989: // -- SecurityRoleReferenceInfo --------------------------------//
0990:
0991: public static void assertSecurityRoleReferenceInfos(String s,
0992: List<SecurityRoleReferenceInfo> expected,
0993: List<SecurityRoleReferenceInfo> actual) {
0994: assertTrue(s,
0995: equalsSecurityRoleReferenceInfos(expected, actual));
0996: }
0997:
0998: public static boolean equalsSecurityRoleReferenceInfos(
0999: List<SecurityRoleReferenceInfo> expected,
1000: List<SecurityRoleReferenceInfo> actual) {
1001: return new SecurityRoleReferenceInfoComparator().compare(
1002: expected, actual);
1003: }
1004:
1005: public static class SecurityRoleReferenceInfoComparator extends
1006: ListComparator<SecurityRoleReferenceInfo> {
1007: public boolean compare(SecurityRoleReferenceInfo a,
1008: SecurityRoleReferenceInfo b) {
1009: return InheritenceTest.equals(a, b);
1010: }
1011: }
1012:
1013: public static void assertEquals(String m,
1014: SecurityRoleReferenceInfo a, SecurityRoleReferenceInfo b) {
1015: assertTrue(m, equals(a, b));
1016: }
1017:
1018: public static boolean equals(SecurityRoleReferenceInfo a,
1019: SecurityRoleReferenceInfo b) {
1020: if (a == null && b == null)
1021: return true;
1022: if (a == null || b == null)
1023: return false;
1024:
1025: if (a.roleName != null ? !a.roleName.equals(b.roleName)
1026: : b.roleName != null)
1027: return false;
1028: if (a.roleLink != null ? !a.roleLink.equals(b.roleLink)
1029: : b.roleLink != null)
1030: return false;
1031: return true;
1032: }
1033:
1034: // -- RemoveMethodInfo --------------------------------//
1035:
1036: public static void assertRemoveMethodInfos(String s,
1037: List<RemoveMethodInfo> expected,
1038: List<RemoveMethodInfo> actual) {
1039: assertTrue(s, equalsRemoveMethodInfos(expected, actual));
1040: }
1041:
1042: public static boolean equalsRemoveMethodInfos(
1043: List<RemoveMethodInfo> expected,
1044: List<RemoveMethodInfo> actual) {
1045: return new RemoveMethodInfoComparator().compare(expected,
1046: actual);
1047: }
1048:
1049: public static class RemoveMethodInfoComparator extends
1050: ListComparator<RemoveMethodInfo> {
1051: public boolean compare(RemoveMethodInfo a, RemoveMethodInfo b) {
1052: return InheritenceTest.equals(a, b);
1053: }
1054: }
1055:
1056: public static void assertEquals(String m, RemoveMethodInfo a,
1057: RemoveMethodInfo b) {
1058: assertTrue(m, equals(a, b));
1059: }
1060:
1061: public static boolean equals(RemoveMethodInfo a, RemoveMethodInfo b) {
1062: if (a == null && b == null)
1063: return true;
1064: if (a == null || b == null)
1065: return false;
1066:
1067: if (a.retainIfException != b.retainIfException)
1068: return false;
1069:
1070: return equals(a.beanMethod, b.beanMethod);
1071: }
1072:
1073: public static void assertInitMethodInfos(final String s,
1074: List<InitMethodInfo> expected, List<InitMethodInfo> actual) {
1075: assertTrue(s, equalsInitMethodInfos(expected, actual));
1076: }
1077:
1078: public static boolean equalsInitMethodInfos(
1079: List<InitMethodInfo> expected, List<InitMethodInfo> actual) {
1080: return new InitMethodInfoComparator().compare(expected, actual);
1081: }
1082:
1083: public static class InitMethodInfoComparator extends
1084: ListComparator<InitMethodInfo> {
1085: public boolean compare(InitMethodInfo o1, InitMethodInfo o2) {
1086: return InheritenceTest.equals(o1, o2);
1087: }
1088: }
1089:
1090: public static void assertEquals(String m, InitMethodInfo a,
1091: InitMethodInfo b) {
1092: assertTrue(m, equals(a, b));
1093: }
1094:
1095: public static boolean equals(InitMethodInfo a, InitMethodInfo b) {
1096: if (a == null && b == null)
1097: return true;
1098: if (a == null || b == null)
1099: return false;
1100:
1101: if (!equals(a.beanMethod, b.beanMethod))
1102: return false;
1103: if (!equals(a.createMethod, b.createMethod))
1104: return false;
1105: return true;
1106: }
1107:
1108: public static void assertEquals(String m, NamedMethodInfo a,
1109: NamedMethodInfo b) {
1110: assertTrue(m, equals(a, b));
1111: }
1112:
1113: public static boolean equals(NamedMethodInfo a, NamedMethodInfo b) {
1114: if (a == null && b == null)
1115: return true;
1116: if (a == null || b == null)
1117: return false;
1118:
1119: if (a.id != null ? !a.id.equals(b.id) : b.id != null)
1120: return false;
1121: if (a.methodName != null ? !a.methodName.equals(b.methodName)
1122: : b.methodName != null)
1123: return false;
1124: if (a.methodParams != null ? !a.methodParams
1125: .equals(b.methodParams) : b.methodParams != null)
1126: return false;
1127: return true;
1128: }
1129:
1130: public static void assertList(final String s, List expected,
1131: List actual, ListComparator comparator) {
1132: assertTrue(s, comparator.compare(expected, actual));
1133: }
1134:
1135: public static abstract class ListComparator<T> {
1136:
1137: public boolean compare(List<T> listA, List<T> listB) {
1138: if (listA == listB)
1139: return true;
1140:
1141: ListIterator iA = listA.listIterator();
1142: ListIterator iB = listB.listIterator();
1143: while (iA.hasNext() && iB.hasNext()) {
1144: T a = (T) iA.next();
1145: T b = (T) iB.next();
1146: if (!(a == null ? b == null : compare(a, b))) {
1147: return false;
1148: }
1149: }
1150: return !(iA.hasNext() || iB.hasNext());
1151: }
1152:
1153: public abstract boolean compare(T o1, T o2);
1154:
1155: }
1156: }
|