1 23 24 28 29 package com.sun.enterprise.tools.common.validation.util; 30 31 import junit.framework.*; 32 import com.sun.enterprise.tools.common.validation.constraints.ConstraintFailure; 33 34 import java.util.ArrayList ; 35 36 37 42 43 public class DisplayTest extends TestCase{ 44 45 46 public DisplayTest(String name){ 47 super(name); 48 } 49 50 51 public static void main(String args[]){ 52 junit.textui.TestRunner.run(suite()); 53 } 54 55 56 public void testText() { 57 CustomDisplay display = new CustomDisplay(); 58 59 60 ArrayList failureMessages = new ArrayList (); 61 ConstraintFailure failure_abc = 62 new ConstraintFailure("abc failed", "value_abc", "name_abc", "failureMessage_abc", "genericFailureMessage_abc"); ConstraintFailure failure_xyz = 66 new ConstraintFailure("constraint_xyz", "value_xyz", "name_xyz", "failureMessage_xyz", "genericFailureMessage_xyz"); failureMessages.add(failure_abc); 70 failureMessages.add(failure_xyz); 71 display.text(failureMessages); 72 73 ArrayList failures = new ArrayList (); 76 failures.add(new Integer (5)); 77 failures.add("failure_message"); display.text(failures); 79 } 80 81 82 85 public static Test suite(){ 86 TestSuite suite = new TestSuite(DisplayTest.class); 87 return suite; 88 } 89 90 91 94 protected void setUp() { 95 } 96 97 98 101 protected void tearDown() { 102 } 103 104 105 private void nyi() { 106 fail("Not yet implemented"); } 108 109 class CustomDisplay extends Display 110 { 111 CustomDisplay(){ 112 super(); 113 } 114 115 protected void reportFailure(String message){ 116 assertTrue((message.equals("failureMessage_abc")) ||(message.equals("failureMessage_xyz"))); } 119 120 protected void reportError(Object object){ 121 Class classObject = object.getClass(); 122 String objectType = classObject.getName(); 123 assertTrue((objectType.equals("java.lang.Integer")) ||(objectType.equals("java.lang.String"))); } 126 } 127 } 128 | Popular Tags |