|
(→Export Dependencies)
|
(→Add Random Test Results to a BuildLife)
|
| Line 446: | |||
| Script Notes: | Script Notes: | ||
| - | * Treat this mostly as a snippet for doing something more interesting with. | + | * This is a good script to use if you need some garbage results on the '''Tests tab'''. |
| - | ==== AHPSCRIPTS-1 ==== | + | <pre>import com.urbancode.anthill3.domain.test.*; |
| + | import java.util.Random; | ||
| - | <pre>import com.urbancode.anthill3.domain.project.*; | + | Random timerand = new Random(); |
| - | import com.urbancode.anthill3.domain.authentication.*; | + | Random successrand = new Random(); |
| - | import com.urbancode.anthill3.domain.security.*; | + | Random totalrand = new Random(); |
| - | import com.urbancode.anthill3.domain.singleton.security.*; | + | int timeint = timerand.nextInt(1048576) + 1; |
| + | int successint = successrand.nextInt(32768) + 1; | ||
| + | int totalint = totalrand.nextInt(32769) + 1; | ||
| - | // Lookup Your roles | + | Random srunrand = new Random(); |
| - | buildRole = RoleFactory.getInstance().restoreForName("Build Master"); | + | Random frunrand = new Random(); |
| - | userRole = RoleFactory.getInstance().restoreForName("User"); | + | int srun = srunrand.nextInt(254) + 1; |
| + | int frun = frunrand.nextInt(254) + 1; | ||
| - | // Look-up the LDAP realm here | + | public newnums() |
| - | // This is a lookup by name, so insert the name of your LDAP realm. | + | { |
| - | realm = AuthenticationRealmFactory.getInstance().restore("LDAP"); | + | timeint = timerand.nextInt(1048576) + 1; |
| + | successint = successrand.nextInt(32768) + 1; | ||
| + | totalint = totalrand.nextInt(32769) + 1; | ||
| + | } | ||
| - | // Do this for each user: | + | public newtimeint() |
| - | User user1 = new User(true, realm); | + | { |
| + | timeint = timerand.nextInt(1048576) + 1; | ||
| + | } | ||
| - | user1.setName("JaneDoe"); | + | public roller() |
| - | user1.setPassword("Bogus"); | + | { |
| - | user1.addRole(userRole); | + | int rollnum=0; |
| - | user1.addRole(buildRole); | + | while(totalint < successint){ |
| - | user1.store();</pre> | + | newnums(); |
| + | rollnum++; | ||
| + | commandOutput.println("REROLL #"+rollnum+". . .TRYING FOR BETTER NUMBERS"); | ||
| + | } | ||
| + | } | ||
| + | while(totalint < successint){roller();} | ||
| + | testReport = new TestReport(); | ||
| + | testReport.setName("Unit Tests"); | ||
| + | testReport.setNumberOfSuites(1); | ||
| + | testReport.setNumberOfTests(totalint); | ||
| + | testReport.setNumberOfSuccesses(successint); | ||
| + | testReport.setNumberOfFailures(totalint-successint); | ||
| + | testReport.setJobTrace(JobTraceLookup.getCurrent()); | ||
| + | testReport.store(); | ||
| + | while(totalint < successint){roller();} | ||
| + | testSuite = new TestSuite(); | ||
| + | testSuite.setName("Test Suite"); | ||
| + | testSuite.setTestReport(testReport); | ||
| + | testSuite.setNumberOfTests(totalint); | ||
| + | testSuite.setNumberOfSuccesses(successint); | ||
| + | testSuite.store(); | ||
| + | for (i=0; i<srun; i++){ | ||
| + | String stringpre = "Inserting test #"; | ||
| + | String stringpost = " into Anthill"; | ||
| + | String pass = Integer.toString(i+1); | ||
| + | String stringer = stringpre + pass + stringpost; | ||
| + | |||
| + | while(totalint < successint){roller();} | ||
| + | newtimeint(); | ||
| + | testCase = new TestCase(); | ||
| + | testCase.setName("testMethod"); | ||
| + | testCase.setClassName("com.urbancode.Test"); | ||
| + | testCase.setTestSuite(testSuite); | ||
| + | testCase.setTime(timeint); | ||
| + | testCase.setMessage(stringer); | ||
| + | testCase.setResult("success"); | ||
| + | testCase.store(); | ||
| + | } | ||
| + | for (i=0; i<frun; i++){ | ||
| + | String stringpre = "Inserting test #"; | ||
| + | String stringpost = " into Anthill"; | ||
| + | String pass = Integer.toString(i+1); | ||
| + | String stringer = stringpre + pass + stringpost; | ||
| + | |||
| + | while(totalint < successint){roller();} | ||
| + | newtimeint(); | ||
| + | |||
| + | testCase = new TestCase(); | ||
| + | testCase.setName("testMethod"); | ||
| + | testCase.setClassName("com.urbancode.Test"); | ||
| + | testCase.setTestSuite(testSuite); | ||
| + | testCase.setTime(timeint); | ||
| + | testCase.setMessage(stringer); | ||
| + | testCase.setResult("failure"); | ||
| + | testCase.store(); | ||
| + | }</pre> | ||