spring-test/lombok/log4j/Junit 라이브러리 추가
- 라이브러리추가(pom.xml) -spring-test -lombok -log4j - 라이브러리 버전 변경(pom.xml) -Junit 4.7 => 4.12 - 의존성 주입 테스트 - com.vam.sample 패키지 생성 - Chef.java / Restaurant.java 생성 - 테스트 위한 클래스 생성 - SampleTests.java 생성
This commit is contained in:
@@ -58,7 +58,7 @@
|
||||
<version>${org.slf4j-version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.15</version>
|
||||
@@ -81,6 +81,33 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>runtime</scope>
|
||||
</dependency> -->
|
||||
|
||||
<!-- log4j 추가 -->
|
||||
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- spring-test 추가 -->
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${org.springframework-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- @Inject -->
|
||||
@@ -113,7 +140,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.7</version>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
11
VamPa/src/main/java/com/vam/sample/Chef.java
Normal file
11
VamPa/src/main/java/com/vam/sample/Chef.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.vam.sample;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Component
|
||||
@Data
|
||||
public class Chef {
|
||||
|
||||
}
|
||||
16
VamPa/src/main/java/com/vam/sample/Restaurant.java
Normal file
16
VamPa/src/main/java/com/vam/sample/Restaurant.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.vam.sample;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Setter;
|
||||
|
||||
@Component
|
||||
@Data
|
||||
public class Restaurant {
|
||||
|
||||
@Setter(onMethod_=@Autowired)
|
||||
private Chef chef;
|
||||
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
<?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 https://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
|
||||
|
||||
<context:component-scan base-package="com.vam.sample"></context:component-scan>
|
||||
|
||||
<!-- Root Context: defines shared resources visible to all other web components -->
|
||||
|
||||
</beans>
|
||||
|
||||
32
VamPa/src/test/java/com/vam/sample/SampleTests.java
Normal file
32
VamPa/src/test/java/com/vam/sample/SampleTests.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.vam.sample;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import lombok.extern.log4j.Log4j;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
|
||||
@Log4j
|
||||
public class SampleTests {
|
||||
|
||||
@Autowired
|
||||
private Restaurant restaurant;
|
||||
|
||||
@Test
|
||||
public void textExit() {
|
||||
|
||||
assertNotNull(restaurant);
|
||||
|
||||
log.info(restaurant);;
|
||||
log.info("-------------------------------");
|
||||
log.info(restaurant.getChef());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Fri Aug 07 23:14:14 KST 2020
|
||||
#Fri Aug 07 23:47:48 KST 2020
|
||||
version=1.0.0-BUILD-SNAPSHOT
|
||||
groupId=com.vam
|
||||
m2e.projectName=VamPa
|
||||
m2e.projectLocation=D\:\\Blog_Project\\VamPa
|
||||
m2e.projectLocation=C\:\\Users\\sjinj\\git\\blog_project\\VamPa
|
||||
artifactId=controller
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<version>${org.slf4j-version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.15</version>
|
||||
@@ -81,6 +81,33 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>runtime</scope>
|
||||
</dependency> -->
|
||||
|
||||
<!-- log4j 추가 -->
|
||||
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- spring-test 추가 -->
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${org.springframework-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- @Inject -->
|
||||
@@ -113,7 +140,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.7</version>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<version>${org.slf4j-version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.15</version>
|
||||
@@ -81,6 +81,33 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>runtime</scope>
|
||||
</dependency> -->
|
||||
|
||||
<!-- log4j 추가 -->
|
||||
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- spring-test 추가 -->
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${org.springframework-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- @Inject -->
|
||||
@@ -113,7 +140,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.7</version>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
11
VamPa_MySQL/src/main/java/com/vam/sample/Chef.java
Normal file
11
VamPa_MySQL/src/main/java/com/vam/sample/Chef.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.vam.sample;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Component
|
||||
@Data
|
||||
public class Chef {
|
||||
|
||||
}
|
||||
16
VamPa_MySQL/src/main/java/com/vam/sample/Restaurant.java
Normal file
16
VamPa_MySQL/src/main/java/com/vam/sample/Restaurant.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.vam.sample;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Setter;
|
||||
|
||||
@Component
|
||||
@Data
|
||||
public class Restaurant {
|
||||
|
||||
@Setter(onMethod_=@Autowired)
|
||||
private Chef chef;
|
||||
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
<?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 https://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
|
||||
|
||||
<!-- Root Context: defines shared resources visible to all other web components -->
|
||||
<context:component-scan base-package="com.vam.sample"></context:component-scan>
|
||||
|
||||
</beans>
|
||||
|
||||
33
VamPa_MySQL/src/test/java/com/vam/sample/SampleTests.java
Normal file
33
VamPa_MySQL/src/test/java/com/vam/sample/SampleTests.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.vam.sample;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import lombok.extern.log4j.Log4j;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
|
||||
@Log4j
|
||||
public class SampleTests {
|
||||
|
||||
@Autowired
|
||||
private Restaurant restaurant;
|
||||
|
||||
@Test
|
||||
public void textExit() {
|
||||
|
||||
assertNotNull(restaurant);
|
||||
|
||||
log.info(restaurant);
|
||||
log.info("-----------------------------------");
|
||||
log.info(restaurant.getChef());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Fri Aug 07 23:14:53 KST 2020
|
||||
#Fri Aug 07 23:49:01 KST 2020
|
||||
version=1.0.0-BUILD-SNAPSHOT
|
||||
groupId=com.vam
|
||||
m2e.projectName=VamPa_MySQL
|
||||
m2e.projectLocation=D\:\\Blog_Project\\VamPa_MySQL
|
||||
m2e.projectLocation=C\:\\Users\\sjinj\\git\\blog_project\\VamPa_MySQL
|
||||
artifactId=controller
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<version>${org.slf4j-version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.15</version>
|
||||
@@ -81,6 +81,33 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>runtime</scope>
|
||||
</dependency> -->
|
||||
|
||||
<!-- log4j 추가 -->
|
||||
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- spring-test 추가 -->
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${org.springframework-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- @Inject -->
|
||||
@@ -113,7 +140,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.7</version>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
Reference in New Issue
Block a user