/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package org.apache.jmeter.gui.util;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.HashSet;
import java.util.Properties;

import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.util.JMeterUtils;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;

public class JSyntaxTextAreaTest extends JMeterTestCase {

  public void testSetLanguage(){
    JSyntaxTextArea textArea = new JSyntaxTextArea(30, 50, false);
    
    try {
      textArea.setLanguage(null);
    } catch(Exception e){
      fail("No Exception expected");
    }
    
    assertEquals(SyntaxConstants.SYNTAX_STYLE_NONE, textArea.getSyntaxEditingStyle());
    
  }
  
    public void testSyntaxNames() throws IllegalArgumentException,
            IllegalAccessException {
        HashSet<String> values = new HashSet<String>();
        for (Field field : SyntaxConstants.class.getFields()) {
            int modifiers = field.getModifiers();
            if (field.getType().equals(String.class)
                    && Modifier.isStatic(modifiers)
                    && Modifier.isPublic(modifiers)) {
                values.add((String) field.get(null));
            }
        }
        final Properties languageProperties = JMeterUtils
                .loadProperties("org/apache/jmeter/gui/util/textarea.properties"); //$NON-NLS-1$;
        for (Object s : languageProperties.values()) {
            if (!values.contains(s)) {
                fail("Invalid property value: " + s);
            }
        }
        // Show unused entries
//        for (Object s : languageProperties.values()) {
//            values.remove(s);
//        }
//        if (values.size() > 0) {
//            System.out.print("Unused JSyntaxAreaTypes:");
//            for (String value : values) {
//                System.out.print(" ");
//                System.out.print(value);
//            }
//            System.out.println();
//        }
    }
}

@@ -835,16 +835,51 @@
 .util;%0A%0A
+import java.awt.HeadlessException;%0A
 import j
@@ -902,16 +902,16 @@
 .Field;%0A
-
 import j
@@ -1195,16 +1195,18 @@
 Case %7B%0A%0A
+  
   public
@@ -1228,18 +1228,41 @@
 nguage()
+ 
 %7B%0A
+        try %7B%0A        
     JSyn
@@ -1328,19 +1328,10 @@
     
-%0A
   
-  try %7B%0A
     
@@ -1368,78 +1368,12 @@
     
-%7D catch(Exception e)%7B%0A      fail(%22No Exception expected%22);%0A    %7D%0A    %0A
+    
     
@@ -1459,17 +1459,111 @@
 ));%0A    
-%0A
+    %7D catch (HeadlessException he) %7B%0A            // Does not work in headless mode%0A        %7D%0A  
   %7D%0A  %0A 

Allow for Headless testing; simplify test case