package com.gjz.spring.test;

import com.gjz.spring.pojo.HelloWorld;
import com.gjz.spring.pojo.Student;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class HelloWorldTest {
    @Test
    public void test(){
        //获取ioc容器
        ApplicationContext ioc = new ClassPathXmlApplicationContext("applicationContext.xml");
        //获取ioc容器中的bean对象
        HelloWorld hello1 = (HelloWorld) ioc.getBean("hello1");
        hello1.sayHello();


    }

    @Test
    public void testDI(){
        //获取ioc容器
        ApplicationContext ioc = new ClassPathXmlApplicationContext("applicationContext.xml");
        //获取ioc容器中的bean对象
        Student studentTwo = ioc.getBean("studentTwo", Student.class);
        System.out.println(studentTwo);


    }

    @Test
    public void testDiCons(){
        //获取ioc容器
        ApplicationContext ioc = new ClassPathXmlApplicationContext("applicationContext.xml");
        //获取ioc容器中的bean对象
        Student studentTwo = ioc.getBean("studentThree", Student.class);
        System.out.println(studentTwo);


    }
}
