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

📄 waddatatests.java

📁 一个基于PlaceLab的室内和室外的智能导航系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/** * For these tests to succeed, you'll need to have my test map wads * in testdata/WadDataTests/.  You can set where I look for the testdata * directory by setting the test_data_dir key in your placelab.ini */package org.placelab.demo.mapview;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.util.Hashtable;import org.eclipse.swt.graphics.ImageData;import org.placelab.mapper.JDBMMapper;import org.placelab.test.TestResult;import org.placelab.test.Testable;public class WadDataTests implements Testable {	// bad wads	private String missingMapImage = "badwad1.mapwad";	private String missingPlaceImage = "badwad2.mapwad";	private String malformedMapIndex = "badwad3.mapwad";	private String wrongSectionMapIndex = "badwad4.mapwad";	private String malformedPlaceIndex = "badwad5.mapwad";	private String wrongSectionPlaceIndex = "badwad6.mapwad";	private String missingMapMeta = "badwad7.mapwad";	private String missingPlaceSet = "badwad8.mapwad";	private String malformedMapMeta = "badwad9.mapwad";	private String malformedPlaceSet = "badwad10.mapwad";	private String malformedDefaults = "badwad11.mapwad";		// good wads	private String noAPCache = "goodwad1.mapwad";	private String noMapIndex = "goodwad2.mapwad";	private String noPlaceIndex = "goodwad3.mapwad";	private String apsMapsAndPlaces = "goodwad4.mapwad";	private String withDefaults = "goodwad5.mapwad";	private String fromDirectory = "wadbase";	private String twoOrigins = "goodwad7.mapwad";		private String testDataDir;	public String getName() {		return "WadDataTests";	}	public void runTests(TestResult result) throws Throwable {		testDataDir = DemoTestsUtil.getTestDataSubDir(this, result, "WadDataTests");		if(testDataDir == null) return;		missingMapImage = testDataDir + missingMapImage;		missingPlaceImage = testDataDir + missingPlaceImage;		malformedMapIndex = testDataDir + malformedMapIndex;		wrongSectionMapIndex = testDataDir + wrongSectionMapIndex;		malformedPlaceIndex = testDataDir + malformedPlaceIndex;		wrongSectionPlaceIndex = testDataDir + wrongSectionPlaceIndex;		missingMapMeta = testDataDir + missingMapMeta;		missingPlaceSet = testDataDir + missingPlaceSet;		malformedMapMeta = testDataDir + malformedMapMeta;		malformedPlaceSet = testDataDir + malformedPlaceSet;		malformedDefaults = testDataDir + malformedDefaults;				noAPCache = testDataDir + noAPCache;		noMapIndex = testDataDir + noMapIndex;		noPlaceIndex = testDataDir + noPlaceIndex;		apsMapsAndPlaces = testDataDir + apsMapsAndPlaces;		withDefaults = testDataDir + withDefaults;		fromDirectory = testDataDir + fromDirectory;		twoOrigins = testDataDir + twoOrigins;				failTests(result);		succeedTests(result);	}		// tests things that should fail	private void failTests(TestResult result) {		missingMapImage(result);		missingPlaceImage(result);		malformedMapIndex(result);		wrongSectionMapIndex(result);		malformedPlaceIndex(result);		wrongSectionPlaceIndex(result);		missingMapMeta(result);		missingPlaceSet(result);		malformedMapMeta(result);		malformedPlaceSet(result);		malformedDefaults(result);	}	private void missingMapImage(TestResult result) {		WadData wad = null;		try {			wad = new WadData(missingMapImage);		} catch (WadDataFormatException wdfe) {			result.assertTrue(this, WadDataFormatException.MISSING_RESOURCE_ERROR,					wdfe.failCode(), "missing map image error code check");			result.assertTrue(this, "images/greatmap.gif", wdfe.badEntryLocation(),				"missing map image entry location check");			return;		} catch (Exception e) {			result.errorCaught(this, e);			result.print("^^ in missingMapImage: " + e.toString());			return;		}		result.fail(this, "a missing map image didn't throw an exception");	}	private void missingPlaceImage(TestResult result) {		WadData wad = null;		try {			wad = new WadData(missingPlaceImage);		} catch (WadDataFormatException wdfe) {			result.assertTrue(this, WadDataFormatException.MISSING_RESOURCE_ERROR,					wdfe.failCode(), "missing place image error code check");			result.assertTrue(this, "images/myhouse.gif", wdfe.badEntryLocation(),				"missing place image entry location check");			return;		} catch (Exception e) {			result.errorCaught(this, e);			result.print("^^ in missingPlaceImage: " + e.toString());			return;		}		result.fail(this, "a missing place image didn't throw an exception");	}	private void malformedMapIndex(TestResult result) {		WadData wad = null;		try {			wad = new WadData(malformedMapIndex);		} catch(WadDataFormatException wdfe) {			result.assertTrue(this, WadDataFormatException.BAD_RESOURCE_ERROR,					wdfe.failCode(), "malformed map index check");			result.assertTrue(this, "maps/maps.index", wdfe.badEntryLocation(),				"malformed map index entry location check");			return;		} catch(Exception e) {			result.errorCaught(this, e);			result.print("^^ in malformedMapIndex: " + e.toString());			return;		}		result.fail(this, "a malformed map index didn't throw an exception");	}	private void wrongSectionMapIndex(TestResult result) {		WadData wad = null;		try {			wad = new WadData(wrongSectionMapIndex);		} catch(WadDataFormatException wdfe) {			result.assertTrue(this, WadDataFormatException.BAD_RESOURCE_ERROR,					wdfe.failCode(), "wrong section map index check");			result.assertTrue(this, "maps/maps.index", wdfe.badEntryLocation(),				"wrong section map index entry location check");			return;		} catch(Exception e) {			result.errorCaught(this, e);			result.print("^^ in wrongSectionMapIndex: " + e.toString());			return;		}		result.fail(this, "a wrong section map index didn't throw an exception");	}	private void malformedPlaceIndex(TestResult result) {		WadData wad = null;		try {			wad = new WadData(malformedPlaceIndex);		} catch(WadDataFormatException wdfe) {			result.assertTrue(this, WadDataFormatException.BAD_RESOURCE_ERROR,					wdfe.failCode(), "malformed place index check");			result.assertTrue(this, "places/places.index", wdfe.badEntryLocation(),				"malformed place index entry location check");			return;		} catch(Exception e) {			result.errorCaught(this, e);			result.print("^^ in malformedPlaceIndex: " + e.toString());			return;		}		result.fail(this, "a malformed place index didn't throw an exception");	}	private void wrongSectionPlaceIndex(TestResult result) {		WadData wad = null;		try {			wad = new WadData(wrongSectionPlaceIndex);		} catch(WadDataFormatException wdfe) {			result.assertTrue(this, WadDataFormatException.BAD_RESOURCE_ERROR,					wdfe.failCode(), "wrong section place index error code check");			result.assertTrue(this, "places/places.index", wdfe.badEntryLocation(),					"wrong section place index entry location check");			return;		} catch(Exception e) {			result.errorCaught(this, e);			result.print("^^ in wrongSectionPlaceIndex: " + e.toString());			return;		}		result.fail(this, "a wrong section place index didn't throw an exception");	}	private void missingMapMeta(TestResult result) {		WadData wad = null;		try {			wad = new WadData(missingMapMeta);		} catch(WadDataFormatException wdfe) {			result.assertTrue(this, WadDataFormatException.MISSING_RESOURCE_ERROR,					wdfe.failCode(), "missing map meta error code check");			result.assertTrue(this, "maps/greatmap.meta", wdfe.badEntryLocation(),					"missing map meta entry location check");			return;		} catch(Exception e) {			result.errorCaught(this, e);			result.print("^^ in missingMapMeta: " + e.toString());			return;		}		result.fail(this, "a missing map meta didn't throw an exception");	}	private void missingPlaceSet(TestResult result) {		WadData wad = null;		try {			wad = new WadData(missingPlaceSet);		} catch(WadDataFormatException wdfe) {			result.assertTrue(this, WadDataFormatException.MISSING_RESOURCE_ERROR,					wdfe.failCode(), "missing place set error code check");			result.assertTrue(this, "places/lame.txt", wdfe.badEntryLocation(),					"missing place set entry location check");			return;		} catch(Exception e) {			result.errorCaught(this, e);			result.print("^^ in missingPlaceSetMeta: " + e.toString());			return;		}		result.fail(this, "a missing place set meta didn't throw an exception");	}	private void malformedMapMeta(TestResult result) {		WadData wad = null;		try {

⌨️ 快捷键说明

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