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

📄 motoroladeviceimportertestcase.java

📁 eclipseme的最新版本的source,欢迎j2me程序员使用
💻 JAVA
字号:
/**
 * Copyright (c) 2003-2006 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.toolkit.motorola.impl;

import java.io.File;
import java.io.FileFilter;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;

import org.eclipse.core.runtime.NullProgressMonitor;

import eclipseme.core.model.AbstractCoreTestCase;
import eclipseme.core.model.device.IDevice;

/**
 * Testcases for the Siemens Device Importer
 * <p />
 * Copyright (c) 2003-2006 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.1 $
 * <br>
 * $Date: 2006/02/11 21:26:47 $
 * <br>
 * @author Craig Setera
 */
public class MotorolaDeviceImporterTestCase extends AbstractCoreTestCase {
	public void testMotorolaDeviceImport()
		throws Exception
	{
		File path = getFileForProperty("motorola.path");
		MotorolaDeviceImporter importer = new MotorolaDeviceImporter();
		
		ArrayList devices = new ArrayList();
		addMatchingDevices(devices, importer, path);
		assertTrue("Expected to find at least one device", devices.size() > 0);
	}
	
	/**
	 * Recursively search for any available devices in the specified
	 * path.
	 * 
	 * @param devices
	 * @param importer
	 */
	private void addMatchingDevices(ArrayList devices, MotorolaDeviceImporter importer, File path) {
		IDevice[] matchingDevices = importer.getMatchingDevices(path, new NullProgressMonitor());
		if (matchingDevices != null) {
			devices.addAll(Arrays.asList(matchingDevices));
		}
		
		File[] subdirs = path.listFiles(new FileFilter() {
			public boolean accept(File pathname) {
				return pathname.isDirectory();
			}
		});
		
		for (int i = 0; i < subdirs.length; i++) {
			addMatchingDevices(devices, importer, subdirs[i]);
		}
	}

	/**
	 * Load the test properties into the system properties. 
	 */
	protected void loadProperties() {
		super.loadProperties();
		InputStream is = MotorolaDeviceImporterTestCase.class.getResourceAsStream("motorola_test.properties");
		loadProperties(is);
	}

}

⌨️ 快捷键说明

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