1 45 46 package edu.rice.cs.drjava.model; 47 import edu.rice.cs.drjava.DrJavaTestCase; 48 49 import java.io.Reader ; 50 import java.io.StringReader ; 51 52 59 60 public class ClassAndInterfaceFinderTest extends DrJavaTestCase { 61 62 63 66 public void testStringInterfaceRecognition() { 67 try { 68 Reader r = new StringReader ("//\n /**/public Class Interface interface Aa.12_34 {}"); 69 ClassAndInterfaceFinder finder = new ClassAndInterfaceFinder(r); 70 String s = finder.getClassOrInterfaceName(); 71 assertEquals("stringInterfaceRecognition","Aa.12_34", s); 72 } 73 catch (Exception e) { 74 fail("stringInterfaceRecognition threw "+e); 75 } 76 } 77 78 79 82 public void testStringInterfaceRejection() { 83 try { 84 Reader r = new StringReader ("//\n /**/public Class Interface interface Aa.12_34 {}"); 85 ClassAndInterfaceFinder finder = new ClassAndInterfaceFinder(r); 86 String s = finder.getClassName(); 87 assertEquals("stringInterfaceRejection","", s); 88 } 89 catch (Exception e) { 90 fail("stringInterfaceRejection threw "+ e); 91 } 92 } 93 94 95 98 public void testStringClassRecognition() { 99 try { 100 Reader r = new StringReader ("//\n /**/public Class Interface class Aa.12_34 {}"); 101 ClassAndInterfaceFinder finder = new ClassAndInterfaceFinder(r); 102 String s = finder.getClassOrInterfaceName(); 103 assertEquals("stringNameRecognition","Aa.12_34", s); 104 } 105 catch (Exception e) { 106 fail("stringClassRecognition threw " +e); 107 } 108 } 109 110 113 public void testStringPackageRecognition() { 114 try { 115 Reader r = new StringReader ("//\n /**/package x public interface Aa.12_34 {}"); 116 ClassAndInterfaceFinder finder = new ClassAndInterfaceFinder(r); 117 String s = finder.getClassOrInterfaceName(); 118 assertEquals("stringNameRecognition","x.Aa.12_34", s); 119 } 120 catch (Exception e) { 121 fail("stringPackageRecognition threw " + e); 122 } 123 } 124 125 126 } 127 | Popular Tags |