Source Code Cross Referenced for DefinitionsDocumentTest.java in  » IDE » DrJava » edu » rice » cs » drjava » model » definitions » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE » DrJava » edu.rice.cs.drjava.model.definitions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*BEGIN_COPYRIGHT_BLOCK
0002:         *
0003:         * Copyright (c) 2001-2007, JavaPLT group at Rice University (javaplt@rice.edu)
0004:         * All rights reserved.
0005:         * 
0006:         * Redistribution and use in source and binary forms, with or without
0007:         * modification, are permitted provided that the following conditions are met:
0008:         *    * Redistributions of source code must retain the above copyright
0009:         *      notice, this list of conditions and the following disclaimer.
0010:         *    * Redistributions in binary form must reproduce the above copyright
0011:         *      notice, this list of conditions and the following disclaimer in the
0012:         *      documentation and/or other materials provided with the distribution.
0013:         *    * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
0014:         *      names of its contributors may be used to endorse or promote products
0015:         *      derived from this software without specific prior written permission.
0016:         * 
0017:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0018:         * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0019:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0020:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
0021:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0022:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0023:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
0024:         * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0025:         * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0026:         * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0027:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0028:         *
0029:         * This software is Open Source Initiative approved Open Source Software.
0030:         * Open Source Initative Approved is a trademark of the Open Source Initiative.
0031:         * 
0032:         * This file is part of DrJava.  Download the current version of this project
0033:         * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
0034:         * 
0035:         * END_COPYRIGHT_BLOCK*/
0036:
0037:        package edu.rice.cs.drjava.model.definitions;
0038:
0039:        import edu.rice.cs.drjava.DrJava;
0040:        import edu.rice.cs.drjava.DrJavaTestCase;
0041:        import edu.rice.cs.drjava.config.OptionConstants;
0042:        import edu.rice.cs.drjava.model.GlobalEventNotifier;
0043:        import edu.rice.cs.drjava.model.definitions.reducedmodel.BraceReduction;
0044:        import edu.rice.cs.drjava.model.definitions.reducedmodel.HighlightStatus;
0045:        import edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedModelStates;
0046:        import edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedToken;
0047:        import edu.rice.cs.util.StringOps;
0048:
0049:        import junit.framework.Test;
0050:        import junit.framework.TestSuite;
0051:
0052:        import javax.swing.text.BadLocationException;
0053:        import java.util.Vector;
0054:
0055:        /** Tests the functionality of the definitions document.
0056:         *  @version $Id: DefinitionsDocumentTest.java 4255 2007-08-28 19:17:37Z mgricken $
0057:         */
0058:        public final class DefinitionsDocumentTest extends DrJavaTestCase
0059:                implements  ReducedModelStates {
0060:            private DefinitionsDocument _defModel;
0061:            private GlobalEventNotifier _notifier;
0062:
0063:            /** Standard constructor.
0064:             * @param name of the test
0065:             */
0066:            public DefinitionsDocumentTest(String name) {
0067:                super (name);
0068:            }
0069:
0070:            /**
0071:             * Create a definitions document to work with.
0072:             */
0073:            protected void setUp() throws Exception {
0074:                super .setUp();
0075:                _notifier = new GlobalEventNotifier();
0076:                _defModel = new DefinitionsDocument(_notifier);
0077:                DrJava.getConfig().resetToDefaults();
0078:            }
0079:
0080:            /**
0081:             * Create a test suite for JUnit to run.
0082:             * @return a test suite based on this class
0083:             */
0084:            public static Test suite() {
0085:                return new TestSuite(DefinitionsDocumentTest.class);
0086:            }
0087:
0088:            /**
0089:             * Test insertion.
0090:             */
0091:            public void testInsertToDoc() throws BadLocationException {
0092:                _defModel.insertString(0, "a/*bc */\"\\{}()", null);
0093:                assertEquals("#0.0", _defModel.getText(0, 8), "a/*bc */");
0094:                assertEquals("#0.1", 14, _defModel.getCurrentLocation());
0095:                _defModel.insertString(0, "Start:", null);
0096:                assertEquals("#1.0", _defModel.getText(0, 14), "Start:a/*bc */");
0097:                assertEquals("#1.1", 6, _defModel.getCurrentLocation());
0098:                // document is:
0099:                // Start:=>a/*bc */"\\{}()
0100:                BraceReduction _reduced = _defModel.getReduced();
0101:                assertEquals("2.1", FREE, _reduced.getStateAtCurrent());
0102:                _reduced.move(2);
0103:                // document is:
0104:                // Start:a/=>*bc */"\\{}()
0105:                assertEquals("2.3", "/*", _reduced.currentToken().getType());
0106:                _reduced.move(2);
0107:                // document is:
0108:                // Start:a/*b=>c */"\\{}()
0109:                assertEquals("2.4", true, _reduced.currentToken().isGap());
0110:                assertEquals("2.5", ReducedToken.INSIDE_BLOCK_COMMENT, _reduced
0111:                        .currentToken().getState());
0112:                _reduced.move(2);
0113:                // document is:
0114:                // Start:a/*bc =>*/"\{}()
0115:                assertEquals("2.6", "*/", _reduced.currentToken().getType());
0116:                _reduced.move(2);
0117:                // document is:
0118:                // Start:a/*bc */=>"\{}()
0119:                assertEquals("2.7", "\"", _reduced.currentToken().getType());
0120:                _reduced.move(1);
0121:                // document is:
0122:                // Start:a/*bc */"=>\{}()
0123:                assertEquals("2.8", "\\", _reduced.currentToken().getType());
0124:                _reduced.move(1);
0125:                // document is:
0126:                // Start:a/*bc */"\=>{}()
0127:                assertEquals("2.9", "{", _reduced.currentToken().getType());
0128:                _reduced.move(1);
0129:                // document is:
0130:                // Start:a/*bc */"\{=>}()
0131:                assertEquals("2.91", "}", _reduced.currentToken().getType());
0132:                _reduced.move(1);
0133:                // document is:
0134:                // Start:a/*bc */"\{}=>()
0135:                assertEquals("2.92", "(", _reduced.currentToken().getType());
0136:                _reduced.move(1);
0137:                // document is:
0138:                // Start:a/*bc */"\\{}(=>)
0139:                assertEquals("2.93", ")", _reduced.currentToken().getType());
0140:            }
0141:
0142:            /**
0143:             * Test inserting a star between a star-slash combo.
0144:             * @exception BadLocationException
0145:             */
0146:            public void testInsertStarIntoStarSlash()
0147:                    throws BadLocationException {
0148:                BraceReduction _reduced = _defModel.getReduced();
0149:                _defModel.insertString(0, "/**/", null);
0150:                // Put new star between second star and second slash
0151:                _defModel.insertString(3, "*", null);
0152:                _defModel.move(-4);
0153:                assertEquals("1", "/*", _reduced.currentToken().getType());
0154:                assertEquals("2", ReducedToken.FREE, _reduced.currentToken()
0155:                        .getState());
0156:                _reduced.move(2);
0157:                assertEquals("3", "*", _reduced.currentToken().getType());
0158:                assertEquals("4", ReducedToken.INSIDE_BLOCK_COMMENT, _reduced
0159:                        .currentToken().getState());
0160:                _reduced.move(1);
0161:                assertEquals("5", "*/", _reduced.currentToken().getType());
0162:                assertEquals("6", ReducedToken.FREE, _reduced.currentToken()
0163:                        .getState());
0164:            }
0165:
0166:            /**
0167:             * Test inserting a slash between a star-slash combo.
0168:             * @exception BadLocationException
0169:             */
0170:            public void testInsertSlashIntoStarSlash()
0171:                    throws BadLocationException {
0172:                BraceReduction _reduced = _defModel.getReduced();
0173:                _defModel.insertString(0, "/**/", null);
0174:                // Put new slash between second star and second slash
0175:                _defModel.insertString(3, "/", null);
0176:                _defModel.move(-4);
0177:                assertEquals("1", "/*", _reduced.currentToken().getType());
0178:                assertEquals("2", ReducedToken.FREE, _reduced.currentToken()
0179:                        .getState());
0180:                _reduced.move(2);
0181:                assertEquals("3", "*/", _reduced.currentToken().getType());
0182:                assertEquals("4", ReducedToken.FREE, _reduced.currentToken()
0183:                        .getState());
0184:                _reduced.move(2);
0185:                assertEquals("5", "/", _reduced.currentToken().getType());
0186:                assertEquals("6", ReducedToken.FREE, _reduced.currentToken()
0187:                        .getState());
0188:            }
0189:
0190:            /** Test inserting a star between a slash-star combo.
0191:             *  @exception BadLocationException
0192:             */
0193:            public void testInsertStarIntoSlashStar()
0194:                    throws BadLocationException {
0195:                BraceReduction _reduced = _defModel.getReduced();
0196:                _defModel.insertString(0, "/**/", null);
0197:                // Put new star between second star and second slash
0198:                _defModel.insertString(1, "*", null);
0199:                _defModel.move(-2);
0200:                assertEquals("1", "/*", _reduced.currentToken().getType());
0201:                assertEquals("2", ReducedToken.FREE, _reduced.currentToken()
0202:                        .getState());
0203:                _reduced.move(2);
0204:                assertEquals("3", "*", _reduced.currentToken().getType());
0205:                assertEquals("4", ReducedToken.INSIDE_BLOCK_COMMENT, _reduced
0206:                        .currentToken().getState());
0207:                _reduced.move(1);
0208:                assertEquals("5", "*/", _reduced.currentToken().getType());
0209:                assertEquals("6", ReducedToken.FREE, _reduced.currentToken()
0210:                        .getState());
0211:            }
0212:
0213:            /** Test removal of text. */
0214:            public void testDeleteDoc() throws BadLocationException {
0215:                _defModel.insertString(0, "a/*bc */", null);
0216:                _defModel.remove(3, 3);
0217:                assertEquals("#0.0", "a/**/", _defModel.getText(0, 5));
0218:                assertEquals("#0.1", 3, _defModel.getCurrentLocation());
0219:                BraceReduction _reduced = _defModel.getReduced();
0220:                assertEquals("1.0", "*/", _reduced.currentToken().getType());
0221:                // no longer support getBlockOffset
0222:                //        assertEquals("1.1",0,rm.getBlockOffset());
0223:                _reduced.move(-2);
0224:                assertEquals("1.2", "/*", _reduced.currentToken().getType());
0225:                _reduced.move(2);
0226:                assertEquals("1.3", ReducedToken.INSIDE_BLOCK_COMMENT, _reduced
0227:                        .getStateAtCurrent());
0228:            }
0229:
0230:            /** Make sure the vector is consistent: all elements immediately adjoin
0231:             *  one another (no overlap), and make sure all indices between start and end
0232:             *  are in the vector. Vector is guaranteed to not have size zero.
0233:             */
0234:            private void _checkHighlightStatusConsistent(
0235:                    Vector<HighlightStatus> v, int start, int end) {
0236:                // location we're at so far
0237:                int walk = start;
0238:                for (int i = 0; i < v.size(); i++) {
0239:                    assertEquals("Item #" + i
0240:                            + "in highlight vector starts at right place",
0241:                            walk, v.get(i).getLocation());
0242:                    // Sanity check: length > 0?
0243:                    assertTrue("Item #" + i
0244:                            + " in highlight vector has positive length", v
0245:                            .get(i).getLength() > 0);
0246:
0247:                    walk += v.get(i).getLength();
0248:                }
0249:                assertEquals("Location after walking highlight vector", end,
0250:                        walk);
0251:            }
0252:
0253:            /** Test that keywords are highlighted properly.
0254:             *  @exception BadLocationException
0255:             */
0256:            public void testHighlightKeywords1() throws BadLocationException {
0257:                Vector<HighlightStatus> v;
0258:                final String s = "public class Foo {\n"
0259:                        + "  private int _x = 0;\n" + "}";
0260:                _defModel.insertString(_defModel.getLength(), s, null);
0261:                v = _defModel.getHighlightStatus(0, _defModel.getLength());
0262:                _checkHighlightStatusConsistent(v, 0, _defModel.getLength());
0263:                // Make sure the keywords are highlighted
0264:                assertEquals("vector length", 12, v.size());
0265:                assertEquals(HighlightStatus.KEYWORD, v.get(0).getState());
0266:                assertEquals(HighlightStatus.NORMAL, v.get(1).getState());
0267:                assertEquals(HighlightStatus.KEYWORD, v.get(2).getState());
0268:                assertEquals(HighlightStatus.NORMAL, v.get(3).getState());
0269:                assertEquals(HighlightStatus.TYPE, v.get(4).getState());
0270:                assertEquals(HighlightStatus.NORMAL, v.get(5).getState());
0271:
0272:                assertEquals(HighlightStatus.KEYWORD, v.get(6).getState());
0273:                assertEquals(HighlightStatus.NORMAL, v.get(7).getState());
0274:                assertEquals(HighlightStatus.TYPE, v.get(8).getState());
0275:                assertEquals(HighlightStatus.NORMAL, v.get(9).getState());
0276:                assertEquals(HighlightStatus.NUMBER, v.get(10).getState());
0277:                assertEquals(HighlightStatus.NORMAL, v.get(11).getState());
0278:            }
0279:
0280:            /** This test case simulates what happens when some text is selected
0281:             *  and there is a keyword around too.
0282:             *  In drjava-20010720-1712 there is a bug that if you enter "int Y" and
0283:             *  then try to select "t Y", it exceptions. This is a test for that case.
0284:             *  The important thing about the selecting thing is that because it wants
0285:             *  to render the last three chars selected, it asks for the first two only
0286:             *  in the call to getHighlightStatus.
0287:             *  @exception BadLocationException
0288:             */
0289:            public void testHighlightKeywords2() throws BadLocationException {
0290:                Vector<HighlightStatus> v;
0291:                final String s = "int y";
0292:                _defModel.insertString(_defModel.getLength(), s, null);
0293:                // First sanity check the whole string's status
0294:                v = _defModel.getHighlightStatus(0, _defModel.getLength());
0295:                _checkHighlightStatusConsistent(v, 0, _defModel.getLength());
0296:                // Make sure the keyword is highlighted
0297:
0298:                assertEquals("vector length", 2, v.size());
0299:                assertEquals(HighlightStatus.TYPE, v.get(0).getState());
0300:                assertEquals(HighlightStatus.NORMAL, v.get(1).getState());
0301:                // Now only ask for highlights for "in"
0302:                v = _defModel.getHighlightStatus(0, 2);
0303:                _checkHighlightStatusConsistent(v, 0, 2);
0304:                assertEquals("vector length", 1, v.size());
0305:                assertEquals(0, v.get(0).getLocation());
0306:                assertEquals(2, v.get(0).getLength());
0307:            }
0308:
0309:            /** Test going to the second line in a two-line document.
0310:             *  @exception BadLocationException
0311:             */
0312:            public void testGotoLine1() throws BadLocationException {
0313:                final String s = "a\n";
0314:                _defModel.insertString(0, s, null);
0315:                _defModel.gotoLine(2);
0316:                assertEquals("#0.0", 2, _defModel.getCurrentLocation());
0317:            }
0318:
0319:            /**
0320:             * Test going to a specific line.
0321:             * @exception BadLocationException
0322:             */
0323:            public void testGotoLine2() throws BadLocationException {
0324:                final String s = "abcd\n";
0325:                _defModel.insertString(0, s, null);
0326:                _defModel.gotoLine(2);
0327:                assertEquals("#0.0", 5, _defModel.getCurrentLocation());
0328:            }
0329:
0330:            /**
0331:             * Test going to the fourth line in a four line document.
0332:             * @exception BadLocationException
0333:             */
0334:            public void testGotoLine3() throws BadLocationException {
0335:                final String s = "a\nb\nc\n";
0336:                _defModel.insertString(0, s, null);
0337:                _defModel.gotoLine(4);
0338:                assertEquals("#0.0", 6, _defModel.getCurrentLocation());
0339:            }
0340:
0341:            /**
0342:             * Test going to a line beyond the number of lines in a document
0343:             * just goes to the end of the file.
0344:             * @exception BadLocationException
0345:             */
0346:            public void testGotoLine4() throws BadLocationException {
0347:                final String s = "a\nb\nc\n";
0348:                _defModel.insertString(0, s, null);
0349:                _defModel.gotoLine(8);
0350:                assertEquals("#0.0", 6, _defModel.getCurrentLocation());
0351:            }
0352:
0353:            /**
0354:             * Test going to the first line of an empty document
0355:             * doesn't do anything funny.  It should stay in the same
0356:             * location.
0357:             */
0358:            public void testGotoLine5() {
0359:                _defModel.gotoLine(1);
0360:                assertEquals("#0.0", 0, _defModel.getCurrentLocation());
0361:            }
0362:
0363:            /**
0364:             * Test going to a line that is greater than the line count
0365:             * of an empty document just keeps you in your current location.
0366:             */
0367:            public void testGotoLine6() {
0368:                _defModel.gotoLine(4);
0369:                assertEquals("#0.0", 0, _defModel.getCurrentLocation());
0370:            }
0371:
0372:            /**
0373:             * Test that going to a line within the document's line count
0374:             * sets the current position to the first character of the line.
0375:             * @exception BadLocationException
0376:             */
0377:            public void testGotoLine7() throws BadLocationException {
0378:                final String s = "11111\n2222\n33333\n44444";
0379:                _defModel.insertString(0, s, null);
0380:                _defModel.gotoLine(3);
0381:                assertEquals("#0.0", 11, _defModel.getCurrentLocation());
0382:            }
0383:
0384:            /**
0385:             * Tests returning the current column in the document.
0386:             */
0387:            public void testGetColumn1() throws BadLocationException {
0388:                final String s = "1234567890";
0389:                assertEquals("#0.0", 0, _defModel.getCurrentCol());
0390:                _defModel.insertString(0, s, null);
0391:                assertEquals("#0.1", 10, _defModel.getCurrentCol());
0392:                _defModel.gotoLine(0);
0393:                assertEquals("#0.2", 0, _defModel.getCurrentCol());
0394:            }
0395:
0396:            /**
0397:             * Tests returning the current column in the document.
0398:             */
0399:            public void testGetColumn2() throws BadLocationException {
0400:                final String s = "1234567890\n1234\n12345";
0401:                _defModel.insertString(0, s, null);
0402:                assertEquals("#0.0", 5, _defModel.getCurrentCol());
0403:            }
0404:
0405:            /**
0406:             * Test returning second line in a two-line document.
0407:             * @exception BadLocationException
0408:             */
0409:            public void testGetLine1() throws BadLocationException {
0410:                final String s = "a\n";
0411:                _defModel.insertString(0, s, null);
0412:                _defModel.setCurrentLocation(2);
0413:                assertEquals("#0.0", 2, _defModel.getCurrentLine());
0414:            }
0415:
0416:            /**
0417:             * Test going to a specific line.
0418:             * @exception BadLocationException
0419:             */
0420:            public void testGetLine2() throws BadLocationException {
0421:                final String s = "abcd\n";
0422:                _defModel.insertString(0, s, null);
0423:                _defModel.setCurrentLocation(2);
0424:                assertEquals("#0.0", 1, _defModel.getCurrentLine());
0425:                _defModel.gotoLine(2);
0426:                assertEquals("#0.1", 2, _defModel.getCurrentLine());
0427:            }
0428:
0429:            /**
0430:             * Test going to the fourth line in a four line document.
0431:             * @exception BadLocationException
0432:             */
0433:            public void testGetLine3() throws BadLocationException {
0434:                final String s = "a\nb\nc\n";
0435:                _defModel.insertString(0, s, null);
0436:                _defModel.setCurrentLocation(6);
0437:                assertEquals("#0.0", 4, _defModel.getCurrentLine());
0438:            }
0439:
0440:            /**
0441:             * Test going to a line beyond the number of lines in a document
0442:             * just goes to the end of the file.
0443:             * @exception BadLocationException
0444:             */
0445:            public void testGetLine4() throws BadLocationException {
0446:                final String s = "a\nb\nc\n";
0447:                _defModel.insertString(0, s, null);
0448:                _defModel.gotoLine(8);
0449:                assertEquals("#0.0", 4, _defModel.getCurrentLine());
0450:            }
0451:
0452:            /**
0453:             * Test going to the first line of an empty document
0454:             * doesn't do anything funny.  It should stay in the same
0455:             * location.
0456:             */
0457:            public void testGetLine5() {
0458:                _defModel.setCurrentLocation(0);
0459:                assertEquals("#0.0", 1, _defModel.getCurrentLine());
0460:            }
0461:
0462:            /**
0463:             * Test going to a line that is greater than the line count
0464:             * of an empty document just keeps you in your current location.
0465:             */
0466:            public void testGetLine6() {
0467:                _defModel.gotoLine(4);
0468:                assertEquals("#0.0", 1, _defModel.getCurrentLine());
0469:            }
0470:
0471:            /**
0472:             * Test that going to a line within the document's line count
0473:             * sets the current position to the first character of the line.
0474:             * @exception BadLocationException
0475:             */
0476:            public void testGetLine7() throws BadLocationException {
0477:                final String s = "12345\n7890\n2345\n789";
0478:                _defModel.insertString(0, s, null);
0479:                _defModel.setCurrentLocation(12);
0480:                assertEquals("#0.0", 3, _defModel.getCurrentLine());
0481:                _defModel.move(-5);
0482:                assertEquals("#0.1", 2, _defModel.getCurrentLine());
0483:                _defModel.setCurrentLocation(19);
0484:                assertEquals("#0.2", 4, _defModel.getCurrentLine());
0485:            }
0486:
0487:            /**
0488:             * Tests line numbering output after deletion of a block
0489:             */
0490:            public void testGetLineDeleteText() throws BadLocationException {
0491:                final String s = "123456789\n123456789\n123456789\n123456789\n";
0492:                _defModel.insertString(0, s, null);
0493:                _defModel.setCurrentLocation(35);
0494:                assertEquals("Before delete", 4, _defModel.getCurrentLine());
0495:                _defModel.remove(0, 30);
0496:                _defModel.setCurrentLocation(5);
0497:                assertEquals("After delete", 1, _defModel.getCurrentLine());
0498:            }
0499:
0500:            /**
0501:             * Tests line numbering output after deletion of a block
0502:             */
0503:            public void testGetLineDeleteText2() throws BadLocationException {
0504:                final String s = "123456789\n123456789\n123456789\n123456789\n";
0505:                _defModel.insertString(0, s, null);
0506:                _defModel.setCurrentLocation(35);
0507:                assertEquals("Before delete", 4, _defModel.getCurrentLine());
0508:                _defModel.remove(18, 7);
0509:                assertEquals("After delete", 2, _defModel.getCurrentLine());
0510:            }
0511:
0512:            /**
0513:             * Test whether removeTabs actually removes all tabs.
0514:             */
0515:            public void testRemoveTabs1() {
0516:                _defModel.setIndent(1);
0517:                String test = "\t this \t\tis a \t\t\t\t\ttest\t\t";
0518:                String result = _defModel._removeTabs(test);
0519:                assertEquals("  this   is a      test  ", result);
0520:            }
0521:
0522:            /**
0523:             * As of drjava-20020122-1534, files with tabs ended up garbled, with
0524:             * some of the text jumbled all around (bug #506630).
0525:             * This test aims to replicate the problem.
0526:             */
0527:            public void testRemoveTabs2() {
0528:                String input = "\ttoken = nextToken(); // read trailing parenthesis\n"
0529:                        + "\tif (token != ')')\n"
0530:                        + "\t  throw new ParseException(\"wrong number of arguments to |\");\n";
0531:
0532:                String expected = " token = nextToken(); // read trailing parenthesis\n"
0533:                        + " if (token != ')')\n"
0534:                        + "   throw new ParseException(\"wrong number of arguments to |\");\n";
0535:
0536:                int count = 5000;
0537:                final StringBuilder bigIn = new StringBuilder(input.length()
0538:                        * count);
0539:                final StringBuilder bigExp = new StringBuilder(expected
0540:                        .length()
0541:                        * count);
0542:                for (int i = 0; i < count; i++) {
0543:                    bigIn.append(input);
0544:                    bigExp.append(expected);
0545:                }
0546:
0547:                String result = _defModel._removeTabs(bigIn.toString());
0548:                assertEquals(bigExp.toString(), result);
0549:            }
0550:
0551:            /**
0552:             * Test whether tabs are removed as appropriate on call to insertString.
0553:             */
0554:            public void testTabRemovalOnInsertString2()
0555:                    throws BadLocationException {
0556:                String[] inputs = {
0557:                        "\ttoken = nextToken(); // read trailing parenthesis\n",
0558:                        "\tif (token != ')')\n",
0559:                        "\t  throw new ParseException(\"wrong number of arguments to |\");\n", };
0560:
0561:                String expected = " token = nextToken(); // read trailing parenthesis\n"
0562:                        + " if (token != ')')\n"
0563:                        + "   throw new ParseException(\"wrong number of arguments to |\");\n";
0564:
0565:                for (int i = 0; i < inputs.length; i++) {
0566:                    _defModel.insertString(_defModel.getLength(), inputs[i],
0567:                            null);
0568:                }
0569:
0570:                assertEquals(expected, _getAllText());
0571:            }
0572:
0573:            /** Test whether tabs are removed as appropriate on call to insertString. */
0574:            public void testTabRemovalOnInsertString()
0575:                    throws BadLocationException {
0576:                _defModel.setIndent(1);
0577:                _defModel.insertString(0, " \t yet \t\tanother\ttest\t", null);
0578:                String result = _defModel.getText();
0579:
0580:                if (_defModel.tabsRemoved()) {
0581:                    assertEquals("   yet   another test ", result);
0582:                } else { // Tabs should have been inserted.
0583:                    assertEquals(" \t yet \t\tanother\ttest\t", result);
0584:                }
0585:            }
0586:
0587:            /** Test package-finding on empty document. */
0588:            public void testPackageNameEmpty() throws InvalidPackageException {
0589:                assertEquals("Package name for empty document", "", _defModel
0590:                        .getPackageName());
0591:            }
0592:
0593:            /** Test package-finding on simple document, with no funny comments. */
0594:            public void testPackageNameSimple() throws Exception {
0595:                final String[] comments = { "/* package very.bad; */",
0596:                        "// package terribly.wrong;" };
0597:
0598:                final String[] packages = { "edu", "edu.rice",
0599:                        "edu.rice.cs.drjava" };
0600:
0601:                for (int i = 0; i < packages.length; i++) {
0602:                    String curPack = packages[i];
0603:
0604:                    for (int j = 0; j < comments.length; j++) {
0605:                        String curComment = comments[j];
0606:                        setUp();
0607:                        _defModel.insertString(0, curComment + "\n\n"
0608:                                + "package " + curPack
0609:                                + ";\nclass Foo { int x; }\n", null);
0610:
0611:                        assertEquals("Package name for document with comment "
0612:                                + curComment, curPack, _defModel
0613:                                .getPackageName());
0614:                    }
0615:                }
0616:            }
0617:
0618:            /** Test package-finding on document with a block comment between parts of package. */
0619:            public void testPackageNameWeird1() throws BadLocationException,
0620:                    InvalidPackageException {
0621:                String weird = "package edu . rice\n./*comment!*/cs.drjava;";
0622:                String normal = "edu.rice.cs.drjava";
0623:                _defModel.insertString(0, weird, null);
0624:
0625:                assertEquals("Package name for weird: '" + weird + "'", normal,
0626:                        _defModel.getPackageName());
0627:            }
0628:
0629:            /** Test package-finding on document with a line comment between parts of package. */
0630:            public void testPackageNameWeird2() throws BadLocationException,
0631:                    InvalidPackageException {
0632:                String weird = "package edu . rice //comment!\n.cs.drjava;";
0633:                String normal = "edu.rice.cs.drjava";
0634:                _defModel.insertString(0, weird, null);
0635:
0636:                assertEquals("Package name for weird: '" + weird + "'", normal,
0637:                        _defModel.getPackageName());
0638:            }
0639:
0640:            /** Puts an otherwise valid package statement after a valid import declaration. This should result in seeing no 
0641:             *  package statement (for the purposes of getSourceRoot), so the resulting package name should be "".
0642:             */
0643:            public void testGetPackageNameWithPackageStatementAfterImport()
0644:                    throws BadLocationException, InvalidPackageException {
0645:                String text = "import java.util.*;\npackage junk;\nclass Foo {}";
0646:                _defModel.insertString(0, text, null);
0647:                assertEquals(
0648:                        "Package name for text with package statement after import",
0649:                        "", _defModel.getPackageName());
0650:            }
0651:
0652:            private String _getAllText() throws BadLocationException {
0653:                return _defModel.getText();
0654:            }
0655:
0656:            /** Tests class name-finding on document. */
0657:            public void testTopLevelClassName() throws BadLocationException,
0658:                    ClassNameNotFoundException {
0659:                String weird = "package edu . rice\n./*comment!*/cs.drjava; class MyClass<T> implements O{";
0660:                String result = "MyClass";
0661:                _defModel.insertString(0, weird, null);
0662:
0663:                assertEquals("class name for weird: '" + weird + "'", result,
0664:                        _defModel.getFirstTopLevelClassName());
0665:            }
0666:
0667:            /** Test interface name-finding on document */
0668:            public void testTopLevelInterfaceName()
0669:                    throws BadLocationException, ClassNameNotFoundException {
0670:                String weird = "package edu . rice\n./*comment!*/cs.drjava; \n"
0671:                        + " interface thisInterface { \n" + " class MyClass {";
0672:                String result = "thisInterface";
0673:                _defModel.insertString(0, weird, null);
0674:
0675:                assertEquals("class name for interface: '" + weird + "'",
0676:                        result, _defModel.getFirstTopLevelClassName());
0677:            }
0678:
0679:            /** Test class name-finding on document */
0680:            public void testTopLevelClassNameWComments()
0681:                    throws BadLocationException, ClassNameNotFoundException {
0682:                String weird = "package edu . rice\n./*comment!*/cs.drjava; \n"
0683:                        + "/* class Y */ \n" + " /* class Foo \n"
0684:                        + " * class Bar \n" + " interface Baz \n" + " */ \n"
0685:                        + "//class Blah\n" + "class MyClass {";
0686:
0687:                String result = "MyClass";
0688:                _defModel.insertString(0, weird, null);
0689:
0690:                assertEquals("class name for class: '" + weird + "'", result,
0691:                        _defModel.getFirstTopLevelClassName());
0692:            }
0693:
0694:            /** Tests that a keyword with no space following it does not cause a StringOutOfBoundsException (bug 742226). */
0695:            public void testTopLevelClassNameNoSpace()
0696:                    throws BadLocationException {
0697:                String c = "class";
0698:                _defModel.insertString(0, c, null);
0699:                try {
0700:                    _defModel.getFirstTopLevelClassName();
0701:                    fail("Should not have found a class name");
0702:                } catch (ClassNameNotFoundException e) {
0703:                    // Good, we expect this
0704:                }
0705:            }
0706:
0707:            /**
0708:             * Tests that the word class is not recognized if it is not followed
0709:             * by whitespace.
0710:             */
0711:            public void testTopLevelClassNameWithClassloaderImport()
0712:                    throws BadLocationException, ClassNameNotFoundException {
0713:                String weird = "import classloader.class; class MyClass {";
0714:                String result = "MyClass";
0715:                _defModel.insertString(0, weird, null);
0716:
0717:                assertEquals("class name for weird: '" + weird + "'", result,
0718:                        _defModel.getFirstTopLevelClassName());
0719:            }
0720:
0721:            /** Tests class name-finding on document. */
0722:            public void testTopLevelClassNameMisleading()
0723:                    throws BadLocationException, ClassNameNotFoundException {
0724:                String weird = "package edu . rice\n./*comment!*/cs.drjava; \n"
0725:                        + " {class X} \n" + " interface thisInterface { \n"
0726:                        + " class MyInnerClass {";
0727:                String result = "thisInterface";
0728:                _defModel.insertString(0, weird, null);
0729:
0730:                assertEquals("class name for interface: '" + weird + "'",
0731:                        result, _defModel.getFirstTopLevelClassName());
0732:            }
0733:
0734:            /** Tests class name-finding on document */
0735:            public void testTopLevelInterfaceNameMisleading()
0736:                    throws BadLocationException, ClassNameNotFoundException {
0737:                String weird = "package edu . rice\n./*comment!*/cs.drjava; \n"
0738:                        + " {interface X} " + " \"class Foo\""
0739:                        + " class MyClass {";
0740:                String result = "MyClass";
0741:                _defModel.insertString(0, weird, null);
0742:
0743:                assertEquals("class name for user interface: '" + weird + "'",
0744:                        result, _defModel.getFirstTopLevelClassName());
0745:            }
0746:
0747:            /** Tests class name-finding on document */
0748:            public void testTopLevelInterfaceNameMisleading2()
0749:                    throws BadLocationException, ClassNameNotFoundException {
0750:                String weird = "package edu . rice\n./*interface comment!*/cs.drjava; \n"
0751:                        + " {interface X<T>} "
0752:                        + " \"class interface Foo\""
0753:                        + " class MyClass extends Foo<T> {";
0754:                String result = "MyClass";
0755:                _defModel.insertString(0, weird, null);
0756:
0757:                assertEquals("class name for user interface: '" + weird + "'",
0758:                        result, _defModel.getFirstTopLevelClassName());
0759:            }
0760:
0761:            /** Tests class name-finding on document. */
0762:            public void testTopLevelInterfaceNameBeforeClassName()
0763:                    throws BadLocationException, ClassNameNotFoundException {
0764:                String weird = "package edu . rice\n./*comment!*/cs.drjava; \n"
0765:                        + " interface thisInterface { \n" + "  } \n"
0766:                        + " class thatClass {\n" + "  }";
0767:                String result = "thisInterface";
0768:                _defModel.insertString(0, weird, null);
0769:
0770:                assertEquals(
0771:                        "interface should have been chosen, rather than the class: '"
0772:                                + weird + "'", result, _defModel
0773:                                .getFirstTopLevelClassName());
0774:            }
0775:
0776:            /** Tests class name-finding on document. */
0777:            public void testTopLevelClassNameWithDelimiters()
0778:                    throws BadLocationException, ClassNameNotFoundException {
0779:                String weird1 = "package edu . rice\n./*comment!*/cs.drjava; \n"
0780:                        + " class MyClass<T> {";
0781:                String result1 = "MyClass";
0782:                _defModel.insertString(0, weird1, null);
0783:
0784:                assertEquals("generics should be removed: '" + weird1 + "'",
0785:                        result1, _defModel.getFirstTopLevelClassName());
0786:
0787:                String weird2 = "package edu . rice\n./*comment!*/cs.drjava; \n"
0788:                        + " class My_Class {";
0789:                String result2 = "My_Class";
0790:                _defModel.insertString(0, weird2, null);
0791:
0792:                assertEquals("underscores should remain: '" + weird1 + "'",
0793:                        result2, _defModel.getFirstTopLevelClassName());
0794:            }
0795:
0796:            /** Tests that the name of a top level enclosing class can be found. */
0797:            public void testTopLevelEnclosingClassName()
0798:                    throws BadLocationException, ClassNameNotFoundException {
0799:                String classes = "import foo;\n" + // 12 (including newline)
0800:                        "class C1 {\n" + // 23
0801:                        "  void foo() { int a; }\n" + // 47
0802:                        "  class C2 { int x;\n" + // 67
0803:                        "    int y;\n" + // 78
0804:                        "    class C3 {}\n" + // 94
0805:                        "  } int b;\n" + // 105
0806:                        "}\n" + // 107
0807:                        "class C4 {\n" + // 118
0808:                        "  class C5 {\n" + // 131
0809:                        "    void bar() { int c; } class C6 {}\n" + // 169
0810:                        "  }\n" + // 173
0811:                        "} class C7 {}"; // 186
0812:
0813:                _defModel.insertString(0, classes, null);
0814:
0815:                // No enclosing class at start
0816:                try {
0817:                    String result = _defModel.getEnclosingTopLevelClassName(3);
0818:                    fail("no enclosing class should be found at start");
0819:                } catch (ClassNameNotFoundException cnnfe) {
0820:                    // Correct: no class name found
0821:                }
0822:
0823:                // No enclosing class before open brace
0824:                try {
0825:                    _defModel.getEnclosingTopLevelClassName(15);
0826:                    fail("no enclosing class should be found before open brace");
0827:                } catch (ClassNameNotFoundException cnnfe) {
0828:                    // Correct: no class name found
0829:                }
0830:
0831:                try {
0832:                    String result = _defModel
0833:                            .getEnclosingTopLevelClassName(186);
0834:                    fail("no enclosing class should be found at end of file");
0835:                } catch (ClassNameNotFoundException cnnfe) {
0836:                    // Correct: no class name found
0837:                }
0838:
0839:                assertEquals("top level class name after first open brace",
0840:                        "C1", _defModel.getEnclosingTopLevelClassName(22));
0841:                assertEquals("top level class name inside C1", "C1", _defModel
0842:                        .getEnclosingTopLevelClassName(26));
0843:                assertEquals("top level class name inside method of C1", "C1",
0844:                        _defModel.getEnclosingTopLevelClassName(42));
0845:                assertEquals("top level class name on C2's brace", "C1",
0846:                        _defModel.getEnclosingTopLevelClassName(58));
0847:                assertEquals("top level class name after C2's brace", "C1",
0848:                        _defModel.getEnclosingTopLevelClassName(59));
0849:                assertEquals("top level class name inside C2", "C1", _defModel
0850:                        .getEnclosingTopLevelClassName(68));
0851:                assertEquals("top level class name inside C3", "C1", _defModel
0852:                        .getEnclosingTopLevelClassName(92));
0853:                assertEquals("top level class name after C3's close brace",
0854:                        "C1", _defModel.getEnclosingTopLevelClassName(93));
0855:                assertEquals("top level class name after C2's close brace",
0856:                        "C1", _defModel.getEnclosingTopLevelClassName(100));
0857:
0858:                // No enclosing class between classes
0859:                try {
0860:                    _defModel.getEnclosingTopLevelClassName(107);
0861:                    fail("no enclosing class should be found between classes");
0862:                } catch (ClassNameNotFoundException cnnfe) {
0863:                    // Correct: no class name found
0864:                }
0865:
0866:                assertEquals("class name inside C4", "C4", _defModel
0867:                        .getEnclosingTopLevelClassName(122));
0868:                assertEquals("class name inside C5", "C4", _defModel
0869:                        .getEnclosingTopLevelClassName(135));
0870:                assertEquals("class name inside C6", "C4", _defModel
0871:                        .getEnclosingTopLevelClassName(167));
0872:                assertEquals("class name inside C7", "C7", _defModel
0873:                        .getEnclosingTopLevelClassName(185));
0874:
0875:                // No enclosing class at end
0876:                try {
0877:                    String result = _defModel
0878:                            .getEnclosingTopLevelClassName(186);
0879:                    fail("no enclosing class should be found at end");
0880:                } catch (ClassNameNotFoundException cnnfe) {
0881:                    // Correct: no class name found
0882:                }
0883:            }
0884:
0885:            /** Tests that the correct qualified class name is returned with a package. */
0886:            public void testQualifiedClassNameWithPackage()
0887:                    throws BadLocationException, ClassNameNotFoundException {
0888:                String classes = "package foo;\n" + // 13
0889:                        "class C1 {}\n" + // 25
0890:                        "class C2 {}"; // 36
0891:                _defModel.insertString(0, classes, null);
0892:
0893:                assertEquals("qualified class name without pos", "foo.C1",
0894:                        _defModel.getQualifiedClassName());
0895:                assertEquals("enclosing class name in C1", "C1", _defModel
0896:                        .getEnclosingTopLevelClassName(23));
0897:                assertEquals("qualified class name with pos in C1", "foo.C1",
0898:                        _defModel.getQualifiedClassName(23));
0899:                assertEquals("qualified class name with pos in C2", "foo.C2",
0900:                        _defModel.getQualifiedClassName(35));
0901:
0902:                // No class name outside classes
0903:                try {
0904:                    _defModel.getQualifiedClassName(15);
0905:                    fail("no qualified class name should be found outside classes");
0906:                } catch (ClassNameNotFoundException cnnfe) {
0907:                    // Correct: no class name found
0908:                }
0909:            }
0910:
0911:            /** Tests that the correct qualified class name is returned without a package. */
0912:            public void testQualifiedClassNameWithoutPackage()
0913:                    throws BadLocationException, ClassNameNotFoundException {
0914:                String classes = "class C1 {}\n" + // 12
0915:                        "class C2 {}"; // 36
0916:                _defModel.insertString(0, classes, null);
0917:
0918:                assertEquals("qualified class name without pos", "C1",
0919:                        _defModel.getQualifiedClassName());
0920:                assertEquals("qualified class name with pos in C1", "C1",
0921:                        _defModel.getQualifiedClassName(10));
0922:                assertEquals("qualified class name with pos in C2", "C2",
0923:                        _defModel.getQualifiedClassName(22));
0924:
0925:                // No class name outside classes
0926:                try {
0927:                    _defModel.getQualifiedClassName(15);
0928:                    fail("no qualified class name should be found outside classes");
0929:                } catch (ClassNameNotFoundException cnnfe) {
0930:                    // Correct: no class name found
0931:                }
0932:            }
0933:
0934:            /** Tests that the name of an enclosing class can be found.
0935:             *
0936:             * Note: I started to write this assuming that we would need to find
0937:             * inner class names, but I'm not sure that's the case.  I'm writing
0938:             * the method for the debugger, which only needs the *top level*
0939:             * enclosing class.  Rather than delete this test, though, I'll leave
0940:             * it in case we ever need to write getEnclosingClassName().
0941:             *
0942:            public void testEnclosingClassName() throws BadLocationException, ClassNameNotFoundException {
0943:              String classes =
0944:                "import foo;\n" +  // 12 (including newline)
0945:                "class C1 {\n" +  // 23
0946:                "  void foo() { int a; }\n" +  // 47
0947:                "  class C2 { int x;\n" +  // 67
0948:                "    int y;\n" +  // 78
0949:                "    class C3 {}\n" +  // 94
0950:                "  } int b;\n" +  // 105
0951:                "}\n" +  // 107
0952:                "class C4 {\n" +  // 118
0953:                "} class C5 {}";  // 131
0954:              _defModel.insertString(0, classes, null);
0955:
0956:              // No enclosing class at start
0957:              try {
0958:                String result = _defModel.getEnclosingClassName(3);
0959:                fail("no enclosing class should be found at start");
0960:              }
0961:              catch (ClassNameNotFoundException cnnfe) {
0962:                // Correct: no class name found
0963:              }
0964:
0965:              // No enclosing class before open brace
0966:              try {
0967:                String result = _defModel.getEnclosingClassName(15);
0968:                fail("no enclosing class should be found before open brace");
0969:              }
0970:              catch (ClassNameNotFoundException cnnfe) {
0971:                // Correct: no class name found
0972:              }
0973:
0974:              assertEquals("class name after first open brace", "C1",
0975:                           _defModel.getEnclosingClassName(22));
0976:              assertEquals("class name inside C1", "C1",
0977:                           _defModel.getEnclosingClassName(26));
0978:              assertEquals("class name inside method of C1", "C1",
0979:                           _defModel.getEnclosingClassName(42));
0980:              assertEquals("class name on C2's brace", "C1",
0981:                           _defModel.getEnclosingClassName(58));
0982:              assertEquals("class name after C2's brace", "C2",
0983:                           _defModel.getEnclosingClassName(59));
0984:              assertEquals("class name inside C2", "C2",
0985:                           _defModel.getEnclosingClassName(68));
0986:              assertEquals("class name inside C3", "C3",
0987:                           _defModel.getEnclosingClassName(92));
0988:              assertEquals("class name after C3's close brace", "C2",
0989:                           _defModel.getEnclosingClassName(93));
0990:              assertEquals("class name after C2's close brace", "C1",
0991:                           _defModel.getEnclosingClassName(100));
0992:
0993:              // No enclosing class between classes
0994:              try {
0995:                String result = _defModel.getEnclosingClassName(107);
0996:                fail("no enclosing class should be found between classes");
0997:              }
0998:              catch (ClassNameNotFoundException cnnfe) {
0999:                // Correct: no class name found
1000:              }
1001:
1002:              assertEquals("class name inside C4", "C4",
1003:                           _defModel.getEnclosingClassName(118));
1004:              assertEquals("class name inside C5", "C5",
1005:                           _defModel.getEnclosingClassName(130));
1006:
1007:              // No enclosing class at end
1008:              try {
1009:                String result = _defModel.getEnclosingClassName(131);
1010:                fail("no enclosing class should be found at end");
1011:              }
1012:              catch (ClassNameNotFoundException cnnfe) {
1013:                // Correct: no class name found
1014:              }
1015:            }*/
1016:
1017:            /** Verify that undoing a multiple-line indent will be a single undo action
1018:             *  @throws BadLocationException
1019:             */
1020:            public void testUndoAndRedoAfterMultipleLineIndent()
1021:                    throws BadLocationException { //this fails
1022:                String text = "public class stuff {\n" + "private int _int;\n"
1023:                        + "private Bar _bar;\n" + "public void foo() {\n"
1024:                        + "_bar.baz(_int);\n" + "}\n" + "}\n";
1025:
1026:                String indented = "public class stuff {\n"
1027:                        + "  private int _int;\n" + "  private Bar _bar;\n"
1028:                        + "  public void foo() {\n" + "    _bar.baz(_int);\n"
1029:                        + "  }\n" + "}\n";
1030:
1031:                _defModel.addUndoableEditListener(_defModel.getUndoManager());
1032:                DrJava.getConfig().setSetting(OptionConstants.INDENT_LEVEL,
1033:                        new Integer(2));
1034:                _defModel.insertString(0, text, null);
1035:                assertEquals("insertion", text, _defModel.getText());
1036:                /* This is necessary here and other places where indenting or commenting takes place because the undoListener in DefinitionsPane 
1037:                 * currently starts compound edits, but here, there's no DefinitionsPane.
1038:                 * Perhaps there's some way to factor the undoListener in CompoundUndoManager to be the one that starts compound edits 
1039:                 * so that it will work with or without the view.
1040:                 */
1041:                _defModel.getUndoManager().startCompoundEdit();
1042:                _defModel.indentLines(0, _defModel.getLength());
1043:                assertEquals("indenting", indented, _defModel.getText());
1044:                _defModel.getUndoManager().undo();
1045:                assertEquals("undo", text, _defModel.getText());
1046:                _defModel.getUndoManager().redo();
1047:                assertEquals("redo", indented, _defModel.getText());
1048:            }
1049:
1050:            /** Verify that undoing a multiple-line indent will be a single undo action
1051:             *  @throws BadLocationException
1052:             */
1053:            public void testUndoAndRedoAfterMultipleLineCommentAndUncomment()
1054:                    throws BadLocationException {
1055:                String text = "public class stuff {\n"
1056:                        + "  private int _int;\n" + "  private Bar _bar;\n"
1057:                        + "  public void foo() {\n" + "    _bar.baz(_int);\n"
1058:                        + "  }\n" + "}\n";
1059:
1060:                String commented = "//public class stuff {\n"
1061:                        + "//  private int _int;\n" + "//  private Bar _bar;\n"
1062:                        + "//  public void foo() {\n"
1063:                        + "//    _bar.baz(_int);\n" + "//  }\n" + "//}\n";
1064:
1065:                _defModel.addUndoableEditListener(_defModel.getUndoManager());
1066:                DrJava.getConfig().setSetting(OptionConstants.INDENT_LEVEL,
1067:                        new Integer(2));
1068:                _defModel.insertString(0, text, null);
1069:                assertEquals("insertion", text, _defModel.getText());
1070:
1071:                _defModel.getUndoManager().startCompoundEdit();
1072:                _defModel.commentLines(0, _defModel.getLength());
1073:                assertEquals("commenting", commented, _defModel.getText());
1074:                _defModel.getUndoManager().undo();
1075:                assertEquals("undo commenting", text, _defModel.getText());
1076:                _defModel.getUndoManager().redo();
1077:                assertEquals("redo commenting", commented, _defModel.getText());
1078:
1079:                _defModel.getUndoManager().startCompoundEdit();
1080:                _defModel.uncommentLines(0, _defModel.getLength());
1081:                assertEquals("uncommenting", text, _defModel.getText());
1082:                _defModel.getUndoManager().undo();
1083:                assertEquals("undo uncommenting", commented, _defModel
1084:                        .getText());
1085:                _defModel.getUndoManager().redo();
1086:                assertEquals("redo uncommenting", text, _defModel.getText());
1087:            }
1088:
1089:            /** Test method for CompoundUndoManager.  Tests that the nested compound edit functionality works correctly.
1090:             *  @throws BadLocationException
1091:             */
1092:            public void testCompoundUndoManager() throws BadLocationException {
1093:                String text = "public class foo {\n" + "int bar;\n" + "}";
1094:
1095:                String indented = "public class foo {\n" + "  int bar;\n" + "}";
1096:                CompoundUndoManager undoManager = _defModel.getUndoManager();
1097:
1098:                _defModel.addUndoableEditListener(undoManager);
1099:                DrJava.getConfig().setSetting(OptionConstants.INDENT_LEVEL,
1100:                        new Integer(2));
1101:
1102:                // 1
1103:
1104:                // Start a compound edit and verify the returned key
1105:                int key = undoManager.startCompoundEdit();
1106:                assertEquals("Should have returned the correct key.", 0, key);
1107:
1108:                // Insert a test string into the document
1109:                _defModel.insertString(0, text, null);
1110:                assertEquals("Should have inserted the text properly.", text,
1111:                        _defModel.getText());
1112:
1113:                // Indent the lines, so as to trigger a nested compound edit
1114:                undoManager.startCompoundEdit();
1115:
1116:                _defModel.indentLines(0, _defModel.getLength());
1117:                assertEquals("Should have indented correctly.", indented,
1118:                        _defModel.getText());
1119:
1120:                undoManager.undo();
1121:                assertEquals("Should have undone correctly.", "", _defModel
1122:                        .getText());
1123:
1124:                // 2
1125:
1126:                String commented = "//public class foo {\n" + "//  int bar;\n"
1127:                        + "//}";
1128:
1129:                // Start a compound edit and verify the returned key
1130:                key = _defModel.getUndoManager().startCompoundEdit();
1131:                assertEquals("Should have returned the correct key.", 2, key);
1132:
1133:                // Insert a test string into the document
1134:                _defModel.insertString(0, text, null);
1135:                assertEquals("Should have inserted the text properly.", text,
1136:                        _defModel.getText());
1137:
1138:                // Indent the lines, so as to trigger a nested compond edit
1139:                _defModel.indentLines(0, _defModel.getLength());
1140:                assertEquals("Should have indented correctly.", indented,
1141:                        _defModel.getText());
1142:
1143:                undoManager.startCompoundEdit();
1144:                _defModel.commentLines(0, _defModel.getLength());
1145:                assertEquals("Should have commented correctly.", commented,
1146:                        _defModel.getText());
1147:
1148:                // Undo the second compound edit
1149:                _defModel.getUndoManager().undo();
1150:                assertEquals("Should have undone the commenting.", indented,
1151:                        _defModel.getText());
1152:
1153:                // Undo the first compound edit
1154:                _defModel.getUndoManager().undo();
1155:                assertEquals("Should have undone the indenting and inserting.",
1156:                        "", _defModel.getText());
1157:
1158:                // 3
1159:
1160:                // Start a compound edit and verify the returned key
1161:                key = _defModel.getUndoManager().startCompoundEdit();
1162:                assertEquals("Should have returned the correct key.", 4, key);
1163:
1164:                // Insert a test string into the document
1165:                _defModel.insertString(0, text, null);
1166:                assertEquals("Should have inserted the text properly.", text,
1167:                        _defModel.getText());
1168:
1169:                // Indent the lines, so as to trigger a nested compond edit
1170:                _defModel.indentLines(0, _defModel.getLength());
1171:                assertEquals("Should have indented correctly.", indented,
1172:                        _defModel.getText());
1173:
1174:                //    // Try to undo the nested edit
1175:                //    try {
1176:                //      _defModel.getUndoManager().undo();
1177:                //      fail("Should not have allowed undoing a nested edit.");
1178:                //    }
1179:                //    catch (CannotUndoException e) {
1180:                //      // Correct: cannot undo a nested edit
1181:                //    }
1182:                //
1183:                //    try {
1184:                //      _defModel.getUndoManager().redo();
1185:                //      fail("Should not have allowed redoing a nested edit.");
1186:                //    }
1187:                //    catch (CannotRedoException cre) {
1188:                //      // Correct: cannot redo a nested edit
1189:                //    }
1190:                //
1191:                // Try end the compound edit with a wrong key
1192:                try {
1193:                    _defModel.getUndoManager().endCompoundEdit(key + 2);
1194:                    //      fail("Should not have allowed ending a compound edit with a wrong key.");
1195:                } catch (IllegalStateException e) {
1196:                    assertEquals(
1197:                            "Should have printed the correct error message.",
1198:                            "Improperly nested compound edits.", e.getMessage());
1199:                }
1200:
1201:                // Indent the lines, so as to trigger a nested compound edit
1202:                undoManager.startCompoundEdit();
1203:                _defModel.indentLines(0, _defModel.getLength());
1204:                assertEquals("Should have indented correctly.", indented,
1205:                        _defModel.getText());
1206:
1207:                // We've taken out this part of the test because of our change to
1208:                // undo where we close the nearest open compound edit upon undo-ing,
1209:                // pasting, commenting, un-commenting, indenting, and backspacing.
1210:                // We should never have a nested edit anymore.
1211:
1212:                // Try to undo the nested edit
1213:                //    try {
1214:                //      _defModel.getUndoManager().undo();
1215:                //      fail("Should not have allowed undoing a nested edit.");
1216:                //    }
1217:                //    catch (CannotUndoException e) {
1218:                //      // Correct: cannot undo a nested edit
1219:                //    }
1220:
1221:                // End the compound edit and undo
1222:                //    _defModel.getUndoManager().endCompoundEdit(key);
1223:                _defModel.getUndoManager().undo();
1224:                assertEquals("Should have undone the indenting and inserting.",
1225:                        "", _defModel.getText());
1226:            }
1227:
1228:            /**
1229:             * Verifies that the undo manager correctly determines if the document has
1230:             * been modified since the last save.
1231:             */
1232:            public void testUndoOrRedoSetsUnmodifiedState()
1233:                    throws BadLocationException {
1234:                _defModel.addUndoableEditListener(_defModel.getUndoManager());
1235:                _defModel.insertString(0, "This is text", null);
1236:                assertTrue("Document should be modified.", _defModel
1237:                        .isModifiedSinceSave());
1238:                _defModel.getUndoManager().undo();
1239:                _defModel.updateModifiedSinceSave();
1240:                assertFalse(
1241:                        "Document should no longer be modified after undo.",
1242:                        _defModel.isModifiedSinceSave());
1243:                _defModel.insertString(0, "This is text", null);
1244:                _defModel.resetModification();
1245:                assertFalse("Document should not be modified after \"save\".",
1246:                        _defModel.isModifiedSinceSave());
1247:                _defModel.getUndoManager().undo();
1248:                _defModel.updateModifiedSinceSave();
1249:                assertTrue("Document should be modified after undo.", _defModel
1250:                        .isModifiedSinceSave());
1251:                _defModel.getUndoManager().redo();
1252:                _defModel.updateModifiedSinceSave();
1253:                assertFalse(
1254:                        "Document should no longer be modified after redo.",
1255:                        _defModel.isModifiedSinceSave());
1256:            }
1257:
1258:            protected final String NEWLINE = "\n"; // Was StringOps.EOL;but swing usees '\n' for newLine
1259:
1260:            protected final String NESTED_CLASSES_TEXT = "/*bof*/package Temp;"
1261:                    + NEWLINE
1262:                    + ""
1263:                    + NEWLINE
1264:                    + "public class Test {"
1265:                    + NEWLINE
1266:                    + "  private int i;"
1267:                    + NEWLINE
1268:                    + "  "
1269:                    + NEWLINE
1270:                    + "  public void foo(Test other) {"
1271:                    + NEWLINE
1272:                    + "    i = other.i;"
1273:                    + NEWLINE
1274:                    + "    "
1275:                    + NEWLINE
1276:                    + "  }"
1277:                    + NEWLINE
1278:                    + "  "
1279:                    + NEWLINE
1280:                    + "  public void bar() {"
1281:                    + NEWLINE
1282:                    + "    System.out.println(i);"
1283:                    + NEWLINE
1284:                    + "  }"
1285:                    + NEWLINE
1286:                    + "  "
1287:                    + NEWLINE
1288:                    + "  public static interface Interf {"
1289:                    + NEWLINE
1290:                    + "    static long C = System.currentTimeMillis();"
1291:                    + NEWLINE
1292:                    + "    public void act();"
1293:                    + NEWLINE
1294:                    + "  }"
1295:                    + NEWLINE
1296:                    + "  "
1297:                    + NEWLINE
1298:                    + "  static class Implementor implements Interf {"
1299:                    + NEWLINE
1300:                    + "    public void act() { /*Implementor.act*/"
1301:                    + NEWLINE
1302:                    + "      System.out.println(C);"
1303:                    + NEWLINE
1304:                    + "      Interf inter = new Interf() { /*Implementor$1*/"
1305:                    + NEWLINE
1306:                    + "        public void act() {"
1307:                    + NEWLINE
1308:                    + "          System.out.println(\"Test$Implementor$1\");"
1309:                    + NEWLINE
1310:                    + "          Interf inter = new Interf() { /*Implementor$1$1*/"
1311:                    + NEWLINE
1312:                    + "            public void act() {"
1313:                    + NEWLINE
1314:                    + "              System.out.println(\"Test$Implementor$1$1\");"
1315:                    + NEWLINE
1316:                    + "            }"
1317:                    + NEWLINE
1318:                    + "          };"
1319:                    + NEWLINE
1320:                    + "          Inner<Integer> inn = new Inner<Integer>() { /*Implementor$1$2*/"
1321:                    + NEWLINE
1322:                    + "            public void set(Integer t) { _t = t; }"
1323:                    + NEWLINE
1324:                    + "          };"
1325:                    + NEWLINE
1326:                    + "        } /*b-Implementor$1*/"
1327:                    + NEWLINE
1328:                    + "      }; /*b-Implementor*/"
1329:                    + NEWLINE
1330:                    + "    } /*c-Implementor*/"
1331:                    + NEWLINE
1332:                    + "    "
1333:                    + NEWLINE
1334:                    + "    public abstract class Inner<T> { /*Implementor$Inner*/"
1335:                    + NEWLINE
1336:                    + "      protected T _t; /*b-Implementor$Inner*/"
1337:                    + NEWLINE
1338:                    + "      public abstract void set(T t);"
1339:                    + NEWLINE
1340:                    + "    }"
1341:                    + NEWLINE
1342:                    + "  }"
1343:                    + NEWLINE
1344:                    + "  "
1345:                    + NEWLINE
1346:                    + "  public void anon() { /*anon()*/"
1347:                    + NEWLINE
1348:                    + "    Interf inter = new Interf() { /*Test$1*/"
1349:                    + NEWLINE
1350:                    + "      class NamedInAnonymous implements Interf { /*Test$1$NamedInAnonymous*/"
1351:                    + NEWLINE
1352:                    + "        public void act() {"
1353:                    + NEWLINE
1354:                    + "          System.out.println(\"Test$1$NamedInAnonymous\");"
1355:                    + NEWLINE
1356:                    + "        }"
1357:                    + NEWLINE
1358:                    + "      }"
1359:                    + NEWLINE
1360:                    + "      public void act() { /*b-Test$1*/"
1361:                    + NEWLINE
1362:                    + "        System.out.println(\"Test$1\");"
1363:                    + NEWLINE
1364:                    + "        NamedInAnonymous nia = new NamedInAnonymous();"
1365:                    + NEWLINE
1366:                    + "        nia.act();"
1367:                    + NEWLINE
1368:                    + "      }"
1369:                    + NEWLINE
1370:                    + "    };"
1371:                    + NEWLINE
1372:                    + "    inter.act(); /*b-anon()*/"
1373:                    + NEWLINE
1374:                    + "    Interf inter2 = new Interf() { /*Test$2*/"
1375:                    + NEWLINE
1376:                    + "      public void act() {"
1377:                    + NEWLINE
1378:                    + "        System.out.println(\"Test$2\");"
1379:                    + NEWLINE
1380:                    + "        Interf inter = new Interf() { /*Test$2$1*/"
1381:                    + NEWLINE
1382:                    + "          public void act() {"
1383:                    + NEWLINE
1384:                    + "            System.out.println(\"Test$2$1\");"
1385:                    + NEWLINE
1386:                    + "          }"
1387:                    + NEWLINE
1388:                    + "        };"
1389:                    + NEWLINE
1390:                    + "        inter.act();"
1391:                    + NEWLINE
1392:                    + "      }"
1393:                    + NEWLINE
1394:                    + "    };"
1395:                    + NEWLINE
1396:                    + "    inter2.act();"
1397:                    + NEWLINE
1398:                    + "    Interf inter3 = new Implementor() { /*Test$3*/"
1399:                    + NEWLINE
1400:                    + "      public void act() {"
1401:                    + NEWLINE
1402:                    + "        System.out.println(\"Test$3\");"
1403:                    + NEWLINE
1404:                    + "      }"
1405:                    + NEWLINE
1406:                    + "    };"
1407:                    + NEWLINE
1408:                    + "    inter3.act();"
1409:                    + NEWLINE
1410:                    + "  }"
1411:                    + NEWLINE
1412:                    + "  "
1413:                    + NEWLINE
1414:                    + "  public Test(int j) { if (true) { i = j; } }"
1415:                    + NEWLINE
1416:                    + "  "
1417:                    + NEWLINE
1418:                    + "  protected abstract class Param<T> {"
1419:                    + NEWLINE
1420:                    + "    T _t;"
1421:                    + NEWLINE
1422:                    + "    public Param(T t, T t2) { _t = t; }"
1423:                    + NEWLINE
1424:                    + "    public abstract void paramDo();"
1425:                    + NEWLINE
1426:                    + "  }"
1427:                    + NEWLINE
1428:                    + "  "
1429:                    + NEWLINE
1430:                    + "  public void anon2() {"
1431:                    + NEWLINE
1432:                    + "    Param<Interf> p = new Param<Interf>(/*anon2()*/new Interf() { /*Test$4*/"
1433:                    + NEWLINE
1434:                    + "      public void act() {"
1435:                    + NEWLINE
1436:                    + "        System.out.println(\"parameter 1 = Test$4\");"
1437:                    + NEWLINE
1438:                    + "        Interf i = new Interf() { /*Test$4$1*/"
1439:                    + NEWLINE
1440:                    + "          public void act() {"
1441:                    + NEWLINE
1442:                    + "            System.out.println(\"Test$4$1\");"
1443:                    + NEWLINE
1444:                    + "          }"
1445:                    + NEWLINE
1446:                    + "        };"
1447:                    + NEWLINE
1448:                    + "      }"
1449:                    + NEWLINE
1450:                    + "    }, /*b-anon2()*/ new Interf() { /*Test$5*/"
1451:                    + NEWLINE
1452:                    + "      public void act() {"
1453:                    + NEWLINE
1454:                    + "        System.out.println(\"parameter 2 = Test$5\");"
1455:                    + NEWLINE
1456:                    + "      }"
1457:                    + NEWLINE
1458:                    + "    }) /*c-anon2()*/ { /*Test$6*/"
1459:                    + NEWLINE
1460:                    + "      public void paramDo() {"
1461:                    + NEWLINE
1462:                    + "        System.out.println(\"Test$6\");"
1463:                    + NEWLINE
1464:                    + "      }"
1465:                    + NEWLINE
1466:                    + "    };"
1467:                    + NEWLINE
1468:                    + "  }"
1469:                    + NEWLINE
1470:                    + ""
1471:                    + NEWLINE
1472:                    + "  public void anon3() {"
1473:                    + NEWLINE
1474:                    + "    Param<Interf> p = new Param<Interf>(/*anon3()*/new Interf() { /*Test$7*/"
1475:                    + NEWLINE
1476:                    + "      class NamedClassAgain {"
1477:                    + NEWLINE
1478:                    + "        void doSomething() { System.out.println(\"doSomething\"); }"
1479:                    + NEWLINE
1480:                    + "      }"
1481:                    + NEWLINE
1482:                    + "      public void act() {"
1483:                    + NEWLINE
1484:                    + "        System.out.println(\"parameter 3 = Test$7\");"
1485:                    + NEWLINE
1486:                    + "        Interf i = new Interf() { /*Test$7$1*/"
1487:                    + NEWLINE
1488:                    + "          public void act() {"
1489:                    + NEWLINE
1490:                    + "            System.out.println(\"Test$7$1\");"
1491:                    + NEWLINE
1492:                    + "          }"
1493:                    + NEWLINE
1494:                    + "        };"
1495:                    + NEWLINE
1496:                    + "      }"
1497:                    + NEWLINE
1498:                    + "    }) /*c-anon2()*/ { /*Test$8*/"
1499:                    + NEWLINE
1500:                    + "      public void paramDo() {"
1501:                    + NEWLINE
1502:                    + "        System.out.println(\"Test$8\");"
1503:                    + NEWLINE
1504:                    + "      }"
1505:                    + NEWLINE
1506:                    + "    };"
1507:                    + NEWLINE
1508:                    + "  }"
1509:                    + NEWLINE
1510:                    + "  "
1511:                    + NEWLINE
1512:                    + "  public static void main(String[] args) {"
1513:                    + NEWLINE
1514:                    + "    Test t1 = new Test(1);"
1515:                    + NEWLINE
1516:                    + "    t1.bar();"
1517:                    + NEWLINE
1518:                    + "    Test t2 = new Test(123);"
1519:                    + NEWLINE
1520:                    + "    t2.bar();"
1521:                    + NEWLINE
1522:                    + "    t1.foo(t2);"
1523:                    + NEWLINE
1524:                    + "    t1.bar();"
1525:                    + NEWLINE
1526:                    + "    Implementor imp = new Implementor();"
1527:                    + NEWLINE
1528:                    + "    imp.act();"
1529:                    + NEWLINE
1530:                    + "    t1.anon();"
1531:                    + NEWLINE
1532:                    + "  }"
1533:                    + NEWLINE
1534:                    + "  public static class Outer {"
1535:                    + NEWLINE
1536:                    + "    public static interface Inner {"
1537:                    + NEWLINE
1538:                    + "      public void innerDo();"
1539:                    + NEWLINE
1540:                    + "    }"
1541:                    + NEWLINE
1542:                    + "    public static interface InnerParam<T> {"
1543:                    + NEWLINE
1544:                    + "      public void innerParam(T t);"
1545:                    + NEWLINE
1546:                    + "    }"
1547:                    + NEWLINE
1548:                    + "    public class Middle<T> {"
1549:                    + NEWLINE
1550:                    + "      T t;"
1551:                    + NEWLINE
1552:                    + "      public abstract class Innerst {"
1553:                    + NEWLINE
1554:                    + "        public abstract void innerstDo();"
1555:                    + NEWLINE
1556:                    + "      }"
1557:                    + NEWLINE
1558:                    + "      "
1559:                    + NEWLINE
1560:                    + "      Innerst i = new Outer.Middle.Innerst() { /*Test$Outer$Middle$1*/"
1561:                    + NEWLINE
1562:                    + "        public void innerstDo() {"
1563:                    + NEWLINE
1564:                    + "          System.out.println(\"Test$Outer$Middle$1\");"
1565:                    + NEWLINE
1566:                    + "        }"
1567:                    + NEWLINE
1568:                    + "      };"
1569:                    + NEWLINE
1570:                    + "    }"
1571:                    + NEWLINE
1572:                    + "  }"
1573:                    + NEWLINE
1574:                    + "  "
1575:                    + NEWLINE
1576:                    + "  public void anonDotTest() {"
1577:                    + NEWLINE
1578:                    + "    Outer.Inner test = new Outer.Inner() { /*Test$9*/"
1579:                    + NEWLINE
1580:                    + "      public void innerDo() {"
1581:                    + NEWLINE
1582:                    + "        System.out.println(\"Test$9\");"
1583:                    + NEWLINE
1584:                    + "      }"
1585:                    + NEWLINE
1586:                    + "    };"
1587:                    + NEWLINE
1588:                    + "    Outer.InnerParam<String> test2 = new Outer.InnerParam<String>() { /*Test$10*/"
1589:                    + NEWLINE
1590:                    + "      public void innerParam(String t) {"
1591:                    + NEWLINE
1592:                    + "        System.out.println(\"Test$10\");"
1593:                    + NEWLINE
1594:                    + "      }"
1595:                    + NEWLINE
1596:                    + "    };"
1597:                    + NEWLINE
1598:                    + "  }"
1599:                    + NEWLINE
1600:                    + "}"
1601:                    + NEWLINE
1602:                    + ""
1603:                    + NEWLINE
1604:                    + "class Foo {"
1605:                    + NEWLINE
1606:                    + "  public void foo() {"
1607:                    + NEWLINE
1608:                    + "    System.out.println(\"foo\");"
1609:                    + NEWLINE
1610:                    + "    FooImplementor fimp = new FooImplementor();"
1611:                    + NEWLINE
1612:                    + "    fimp.act();"
1613:                    + NEWLINE
1614:                    + "  }"
1615:                    + NEWLINE
1616:                    + "  "
1617:                    + NEWLINE
1618:                    + "  static interface FooInterf {"
1619:                    + NEWLINE
1620:                    + "    static long C = System.currentTimeMillis(); /*Foo$FooInterf*/"
1621:                    + NEWLINE
1622:                    + "    public void act();"
1623:                    + NEWLINE
1624:                    + "  }"
1625:                    + NEWLINE
1626:                    + "  "
1627:                    + NEWLINE
1628:                    + "  public static class FooImplementor implements FooInterf { /*Foo$FooImplementor*/"
1629:                    + NEWLINE
1630:                    + "    public void act() {"
1631:                    + NEWLINE
1632:                    + "      System.out.println(C); /*b-Foo$FooImplementor*/"
1633:                    + NEWLINE
1634:                    + "      FooInterf inter = new FooInterf() { /*Foo$FooImplementor$1*/"
1635:                    + NEWLINE
1636:                    + "        public void act() {"
1637:                    + NEWLINE
1638:                    + "          System.out.println(\"Foo$FooImplementor$1\");"
1639:                    + NEWLINE
1640:                    + "          FooInterf inter = new FooInterf() { /*Foo$FooImplementor$1$1*/"
1641:                    + NEWLINE
1642:                    + "            public void act() {"
1643:                    + NEWLINE
1644:                    + "              System.out.println(\"Foo$FooImplementor$1$1\");"
1645:                    + NEWLINE
1646:                    + "            }"
1647:                    + NEWLINE
1648:                    + "          };"
1649:                    + NEWLINE
1650:                    + "        }"
1651:                    + NEWLINE
1652:                    + "      };"
1653:                    + NEWLINE
1654:                    + "    }"
1655:                    + NEWLINE
1656:                    + "    public class Inner<T> { /*Foo$FooImplementor$Inner*/"
1657:                    + NEWLINE
1658:                    + "      T t;"
1659:                    + NEWLINE
1660:                    + "    }"
1661:                    + NEWLINE
1662:                    + "  }"
1663:                    + NEWLINE
1664:                    + "}"
1665:                    + NEWLINE
1666:                    + "abstract class Fee {"
1667:                    + NEWLINE
1668:                    + "  public abstract void feeDo();"
1669:                    + NEWLINE
1670:                    + "  public abstract void feeAct();"
1671:                    + NEWLINE
1672:                    + "  protected String s, t, u;"
1673:                    + NEWLINE
1674:                    + "  "
1675:                    + NEWLINE
1676:                    + "  public static class FeeConc extends Fee {/*Fee$FeeConc*/"
1677:                    + NEWLINE
1678:                    + "    {"
1679:                    + NEWLINE
1680:                    + "      s = \"FeeConc/s\";"
1681:                    + NEWLINE
1682:                    + "    }"
1683:                    + NEWLINE
1684:                    + "    public void feeDo() { System.out.println(\"FeeConc/feeDo\"); }"
1685:                    + NEWLINE
1686:                    + "    {"
1687:                    + NEWLINE
1688:                    + "      t = \"FeeConc/t\";"
1689:                    + NEWLINE
1690:                    + "    }"
1691:                    + NEWLINE
1692:                    + "    public abstract void feeAct() { System.out.println(\"FeeConc/feeAct\"); }"
1693:                    + NEWLINE
1694:                    + "    {"
1695:                    + NEWLINE
1696:                    + "      u = \"FeeConc/u\";"
1697:                    + NEWLINE
1698:                    + "    }"
1699:                    + NEWLINE
1700:                    + "  }"
1701:                    + NEWLINE
1702:                    + "  "
1703:                    + NEWLINE
1704:                    + "  public static void main(String[] args) {"
1705:                    + NEWLINE
1706:                    + "    Fee f = new Fee() {/*Fee$1*/"
1707:                    + NEWLINE
1708:                    + "      {"
1709:                    + NEWLINE
1710:                    + "        s = \"Fee$1/s\";"
1711:                    + NEWLINE
1712:                    + "      }"
1713:                    + NEWLINE
1714:                    + "      public void feeDo() { System.out.println(\"Fee$1/feeDo\"); }"
1715:                    + NEWLINE
1716:                    + "      {"
1717:                    + NEWLINE
1718:                    + "        t = \"Fee$1/t\";"
1719:                    + NEWLINE
1720:                    + "      }"
1721:                    + NEWLINE
1722:                    + "      public abstract void feeAct() { System.out.println(\"Fee$1/feeAct\"); }"
1723:                    + NEWLINE + "      {" + NEWLINE
1724:                    + "        u = \"Fee$1/u\";" + NEWLINE + "      }"
1725:                    + NEWLINE + "    };" + NEWLINE + "  }" + NEWLINE
1726:                    + "}/*eof*/" + NEWLINE;
1727:
1728:            /**
1729:             * Test finding anonymous class index on document.
1730:             */
1731:            public void testAnonymousClassIndex() throws BadLocationException,
1732:                    ClassNameNotFoundException {
1733:                _defModel.insertString(0, NESTED_CLASSES_TEXT, null);
1734:
1735:                String substr;
1736:                int exp, act;
1737:                substr = "{ /*Test$4*/";
1738:                exp = 4;
1739:                act = _defModel
1740:                        ._getAnonymousInnerClassIndex(NESTED_CLASSES_TEXT
1741:                                .indexOf(substr));
1742:                assertEquals("index at " + substr + " exp=`" + exp + "`, act=`"
1743:                        + act + "`", exp, act);
1744:
1745:                substr = "{ /*Test$5*/";
1746:                exp = 5;
1747:                act = _defModel
1748:                        ._getAnonymousInnerClassIndex(NESTED_CLASSES_TEXT
1749:                                .indexOf(substr));
1750:                assertEquals("index at " + substr + " exp=`" + exp + "`, act=`"
1751:                        + act + "`", exp, act);
1752:
1753:                substr = "{ /*Test$6*/";
1754:                exp = 6;
1755:                act = _defModel
1756:                        ._getAnonymousInnerClassIndex(NESTED_CLASSES_TEXT
1757:                                .indexOf(substr));
1758:                assertEquals("index at " + substr + " exp=`" + exp + "`, act=`"
1759:                        + act + "`", exp, act);
1760:
1761:                substr = "{ /*Test$7*/";
1762:                exp = 7;
1763:                act = _defModel
1764:                        ._getAnonymousInnerClassIndex(NESTED_CLASSES_TEXT
1765:                                .indexOf(substr));
1766:                assertEquals("index at " + substr + " exp=`" + exp + "`, act=`"
1767:                        + act + "`", exp, act);
1768:
1769:                substr = "{ /*Test$8*/";
1770:                exp = 8;
1771:                act = _defModel
1772:                        ._getAnonymousInnerClassIndex(NESTED_CLASSES_TEXT
1773:                                .indexOf(substr));
1774:                assertEquals("index at " + substr + " exp=`" + exp + "`, act=`"
1775:                        + act + "`", exp, act);
1776:            }
1777:
1778:            /**
1779:             * Test exact class name-finding on document.
1780:             */
1781:            public void testExactClassName() throws BadLocationException,
1782:                    ClassNameNotFoundException {
1783:                _defModel.insertString(0, NESTED_CLASSES_TEXT, null);
1784:
1785:                String substr, exp1, exp2, act1, act2;
1786:                substr = "private int i";
1787:                exp1 = "Temp.Test";
1788:                exp2 = "Test";
1789:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1790:                        .indexOf(substr), true);
1791:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1792:                        .indexOf(substr), false);
1793:                assertEquals("class name at " + substr + " exp=`" + exp1
1794:                        + "`, act=`" + act1 + "`", exp1, act1);
1795:                assertEquals("class name at " + substr + " exp=`" + exp2
1796:                        + "`, act=`" + act2 + "`", exp2, act2);
1797:
1798:                substr = "= other.i";
1799:                exp1 = "Temp.Test";
1800:                exp2 = "Test";
1801:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1802:                        .indexOf(substr), true);
1803:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1804:                        .indexOf(substr), false);
1805:                assertEquals("class name at " + substr + " exp=`" + exp1
1806:                        + "`, act=`" + act1 + "`", exp1, act1);
1807:                assertEquals("class name at " + substr + " exp=`" + exp2
1808:                        + "`, act=`" + act2 + "`", exp2, act2);
1809:
1810:                substr = "System.out.println(i)";
1811:                exp1 = "Temp.Test";
1812:                exp2 = "Test";
1813:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1814:                        .indexOf(substr), true);
1815:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1816:                        .indexOf(substr), false);
1817:                assertEquals("class name at " + substr + " exp=`" + exp1
1818:                        + "`, act=`" + act1 + "`", exp1, act1);
1819:                assertEquals("class name at " + substr + " exp=`" + exp2
1820:                        + "`, act=`" + act2 + "`", exp2, act2);
1821:
1822:                substr = "System.currentTimeMillis";
1823:                exp1 = "Temp.Test$Interf";
1824:                exp2 = "Interf";
1825:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1826:                        .indexOf(substr), true);
1827:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1828:                        .indexOf(substr), false);
1829:                assertEquals("class name at " + substr + " exp=`" + exp1
1830:                        + "`, act=`" + act1 + "`", exp1, act1);
1831:                assertEquals("class name at " + substr + " exp=`" + exp2
1832:                        + "`, act=`" + act2 + "`", exp2, act2);
1833:
1834:                substr = "Implementor implements Interf";
1835:                exp1 = "Temp.Test";
1836:                exp2 = "Test";
1837:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1838:                        .indexOf(substr), true);
1839:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1840:                        .indexOf(substr), false);
1841:                assertEquals("class name at " + substr + " exp=`" + exp1
1842:                        + "`, act=`" + act1 + "`", exp1, act1);
1843:                assertEquals("class name at " + substr + " exp=`" + exp2
1844:                        + "`, act=`" + act2 + "`", exp2, act2);
1845:
1846:                substr = "/*Implementor.act*/";
1847:                exp1 = "Temp.Test$Implementor";
1848:                exp2 = "Implementor";
1849:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1850:                        .indexOf(substr), true);
1851:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1852:                        .indexOf(substr), false);
1853:                assertEquals("class name at " + substr + " exp=`" + exp1
1854:                        + "`, act=`" + act1 + "`", exp1, act1);
1855:                assertEquals("class name at " + substr + " exp=`" + exp2
1856:                        + "`, act=`" + act2 + "`", exp2, act2);
1857:
1858:                substr = "/*Implementor$1*/";
1859:                exp1 = "Temp.Test$Implementor$1";
1860:                exp2 = "1";
1861:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1862:                        .indexOf(substr), true);
1863:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1864:                        .indexOf(substr), false);
1865:                assertEquals("class name at " + substr + " exp=`" + exp1
1866:                        + "`, act=`" + act1 + "`", exp1, act1);
1867:                assertEquals("class name at " + substr + " exp=`" + exp2
1868:                        + "`, act=`" + act2 + "`", exp2, act2);
1869:
1870:                substr = "\"Test$Implementor$1\"";
1871:                exp1 = "Temp.Test$Implementor$1";
1872:                exp2 = "1";
1873:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1874:                        .indexOf(substr), true);
1875:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1876:                        .indexOf(substr), false);
1877:                assertEquals("class name at " + substr + " exp=`" + exp1
1878:                        + "`, act=`" + act1 + "`", exp1, act1);
1879:                assertEquals("class name at " + substr + " exp=`" + exp2
1880:                        + "`, act=`" + act2 + "`", exp2, act2);
1881:
1882:                substr = "/*Implementor$1$1*/";
1883:                exp1 = "Temp.Test$Implementor$1$1";
1884:                exp2 = "1";
1885:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1886:                        .indexOf(substr), true);
1887:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1888:                        .indexOf(substr), false);
1889:                assertEquals("class name at " + substr + " exp=`" + exp1
1890:                        + "`, act=`" + act1 + "`", exp1, act1);
1891:                assertEquals("class name at " + substr + " exp=`" + exp2
1892:                        + "`, act=`" + act2 + "`", exp2, act2);
1893:
1894:                substr = "\"Test$Implementor$1$1\"";
1895:                exp1 = "Temp.Test$Implementor$1$1";
1896:                exp2 = "1";
1897:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1898:                        .indexOf(substr), true);
1899:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1900:                        .indexOf(substr), false);
1901:                assertEquals("class name at " + substr + " exp=`" + exp1
1902:                        + "`, act=`" + act1 + "`", exp1, act1);
1903:                assertEquals("class name at " + substr + " exp=`" + exp2
1904:                        + "`, act=`" + act2 + "`", exp2, act2);
1905:
1906:                substr = "/*Implementor$1$2*/";
1907:                exp1 = "Temp.Test$Implementor$1$2";
1908:                exp2 = "2";
1909:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1910:                        .indexOf(substr), true);
1911:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1912:                        .indexOf(substr), false);
1913:                assertEquals("class name at " + substr + " exp=`" + exp1
1914:                        + "`, act=`" + act1 + "`", exp1, act1);
1915:                assertEquals("class name at " + substr + " exp=`" + exp2
1916:                        + "`, act=`" + act2 + "`", exp2, act2);
1917:
1918:                substr = "/*b-Implementor$1*/";
1919:                exp1 = "Temp.Test$Implementor$1";
1920:                exp2 = "1";
1921:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1922:                        .indexOf(substr), true);
1923:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1924:                        .indexOf(substr), false);
1925:                assertEquals("class name at " + substr + " exp=`" + exp1
1926:                        + "`, act=`" + act1 + "`", exp1, act1);
1927:                assertEquals("class name at " + substr + " exp=`" + exp2
1928:                        + "`, act=`" + act2 + "`", exp2, act2);
1929:
1930:                substr = "/*b-Implementor*/";
1931:                exp1 = "Temp.Test$Implementor";
1932:                exp2 = "Implementor";
1933:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1934:                        .indexOf(substr), true);
1935:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1936:                        .indexOf(substr), false);
1937:                assertEquals("class name at " + substr + " exp=`" + exp1
1938:                        + "`, act=`" + act1 + "`", exp1, act1);
1939:                assertEquals("class name at " + substr + " exp=`" + exp2
1940:                        + "`, act=`" + act2 + "`", exp2, act2);
1941:
1942:                substr = "/*c-Implementor*/";
1943:                exp1 = "Temp.Test$Implementor";
1944:                exp2 = "Implementor";
1945:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1946:                        .indexOf(substr), true);
1947:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1948:                        .indexOf(substr), false);
1949:                assertEquals("class name at " + substr + " exp=`" + exp1
1950:                        + "`, act=`" + act1 + "`", exp1, act1);
1951:                assertEquals("class name at " + substr + " exp=`" + exp2
1952:                        + "`, act=`" + act2 + "`", exp2, act2);
1953:
1954:                substr = "/*Implementor$Inner*/";
1955:                exp1 = "Temp.Test$Implementor$Inner";
1956:                exp2 = "Inner";
1957:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1958:                        .indexOf(substr), true);
1959:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1960:                        .indexOf(substr), false);
1961:                assertEquals("class name at " + substr + " exp=`" + exp1
1962:                        + "`, act=`" + act1 + "`", exp1, act1);
1963:                assertEquals("class name at " + substr + " exp=`" + exp2
1964:                        + "`, act=`" + act2 + "`", exp2, act2);
1965:
1966:                substr = "/*b-Implementor$Inner*/";
1967:                exp1 = "Temp.Test$Implementor$Inner";
1968:                exp2 = "Inner";
1969:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1970:                        .indexOf(substr), true);
1971:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1972:                        .indexOf(substr), false);
1973:                assertEquals("class name at " + substr + " exp=`" + exp1
1974:                        + "`, act=`" + act1 + "`", exp1, act1);
1975:                assertEquals("class name at " + substr + " exp=`" + exp2
1976:                        + "`, act=`" + act2 + "`", exp2, act2);
1977:
1978:                substr = "/*anon()*/";
1979:                exp1 = "Temp.Test";
1980:                exp2 = "Test";
1981:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1982:                        .indexOf(substr), true);
1983:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1984:                        .indexOf(substr), false);
1985:                assertEquals("class name at " + substr + " exp=`" + exp1
1986:                        + "`, act=`" + act1 + "`", exp1, act1);
1987:                assertEquals("class name at " + substr + " exp=`" + exp2
1988:                        + "`, act=`" + act2 + "`", exp2, act2);
1989:
1990:                substr = "/*Test$1*/";
1991:                exp1 = "Temp.Test$1";
1992:                exp2 = "1";
1993:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1994:                        .indexOf(substr), true);
1995:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
1996:                        .indexOf(substr), false);
1997:                assertEquals("class name at " + substr + " exp=`" + exp1
1998:                        + "`, act=`" + act1 + "`", exp1, act1);
1999:                assertEquals("class name at " + substr + " exp=`" + exp2
2000:                        + "`, act=`" + act2 + "`", exp2, act2);
2001:
2002:                substr = "/*Test$1$NamedInAnonymous*/";
2003:                exp1 = "Temp.Test$1$NamedInAnonymous";
2004:                exp2 = "NamedInAnonymous";
2005:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2006:                        .indexOf(substr), true);
2007:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2008:                        .indexOf(substr), false);
2009:                assertEquals("class name at " + substr + " exp=`" + exp1
2010:                        + "`, act=`" + act1 + "`", exp1, act1);
2011:                assertEquals("class name at " + substr + " exp=`" + exp2
2012:                        + "`, act=`" + act2 + "`", exp2, act2);
2013:
2014:                substr = "\"Test$1$NamedInAnonymous\"";
2015:                exp1 = "Temp.Test$1$NamedInAnonymous";
2016:                exp2 = "NamedInAnonymous";
2017:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2018:                        .indexOf(substr), true);
2019:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2020:                        .indexOf(substr), false);
2021:                assertEquals("class name at " + substr + " exp=`" + exp1
2022:                        + "`, act=`" + act1 + "`", exp1, act1);
2023:                assertEquals("class name at " + substr + " exp=`" + exp2
2024:                        + "`, act=`" + act2 + "`", exp2, act2);
2025:
2026:                substr = "/*b-Test$1*/";
2027:                exp1 = "Temp.Test$1";
2028:                exp2 = "1";
2029:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2030:                        .indexOf(substr), true);
2031:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2032:                        .indexOf(substr), false);
2033:                assertEquals("class name at " + substr + " exp=`" + exp1
2034:                        + "`, act=`" + act1 + "`", exp1, act1);
2035:                assertEquals("class name at " + substr + " exp=`" + exp2
2036:                        + "`, act=`" + act2 + "`", exp2, act2);
2037:
2038:                substr = "\"Test$1\"";
2039:                exp1 = "Temp.Test$1";
2040:                exp2 = "1";
2041:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2042:                        .indexOf(substr), true);
2043:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2044:                        .indexOf(substr), false);
2045:                assertEquals("class name at " + substr + " exp=`" + exp1
2046:                        + "`, act=`" + act1 + "`", exp1, act1);
2047:                assertEquals("class name at " + substr + " exp=`" + exp2
2048:                        + "`, act=`" + act2 + "`", exp2, act2);
2049:
2050:                substr = "/*b-anon()*/";
2051:                exp1 = "Temp.Test";
2052:                exp2 = "Test";
2053:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2054:                        .indexOf(substr), true);
2055:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2056:                        .indexOf(substr), false);
2057:                assertEquals("class name at " + substr + " exp=`" + exp1
2058:                        + "`, act=`" + act1 + "`", exp1, act1);
2059:                assertEquals("class name at " + substr + " exp=`" + exp2
2060:                        + "`, act=`" + act2 + "`", exp2, act2);
2061:
2062:                substr = "/*Test$2*/";
2063:                exp1 = "Temp.Test$2";
2064:                exp2 = "2";
2065:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2066:                        .indexOf(substr), true);
2067:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2068:                        .indexOf(substr), false);
2069:                assertEquals("class name at " + substr + " exp=`" + exp1
2070:                        + "`, act=`" + act1 + "`", exp1, act1);
2071:                assertEquals("class name at " + substr + " exp=`" + exp2
2072:                        + "`, act=`" + act2 + "`", exp2, act2);
2073:
2074:                substr = "\"Test$2\"";
2075:                exp1 = "Temp.Test$2";
2076:                exp2 = "2";
2077:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2078:                        .indexOf(substr), true);
2079:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2080:                        .indexOf(substr), false);
2081:                assertEquals("class name at " + substr + " exp=`" + exp1
2082:                        + "`, act=`" + act1 + "`", exp1, act1);
2083:                assertEquals("class name at " + substr + " exp=`" + exp2
2084:                        + "`, act=`" + act2 + "`", exp2, act2);
2085:
2086:                substr = "/*Test$2$1*/";
2087:                exp1 = "Temp.Test$2$1";
2088:                exp2 = "1";
2089:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2090:                        .indexOf(substr), true);
2091:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2092:                        .indexOf(substr), false);
2093:                assertEquals("class name at " + substr + " exp=`" + exp1
2094:                        + "`, act=`" + act1 + "`", exp1, act1);
2095:                assertEquals("class name at " + substr + " exp=`" + exp2
2096:                        + "`, act=`" + act2 + "`", exp2, act2);
2097:
2098:                substr = "\"Test$2$1\"";
2099:                exp1 = "Temp.Test$2$1";
2100:                exp2 = "1";
2101:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2102:                        .indexOf(substr), true);
2103:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2104:                        .indexOf(substr), false);
2105:                assertEquals("class name at " + substr + " exp=`" + exp1
2106:                        + "`, act=`" + act1 + "`", exp1, act1);
2107:                assertEquals("class name at " + substr + " exp=`" + exp2
2108:                        + "`, act=`" + act2 + "`", exp2, act2);
2109:
2110:                substr = "/*Test$3*/";
2111:                exp1 = "Temp.Test$3";
2112:                exp2 = "3";
2113:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2114:                        .indexOf(substr), true);
2115:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2116:                        .indexOf(substr), false);
2117:                assertEquals("class name at " + substr + " exp=`" + exp1
2118:                        + "`, act=`" + act1 + "`", exp1, act1);
2119:                assertEquals("class name at " + substr + " exp=`" + exp2
2120:                        + "`, act=`" + act2 + "`", exp2, act2);
2121:
2122:                substr = "\"Test$3\"";
2123:                exp1 = "Temp.Test$3";
2124:                exp2 = "3";
2125:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2126:                        .indexOf(substr), true);
2127:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2128:                        .indexOf(substr), false);
2129:                assertEquals("class name at " + substr + " exp=`" + exp1
2130:                        + "`, act=`" + act1 + "`", exp1, act1);
2131:                assertEquals("class name at " + substr + " exp=`" + exp2
2132:                        + "`, act=`" + act2 + "`", exp2, act2);
2133:
2134:                substr = "(true) { i = j; }";
2135:                exp1 = "Temp.Test";
2136:                exp2 = "Test";
2137:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2138:                        .indexOf(substr), true);
2139:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2140:                        .indexOf(substr), false);
2141:                assertEquals("class name at " + substr + " exp=`" + exp1
2142:                        + "`, act=`" + act1 + "`", exp1, act1);
2143:                assertEquals("class name at " + substr + " exp=`" + exp2
2144:                        + "`, act=`" + act2 + "`", exp2, act2);
2145:
2146:                substr = "new Test(1)";
2147:                exp1 = "Temp.Test";
2148:                exp2 = "Test";
2149:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2150:                        .indexOf(substr), true);
2151:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2152:                        .indexOf(substr), false);
2153:                assertEquals("class name at " + substr + " exp=`" + exp1
2154:                        + "`, act=`" + act1 + "`", exp1, act1);
2155:                assertEquals("class name at " + substr + " exp=`" + exp2
2156:                        + "`, act=`" + act2 + "`", exp2, act2);
2157:
2158:                substr = "class Foo";
2159:                exp1 = "";
2160:                exp2 = "";
2161:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2162:                        .indexOf(substr), true);
2163:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2164:                        .indexOf(substr), false);
2165:                assertEquals("class name at " + substr + " exp=`" + exp1
2166:                        + "`, act=`" + act1 + "`", exp1, act1);
2167:                assertEquals("class name at " + substr + " exp=`" + exp2
2168:                        + "`, act=`" + act2 + "`", exp2, act2);
2169:
2170:                substr = "FooImplementor fimp";
2171:                exp1 = "Temp.Foo";
2172:                exp2 = "Foo";
2173:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2174:                        .indexOf(substr), true);
2175:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2176:                        .indexOf(substr), false);
2177:                assertEquals("class name at " + substr + " exp=`" + exp1
2178:                        + "`, act=`" + act1 + "`", exp1, act1);
2179:                assertEquals("class name at " + substr + " exp=`" + exp2
2180:                        + "`, act=`" + act2 + "`", exp2, act2);
2181:
2182:                substr = "/*Foo$FooInterf*/";
2183:                exp1 = "Temp.Foo$FooInterf";
2184:                exp2 = "FooInterf";
2185:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2186:                        .indexOf(substr), true);
2187:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2188:                        .indexOf(substr), false);
2189:                assertEquals("class name at " + substr + " exp=`" + exp1
2190:                        + "`, act=`" + act1 + "`", exp1, act1);
2191:                assertEquals("class name at " + substr + " exp=`" + exp2
2192:                        + "`, act=`" + act2 + "`", exp2, act2);
2193:
2194:                substr = "/*Foo$FooImplementor*/";
2195:                exp1 = "Temp.Foo$FooImplementor";
2196:                exp2 = "FooImplementor";
2197:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2198:                        .indexOf(substr), true);
2199:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2200:                        .indexOf(substr), false);
2201:                assertEquals("class name at " + substr + " exp=`" + exp1
2202:                        + "`, act=`" + act1 + "`", exp1, act1);
2203:                assertEquals("class name at " + substr + " exp=`" + exp2
2204:                        + "`, act=`" + act2 + "`", exp2, act2);
2205:
2206:                substr = "/*b-Foo$FooImplementor*/";
2207:                exp1 = "Temp.Foo$FooImplementor";
2208:                exp2 = "FooImplementor";
2209:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2210:                        .indexOf(substr), true);
2211:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2212:                        .indexOf(substr), false);
2213:                assertEquals("class name at " + substr + " exp=`" + exp1
2214:                        + "`, act=`" + act1 + "`", exp1, act1);
2215:                assertEquals("class name at " + substr + " exp=`" + exp2
2216:                        + "`, act=`" + act2 + "`", exp2, act2);
2217:
2218:                substr = "/*Foo$FooImplementor$1*/";
2219:                exp1 = "Temp.Foo$FooImplementor$1";
2220:                exp2 = "1";
2221:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2222:                        .indexOf(substr), true);
2223:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2224:                        .indexOf(substr), false);
2225:                assertEquals("class name at " + substr + " exp=`" + exp1
2226:                        + "`, act=`" + act1 + "`", exp1, act1);
2227:                assertEquals("class name at " + substr + " exp=`" + exp2
2228:                        + "`, act=`" + act2 + "`", exp2, act2);
2229:
2230:                substr = "\"Foo$FooImplementor$1\"";
2231:                exp1 = "Temp.Foo$FooImplementor$1";
2232:                exp2 = "1";
2233:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2234:                        .indexOf(substr), true);
2235:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2236:                        .indexOf(substr), false);
2237:                assertEquals("class name at " + substr + " exp=`" + exp1
2238:                        + "`, act=`" + act1 + "`", exp1, act1);
2239:                assertEquals("class name at " + substr + " exp=`" + exp2
2240:                        + "`, act=`" + act2 + "`", exp2, act2);
2241:
2242:                substr = "/*Foo$FooImplementor$1$1*/";
2243:                exp1 = "Temp.Foo$FooImplementor$1$1";
2244:                exp2 = "1";
2245:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2246:                        .indexOf(substr), true);
2247:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2248:                        .indexOf(substr), false);
2249:                assertEquals("class name at " + substr + " exp=`" + exp1
2250:                        + "`, act=`" + act1 + "`", exp1, act1);
2251:                assertEquals("class name at " + substr + " exp=`" + exp2
2252:                        + "`, act=`" + act2 + "`", exp2, act2);
2253:
2254:                substr = "\"Foo$FooImplementor$1$1\"";
2255:                exp1 = "Temp.Foo$FooImplementor$1$1";
2256:                exp2 = "1";
2257:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2258:                        .indexOf(substr), true);
2259:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2260:                        .indexOf(substr), false);
2261:                assertEquals("class name at " + substr + " exp=`" + exp1
2262:                        + "`, act=`" + act1 + "`", exp1, act1);
2263:                assertEquals("class name at " + substr + " exp=`" + exp2
2264:                        + "`, act=`" + act2 + "`", exp2, act2);
2265:
2266:                substr = "/*Foo$FooImplementor$Inner*/";
2267:                exp1 = "Temp.Foo$FooImplementor$Inner";
2268:                exp2 = "Inner";
2269:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2270:                        .indexOf(substr), true);
2271:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2272:                        .indexOf(substr), false);
2273:                assertEquals("class name at " + substr + " exp=`" + exp1
2274:                        + "`, act=`" + act1 + "`", exp1, act1);
2275:                assertEquals("class name at " + substr + " exp=`" + exp2
2276:                        + "`, act=`" + act2 + "`", exp2, act2);
2277:
2278:                substr = "/*eof*/";
2279:                exp1 = "";
2280:                exp2 = "";
2281:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2282:                        .indexOf(substr), true);
2283:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2284:                        .indexOf(substr), false);
2285:                assertEquals("class name at " + substr + " exp=`" + exp1
2286:                        + "`, act=`" + act1 + "`", exp1, act1);
2287:                assertEquals("class name at " + substr + " exp=`" + exp2
2288:                        + "`, act=`" + act2 + "`", exp2, act2);
2289:
2290:                substr = "/*bof*/";
2291:                exp1 = "";
2292:                exp2 = "";
2293:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2294:                        .indexOf(substr), true);
2295:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2296:                        .indexOf(substr), false);
2297:                assertEquals("class name at " + substr + " exp=`" + exp1
2298:                        + "`, act=`" + act1 + "`", exp1, act1);
2299:                assertEquals("class name at " + substr + " exp=`" + exp2
2300:                        + "`, act=`" + act2 + "`", exp2, act2);
2301:
2302:                substr = "public class Test";
2303:                exp1 = "";
2304:                exp2 = "";
2305:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2306:                        .indexOf(substr), true);
2307:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2308:                        .indexOf(substr), false);
2309:                assertEquals("class name at " + substr + " exp=`" + exp1
2310:                        + "`, act=`" + act1 + "`", exp1, act1);
2311:                assertEquals("class name at " + substr + " exp=`" + exp2
2312:                        + "`, act=`" + act2 + "`", exp2, act2);
2313:
2314:                substr = "/*anon2()*/";
2315:                exp1 = "Temp.Test";
2316:                exp2 = "Test";
2317:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2318:                        .indexOf(substr), true);
2319:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2320:                        .indexOf(substr), false);
2321:                assertEquals("class name at " + substr + " exp=`" + exp1
2322:                        + "`, act=`" + act1 + "`", exp1, act1);
2323:                assertEquals("class name at " + substr + " exp=`" + exp2
2324:                        + "`, act=`" + act2 + "`", exp2, act2);
2325:
2326:                substr = "/*Test$4*/";
2327:                exp1 = "Temp.Test$4";
2328:                exp2 = "4";
2329:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2330:                        .indexOf(substr), true);
2331:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2332:                        .indexOf(substr), false);
2333:                assertEquals("class name at " + substr + " exp=`" + exp1
2334:                        + "`, act=`" + act1 + "`", exp1, act1);
2335:                assertEquals("class name at " + substr + " exp=`" + exp2
2336:                        + "`, act=`" + act2 + "`", exp2, act2);
2337:
2338:                substr = "\"parameter 1 = Test$4\"";
2339:                exp1 = "Temp.Test$4";
2340:                exp2 = "4";
2341:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2342:                        .indexOf(substr), true);
2343:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2344:                        .indexOf(substr), false);
2345:                assertEquals("class name at " + substr + " exp=`" + exp1
2346:                        + "`, act=`" + act1 + "`", exp1, act1);
2347:                assertEquals("class name at " + substr + " exp=`" + exp2
2348:                        + "`, act=`" + act2 + "`", exp2, act2);
2349:
2350:                substr = "/*Test$4$1*/";
2351:                exp1 = "Temp.Test$4$1";
2352:                exp2 = "1";
2353:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2354:                        .indexOf(substr), true);
2355:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2356:                        .indexOf(substr), false);
2357:                assertEquals("class name at " + substr + " exp=`" + exp1
2358:                        + "`, act=`" + act1 + "`", exp1, act1);
2359:                assertEquals("class name at " + substr + " exp=`" + exp2
2360:                        + "`, act=`" + act2 + "`", exp2, act2);
2361:
2362:                substr = "\"Test$4$1\"";
2363:                exp1 = "Temp.Test$4$1";
2364:                exp2 = "1";
2365:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2366:                        .indexOf(substr), true);
2367:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2368:                        .indexOf(substr), false);
2369:                assertEquals("class name at " + substr + " exp=`" + exp1
2370:                        + "`, act=`" + act1 + "`", exp1, act1);
2371:                assertEquals("class name at " + substr + " exp=`" + exp2
2372:                        + "`, act=`" + act2 + "`", exp2, act2);
2373:
2374:                substr = "/*b-anon2()*/";
2375:                exp1 = "Temp.Test";
2376:                exp2 = "Test";
2377:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2378:                        .indexOf(substr), true);
2379:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2380:                        .indexOf(substr), false);
2381:                assertEquals("class name at " + substr + " exp=`" + exp1
2382:                        + "`, act=`" + act1 + "`", exp1, act1);
2383:                assertEquals("class name at " + substr + " exp=`" + exp2
2384:                        + "`, act=`" + act2 + "`", exp2, act2);
2385:
2386:                substr = "/*Test$5*/";
2387:                exp1 = "Temp.Test$5";
2388:                exp2 = "5";
2389:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2390:                        .indexOf(substr), true);
2391:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2392:                        .indexOf(substr), false);
2393:                assertEquals("class name at " + substr + " exp=`" + exp1
2394:                        + "`, act=`" + act1 + "`", exp1, act1);
2395:                assertEquals("class name at " + substr + " exp=`" + exp2
2396:                        + "`, act=`" + act2 + "`", exp2, act2);
2397:
2398:                substr = "\"parameter 2 = Test$5\"";
2399:                exp1 = "Temp.Test$5";
2400:                exp2 = "5";
2401:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2402:                        .indexOf(substr), true);
2403:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2404:                        .indexOf(substr), false);
2405:                assertEquals("class name at " + substr + " exp=`" + exp1
2406:                        + "`, act=`" + act1 + "`", exp1, act1);
2407:                assertEquals("class name at " + substr + " exp=`" + exp2
2408:                        + "`, act=`" + act2 + "`", exp2, act2);
2409:
2410:                substr = "/*c-anon2()*/";
2411:                exp1 = "Temp.Test";
2412:                exp2 = "Test";
2413:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2414:                        .indexOf(substr), true);
2415:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2416:                        .indexOf(substr), false);
2417:                assertEquals("class name at " + substr + " exp=`" + exp1
2418:                        + "`, act=`" + act1 + "`", exp1, act1);
2419:                assertEquals("class name at " + substr + " exp=`" + exp2
2420:                        + "`, act=`" + act2 + "`", exp2, act2);
2421:
2422:                substr = "/*Test$6*/";
2423:                exp1 = "Temp.Test$6";
2424:                exp2 = "6";
2425:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2426:                        .indexOf(substr), true);
2427:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2428:                        .indexOf(substr), false);
2429:                assertEquals("class name at " + substr + " exp=`" + exp1
2430:                        + "`, act=`" + act1 + "`", exp1, act1);
2431:                assertEquals("class name at " + substr + " exp=`" + exp2
2432:                        + "`, act=`" + act2 + "`", exp2, act2);
2433:
2434:                substr = "\"Test$6\"";
2435:                exp1 = "Temp.Test$6";
2436:                exp2 = "6";
2437:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2438:                        .indexOf(substr), true);
2439:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2440:                        .indexOf(substr), false);
2441:                assertEquals("class name at " + substr + " exp=`" + exp1
2442:                        + "`, act=`" + act1 + "`", exp1, act1);
2443:                assertEquals("class name at " + substr + " exp=`" + exp2
2444:                        + "`, act=`" + act2 + "`", exp2, act2);
2445:
2446:                substr = "/*anon3()*/";
2447:                exp1 = "Temp.Test";
2448:                exp2 = "Test";
2449:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2450:                        .indexOf(substr), true);
2451:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2452:                        .indexOf(substr), false);
2453:                assertEquals("class name at " + substr + " exp=`" + exp1
2454:                        + "`, act=`" + act1 + "`", exp1, act1);
2455:                assertEquals("class name at " + substr + " exp=`" + exp2
2456:                        + "`, act=`" + act2 + "`", exp2, act2);
2457:
2458:                substr = "/*Test$7*/";
2459:                exp1 = "Temp.Test$7";
2460:                exp2 = "7";
2461:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2462:                        .indexOf(substr), true);
2463:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2464:                        .indexOf(substr), false);
2465:                assertEquals("class name at " + substr + " exp=`" + exp1
2466:                        + "`, act=`" + act1 + "`", exp1, act1);
2467:                assertEquals("class name at " + substr + " exp=`" + exp2
2468:                        + "`, act=`" + act2 + "`", exp2, act2);
2469:
2470:                substr = "\"doSomething\"";
2471:                exp1 = "Temp.Test$7$NamedClassAgain";
2472:                exp2 = "NamedClassAgain";
2473:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2474:                        .indexOf(substr), true);
2475:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2476:                        .indexOf(substr), false);
2477:                assertEquals("class name at " + substr + " exp=`" + exp1
2478:                        + "`, act=`" + act1 + "`", exp1, act1);
2479:                assertEquals("class name at " + substr + " exp=`" + exp2
2480:                        + "`, act=`" + act2 + "`", exp2, act2);
2481:
2482:                substr = "\"parameter 3 = Test$7\"";
2483:                exp1 = "Temp.Test$7";
2484:                exp2 = "7";
2485:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2486:                        .indexOf(substr), true);
2487:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2488:                        .indexOf(substr), false);
2489:                assertEquals("class name at " + substr + " exp=`" + exp1
2490:                        + "`, act=`" + act1 + "`", exp1, act1);
2491:                assertEquals("class name at " + substr + " exp=`" + exp2
2492:                        + "`, act=`" + act2 + "`", exp2, act2);
2493:
2494:                substr = "/*Test$7$1*/";
2495:                exp1 = "Temp.Test$7$1";
2496:                exp2 = "1";
2497:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2498:                        .indexOf(substr), true);
2499:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2500:                        .indexOf(substr), false);
2501:                assertEquals("class name at " + substr + " exp=`" + exp1
2502:                        + "`, act=`" + act1 + "`", exp1, act1);
2503:                assertEquals("class name at " + substr + " exp=`" + exp2
2504:                        + "`, act=`" + act2 + "`", exp2, act2);
2505:
2506:                substr = "\"Test$7$1\"";
2507:                exp1 = "Temp.Test$7$1";
2508:                exp2 = "1";
2509:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2510:                        .indexOf(substr), true);
2511:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2512:                        .indexOf(substr), false);
2513:                assertEquals("class name at " + substr + " exp=`" + exp1
2514:                        + "`, act=`" + act1 + "`", exp1, act1);
2515:                assertEquals("class name at " + substr + " exp=`" + exp2
2516:                        + "`, act=`" + act2 + "`", exp2, act2);
2517:
2518:                substr = "/*c-anon2()*/";
2519:                exp1 = "Temp.Test";
2520:                exp2 = "Test";
2521:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2522:                        .indexOf(substr), true);
2523:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2524:                        .indexOf(substr), false);
2525:                assertEquals("class name at " + substr + " exp=`" + exp1
2526:                        + "`, act=`" + act1 + "`", exp1, act1);
2527:                assertEquals("class name at " + substr + " exp=`" + exp2
2528:                        + "`, act=`" + act2 + "`", exp2, act2);
2529:
2530:                substr = "/*Test$8*/";
2531:                exp1 = "Temp.Test$8";
2532:                exp2 = "8";
2533:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2534:                        .indexOf(substr), true);
2535:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2536:                        .indexOf(substr), false);
2537:                assertEquals("class name at " + substr + " exp=`" + exp1
2538:                        + "`, act=`" + act1 + "`", exp1, act1);
2539:                assertEquals("class name at " + substr + " exp=`" + exp2
2540:                        + "`, act=`" + act2 + "`", exp2, act2);
2541:
2542:                substr = "\"Test$8\"";
2543:                exp1 = "Temp.Test$8";
2544:                exp2 = "8";
2545:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2546:                        .indexOf(substr), true);
2547:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2548:                        .indexOf(substr), false);
2549:                assertEquals("class name at " + substr + " exp=`" + exp1
2550:                        + "`, act=`" + act1 + "`", exp1, act1);
2551:                assertEquals("class name at " + substr + " exp=`" + exp2
2552:                        + "`, act=`" + act2 + "`", exp2, act2);
2553:
2554:                substr = "abstract void feeDo()";
2555:                exp1 = "Temp.Fee";
2556:                exp2 = "Fee";
2557:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2558:                        .indexOf(substr), true);
2559:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2560:                        .indexOf(substr), false);
2561:                assertEquals("class name at " + substr + " exp=`" + exp1
2562:                        + "`, act=`" + act1 + "`", exp1, act1);
2563:                assertEquals("class name at " + substr + " exp=`" + exp2
2564:                        + "`, act=`" + act2 + "`", exp2, act2);
2565:
2566:                substr = "class FeeConc extends Fee";
2567:                exp1 = "Temp.Fee";
2568:                exp2 = "Fee";
2569:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2570:                        .indexOf(substr), true);
2571:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2572:                        .indexOf(substr), false);
2573:                assertEquals("class name at " + substr + " exp=`" + exp1
2574:                        + "`, act=`" + act1 + "`", exp1, act1);
2575:                assertEquals("class name at " + substr + " exp=`" + exp2
2576:                        + "`, act=`" + act2 + "`", exp2, act2);
2577:
2578:                substr = "/*Fee$FeeConc*/";
2579:                exp1 = "Temp.Fee$FeeConc";
2580:                exp2 = "FeeConc";
2581:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2582:                        .indexOf(substr), true);
2583:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2584:                        .indexOf(substr), false);
2585:                assertEquals("class name at " + substr + " exp=`" + exp1
2586:                        + "`, act=`" + act1 + "`", exp1, act1);
2587:                assertEquals("class name at " + substr + " exp=`" + exp2
2588:                        + "`, act=`" + act2 + "`", exp2, act2);
2589:
2590:                substr = "\"FeeConc/feeDo\"";
2591:                exp1 = "Temp.Fee$FeeConc";
2592:                exp2 = "FeeConc";
2593:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2594:                        .indexOf(substr), true);
2595:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2596:                        .indexOf(substr), false);
2597:                assertEquals("class name at " + substr + " exp=`" + exp1
2598:                        + "`, act=`" + act1 + "`", exp1, act1);
2599:                assertEquals("class name at " + substr + " exp=`" + exp2
2600:                        + "`, act=`" + act2 + "`", exp2, act2);
2601:
2602:                substr = "\"FeeConc/feeAct\"";
2603:                exp1 = "Temp.Fee$FeeConc";
2604:                exp2 = "FeeConc";
2605:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2606:                        .indexOf(substr), true);
2607:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2608:                        .indexOf(substr), false);
2609:                assertEquals("class name at " + substr + " exp=`" + exp1
2610:                        + "`, act=`" + act1 + "`", exp1, act1);
2611:                assertEquals("class name at " + substr + " exp=`" + exp2
2612:                        + "`, act=`" + act2 + "`", exp2, act2);
2613:
2614:                substr = "\"FeeConc/s\"";
2615:                exp1 = "Temp.Fee$FeeConc";
2616:                exp2 = "FeeConc";
2617:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2618:                        .indexOf(substr), true);
2619:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2620:                        .indexOf(substr), false);
2621:                assertEquals("class name at " + substr + " exp=`" + exp1
2622:                        + "`, act=`" + act1 + "`", exp1, act1);
2623:                assertEquals("class name at " + substr + " exp=`" + exp2
2624:                        + "`, act=`" + act2 + "`", exp2, act2);
2625:
2626:                substr = "\"FeeConc/t\"";
2627:                exp1 = "Temp.Fee$FeeConc";
2628:                exp2 = "FeeConc";
2629:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2630:                        .indexOf(substr), true);
2631:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2632:                        .indexOf(substr), false);
2633:                assertEquals("class name at " + substr + " exp=`" + exp1
2634:                        + "`, act=`" + act1 + "`", exp1, act1);
2635:                assertEquals("class name at " + substr + " exp=`" + exp2
2636:                        + "`, act=`" + act2 + "`", exp2, act2);
2637:
2638:                substr = "\"FeeConc/u\"";
2639:                exp1 = "Temp.Fee$FeeConc";
2640:                exp2 = "FeeConc";
2641:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2642:                        .indexOf(substr), true);
2643:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2644:                        .indexOf(substr), false);
2645:                assertEquals("class name at " + substr + " exp=`" + exp1
2646:                        + "`, act=`" + act1 + "`", exp1, act1);
2647:                assertEquals("class name at " + substr + " exp=`" + exp2
2648:                        + "`, act=`" + act2 + "`", exp2, act2);
2649:
2650:                substr = "/*Fee$1*/";
2651:                exp1 = "Temp.Fee$1";
2652:                exp2 = "1";
2653:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2654:                        .indexOf(substr), true);
2655:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2656:                        .indexOf(substr), false);
2657:                assertEquals("class name at " + substr + " exp=`" + exp1
2658:                        + "`, act=`" + act1 + "`", exp1, act1);
2659:                assertEquals("class name at " + substr + " exp=`" + exp2
2660:                        + "`, act=`" + act2 + "`", exp2, act2);
2661:
2662:                substr = "\"Fee$1/feeDo\"";
2663:                exp1 = "Temp.Fee$1";
2664:                exp2 = "1";
2665:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2666:                        .indexOf(substr), true);
2667:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2668:                        .indexOf(substr), false);
2669:                assertEquals("class name at " + substr + " exp=`" + exp1
2670:                        + "`, act=`" + act1 + "`", exp1, act1);
2671:                assertEquals("class name at " + substr + " exp=`" + exp2
2672:                        + "`, act=`" + act2 + "`", exp2, act2);
2673:
2674:                substr = "\"Fee$1/feeAct\"";
2675:                exp1 = "Temp.Fee$1";
2676:                exp2 = "1";
2677:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2678:                        .indexOf(substr), true);
2679:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2680:                        .indexOf(substr), false);
2681:                assertEquals("class name at " + substr + " exp=`" + exp1
2682:                        + "`, act=`" + act1 + "`", exp1, act1);
2683:                assertEquals("class name at " + substr + " exp=`" + exp2
2684:                        + "`, act=`" + act2 + "`", exp2, act2);
2685:
2686:                substr = "\"Fee$1/s\"";
2687:                exp1 = "Temp.Fee$1";
2688:                exp2 = "1";
2689:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2690:                        .indexOf(substr), true);
2691:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2692:                        .indexOf(substr), false);
2693:                assertEquals("class name at " + substr + " exp=`" + exp1
2694:                        + "`, act=`" + act1 + "`", exp1, act1);
2695:                assertEquals("class name at " + substr + " exp=`" + exp2
2696:                        + "`, act=`" + act2 + "`", exp2, act2);
2697:
2698:                substr = "\"Fee$1/t\"";
2699:                exp1 = "Temp.Fee$1";
2700:                exp2 = "1";
2701:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2702:                        .indexOf(substr), true);
2703:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2704:                        .indexOf(substr), false);
2705:                assertEquals("class name at " + substr + " exp=`" + exp1
2706:                        + "`, act=`" + act1 + "`", exp1, act1);
2707:                assertEquals("class name at " + substr + " exp=`" + exp2
2708:                        + "`, act=`" + act2 + "`", exp2, act2);
2709:
2710:                substr = "\"Fee$1/u\"";
2711:                exp1 = "Temp.Fee$1";
2712:                exp2 = "1";
2713:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2714:                        .indexOf(substr), true);
2715:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2716:                        .indexOf(substr), false);
2717:                assertEquals("class name at " + substr + " exp=`" + exp1
2718:                        + "`, act=`" + act1 + "`", exp1, act1);
2719:                assertEquals("class name at " + substr + " exp=`" + exp2
2720:                        + "`, act=`" + act2 + "`", exp2, act2);
2721:
2722:                substr = "/*Test$Outer$Middle$1*/";
2723:                exp1 = "Temp.Test$Outer$Middle$1";
2724:                exp2 = "1";
2725:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2726:                        .indexOf(substr), true);
2727:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2728:                        .indexOf(substr), false);
2729:                assertEquals("class name at " + substr + " exp=`" + exp1
2730:                        + "`, act=`" + act1 + "`", exp1, act1);
2731:                assertEquals("class name at " + substr + " exp=`" + exp2
2732:                        + "`, act=`" + act2 + "`", exp2, act2);
2733:
2734:                substr = "\"Test$Outer$Middle$1\"";
2735:                exp1 = "Temp.Test$Outer$Middle$1";
2736:                exp2 = "1";
2737:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2738:                        .indexOf(substr), true);
2739:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2740:                        .indexOf(substr), false);
2741:                assertEquals("class name at " + substr + " exp=`" + exp1
2742:                        + "`, act=`" + act1 + "`", exp1, act1);
2743:                assertEquals("class name at " + substr + " exp=`" + exp2
2744:                        + "`, act=`" + act2 + "`", exp2, act2);
2745:
2746:                substr = "/*Test$9*/";
2747:                exp1 = "Temp.Test$9";
2748:                exp2 = "9";
2749:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2750:                        .indexOf(substr), true);
2751:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2752:                        .indexOf(substr), false);
2753:                assertEquals("class name at " + substr + " exp=`" + exp1
2754:                        + "`, act=`" + act1 + "`", exp1, act1);
2755:                assertEquals("class name at " + substr + " exp=`" + exp2
2756:                        + "`, act=`" + act2 + "`", exp2, act2);
2757:
2758:                substr = "\"Test$9\"";
2759:                exp1 = "Temp.Test$9";
2760:                exp2 = "9";
2761:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2762:                        .indexOf(substr), true);
2763:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2764:                        .indexOf(substr), false);
2765:                assertEquals("class name at " + substr + " exp=`" + exp1
2766:                        + "`, act=`" + act1 + "`", exp1, act1);
2767:                assertEquals("class name at " + substr + " exp=`" + exp2
2768:                        + "`, act=`" + act2 + "`", exp2, act2);
2769:
2770:                substr = "/*Test$10*/";
2771:                exp1 = "Temp.Test$10";
2772:                exp2 = "10";
2773:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2774:                        .indexOf(substr), true);
2775:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2776:                        .indexOf(substr), false);
2777:                assertEquals("class name at " + substr + " exp=`" + exp1
2778:                        + "`, act=`" + act1 + "`", exp1, act1);
2779:                assertEquals("class name at " + substr + " exp=`" + exp2
2780:                        + "`, act=`" + act2 + "`", exp2, act2);
2781:
2782:                substr = "\"Test$10\"";
2783:                exp1 = "Temp.Test$10";
2784:                exp2 = "10";
2785:                act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2786:                        .indexOf(substr), true);
2787:                act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT
2788:                        .indexOf(substr), false);
2789:                assertEquals("class name at " + substr + " exp=`" + exp1
2790:                        + "`, act=`" + act1 + "`", exp1, act1);
2791:                assertEquals("class name at " + substr + " exp=`" + exp2
2792:                        + "`, act=`" + act2 + "`", exp2, act2);
2793:            }
2794:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.