package no.abmu.questionnarie.domain;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.hibernate.HibernateException;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Environment;
import org.springframework.orm.hibernate3.SessionFactoryUtils;
import org.springframework.orm.hibernate3.SessionHolder;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import no.abmu.test.utilh3.*;
import no.abmu.test.utilh3.DomainTestHelper;
import no.abmu.questionnarie.domain.fixtures.PostTestFixture;
import no.abmu.questionnarie.domain.fixtures.ReportSchemaTestFixture;
import no.abmu.questionnarie.domain.fixtures.AccountTestFixture;

import java.util.List;
import java.util.Set;
import java.sql.Connection;
import java.sql.CallableStatement;
import java.sql.SQLException;

import junit.framework.*;

public class PostHsqlMemVanillaTest extends AbstractLocalTest
{

    private static final Log logger = (Log) LogFactory.getLog(PostHsqlMemVanillaTest.class);




    PostTestFixture postTestFixture = new PostTestFixture();

    @org.junit.Test
    public void testPost() throws HibernateException
    {
        postTestFixture.persist(session);

        session.flush();
        session.clear();

        Query query=session.createQuery("from " + IntPost.class.getName());
        List intList = query.list();
//        List intList = session.find("from " + IntPost.class.getName());
        assertEquals("should have size 4 not ", intList.size(), 4);
        List stringList = session.createQuery("from " + StringPost.class.getName()).list();
        assertEquals("should have size 4 not ", stringList.size(), 4);
        List boolList = session.createQuery("from " + BoolPost.class.getName()).list();
        assertTrue("should have size 3 not " + boolList.size(), boolList.size() == 3);
    }



    public static junit.framework.Test suite()
    {
        return new TestSuite(PostHsqlMemVanillaTest.class);
    }

    public static void main(String args[])
    {
        junit.textui.TestRunner.run(PostHsqlMemVanillaTest.suite());
    }

}

