package net.pascalalma.mybusinessservices;

import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author pascal
 */
public class TestCustomerbusinessService {

    private Logger log;
    private CustomerBusinessServiceRemote ots = null;
    private Context context = null;

    public TestCustomerbusinessService() {
        log = LoggerFactory.getLogger(getClass());
    }

    @Before
    public void setUp() throws Exception {
        log.debug("setUp");
        Properties props = new Properties();
        props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                "org.apache.openejb.client.LocalInitialContextFactory");

        props.put("MyDS", "new://Resource?type=DataSource");
        props.put("MyDS.JdbcDriver", "org.hsqldb.jdbcDriver");
        props.put("MyDS.JdbcUrl", "jdbc:hsqldb:.");

        context = new InitialContext(props);
        log.debug("End of setUp");

    }

    @After
    public void tearDown() throws Exception {
        log.debug("tearDown");

    }

    @Test
    public void checkValidateOrder() throws Exception {
       
        ots = (CustomerBusinessServiceRemote) context.lookup("CustomerBusinessServiceRemote");

        assert ots != null;

        ots.validateCustomer("1");
        
    }
}

