You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by pc...@apache.org on 2004/02/18 03:55:26 UTC
cvs commit: xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam ClassesJamTest.java JamTestBase.java SourcesJamTest.java JamTests.java
pcal 2004/02/17 18:55:26
Modified: v2/test/src/jamtest build.xml
Added: v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam
ClassesJamTest.java JamTestBase.java
SourcesJamTest.java
Removed: v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam
JamTests.java
Log:
jam: quick refactor and new cases for new jam drts
Revision Changes Path
1.2 +11 -2 xml-xmlbeans/v2/test/src/jamtest/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/build.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- build.xml 18 Feb 2004 01:32:54 -0000 1.1
+++ build.xml 18 Feb 2004 02:55:26 -0000 1.2
@@ -5,6 +5,7 @@
<property name='src-jamtest' value='.' />
<property name='xbean-build-dir' value='../../../build'/>
<property name='build-dir' value='${xbean-build-dir}/test/jamtest'/>
+ <property name='dummy-dir' value='${xbean-build-dir}/test/jamtest/dummyclasses'/>
<property name='junit-jar' value='../../../external/lib/junit.jar' />
<path id='classpath' >
@@ -21,7 +22,7 @@
<property name='classpath-value' refid='classpath'/>
<target name='all' depends='build,run' />
-
+
<target name='build' >
<mkdir dir='${build-dir}'/>
<javac
@@ -30,6 +31,13 @@
classpathref='classpath'
includes='**/*.java'
/>
+ <mkdir dir='${dummy-dir}'/>
+ <javac
+ srcdir='dummyclasses'
+ destdir='${dummy-dir}'
+ classpathref='classpath'
+ includes='**/*.java'
+ />
</target>
<target name='run'>
@@ -50,7 +58,8 @@
<pathelement path='${classpath-value}'/> <!--ref no workie-->
</classpath>
<formatter type='plain' usefile='false'/>
- <test name='org.apache.xmlbeans.test.jam.JamTests'/>
+ <test name='org.apache.xmlbeans.test.jam.SourcesJamTest'/>
+ <test name='org.apache.xmlbeans.test.jam.ClassesJamTest'/>
</junit>
</target>
1.1 xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/ClassesJamTest.java
Index: ClassesJamTest.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache
* XMLBeans", nor may "Apache" appear in their name, without prior
* written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2003 BEA Systems
* Inc., <http://www.bea.com/>. For more information on the Apache Software
* Foundation, please see <http://www.apache.org/>.
*/
package org.apache.xmlbeans.test.jam;
import org.apache.xmlbeans.impl.jam.JServiceFactory;
import org.apache.xmlbeans.impl.jam.JServiceParams;
import java.io.IOException;
/**
* Runs the JamTestBase cases by loading the types from source.
*
* @author Patrick Calahan <pc...@bea.com>
*/
public class ClassesJamTest extends JamTestBase {
// ========================================================================
// Constructors
public ClassesJamTest(String name) {
super(name);
}
// ========================================================================
// JamTestBase implementation
protected JServiceParams getBasicServiceParams() throws IOException {
JServiceFactory jsf = JServiceFactory.getInstance();
JServiceParams params = jsf.createServiceParams();
params.includeClassFiles(getDummyclassesClassDir(),"**/*.class");
return params;
}
protected boolean isAnnotationsAvailable() {
return false;
}
}
1.1 xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/JamTestBase.java
Index: JamTestBase.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache
* XMLBeans", nor may "Apache" appear in their name, without prior
* written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2003 BEA Systems
* Inc., <http://www.bea.com/>. For more information on the Apache Software
* Foundation, please see <http://www.apache.org/>.
*/
package org.apache.xmlbeans.test.jam;
import junit.framework.TestCase;
import org.apache.xmlbeans.impl.jam.*;
import java.io.File;
import java.io.IOException;
/**
* <p>Abstract base class for basic jam test cases. These test cases work
* against an abstract JService - they don't care how the java types
* were loaded. Extending classes are responsible for implementing the
* getService() method which should create the service from sources, or
* classes, or whatever is appropriate.</p>
*
* @author Patrick Calahan <pc...@bea.com>
*/
public abstract class JamTestBase extends TestCase {
// ========================================================================
// Constants
protected static final String
DUMMY = "org.apache.xmlbeans.test.jam.dummyclasses";
// ========================================================================
// Variables
private JService mService = null;
private JClassLoader mLoader = null;
// ========================================================================
// Constructors
public JamTestBase() {
super("JamTestBase");
}
public JamTestBase(String casename) {
super(casename);
}
// ========================================================================
// Abstract methods
/**
* Called during setup() to return the parameters which we can use to
* create a service that contains all of java types under dummyclasses.
*/
protected abstract JServiceParams getBasicServiceParams() throws Exception;
//kind of a quick hack for now, should remove this and make sure that
//even the classes case make the annotations available using a special
//JInitializer
protected abstract boolean isAnnotationsAvailable();
// ========================================================================
// Utility methods
/**
* Returns the directory in which the sources for the dummyclasses live.
*/
protected File getDummyclassesSourceRoot() {
return new File("dummyclasses");
}
/**
* Returns the directory into which the dummyclasses have been compiled.
*/
protected File getDummyclassesClassDir() {
return new File("../../../build/test/jamtest/dummyclasses");
}
// ========================================================================
// TestCase implementation
public void setUp() throws Exception {
JServiceFactory jsf = JServiceFactory.getInstance();
mService = jsf.createService(getBasicServiceParams());
if (mService == null) throw new IllegalArgumentException("null service");
mLoader = mService.getClassLoader();
if (mLoader == null) throw new IllegalArgumentException("null loader");
}
// ========================================================================
// Test methods
public void testInterfaceIsAssignableFrom()
throws ClassNotFoundException
{
JClass fooImpl = mLoader.loadClass(DUMMY+".FooImpl");
JClass foo = mLoader.loadClass(DUMMY+".Foo");
assertTrue("Foo should be assignableFrom FooImpl",
foo.isAssignableFrom(fooImpl));
assertTrue("FooImpl should not be assignableFrom Foo",
!fooImpl.isAssignableFrom(foo));
}
public void testClassIsAssignableFrom()
throws ClassNotFoundException
{
JClass fooImpl = mLoader.loadClass(DUMMY+".FooImpl");
JClass base = mLoader.loadClass(DUMMY+".Base");
assertTrue("Base should be assignableFrom FooImpl",
base.isAssignableFrom(fooImpl));
assertTrue("FooImpl should not be assignableFrom Base",
!fooImpl.isAssignableFrom(base));
}
public void testClassIsAssignableFromDifferentClassLoaders()
throws ClassNotFoundException
{
JClass baz = mLoader.loadClass(DUMMY+".Baz");
JClass runnable = mLoader.loadClass("java.lang.Runnable");
assertTrue("Runnable should be assignableFrom Baz",
runnable.isAssignableFrom(baz));
assertTrue("Baz should not be assignableFrom Runnable",
!baz.isAssignableFrom(runnable));
}
public void testAnnotationsAndInheritance() {
JClass ejb = mLoader.loadClass(DUMMY+".ejb.TraderEJB");
JClass ienv = ejb.getInterfaces()[0];
JMethod ejbBuy = ejb.getMethods()[0];
JMethod ienvBuy = ienv.getMethods()[0];
String INTER_ANN = "ejbgen:remote-method@transaction-attribute";
String INTER_ANN_VALUE = "NotSupported";
String CLASS_ANN = "ejbgen:remote-method@isolation-level";
String CLASS_ANN_VALUE = "Serializable";
verifyAnnotationAbsent(ejbBuy,INTER_ANN);
verifyAnnotationAbsent(ienvBuy,CLASS_ANN);
if (isAnnotationsAvailable()) {
verifyAnnotation(ienvBuy,INTER_ANN,INTER_ANN_VALUE);
verifyAnnotation(ejbBuy,CLASS_ANN,CLASS_ANN_VALUE);
} else {
verifyAnnotationAbsent(ienvBuy,INTER_ANN);
verifyAnnotationAbsent(ejbBuy,CLASS_ANN);
}
}
// ========================================================================
// Private methods
private void verifyAnnotation(JElement j, String ann, String val) {
JAnnotation a = j.getAnnotation(ann);
assertTrue(j.getParent().getQualifiedName()+" '"+j.getQualifiedName()+"' is missing expected annotation '"+ann+"'",
a != null);
assertTrue(j.getQualifiedName()+" annotation '"+ann+"' does not equal "+
val,val.equals(a.getStringValue().trim()));
}
private void verifyAnnotationAbsent(JElement j, String ann) {
JAnnotation a = j.getAnnotation(ann);
assertTrue("'"+j.getQualifiedName()+"' expected to NOT have annotation '"+ann+"'",
a == null);
}
}
1.1 xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/SourcesJamTest.java
Index: SourcesJamTest.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache
* XMLBeans", nor may "Apache" appear in their name, without prior
* written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2003 BEA Systems
* Inc., <http://www.bea.com/>. For more information on the Apache Software
* Foundation, please see <http://www.apache.org/>.
*/
package org.apache.xmlbeans.test.jam;
import org.apache.xmlbeans.impl.jam.JServiceFactory;
import org.apache.xmlbeans.impl.jam.JServiceParams;
import java.io.IOException;
/**
* Runs the JamTestBase cases by loading the types from source.
*
* @author Patrick Calahan <pc...@bea.com>
*/
public class SourcesJamTest extends JamTestBase {
// ========================================================================
// Constructors
public SourcesJamTest(String name) {
super(name);
}
// ========================================================================
// JamTestBase implementation
protected JServiceParams getBasicServiceParams() throws IOException {
JServiceFactory jsf = JServiceFactory.getInstance();
JServiceParams params = jsf.createServiceParams();
params.includeSourceFiles(getDummyclassesSourceRoot(),"**/*.java");
return params;
}
protected boolean isAnnotationsAvailable() {
return true;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org