package verwaltung.test;

import java.lang.annotation.Annotation;
import java.lang.reflect.*;

import junit.framework.TestCase;
import verwaltung.*;
import verwaltung.annotation.*;

public class PersonTest extends TestCase {
	
	static private Person hugo = null;

	public static void main(String[] args) {
		junit.textui.TestRunner.run(PersonTest.class);
	}

	protected void setUp() throws Exception {
		if (hugo == null) {
			hugo = new Person("Hugo");
		}
	}

	/*
	 * Test method for 'verwaltung.Person.Person(String)'
	 */
	public void testPerson() {
		assertNotNull(hugo);
	}

	/**
	 * Test method for 'verwaltung.Person.setName(String)'
	 */
	public void testSetName() {
		hugo.setName("Boss");
		//assertEquals("Boss", hugo.getName());
	}
	
	/**
	 * Was passiert, wenn ein Null-Parameter uebergeben wird?
	 */
	public void testSetNullName() {
		hugo.setName(null);
        hugo.setName("Hase");
	}

	/*
	 * Test method for 'verwaltung.Person.run()'
	 */
	public void xxxtestRun() {
	    hugo.run();
	}
    
    public void testLifeStyleAnnotation() {
        Class<Person> cl = Person.class;
        Annotation a = cl.getAnnotation(LifeStyle.class);
        assertNotNull("Person has no @LifeStyle", a);
    }
    
    public void testWorkStyleAnnotation() throws SecurityException,
            NoSuchMethodException {
        Method m = Person.class.getMethod("arbeite");
        Annotation a = m.getAnnotation(WorkStyle.class);
        assertNotNull("Person.arbeite() has no @WorkStyle", a);
    }

    public void testArchiviertAnnotation() throws SecurityException,
            NoSuchFieldException {
        Field f = Person.class.getField("name");
        Annotation a = f.getAnnotation(Archiviert.class);
        assertNotNull("Person.name has no @Archiviert", a);
    }

}
