1 19 20 package org.netbeans.modules.db.api.sql; 21 22 import junit.framework.*; 23 24 32 public class SQLKeywordsTest extends TestCase { 33 34 public SQLKeywordsTest(String testName) { 35 super(testName); 36 } 37 38 public void testIsSQL99ReservedKeyword() { 39 for (int i = 0; i < SQLKeywords.SQL99_RESERVED.length; i++) { 40 String identifier = SQLKeywords.SQL99_RESERVED[i].toUpperCase(); 41 assertTrue(identifier + " should be a reserved keyword", SQLKeywords.isSQL99ReservedKeyword(identifier)); 42 identifier = identifier.toLowerCase(); 43 assertTrue(identifier + " should be a reserved keyword", SQLKeywords.isSQL99ReservedKeyword(identifier)); 44 } 45 46 assertFalse(SQLKeywords.isSQL99ReservedKeyword("FOOBAR")); 48 49 try { 51 SQLKeywords.isSQL99ReservedKeyword(null); 52 fail("Should have thrown NullPointerException"); 53 } catch (NullPointerException e) { } 54 } 55 56 public void testIsSQL99NonReservedKeyword() { 57 for (int i = 0; i < SQLKeywords.SQL99_NON_RESERVED.length; i++) { 58 String identifier = SQLKeywords.SQL99_NON_RESERVED[i].toUpperCase(); 59 assertTrue(identifier + " should be a non-reserved keyword", SQLKeywords.isSQL99NonReservedKeyword(identifier)); 60 identifier = identifier.toLowerCase(); 61 assertTrue(identifier + " should be a non-reserved keyword", SQLKeywords.isSQL99NonReservedKeyword(identifier)); 62 } 63 64 assertFalse(SQLKeywords.isSQL99NonReservedKeyword("FOOBAR")); 66 67 try { 69 SQLKeywords.isSQL99NonReservedKeyword(null); 70 fail("Should have thrown NullPointerException"); 71 } catch (NullPointerException e) { } 72 } 73 74 public void testIsSQL99Keyword() { 75 for (int i = 0; i < SQLKeywords.SQL99_RESERVED.length; i++) { 76 String identifier = SQLKeywords.SQL99_RESERVED[i].toUpperCase(); 77 assertTrue(identifier + " should be a keyword", SQLKeywords.isSQL99Keyword(identifier)); 78 identifier = identifier.toLowerCase(); 79 assertTrue(identifier + " should be a keyword", SQLKeywords.isSQL99Keyword(identifier)); 80 } 81 for (int i = 0; i < SQLKeywords.SQL99_NON_RESERVED.length; i++) { 82 String identifier = SQLKeywords.SQL99_RESERVED[i].toUpperCase(); 83 assertTrue(identifier + " should be a keyword", SQLKeywords.isSQL99Keyword(identifier)); 84 identifier = identifier.toLowerCase(); 85 assertTrue(identifier + " should be a keyword", SQLKeywords.isSQL99Keyword(identifier)); 86 } 87 88 assertFalse(SQLKeywords.isSQL99Keyword("FOOBAR")); 90 91 try { 93 SQLKeywords.isSQL99Keyword(null); 94 fail("Should have thrown NullPointerException"); 95 } catch (NullPointerException e) { } 96 } 97 } 98 | Popular Tags |