1 19 package org.netbeans.modules.java.hints; 20 21 import com.sun.source.util.TreePath; 22 import java.util.Collections ; 23 import java.util.HashMap ; 24 import java.util.List ; 25 import java.util.Set ; 26 import org.netbeans.api.java.source.CompilationInfo; 27 import org.netbeans.modules.java.hints.spi.ErrorRule; 28 import org.netbeans.modules.java.hints.spi.ErrorRule.Data; 29 import org.netbeans.spi.editor.hints.Fix; 30 31 35 public class CreatorBasedLazyFixListTest extends JavaHintsTestBase { 36 37 public CreatorBasedLazyFixListTest(String testName) { 38 super(testName); 39 } 40 41 protected void setUp() throws Exception { 42 super.setUp(); 43 } 44 45 protected void tearDown() throws Exception { 46 super.tearDown(); 47 } 48 49 public void testCancel() throws Exception { 50 prepareTest("Simple"); 51 52 final int[] calledCount = new int[1]; 53 final boolean[] cancel = new boolean[1]; 54 final CreatorBasedLazyFixList[] list = new CreatorBasedLazyFixList[1]; 55 56 list[0] = new CreatorBasedLazyFixList(null, "", 0, Collections.singleton((ErrorRule) new ErrorRule() { 57 public Set getCodes() { 58 throw new UnsupportedOperationException ("Not supported yet."); 59 } 60 61 public List <Fix> run(CompilationInfo compilationInfo, 62 String diagnosticKey, int offset, TreePath treePath, 63 Data data) { 64 calledCount[0]++; 65 if (cancel[0]) { 66 list[0].cancel(); 67 } 68 69 return Collections.<Fix>emptyList(); 70 } 71 72 public void cancel() { 73 } 75 76 public String getId() { 77 throw new UnsupportedOperationException ("Not supported yet."); 78 } 79 80 public String getDisplayName() { 81 throw new UnsupportedOperationException ("Not supported yet."); 82 } 83 84 public String getDescription() { 85 throw new UnsupportedOperationException ("Not supported yet."); 86 } 87 }), new HashMap <Class , Data>()); 88 89 cancel[0] = true; 90 91 list[0].compute(info); 92 93 assertEquals(1, calledCount[0]); 94 95 list[0].compute(info); 96 97 assertEquals(2, calledCount[0]); 98 99 cancel[0] = false; 100 101 list[0].compute(info); 102 103 assertEquals(3, calledCount[0]); 104 105 list[0].compute(info); 106 107 assertEquals(3, calledCount[0]); 108 } 109 110 @Override 111 protected String testDataExtension() { 112 return "org/netbeans/test/java/hints/"; 113 } 114 115 @Override 116 protected boolean createCaches() { 117 return false; 118 } 119 120 } 121 | Popular Tags |