001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework;
043:
044: import org.netbeans.modules.uml.core.AbstractUMLTestCase;
045: import org.netbeans.modules.uml.core.reverseengineering.parsers.javaparser.REJavaParser;
046: import org.netbeans.modules.uml.core.support.umlsupport.IStrings;
047: import org.netbeans.modules.uml.core.support.umlutils.ETList;
048:
049: /**
050: * Test cases for LanguageManager.
051: */
052: public class LanguageManagerTestCase extends AbstractUMLTestCase {
053:
054: public static void main(String[] args) {
055: junit.textui.TestRunner.run(LanguageManagerTestCase.class);
056: }
057:
058: private ILanguageManager lm = product.getLanguageManager();
059:
060: public void testGetAttributeDefaultType() {
061: assertEquals("int", lm
062: .getAttributeDefaultType(createClass("A")).getName());
063: }
064:
065: public void testRetrieveContextForFile() {
066: writeFile(null, null);
067: assertEquals(
068: "org.netbeans.modules.uml.core.roundtripframework."
069: + "requestprocessors.javarpcomponent.JavaRequestProcessor",
070: lm.retrieveContextForFile("Xyz.java", "RoundTrip"));
071: }
072:
073: public void testRetrieveContextForLanguage() {
074: assertEquals(
075: "org.netbeans.modules.uml.core.roundtripframework."
076: + "requestprocessors.javarpcomponent.JavaRequestProcessor",
077: lm.retrieveContextForLanguage("Java", "RoundTrip"));
078: }
079:
080: public void testGetDefaultForLanguage() {
081: assertEquals("null", lm.getDefaultForLanguage("Java",
082: "UnknownDataType Initialization"));
083: }
084:
085: public void testGetDefaultLanguage() {
086: assertEquals("Java", lm.getDefaultLanguage(createClass("Foo"))
087: .getName());
088: }
089:
090: public void testGetDefaultSourceFileExtensionForLanguage() {
091: assertEquals("java", lm
092: .getDefaultSourceFileExtensionForLanguage("Java"));
093: }
094:
095: public void testGetFileExtensionFilters() {
096: ILanguageFilter fil = lm.getFileExtensionFilters("Java").get(0);
097: assertEquals("Source Files", fil.getName());
098: assertEquals("*.java", fil.getFilter());
099: }
100:
101: public void testGetFileExtensionsForLanguage() {
102: IStrings s = lm.getFileExtensionsForLanguage("Java");
103: assertEquals(1, s.size());
104: assertEquals("java", s.get(0));
105: }
106:
107: public void testGetLanguageForFile() {
108: assertEquals("Java", lm.getLanguageForFile("Xyz.java")
109: .getName());
110: }
111:
112: public void testGetLanguage() {
113: assertEquals("Java", lm.getLanguage("Java").getName());
114: }
115:
116: public void testGetLanguagesWithCodeGenSupport() {
117: ETList<ILanguage> langs = lm.getLanguagesWithCodeGenSupport();
118: assertEquals(1, langs.size());
119: }
120:
121: public void testGetOperationDefaultType() {
122: assertEquals("void", lm.getOperationDefaultType(
123: createClass("Yak")).getName());
124: }
125:
126: public void testGetParserForFile() {
127: assertTrue(lm.getParserForFile("Xyz.java", "Default") instanceof REJavaParser);
128:
129: }
130:
131: public void testRetrieveParserForLanguage() {
132: assertTrue(lm.retrieveParserForLanguage("Java", "Default") instanceof REJavaParser);
133: }
134:
135: public void testGetSupportedLanguages2() {
136: assertEquals(2, lm.getSupportedLanguages2().size());
137: }
138:
139: public void testGetSupportedLanguagesAsString() {
140: assertEquals("Java|UML", lm.getSupportedLanguagesAsString());
141: }
142:
143: public void testGetSupportedLanguages() {
144: assertEquals(2, lm.getSupportedLanguages().size());
145: }
146: }
|