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-2006 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: /*
043: * TestCreatePlatforms.java
044: * NetBeans JUnit based test
045: *
046: * Created on 14 September 2004, 15:37
047: */
048:
049: package projects;
050:
051: import java.io.InputStream;
052:
053: import java.net.InetAddress;
054: import java.net.UnknownHostException;
055: import java.util.Properties;
056: import org.netbeans.jellytools.JellyTestCase;
057:
058: import org.netbeans.junit.*;
059: import junit.framework.*;
060:
061: import org.netbeans.api.java.platform.JavaPlatformManager;
062: import org.netbeans.api.java.platform.JavaPlatform;
063:
064: /**
065: *
066: */
067: public class PlatformsTest extends JellyTestCase {
068:
069: public static final String JDK13_NAME = "JDK1.3";
070: public static final String JDK14_NAME = "JDK1.4";
071: public static final String JDK15_NAME = "JDK1.5";
072:
073: public PlatformsTest(java.lang.String testName) {
074: super (testName);
075: }
076:
077: public static void main(java.lang.String[] args) {
078: junit.textui.TestRunner.run(suite());
079: }
080:
081: public static Test suite() {
082: //TestSuite suite = new NbTestSuite(TestCreatePlatforms.class);
083: TestSuite suite = new NbTestSuite();
084: suite.addTest(new PlatformsTest("testCreatePlatforms"));
085: suite.addTest(new PlatformsTest("testAvailablePlatforms"));
086: return suite;
087: }
088:
089: // -------------------------------------------------------------------------
090:
091: public void testAvailablePlatforms() {
092:
093: JavaPlatformManager platMan = JavaPlatformManager.getDefault();
094: JavaPlatform platforms[] = platMan.getInstalledPlatforms();
095: String[] platNames = new String[platforms.length];
096: for (int i = 0; i < platforms.length; i++) {
097: System.out.println("Display Name: "
098: + platforms[i].getDisplayName());
099: platNames[i] = platforms[i].getDisplayName();
100: }
101: // there should be test if all added platforms are really added in IDE
102:
103: }
104:
105: // TODO Javadoc can be also added to platform
106: public void testCreatePlatforms() {
107:
108: // learn hostname
109: String hostName = null;
110: try {
111: hostName = InetAddress.getLocalHost().getHostName();
112: } catch (UnknownHostException uhe) {
113: fail("Cannot get hostname: " + uhe.getMessage()); // NOI18N
114: }
115: hostName = hostName.replace('-', '_');
116:
117: // load platforms.properties file
118: InputStream is = this .getClass().getResourceAsStream(
119: "platforms.properties");
120: Properties props = new Properties();
121: try {
122: props.load(is);
123: } catch (java.io.IOException ioe) {
124: fail("Cannot load platforms properties: "
125: + ioe.getMessage()); // NOI18N
126: }
127:
128: // get folder from prop file
129:
130: // XXX add correct paths to platform.properties
131: String folderJDK13Path = props.getProperty(hostName
132: + "_jdk13_folder");
133: TestProjectUtils.addPlatform(JDK13_NAME, folderJDK13Path);
134: String folderJDK14Path = props.getProperty(hostName
135: + "_jdk14_folder");
136: TestProjectUtils.addPlatform(JDK14_NAME, folderJDK14Path);
137: String folderJDK15Path = props.getProperty(hostName
138: + "_jdk15_folder");
139: TestProjectUtils.addPlatform(JDK15_NAME, folderJDK15Path);
140:
141: }
142:
143: }
|