Methods Summary |
---|
public static void | addVerifierEventsListener(VerifierEventsListener l)support notification of test completion with a ChangeEvent
the ChangeEvent source is the corresponding Result object
listenerList.add(l);
|
protected void | check(Descriptor descriptor)
Entry point for executing all tests pertinent to this architecture
logger.log(Level.FINE, "com.sun.enterprise.tools.verifier.CheckMgr.check",
new Object[]{getClass().getName(), descriptor.getName()});
setRuntimeDDPresent(getAbstractArchiveUri(descriptor));
// Load the list of tests from the property file for this manager
loadTestInformationFromPropsFile();
// These temporary placeholder will keep the results of the tests
logger.log(Level.FINE, "com.sun.enterprise.tools.verifier.CheckMgr.RunAllTests",
new Object[]{descriptor.getName()});
String schemaVersion = getSchemaVersion(descriptor);
context.setSchemaVersion(schemaVersion);
context.setJavaEEVersion(frameworkContext.getJavaEEVersion());
context.setComponentNameConstructor(getComponentNameConstructor(descriptor));
FileArchive moduleArchive = new FileArchive();
moduleArchive.open(getAbstractArchiveUri(descriptor));
context.setModuleArchive(moduleArchive);
ResultManager resultManager = frameworkContext.getResultManager();
for (int i = 0; i < test.size(); i++) {
TestInformation ti = (TestInformation) test.elementAt(i);
String minVersion = ti.getMinimumVersion();
String maxVersion = ti.getMaximumVersion();
// does this test apply to the schema version implemented by
// this component's descriptor
if (schemaVersion != null && minVersion != null &&
schemaVersion.compareTo(minVersion) < 0) {
logger.log(Level.FINE, "com.sun.enterprise.tools.verifier.CheckMgr.version.NOT_APPLICABLE",
new Object[]{ti.getClassName()});
continue;
}
if (schemaVersion != null && maxVersion != null &&
schemaVersion.compareTo(maxVersion) > 0) {
logger.log(Level.FINE, "com.sun.enterprise.tools.verifier.CheckMgr.version.NOT_APPLICABLE",
new Object[]{ti.getClassName()});
continue;
}
if(!isApplicable(ti, descriptor)) {
logger.log(Level.FINE, "com.sun.enterprise.tools.verifier.CheckMgr.version.NOT_APPLICABLE",
new Object[]{ti.getClassName()});
continue;
}
try {
Class c = Class.forName(ti.getClassName());
VerifierCheck t = (VerifierCheck) c.newInstance();
t.setVerifierContext(context);
Result r = t.check(descriptor);
// no need to setComponentName as it is already set in
// VerifierTest.getInitialisedResult(). By Sahoo
// r.setComponentName(getArchiveUri(descriptor));
setModuleName(r);
resultManager.add(r);
// notify listeners of test completion
fireTestFinishedEvent(r);
} catch (Throwable e) {
LogRecord logRecord = new LogRecord(Level.SEVERE,
ti.getClassName());
logRecord.setThrown(e);
resultManager.log(logRecord);
}
}
fireAllTestsFinishedEvent();
// done adding it to hastable vector.
|
protected void | checkPersistenceUnits(RootDeploymentDescriptor descriptor)
if (frameworkContext.isPartition() &&
!frameworkContext.isPersistenceUnits())
return;
CheckMgr puCheckMgr = new PersistenceUnitCheckMgrImpl(
frameworkContext, context);
for(PersistenceUnitsDescriptor pus :
descriptor.getPersistenceUnitsDescriptors()) {
for (PersistenceUnitDescriptor pu :
pus.getPersistenceUnitDescriptors()) {
puCheckMgr.check(pu);
}
}
|
protected void | checkWebServices(Descriptor descriptor)
if (frameworkContext.isPartition() &&
!frameworkContext.isWebServices())
return;
BundleDescriptor bundleDescriptor = (BundleDescriptor) descriptor;
WebServiceCheckMgrImpl webServiceCheckMgr = new WebServiceCheckMgrImpl(
frameworkContext);
if (bundleDescriptor.hasWebServices()) {
WebServicesDescriptor wdesc = bundleDescriptor.getWebServices();
webServiceCheckMgr.setVerifierContext(context);
webServiceCheckMgr.check(wdesc);
}
|
protected void | fireAllTestsFinishedEvent()
Object[] listeners;
synchronized (listenerList) {
listeners = listenerList.toArray();
}
if (listeners == null)
return;
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] instanceof VerifierEventsListener) {
// create the event:
EventObject event = new EventObject(this);
((VerifierEventsListener) listeners[i]).allTestsFinished(event);
}
}
|
protected void | fireTestFinishedEvent(Result r)
Object[] listeners;
synchronized (listenerList) {
listeners = listenerList.toArray();
}
if (listeners == null)
return;
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] instanceof VerifierEventsListener) {
// create the event:
EventObject event = new EventObject(r);
((VerifierEventsListener) listeners[i]).testFinished(event);
}
}
|
protected java.lang.String | getAbstractArchiveUri(Descriptor descriptor)
String archBase = context.getAbstractArchive().getArchiveUri();
if (descriptor instanceof Application)
return archBase;
ModuleDescriptor mdesc = getBundleDescriptor(descriptor).getModuleDescriptor();
if(mdesc.isStandalone()) {
return archBase;
} else {
return archBase + File.separator +
FileUtils.makeFriendlyFileName(mdesc.getArchiveUri());
}
|
protected java.lang.String | getArchiveUri(Descriptor descriptor)
String archiveUri = getBundleDescriptor(descriptor).getModuleDescriptor().getArchiveUri();
return new File(archiveUri).getName();
|
protected BundleDescriptor | getBundleDescriptor(Descriptor descriptor)EjbCheckMgrImpl, WebServiceClientCheckMgrImpl and WebServiceCheckMgrImpl
classes override this method. For each of these areas the tests are run
on descriptors rather than bundle descriptors.
return (BundleDescriptor) descriptor;
|
protected abstract com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor | getComponentNameConstructor(Descriptor descriptor)
|
protected java.util.Vector | getFinalTestList(java.util.Vector orignalList, java.util.Vector excludeList)
if (excludeList == null) return orignalList;
if (orignalList.size() != 0 && excludeList.size() != 0) {
for (int i = 0; i < excludeList.size(); i++) {
for (int j = 0; j < orignalList.size(); j++) {
if (((TestInformation) orignalList.elementAt(j)).getClassName()
.equals(
((TestInformation) excludeList.elementAt(i)).getClassName())) {
orignalList.remove(j);
}
}
}
}
return orignalList;
|
private boolean | getRuntimeDDPresent()
return isDDPresent;
|
protected abstract java.lang.String | getSchemaVersion(Descriptor descriptor)
|
protected abstract java.lang.String | getSunONETestsListFileName()Adding a new function to get the SunONE AS test lists for Ejb tests
|
protected static java.lang.String | getSunPrefix()
return "sun-"; // NOI18N
|
protected java.util.Vector | getTestFromExcludeList()
Vector<TestInformation> testExcluded = new Vector<TestInformation>();
logger.log(Level.FINE,
"com.sun.enterprise.tools.verifier.CheckMgr.TestnamesPropsFile"); // NOI18N
// parse the xml file
File inputFile = getTestsFileFor(excludeListFileName);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(inputFile);
NodeList list = doc.getElementsByTagName("test"); // NOI18N
for (int i = 0; i < list.getLength(); i++) {
Element e = (Element) list.item(i);
NodeList nl = e.getChildNodes();
TestInformation ti = new TestInformation();
for (int j = 0; j < nl.getLength(); j++) {
String nodeName = nl.item(j).getNodeName();
if ("test-class".equals(nodeName.trim())) { // NOI18N
Node el = nl.item(j);
ti.setClassName(el.getFirstChild().getNodeValue().trim());
}
}
testExcluded.addElement(ti);
}
return testExcluded;
|
private java.io.File | getTestsFileFor(java.lang.String filename)Retrieve Web tests from TestNamesWeb.conf file
// in case of appserver the config file will be <AS>/lib/verifier and
// for AVK it will be <AVK>/config/verifier.
// Put checks if this directory is null.
File f = new File(frameworkContext.getConfigDirStr());
f = new File(f, filename);
return new File(f.toString());
|
protected abstract java.lang.String | getTestsListFileName()
|
protected boolean | isApplicable(TestInformation test, Descriptor descriptor)This method is overridden in EjbCheckMgrImpl. This method is used to
ensure that entity and mdb tests are not run for session descriptors and
similarly the other way round.
return true;
|
private void | loadTestInformationFromPropsFile()
load all the test names from the property file. Each manager has its
list of test to be performed for each archive in a property file.
The tests list of a list of class name implementing a particular test
if(!test.isEmpty())
return;
logger.log(Level.FINE,
"com.sun.enterprise.tools.verifier.CheckMgr.TestnamesPropsFile"); // NOI18N
File inputFile = getTestsFileFor(getTestsListFileName());
// parse the xml file
DocumentBuilder db = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
Document doc = db.parse(inputFile);
NodeList list = doc.getElementsByTagName("test"); // NOI18N
for (int i = 0; i < list.getLength(); i++) {
Element e = (Element) list.item(i);
NodeList nl = e.getChildNodes();
TestInformation ti = new TestInformation();
for (int j = 0; j < nl.getLength(); j++) {
String nodeName = nl.item(j).getNodeName();
if ("test-class".equals(nodeName.trim())) { // NOI18N
Node el = nl.item(j);
ti.setClassName(el.getFirstChild().getNodeValue().trim());
}
if ("minimum-version".equals(nodeName.trim())) { // NOI18N
Node el = nl.item(j);
ti.setMinimumVersion(
el.getFirstChild().getNodeValue().trim());
}
if ("maximum-version".equals(nodeName.trim())) { // NOI18N
Node el = nl.item(j);
ti.setMaximumVersion(
el.getFirstChild().getNodeValue().trim());
}
}
test.addElement(ti);
}
if ((!frameworkContext.isPortabilityMode() &&
getRuntimeDDPresent()))
readSunONETests(test);
// to get the list of tests to be excluded
Vector<TestInformation> testExcluded = getTestFromExcludeList();
// to exclude the tests
test = getFinalTestList(test, testExcluded);
|
private void | readSunONETests(java.util.Vector test)
String sunonetests = getSunONETestsListFileName();
if (sunonetests == null)
return;
File inputFile = getTestsFileFor(sunonetests);
if (!inputFile.exists())
return;
DocumentBuilder db = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
Document doc = db.parse(inputFile);
NodeList list = doc.getElementsByTagName("test"); // NOI18N
for (int i = 0; i < list.getLength(); i++) {
Element e = (Element) list.item(i);
NodeList nl = e.getChildNodes();
TestInformation ti = new TestInformation();
for (int j = 0; j < nl.getLength(); j++) {
String nodeName = nl.item(j).getNodeName();
if ("test-class".equals(nodeName.trim())) { // NOI18N
Node el = nl.item(j);
ti.setClassName(el.getFirstChild().getNodeValue().trim());
}
if ("minimum-version".equals(nodeName.trim())) { // NOI18N
Node el = nl.item(j);
ti.setMinimumVersion(
el.getFirstChild().getNodeValue().trim());
}
if ("maximum-version".equals(nodeName.trim())) { // NOI18N
Node el = nl.item(j);
ti.setMaximumVersion(
el.getFirstChild().getNodeValue().trim());
}
}
test.addElement(ti);
}
|
public static void | removeVerifierEventsListener(VerifierEventsListener l)Remove change listener
listenerList.remove(l);
|
protected abstract void | setModuleName(Result r)
|
protected void | setRuntimeDDPresent(java.lang.String uri)
InputStream is = null;
try {
AbstractArchive abstractArchive = new FileArchiveFactory().openArchive(
uri);
Archivist archivist = ArchivistFactory.getArchivistForArchive(
abstractArchive);
if(archivist != null) {
String ddFileEntryName = archivist.getRuntimeDeploymentDescriptorPath();
is = abstractArchive.getEntry(ddFileEntryName);
if (is != null) {
isDDPresent = true;
}
}
} catch (IOException e) {
isDDPresent = false;
} finally {
try {
if(is != null)
is.close();
} catch (Exception e) {
// nothing to do here
}
}
|
public void | setVerifierContext(Context context)This method sets the Context object
this.context = context;
|