Skip to content

Commit

Permalink
2022-12-26-Mon-20:08 Converted into Xml
Browse files Browse the repository at this point in the history
  • Loading branch information
liberalwig committed Dec 26, 2022
1 parent f1783be commit f9cd877
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/main/resources/appConfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="memberService" class="hello.core.member.MemberServiceImpl">
<constructor-arg name="memberRepository" ref="memberRepository" />
</bean>

<bean id="memberRepository" class="hello.core.member.MemoryMemberRepository"/>

<bean id="orderService" class="hello.core.order.OrderServiceImpl">
<constructor-arg name="memberRepository" ref="memberRepository"/>
<constructor-arg name="discountPolicy" ref="discountPolicy"/>
</bean>

<bean id="discountPolicy" class="hello.core.discount.RateDiscountPolicy"/>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,4 @@ public DiscountPolicy fixDiscountPolicy() {
return new FixDiscountPolicy();
}
}


}
19 changes: 19 additions & 0 deletions src/test/java/hello/core/xml/XmlAppContext.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package hello.core.xml;

import hello.core.member.MemberService;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;

import static org.assertj.core.api.Assertions.assertThat;

public class XmlAppContext {

@Test
void xmlAppContext() {
ApplicationContext ac = new GenericXmlApplicationContext("appConfig.xml");
MemberService memberService = ac.getBean("memberService", MemberService.class);
assertThat(memberService).isInstanceOf(MemberService.class);
}
}

0 comments on commit f9cd877

Please sign in to comment.