001: /*******************************************************************************
002: * Copyright (c) 2006, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.ui.tests.target;
011:
012: import java.util.Dictionary;
013:
014: import junit.framework.Test;
015: import junit.framework.TestCase;
016: import junit.framework.TestSuite;
017:
018: import org.eclipse.core.runtime.Platform;
019: import org.eclipse.pde.core.plugin.TargetPlatform;
020: import org.eclipse.pde.internal.core.ExecutionEnvironmentAnalyzer;
021: import org.eclipse.pde.internal.core.TargetPlatformHelper;
022: import org.osgi.framework.Constants;
023:
024: public class TargetEnvironmentTestCase extends TestCase {
025:
026: public static Test suite() {
027: return new TestSuite(TargetEnvironmentTestCase.class);
028: }
029:
030: public void testOS() {
031: assertEquals(Platform.getOS(), TargetPlatform.getOS());
032: }
033:
034: public void testWS() {
035: assertEquals(Platform.getWS(), TargetPlatform.getWS());
036: }
037:
038: public void testArch() {
039: assertEquals(Platform.getOSArch(), TargetPlatform.getOSArch());
040: }
041:
042: public void testNL() {
043: assertEquals(Platform.getNL(), TargetPlatform.getNL());
044: }
045:
046: public void testEnvironmentDictionarySize() {
047: Dictionary dictionary = TargetPlatformHelper
048: .getTargetEnvironment();
049: assertEquals(6, dictionary.size());
050: }
051:
052: public void testDictionaryOS() {
053: Dictionary dictionary = TargetPlatformHelper
054: .getTargetEnvironment();
055: assertEquals(Platform.getOS(), dictionary.get("osgi.os"));
056: }
057:
058: public void testDictionaryWS() {
059: Dictionary dictionary = TargetPlatformHelper
060: .getTargetEnvironment();
061: assertEquals(Platform.getWS(), dictionary.get("osgi.ws"));
062: }
063:
064: public void testDictionaryArch() {
065: Dictionary dictionary = TargetPlatformHelper
066: .getTargetEnvironment();
067: assertEquals(Platform.getOSArch(), dictionary.get("osgi.arch"));
068: }
069:
070: public void testDictionaryNL() {
071: Dictionary dictionary = TargetPlatformHelper
072: .getTargetEnvironment();
073: assertEquals(Platform.getNL(), dictionary.get("osgi.nl"));
074: }
075:
076: public void testResolveOptional() {
077: Dictionary dictionary = TargetPlatformHelper
078: .getTargetEnvironment();
079: assertTrue("true"
080: .equals(dictionary.get("osgi.resolveOptional")));
081: }
082:
083: public void testStateDictionaryNumber() {
084: Dictionary[] dictionaries = TargetPlatformHelper.getState()
085: .getPlatformProperties();
086: String[] envs = ExecutionEnvironmentAnalyzer
087: .getKnownExecutionEnvironments();
088: assertEquals(envs.length, dictionaries.length);
089: }
090:
091: public void testStateDictionaryLength() {
092: Dictionary[] dictionaries = TargetPlatformHelper.getState()
093: .getPlatformProperties();
094: Dictionary dictionary = TargetPlatformHelper
095: .getTargetEnvironment();
096: for (int i = 0; i < dictionaries.length; i++)
097: assertTrue(dictionary.size() + 2 <= dictionaries[i].size());
098: }
099:
100: public void testSystemPackages() {
101: Dictionary[] dictionaries = TargetPlatformHelper.getState()
102: .getPlatformProperties();
103: for (int i = 0; i < dictionaries.length; i++)
104: assertNotNull(dictionaries[i]
105: .get(Constants.FRAMEWORK_SYSTEMPACKAGES));
106: }
107:
108: public void testExecutionEnvironment() {
109: Dictionary[] dictionaries = TargetPlatformHelper.getState()
110: .getPlatformProperties();
111: for (int i = 0; i < dictionaries.length; i++)
112: assertNotNull(dictionaries[i]
113: .get(Constants.FRAMEWORK_EXECUTIONENVIRONMENT));
114: }
115:
116: }
|