1 2 22 23 package com.jaspersoft.jasperserver.war.wizard; 24 25 26 import com.jaspersoft.jasperserver.war.wizard.TestAttribute.DataSourceAttrb; 27 28 import junit.framework.Test; 29 import junit.framework.TestCase; 30 import junit.framework.TestSuite; 31 32 33 38 public class SalesByMonthWizardFlow 39 extends AbstractHttpWizardBaseFlow { 40 45 public SalesByMonthWizardFlow(String s) { 46 super(s); 47 } 48 49 50 54 55 63 public void testWizardFlowWithJDBC() 64 throws Exception { 65 TestAttribute attrbs = new TestAttribute(); 66 attrbs.setReportName("TestJDBC"+String.valueOf((int)(Math.random()*1000))); 67 attrbs.setLabel("Test report by http unit test for JDBC"); 68 attrbs.setJrxml("SalesByMonth.jrxml"); 69 attrbs.setJrmlResources(resourceMap); 70 DataSourceAttrb dsattrbs = attrbs.new DataSourceAttrb(); 71 dsattrbs.setDataSourceType(TestAttribute.DSTYPE_JDBC); 72 dsattrbs.setName("jdbc"); 73 dsattrbs.setLabel("Using JDBC DS"); 74 dsattrbs.setDriver("com.mysql.jdbc.Driver"); 75 dsattrbs.setUrl("jdbc:mysql://localhost:3306/jasperserver"); 76 dsattrbs.setUsername("root"); 77 dsattrbs.setPassword("root"); 78 attrbs.setDataSourceAttrb(dsattrbs); 79 this.runWizardFlow(attrbs); 80 } 81 82 83 84 92 public void testWizardFlowWithJNDI() 93 throws Exception { 94 TestAttribute attrbs = new TestAttribute(); 95 attrbs.setReportName("TestJNDI"+String.valueOf((int)(Math.random()*1000))); 96 attrbs.setLabel("Test report by http unit test for JNDI"); 97 attrbs.setJrxml("SalesByMonth.jrxml"); 98 attrbs.setJrmlResources(resourceMap); 99 DataSourceAttrb dsattrbs = attrbs.new DataSourceAttrb(); 100 dsattrbs.setDataSourceType(TestAttribute.DSTYPE_JNDI); 101 dsattrbs.setName("jndi"); 102 dsattrbs.setLabel("Using jndi ds"); 103 dsattrbs.setServiceName("jdbc/jserver"); 104 attrbs.setDataSourceAttrb(dsattrbs); 105 this.runWizardFlow(attrbs); 106 } 107 108 109 public void individualLoadFilePage() throws Exception {}; 110 111 112 113 117 118 119 122 protected String [] getloginCredentials() { 123 return new String [] { USERNAME, PASSWORD }; 124 } 125 126 127 128 132 133 134 139 public static void main(String [] args) { 140 try { 141 junit.textui.TestRunner.run(suite()); 142 } catch (Exception _ex) { 143 _ex.printStackTrace(); 144 } 145 } 146 147 154 public static Test suite() 155 throws Exception { 156 TestSuite suite = new TestSuite(); 157 158 TestCase test1 = new SalesByMonthWizardFlow("testWizardFlowWithJDBC"); 159 TestCase test2 = new SalesByMonthWizardFlow("testWizardFlowWithJNDI"); 160 suite.addTest(test1); 161 suite.addTest(test2); 162 163 return suite; 164 } 165 } 166 | Popular Tags |