Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. package gov.bsp.lcmis.internal.domain;
  2.  
  3. import static org.hamcrest.CoreMatchers.notNullValue;
  4. import static org.junit.Assert.*;
  5.  
  6. import java.math.BigDecimal;
  7. import java.sql.Connection;
  8. import java.sql.SQLException;
  9. import java.text.DateFormat;
  10. import java.text.ParseException;
  11. import java.text.SimpleDateFormat;
  12. import java.util.Calendar;
  13. import java.util.Date;
  14. import java.util.List;
  15. import java.util.Locale;
  16.  
  17. import javax.naming.NamingException;
  18. import javax.sql.DataSource;
  19.  
  20. import org.junit.BeforeClass;
  21. import org.junit.Test;
  22. import org.junit.runner.RunWith;
  23. import org.slf4j.Logger;
  24. import org.slf4j.LoggerFactory;
  25. import org.springframework.beans.BeansException;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.context.ApplicationContext;
  28. import org.springframework.context.ApplicationContextAware;
  29. import org.springframework.jdbc.datasource.AbstractDataSource;
  30. import org.springframework.jdbc.datasource.DriverManagerDataSource;
  31. import org.springframework.mock.jndi.SimpleNamingContextBuilder;
  32. import org.springframework.test.context.ActiveProfiles;
  33. import org.springframework.test.context.ContextConfiguration;
  34. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  35. import org.springframework.test.context.web.WebAppConfiguration;
  36.  
  37. import gov.bsp.lcmis.internal.fsm.exception.FSMBusinessException;
  38. import gov.bsp.lcmis.internal.fsm.manager.ApprovedPostedTransactionsManager;
  39. import gov.bsp.lcmis.internal.fsm.service.RetrieveApprovedPostedTransactionsService;
  40. import gov.bsp.lcmis.internal.lmm.domain.BidMemoComponentPmcImpl;
  41. import gov.bsp.lcmis.internal.report.domain.RvcReport;
  42. import gov.bsp.lcmis.internal.report.manager.RvcManagerTest;
  43. import gov.bsp.lcmis.internal.report.service.GenerateRvcReportService;
  44.  
  45. @RunWith(SpringJUnit4ClassRunner.class)
  46. @WebAppConfiguration
  47. @ContextConfiguration(value="file:src/main/webapp/WEB-INF/dispatcher-servlet.xml")
  48. public class MTestClass {
  49.  
  50. private static Logger log = LoggerFactory.getLogger(MTestClass.class);
  51.  
  52. @Autowired
  53. private RetrieveApprovedPostedTransactionsService manager;
  54.  
  55. /**
  56. * SET THE DATABASE CREDS and URL
  57. */
  58. private static String url = "jdbc:db2://localhost:50000/bspdb2";
  59.  
  60. private static String username = "db2admin";
  61.  
  62. private static String password = "password123";
  63.  
  64. /**
  65. * Note to Architect : please setup an environment dependent datasource
  66. * to remove the need for commenting and uncommenting the @Test method.
  67. */
  68. @BeforeClass
  69. public static void setupClass() {
  70. //create the datasource
  71. DriverManagerDataSource datasource = new DriverManagerDataSource(url, username, password);
  72. datasource.setDriverClassName("com.ibm.db2.jcc.DB2Driver");
  73.  
  74. //bind to a jndi string
  75. SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
  76. builder.bind("lcmisbsp", datasource);
  77. try {
  78. builder.activate();
  79. } catch (IllegalStateException | NamingException e) {
  80. log.error("Error setting up test class, ", e);
  81. }
  82. }
  83.  
  84. /**
  85. * The @Test annotation
  86. * Uncomment when running, comment when Committing.
  87. *
  88. * @throws FSMBusinessException
  89. * @throws ParseException
  90. */
  91. @Test
  92. public void test() throws FSMBusinessException, ParseException {
  93. assertThat(manager, notNullValue());
  94.  
  95. List<TransactionPageObject> test = manager.retrieveApprovedPostedTransactions("fsm.maker");
  96. System.out.println(test.size());
  97.  
  98. for (TransactionPageObject t : test) {
  99. System.out.println(t.getMaker());
  100. System.out.println(t.getBankName());
  101. }
  102. assertNotNull(test);
  103.  
  104.  
  105. }
  106.  
  107.  
  108.  
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement