FileDocCategorySizeDatePackage
TestLandmark.javaAPI DocphoneME MR2 API (J2ME)4135Wed May 02 18:00:40 BST 2007com.sun.j2me.location

TestLandmark

public class TestLandmark extends com.sun.midp.i3test.TestCase
Tests for Landmark implementation.

Fields Summary
Constructors Summary
Methods Summary
voidTest1()
Body of the test 1. This test emulates a situation when the name is null when Landmark is created. Should be caused a NullPointerException.

	    QualifiedCoordinates testCoord = new QualifiedCoordinates(
	        0, 0, 0f, 0f, 0f);
	    AddressInfo testAddr = new AddressInfo();
	    try {
		Landmark testLandmark = new Landmark(null, "Descr",
		    testCoord, testAddr);
		fail("NullPointerException wasn't caused");
	    } catch (java.lang.NullPointerException e) {
	        assertTrue("NullPointerException was caused", true);
	    } catch (Throwable e) {
		fail("Wrong exception was caused");
	    }
    
voidTest2()
Body of the test 2. This test sets and checks the name of landmark.

        QualifiedCoordinates testCoord = new QualifiedCoordinates(
	    0, 0, 0f, 0f, 0f);
	AddressInfo testAddr = new AddressInfo();
	Landmark testLandmark = new Landmark("testName", "Descr",
	    testCoord, testAddr);
	assertTrue(testLandmark.getName() == "testName");
    
voidTest3()
Body of the test 3. This test sets and checks the description of landmark.

        QualifiedCoordinates testCoord = new QualifiedCoordinates(
	    0, 0, 0f, 0f, 0f);
	AddressInfo testAddr = new AddressInfo();
	Landmark testLandmark = new Landmark("Name", "testDescr",
	    testCoord, testAddr);
	assertTrue(testLandmark.getDescription() == "testDescr");
    
voidTest4()
Body of the test 4. This test sets and checks the coordinates of landmark.

        QualifiedCoordinates testCoord = new QualifiedCoordinates(
	    1, 2, 3f, 4f, 5f);
	AddressInfo testAddr = new AddressInfo();
	Landmark testLandmark = new Landmark("Name", "testDescr",
	    testCoord, testAddr);
	QualifiedCoordinates savedCoord = 
	    testLandmark.getQualifiedCoordinates();
	assertTrue(savedCoord.getLatitude() ==
	    testCoord.getLatitude());
	assertTrue(savedCoord.getLongitude() ==
	    testCoord.getLongitude());
	assertTrue(savedCoord.getAltitude() ==
	    testCoord.getAltitude());
	assertTrue(savedCoord.getHorizontalAccuracy() ==
	    testCoord.getHorizontalAccuracy());
	assertTrue(savedCoord.getVerticalAccuracy() ==
	    testCoord.getVerticalAccuracy());
    
public voidrunTests()
Tests execute

        declare("Name is null when landmark is created");
	Test1();
        declare("Set/get name");
	Test2();
        declare("Set/get description");
	Test3();
        declare("Set/get coordinates");
	Test4();