dataset error "NO such Table Exception"

am runnug a data set test in my module but am getting a "No Such Table Exeption . here is my dataset

<?xml version='1.0' encoding='UTF-8'?>

<dataset>
  <facelist_multipart multipart_id="1" patient_id="1" />
</dataset>

my test class

package org.openmrs.module.facelist;

import org.junit.Assert; import org.junit.Test; import org.openmrs.api.context.Context; import org.openmrs.module.facelist.Service.MultipartService; import org.openmrs.test.BaseModuleContextSensitiveTest;

/**

  • Tests the MyModuleService class and all of its methods **/ public class MyModuleServiceTest extends BaseModuleContextSensitiveTest {

     @Test
     public void shouldreturnId() throws Exception {
     	
     	
     	
     	
     	initializeInMemoryDatabase();
     
     	executeDataSet("Dataset.xml");
     	authenticate();
     	
     	MultipartService muiltipartService = Context.getService(MultipartService.class);
     	
    
     	Assert.assertEquals( muiltipartService.getMultipart(1).getPatient_ID(),1);
     }
    

    }

test configuration file

<?xml version="1.0" encoding="UTF-8"?>



						
 <hibernate-configuration>
<session-factory>
	<mapping resource="Multipart.hbm.xml"/>
</session-factory>

</hibernate-configuration> 

and my testing application context file

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
						http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
						
						
	<bean id="sessionFactory" class="org.openmrs.api.db.hibernate.HibernateSessionFactoryBean">
    <property name="configLocations">
        <list>
             <value>classpath*:hibernate.cfg.xml</value>  
            <value>classpath*: ManagingMultipart-hibernate.cfg.xml</value>
        </list>
    </property>
    <property name="mappingJarLocations">
        <ref bean="mappingJarResources" />
    </property>
    <!--  default properties must be set in the hibernate.default.properties -->
</bean>

</beans>

@dkayiwa @tendomart

Give a detailed error log

thx @tendomart… i had already given the link to the error log https://hastebin.com/nojamipuge.swift in the post as “No such Table Exception”

Have you mapped it in the TestingApplicationContext.xml file as here? https://github.com/openmrs/openmrs-module-reporting/blob/master/api-tests/src/test/resources/TestingApplicationContext.xml#L20

And here? https://github.com/openmrs/openmrs-module-reporting/blob/master/api-tests/src/test/resources/reporting-hibernate.cfg.xml#L8-L9

1 Like

Why do you have a space in classpath*: ManagingMultipart-hibernate.cfg.xml in the TestApplicationContext.xml file?

1 Like

thx so much sir dan…

i had no included this

<!DOCTYPE hibernate-configuration PUBLIC
	"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
	"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

in the my managingMultipart-hibernate-cfg.xml file …it now works pretty fine

yes sir mr wycliff your ryt, wen i removed it , it now works

one problem i now have , to be sincere i have never written a test unit for a controler , i have read about using the mocker concept , but ive not sen an example of how its used n openmrs , coz wat i tried out doesnt work in open mrs …can i gte an example sir

Here are some examples