1 23 package com.sun.enterprise.tools.verifier.tests.ejb.beanclass; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import java.lang.reflect.Modifier ; 27 import com.sun.enterprise.deployment.*; 28 import com.sun.enterprise.tools.verifier.Result; 29 import com.sun.enterprise.tools.verifier.tests.*; 30 31 35 public class EjbClassModifiersAbstract extends EjbTest { 36 37 38 46 public Result check(EjbDescriptor descriptor) { 47 48 Result result = getInitializedResult(); 49 boolean shouldBeAbstract = false; 50 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 51 52 if (descriptor instanceof EjbEntityDescriptor) { 53 String persistentType = ((EjbEntityDescriptor)descriptor).getPersistenceType(); 54 if (EjbEntityDescriptor.CONTAINER_PERSISTENCE.equals(persistentType)) { 55 if (EjbCMPEntityDescriptor.CMP_1_1!=((EjbCMPEntityDescriptor) descriptor).getCMPVersion()) { 56 shouldBeAbstract = true; 57 } 58 } 59 } 60 Class c = loadEjbClass(descriptor, result); 61 if (c!=null) { 62 63 boolean isAbstract = false; 64 int modifiers = c.getModifiers(); 65 if (Modifier.isAbstract(modifiers)) { 66 isAbstract = true; 67 } 68 69 if (!isAbstract && !shouldBeAbstract) { 70 result.addGoodDetails(smh.getLocalString 71 ("tests.componentNameConstructor", 72 "For [ {0} ]", 73 new Object [] {compName.toString()})); 74 result.passed(smh.getLocalString 75 (getClass().getName() + ".passed", 76 "[ {0} ] properly declares non-abstract class modifier.", 77 new Object [] {descriptor.getEjbClassName()})); 78 } 79 if (isAbstract && shouldBeAbstract) { 80 result.addGoodDetails(smh.getLocalString 81 ("tests.componentNameConstructor", 82 "For [ {0} ]", 83 new Object [] {compName.toString()})); 84 result.passed(smh.getLocalString 85 (getClass().getName() + ".passed2", 86 "[ {0} ] properly declares abstract class modifier.", 87 new Object [] {descriptor.getEjbClassName()})); 88 } 89 if (isAbstract && !shouldBeAbstract ) { 90 result.addErrorDetails(smh.getLocalString 91 ("tests.componentNameConstructor", 92 "For [ {0} ]", 93 new Object [] {compName.toString()})); 94 result.failed(smh.getLocalString 95 (getClass().getName() + ".failed", 96 "Error: Ejb Class [ {0} ] was found, but was declared as abstract. The class [ {1} ] must not be abstract.", 97 new Object [] {descriptor.getEjbClassName(),descriptor.getEjbClassName()})); 98 } 99 if (!isAbstract && shouldBeAbstract ) { 100 result.addErrorDetails(smh.getLocalString 101 ("tests.componentNameConstructor", 102 "For [ {0} ]", 103 new Object [] {compName.toString()})); 104 result.failed(smh.getLocalString 105 (getClass().getName() + ".failed2", 106 "Error: CMP 2.0 Entity Bean Class [ {0} ] was found, but was declared as non abstract. The class [ {1} ] must be abstract.", 107 new Object [] {descriptor.getEjbClassName(),descriptor.getEjbClassName()})); 108 } 109 110 } 111 return result; 112 113 } 114 } 115 | Popular Tags |