MCPcopy Index your code
hub / github.com/OWASP/SecurityShepherd / testClassCreate

Method testClassCreate

src/test/java/dbProcs/SetterTest.java:51–87  ·  view source on GitHub ↗

Test to ensure class's can be created with this method. Other Unit Tests use this method, but not nessisarily every time, as a class may already exist. This Method creates a random class name so it can run every time without failure

()

Source from the content-addressed store, hash-verified

49 * This Method creates a random class name so it can run every time without failure
50 */
51 @Test
52 public void testClassCreate()
53 {
54 Random rand = new Random();
55 String className = "newC"+rand.nextInt(50)+rand.nextInt(50)+rand.nextInt(50);
56 if(!Setter.classCreate(applicationRoot, className, "2015"))
57 {
58 fail("Could not Create Class");
59 }
60 else
61 {
62 try
63 {
64 boolean pass = false;
65 ResultSet rs = Getter.getClassInfo(applicationRoot);
66 while(rs.next())
67 {
68 if(rs.getString(2).equalsIgnoreCase(className))
69 {
70 pass = true;
71 break;
72 }
73 }
74 if(!pass)
75 {
76 fail("Could not find class in DB");
77 }
78 else
79 return; // PASS
80 }
81 catch(Exception e)
82 {
83 log.fatal("Could not Find Created Class: " + e.toString());
84 fail("Could not Find Created Class");
85 }
86 }
87 }
88
89 @Test
90 public void testIncrementBadSubmission()

Callers

nothing calls this directly

Calls 2

classCreateMethod · 0.95
getClassInfoMethod · 0.95

Tested by

no test coverage detected