Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gov.bsp.lcmis.internal.test;
- import static org.junit.Assert.assertEquals;
- import java.util.HashMap;
- import java.util.Map;
- import javax.naming.NamingException;
- import org.junit.BeforeClass;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.jdbc.datasource.DriverManagerDataSource;
- import org.springframework.mock.jndi.SimpleNamingContextBuilder;
- import org.springframework.test.context.ActiveProfiles;
- import org.springframework.test.context.ContextConfiguration;
- import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
- import org.springframework.test.context.web.WebAppConfiguration;
- import gov.bsp.lcmis.internal.posting.controller.LedgerPostingController;
- import gov.bsp.lcmis.internal.posting.domain.PendingPreForeclosureEntries;
- import gov.bsp.lcmis.internal.posting.exception.PostingBusinessException;
- import gov.bsp.lcmis.internal.posting.repo.RetrieveSingleTransactionRepo;
- import gov.bsp.lcmis.internal.user.controller.EmergencyLoanRatesController;
- import gov.bsp.lcmis.posting.cfas.repo.CfasPostingRepo;
- import gov.bsp.lcmis.rates.exception.RatesBusinessException;
- /**
- * This class tests if the context that is setup by dispatcher-servlet.xml is
- * complete and will run. Completeness includes : (1) that all bean definitions
- * have corresponding classes in the classpath.
- *
- * Note that the datasource set up here cannot be used to query the database in
- * other junit tests. A little tweaking is needed.
- *
- * @author enrique.feleo
- *
- */
- @RunWith(SpringJUnit4ClassRunner.class)
- @WebAppConfiguration
- @ContextConfiguration(value = "file:src/main/webapp/WEB-INF/dispatcher-servlet.xml")
- @ActiveProfiles("test")
- public class ApplicationContextsTest {
- private static Logger logger = LoggerFactory.getLogger(ApplicationContextsTest.class);
- private static String url = "jdbc:db2://localhost:50000/mydb2";
- private static String username = "db2admin";
- private static String password = "password";
- @Autowired
- LedgerPostingController ledgerPostingController;
- @Autowired
- EmergencyLoanRatesController emergencyLoanRatesController;
- @Autowired
- RetrieveSingleTransactionRepo retrieveTrans;
- @Autowired
- CfasPostingRepo cfasRepo;
- //
- // @Autowired
- // SearchController controller;
- /*
- * @BeforeClass public static void setupClass() { //create the datasource
- * DataSource datasource = new AbstractDataSource() {
- *
- * @Override public Connection getConnection(String username, String
- * password) throws SQLException { return null; }
- *
- * @Override public Connection getConnection() throws SQLException { return
- * null; } };
- *
- * String automationPrefix = System.getProperty("automationTest.suffix"); if
- * (automationPrefix == null) { automationPrefix = ""; }
- * logger.debug(automationPrefix);
- *
- * //bind to a jndi string SimpleNamingContextBuilder builder = new
- * SimpleNamingContextBuilder(); builder.bind(new
- * StringBuilder("lcmisbsp").append(automationPrefix).toString(),
- * datasource); builder.bind(new
- * StringBuilder("${cfas.jndi.name}").append(automationPrefix).toString(),
- * datasource); builder.bind(new
- * StringBuilder("${ops.jndi.name}").append(automationPrefix).toString(),
- * datasource); try { builder.activate(); } catch (IllegalStateException |
- * NamingException e) { logger.error("Error setting up test class, ", e); }
- * }
- *
- * @Test public void test() { assertThat(controller, notNullValue()); }
- */
- @BeforeClass
- public static void setupClass() {
- // create the datasource
- DriverManagerDataSource datasource = new DriverManagerDataSource(url, username, password);
- datasource.setDriverClassName("com.ibm.db2.jcc.DB2Driver");
- // bind to a jndi string
- SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
- builder.bind("lcmisbsp", datasource);
- builder.bind("${cfas.jndi.name}", datasource);
- builder.bind("${ops.jndi.name}", datasource);
- try {
- builder.activate();
- } catch (IllegalStateException | NamingException e) {
- logger.error("Error setting up test class, ", e);
- }
- }
- @Test
- public void test() {
- // try {
- PendingPreForeclosureEntries entry = retrieveTrans.retrieveSingleTransaction("27");
- System.out.println(entry.getBankCode()+"||"+entry.getEub());
- // System.out.println(map.get("status"));
- // System.out.println(map.get("maxDate"));
- // } catch (RatesBusinessException e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- /*try {
- String paymentNumber = "2017077770";
- String pnNumber = "";
- String type = "INPUT";
- int id = 1;
- boolean isPosted = ledgerPostingController.postAdjustmentToLedgers(paymentNumber, pnNumber, type, id);
- assertEquals(true, isPosted);
- } catch (PostingBusinessException e) {
- logger.error("Error found in testing. ", e);
- }*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement