예제 #1
0
 @Test
 public void testsameiddifferentnameEquals() {
   System.out.println("equals");
   Student instance1 = new Student();
   instance1.setName("Ranjith");
   instance1.setId("c0663421");
   Student instance2 = new Student();
   instance2.setName("surya");
   instance2.setId("c0663421");
   assertFalse(instance1.getName().equals(instance2.getName()));
 }
예제 #2
0
 /** Test of equals method, of class Student. */
 @Test
 public void testEquals() {
   System.out.println("equals");
   Student instance1 = new Student();
   instance1.setName("Ranjith");
   instance1.setId("c0663421");
   Student instance2 = new Student();
   instance2.setName("Ranjith");
   instance2.setId("c0663421");
   assertEquals(instance1, instance2);
 }
예제 #3
0
 @Test
 public void namevalueTest() {
   System.out.println("StudentTest");
   Student instance = new Student();
   String expResult = "Bill Smith";
   instance.setName(expResult);
   String result = instance.getName();
   assertEquals(expResult, result);
 }
예제 #4
0
 /** Test of toString method, of class Student. */
 @Test
 public void testToString() {
   try {
     System.out.println("toString");
     Student instance = new Student();
     instance.setName("Bill Smith");
     instance.setId("c0123456");
     instance.setGender("male");
     instance.setGrade(89.3);
     String jsonString = instance.toString();
     JSONObject result = (JSONObject) new JSONParser().parse(jsonString);
     JSONObject expResult =
         (JSONObject)
             new JSONParser()
                 .parse(
                     "{\"name\":\"Bill Smith\",\"id\":\"c0123456\",\"gender\":\"male\",\"grade\":\"89.3\"}");
     assertEquals(expResult, result);
   } catch (ParseException ex) {
     System.err.println("Invalid JSON Format");
     fail("Invalid JSON Format");
   }
 }