⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libraryimportertests.java

📁 eclipseme的最新版本的source,欢迎j2me程序员使用
💻 JAVA
字号:
/**
 * Copyright (c) 2003-2005 Craig Setera
 * All Rights Reserved.
 * Licensed under the Eclipse Public License - v 1.0
 * For more information see http://www.eclipse.org/legal/epl-v10.html
 */
package eclipseme.core.model;

import java.io.File;
import java.net.MalformedURLException;

import eclipseme.core.importer.LibraryImporter;
import eclipseme.core.model.ILibrary;

/**
 * Type description
 * <p />
 * Copyright (c) 2003-2005 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.2 $
 * <br>
 * $Date: 2006/02/13 01:16:53 $
 * <br>
 * @author Craig Setera
 */
public class LibraryImporterTests extends AbstractCoreTestCase {
	public void testCLDC10() throws Exception {
		ILibrary library = initialLibraryTest("wtk.lib.cldc10");
		
		// Test the API
		assertTrue("Expected configuration", library.hasConfiguration());
		API[] apis = library.getAPIs();
		assertNotNull("APIs are null", apis);
		assertEquals("API length", 1, apis.length);
		API api = apis[0];
		
		assertNotNull("API is null", api);
		assertEquals("API Identifier", "CLDC", api.getIdentifier());
		assertEquals("API version", new Version("1.0"), api.getVersion());
		assertEquals("API type", APIType.CONFIGURATION, api.getType());
		assertNotNull("Configuration API should not be null", library.getAPI(APIType.CONFIGURATION));
		assertNull("Profile API should be null", library.getAPI(APIType.PROFILE));
	}
	
	public void testCLDC11() throws Exception {
		ILibrary library = initialLibraryTest("wtk.lib.cldc11");
		
		// Test the API
		assertTrue("Expected configuration", library.hasConfiguration());
		API[] apis = library.getAPIs();
		assertNotNull("APIs are null", apis);
		assertEquals("API length", 1, apis.length);
		API api = apis[0];
		
		assertNotNull("API is null", api);
		assertEquals("API Identifier", "CLDC", api.getIdentifier());
		assertEquals("API version", new Version("1.1"), api.getVersion());
		assertEquals("API type", APIType.CONFIGURATION, api.getType());
		assertNotNull("Configuration API should not be null", library.getAPI(APIType.CONFIGURATION));
		assertNull("Profile API should be null", library.getAPI(APIType.PROFILE));
	}
	
	public void testMIDP10() throws Exception {
		ILibrary library = initialLibraryTest("wtk.lib.midp10");
		
		// Test the API
		assertTrue("Expected profile", library.hasProfile());
		API[] apis = library.getAPIs();
		assertNotNull("APIs are null", apis);
		assertEquals("API length", 1, apis.length);
		API api = apis[0];
		
		assertNotNull("API is null", api);
		assertEquals("API Identifier", "MIDP", api.getIdentifier());
		assertEquals("API version", new Version("1.0"), api.getVersion());
		assertEquals("API type", APIType.PROFILE, api.getType());
		assertNull("Configuration API should be null", library.getAPI(APIType.CONFIGURATION));
		assertNotNull("Profile API should not be null", library.getAPI(APIType.PROFILE));
	}
	
	public void testMIDP20() throws Exception {
		ILibrary library = initialLibraryTest("wtk.lib.midp20");
		
		// Test the API
		assertTrue("Expected profile", library.hasProfile());
		API[] apis = library.getAPIs();
		assertNotNull("APIs are null", apis);
		assertEquals("API length", 1, apis.length);
		API api = apis[0];
		
		assertNotNull("API is null", api);
		assertEquals("API Identifier", "MIDP", api.getIdentifier());
		assertEquals("API version", new Version("2.0"), api.getVersion());
		assertEquals("API type", APIType.PROFILE, api.getType());
		assertNull("Configuration API should be null", library.getAPI(APIType.CONFIGURATION));
		assertNotNull("Profile API should not be null", library.getAPI(APIType.PROFILE));
	}
	
	public void testJSR75() throws Exception {
		ILibrary library = initialLibraryTest("wtk.lib.jsr75");
		
		// Test the API
		assertFalse("Expected not configuration", library.hasConfiguration());
		assertFalse("Expected not profile", library.hasProfile());
		API[] apis = library.getAPIs();
		assertNotNull("APIs are null", apis);
		assertEquals("API length", 1, apis.length);
		API api = apis[0];
		
		assertNotNull("API is null", api);
		assertEquals("API Identifier", "JSR75", api.getIdentifier());
		assertEquals("API version", new Version("1.0"), api.getVersion());
		assertEquals("API type", APIType.OPTIONAL, api.getType());
		assertNull("Configuration API should be null", library.getAPI(APIType.CONFIGURATION));
		assertNull("Profile API should be null", library.getAPI(APIType.PROFILE));
	}
	
	public void testWTK1() throws Exception {
		ILibrary library = initialLibraryTest("wtk1.lib.combined");
		
		// Test the API
		assertTrue("Expected configuration", library.hasConfiguration());
		assertTrue("Expected profile", library.hasProfile());
		API[] apis = library.getAPIs();
		assertNotNull("APIs are null", apis);
		assertEquals("API length", 2, apis.length);
		assertNotNull("Configuration API should not be null", library.getAPI(APIType.CONFIGURATION));
		assertNotNull("Profile API should not be null", library.getAPI(APIType.PROFILE));
	}

	/**
	 * @param fileProperty
	 * @return
	 * @throws MalformedURLException
	 */
	private ILibrary initialLibraryTest(String fileProperty) throws MalformedURLException {
		File testJar = getFileForProperty(fileProperty);
		assertNotNull("Library", testJar);
		assertTrue(testJar + " does not exist", testJar.exists());
		
		LibraryImporter importer = new LibraryImporter();
		ILibrary library = importer.createLibraryFor(testJar);
		assertNotNull("Library ", library);
		assertEquals("Library file", testJar, library.toFile());
		assertEquals("Library URL", testJar.toURL(), library.toURL());
		return library;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -