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