Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Databases
»
Object Relational Mapping
Hibernate DAO MAVEn testing unit
Suresh Khant
,
Ranch Hand
Mar 09, 2013 17:06:11
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Hi All,
could any one provide me examples for DAO
testing
unit ,
it should include hibernate with maven2 structure
Suresh Khant
,
Ranch Hand
Mar 10, 2013 00:41:49
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Hi All,
I have code which works in non
maven
environment , I converted the project to maven (maven2) but I am getting some errors
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/transaction/SystemException at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:266) at org.jboss.logging.Logger.getMessageLogger(Logger.java:2248) at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214) at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:176) at com.diw.attendance.api.dao.HibernateFactory.configureSessionFactory(HibernateFactory.java:81) at com.diw.attendance.api.dao.HibernateFactory.buildIfNeeded(HibernateFactory.java:31) at com.diw.attendance.api.dao.AbstractDao.<init>(AbstractDao.java:15) at com.diw.attendance.api.dao.EventDao.<init>(EventDao.java:8) at com.diw.attendance.test.dao.EventTest.setup(EventTest.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:122) at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:86) at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77) at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42) at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88) at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51) at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44) at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27) at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37) at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
package com.diw.attendance.test.dao; import java.util.Date; import java.util.List; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import com.diw.attendance.api.dao.Event; import com.diw.attendance.api.dao.EventDao; public class EventTest { private EventDao eventDao; @Before public void setup() { eventDao = new EventDao(); } @BeforeClass public static void testSetup() { } @AfterClass public static void testCleanup() { // Teardown for data used by the unit tests } /* * @Test(expected = IllegalArgumentException.class) public void * testExceptionIsThrown() { MyClassTest tester = new MyClassTest(); * tester.multiply(1000, 5);MyClassTest } */ /* * @Test public void testMultiply() { * * assertEquals(50, 5 * 10); * * } */ @Test public void createEvent() { Event event = new Event(); event.setName("system12"); // event.setId(2L); event.setDuration(123); event.setStartDate(new Date()); eventDao.createOrUpdate(event); } @Test public void listEvent() { List<Event> list = eventDao.findAll(); for (Event event2 : list) { System.out.println("" + event2.getName()); } System.out.println("List size is " + list.size()); } @Test public void getEvent(){ Event event = eventDao.find(1L); System.out.println("event name"+event.getId()); } @Test public void deleteEvent(){ Event event = eventDao.find(2L); eventDao.delete(event); } @Test public void updateEvent(){ Event event = eventDao.find(5L); event.setName("updatedname"); eventDao.update(event); } }
Post by:
autobot
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
This thread has been viewed 1808 times.
Similar Threads
unite testing
Unit Testing tool -> Struts + Hiberante
hibernate unit testing
Unit testing with Hibernate without a running database
Hibernate Template not inserting data into the DB
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 02:39:03
.