Source code (test) - Guide to Inheritance in Java
This commit is contained in:
parent
dffe5cb81d
commit
e789eaa9ae
|
@ -0,0 +1,46 @@
|
|||
package com.baeldung.inheritance;
|
||||
|
||||
import com.baeldung.inheritance.*;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class AppTest extends TestCase {
|
||||
|
||||
public AppTest(String testName) {
|
||||
super( testName );
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new TestSuite(AppTest.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public void testStaticMethodUsingBaseClassVariable() {
|
||||
Car first = new ArmoredCar();
|
||||
assertEquals("Car", first.msg());
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public void testStaticMethodUsingDerivedClassVariable() {
|
||||
ArmoredCar second = new ArmoredCar();
|
||||
assertEquals("ArmoredCar", second.msg());
|
||||
}
|
||||
|
||||
public void testAssignArmoredCarToCar() {
|
||||
Employee e1 = new Employee("Shreya", new ArmoredCar());
|
||||
assertNotNull(e1.getCar());
|
||||
}
|
||||
|
||||
public void testAssignSpaceCarToCar() {
|
||||
Employee e2 = new Employee("Paul", new SpaceCar());
|
||||
assertNotNull(e2.getCar());
|
||||
}
|
||||
|
||||
public void testBMWToCar() {
|
||||
Employee e3 = new Employee("Pavni", new BMW());
|
||||
assertNotNull(e3.getCar());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue