It's me again :))

I'am almost at the end of the road. Here is my ant target:

<target name="unittest">
    <junit showoutput="true" fork="true" printsummary="yes">
        <classpath>
            <pathelement path="${build.tests.dir}"/>
            <pathelement path="${libs.dir}/merlin-kernel-unit-3.2.5.jar"/>
            <pathelement path="${libs.dir}/avalon-repository-main-1.2.jar"/>
            <pathelement path="${libs.dir}/junit-3.8.1.jar"/>
    </classpath>
    <batchtest fork="true" todir="${build.tests.dir}">
        <formatter type="xml"/>
            <fileset dir="${build.tests.dir}">
                <include name="com/mrt/vend/impl/tests/**"/>
            </fileset>
        </batchtest>
    </junit>
</target>

and here is my block.xml
<container name="mrt-vend-client">
    <classloader>
        <classpath>
            <repository>
                <resource id="commons-lang:commons-lang" version="2.0"/>
                <resource id="commons-logging:commons-logging"
version="1.0.3"/>
                <resource id="commons-collections:commons-collections"
version="3.0"/>
                <resource id="commons-beanutils:commons-beanutils"
version="1.6"/>
                <resource id="hibernate:hibernate" version="2.1.1"/>
                <resource id="dom4j:dom4j" version="1.4"/>
                <resource id="cglib:cglib" version="2.0-rc2"/>
                <resource id="asm:asm" version="1.4.1"/>
                <resource id="hsqldb:hsqldb" version="1.7.1"/>
                <resource id="ehcache:ehcache" version="0.7"/>
                <resource id="odmg:odmg" version="3.0"/>
            </repository>
            <fileset dir="c:/projekty/mrt-vend2/libs">
                <include name="jta.jar"/>
                <include name="mrt-service-impl-0.1.jar"/>
            </fileset>
            <fileset dir="c:/projekty/mrt-vend2/build/classes"/>
        </classpath>
    </classloader>
    <component name="hibernate-service"
class="com.mrt.service.hibernate.HibernateServiceImpl" activation="startup">
        <configuration>
        </configuration>
    </component>
    <!-- DAO Services -->
    <component name="location-dao"
class="com.mrt.vend.impl.LocationDAOServiceImpl"/>
</container>

${build.tests.dir}(build/tests) - contains test case classes
build/classes        -  contains project classes

and here is test case source:

public void testSave() throws Exception {
    LocationDAOService obj =
(LocationDAOService)resolve("/mrt-vend-client/location-dao");
    assertNotNull(obj);
}

and here is exception I get:

java.lang.NoClassDefFoundError: com/mrt/vend/LocationDAOService
at
com.mrt.vend.impl.tests.LocationDAOServiceTest.testSave(LocationDAOServiceTe
st.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)

this is clear for me because there isn't com/mrt/vend/LocationDAOService on
test case classpath, but when I do this:

<target name="unittest">
    <junit showoutput="true" fork="true" printsummary="yes">
        <classpath>
            <pathelement path="${build.tests.dir}"/>
            <pathelement path="${build.classes.dir}"/>

i get this exception
    [junit] ---- exception
report ----------------------------------------------
------------
    [junit] Exception: org.apache.avalon.merlin.KernelException
    [junit] Message: Install failure:
file:/C:/projekty/mrt-vend2/src/conf/block
-locationdao-test.xml
    [junit] ---- 
cause ---------------------------------------------------------
------------
    [junit] Exception: org.apache.avalon.composition.model.ModelException
    [junit] Message: Could not create classloader.
    [junit] ---- 
cause ---------------------------------------------------------
------------
    [junit] Exception: org.apache.avalon.composition.model.ModelException
    [junit] Message: Unexpected error while attempting to scan directory:
file:/
C:/projekty/mrt-vend2/build/classes/
    [junit] ---- 
cause ---------------------------------------------------------
------------
    [junit] Exception: org.apache.avalon.composition.model.ModelException
    [junit] Message: Component type
[com.mrt.service.hibernate.HibernateServiceI
mpl] contains a reference to the class
[org/apache/avalon/framework/logger/Abstr
actLogEnabled] which does not exist in the classloader.
    [junit] ---- stack
trace ---------------------------------------------------
------------
    [junit] org.apache.avalon.composition.model.ModelException: Component
type [
com.mrt.service.hibernate.HibernateServiceImpl] contains a reference to the
clas
s [org/apache/avalon/framework/logger/AbstractLogEnabled] which does not
exist i
n the classloader.
    [junit]
org.apache.avalon.composition.model.impl.Scanner.getComponentClass(S
canner.java:538)
    [junit]
org.apache.avalon.composition.model.impl.Scanner.addType(Scanner.jav
a:376)
    [junit]
org.apache.avalon.composition.model.impl.Scanner.scanFile(Scanner.ja
va:365)
    [junit]
org.apache.avalon.composition.model.impl.Scanner.scanDirectoryConten
t(Scanner.java:354)
    [junit]
org.apache.avalon.composition.model.impl.Scanner.scanDirectoryConten
t(Scanner.java:350)
    [junit]
org.apache.avalon.composition.model.impl.Scanner.scanDirectoryConten
t(Scanner.java:350)
    [junit]
org.apache.avalon.composition.model.impl.Scanner.scanDirectoryConten
t(Scanner.java:350)
    [junit]
org.apache.avalon.composition.model.impl.Scanner.scanDirectoryConten
t(Scanner.java:350)
    [junit]
org.apache.avalon.composition.model.impl.Scanner.scanDirectory(Scann
er.java:210)
    [junit]
org.apache.avalon.composition.model.impl.Scanner.scanURL(Scanner.jav
a:191)
    [junit]
org.apache.avalon.composition.model.impl.Scanner.scan(Scanner.java:1
70)
    [junit]
org.apache.avalon.composition.model.impl.DefaultClassLoaderModel.<in
it>(DefaultClassLoaderModel.java:235)
    [junit]
org.apache.avalon.composition.model.impl.DefaultClassLoaderModel.cre
ateClassLoaderModel(DefaultClassLoaderModel.java:129)
    [junit]
org.apache.avalon.composition.model.impl.DefaultContainmentModel.cre
ateContainmentModel(DefaultContainmentModel.java:634)
    [junit]
org.apache.avalon.composition.model.impl.DefaultContainmentModel.cre
ateContainmentModel(DefaultContainmentModel.java:597)
    [junit]
org.apache.avalon.composition.model.impl.DefaultContainmentModel.cre
ateContainmentModel(DefaultContainmentModel.java:844)
    [junit]
org.apache.avalon.composition.model.impl.DefaultContainmentModel.add
ContainmentModel(DefaultContainmentModel.java:376)
    [junit]
org.apache.avalon.composition.model.impl.DefaultContainmentModel.add
Model(DefaultContainmentModel.java:370)
    [junit]
org.apache.avalon.merlin.impl.DefaultFactory.create(DefaultFactory.j
ava:488)
    [junit]
org.apache.avalon.merlin.unit.AbstractMerlinTestCase.setUp(AbstractM
erlinTestCase.java:198)
    [junit] junit.framework.TestCase.runBare(TestCase.java:125)
    [junit] junit.framework.TestResult$1.protect(TestResult.java:106)
    [junit] junit.framework.TestResult.runProtected(TestResult.java:124)
    [junit] junit.framework.TestResult.run(TestResult.java:109)
    [junit] junit.framework.TestCase.run(TestCase.java:118)
    [junit] junit.framework.TestSuite.runTest(TestSuite.java:208)
    [junit] junit.framework.TestSuite.run(TestSuite.java:203)
    [junit]
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUn
itTestRunner.java:325)
    [junit]
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JU
nitTestRunner.java:536)




[junit] --------------------------------------------------------------------
------------

    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 2,468 sec
    [junit] TEST com.mrt.vend.impl.tests.LocationDAOServiceTest FAILED
    [junit] Running com.mrt.vend.model.tests.AccessRightBeanTest
    [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0,5 sec
    [junit] Running com.mrt.vend.model.tests.AdditionalDevicesBeanTest
    [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0,485 sec
    [junit] Running com.mrt.vend.model.tests.CoinslotBeanTest
    [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0,547 sec
    [junit] Running com.mrt.vend.model.tests.CoinslotMessageBeanTest
    [junit] Tests run: 2, Failures: 1, Errors: 0, Time elapsed: 0,532 sec
    [junit] TEST com.mrt.vend.model.tests.CoinslotMessageBeanTest FAILED
    [junit] Running com.mrt.vend.model.tests.CoinslotTypeBeanTest
    [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0,516 sec

Please help.

Jaroslaw Palka





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to