sirin05137 / CSE364_Project

2 stars 0 forks source link

JUnit Test #34

Closed yuujinleee closed 3 years ago

yuujinleee commented 3 years ago

image

계속 에러 발생. pom.xml 의 spring-boot-starter-parent 버전 문제로 보임. (하위 dependancy와 matching이 되지 않는 문제.. ?)

yuujinleee commented 3 years ago

https://stackoverflow.com/questions/25991831/problems-with-dependencies-for-spring-4-1-0-release-and-hibernate-4-3-6-final

yuujinleee commented 3 years ago

수정 전 - org.springframework.boot

mvn dependency:tree > tree.txt

[INFO] Group11:cse364-project:jar:1.0-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.0.2.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.0.2.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.2.RELEASE:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.19:runtime
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.0.2.RELEASE:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.12.0:compile
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.12.0:compile
[INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.9.Final:compile
[INFO] |  |  +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] |  |  \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] |  +- org.springframework:spring-web:jar:5.0.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:5.0.6.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.0.2.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.0.2.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.2.RELEASE:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] |  |  +- net.minidev:json-smart:jar:2.3:test
[INFO] |  |  |  \- net.minidev:accessors-smart:jar:1.2:test
[INFO] |  |  |     \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] |  +- org.assertj:assertj-core:jar:3.9.1:test
[INFO] |  +- org.mockito:mockito-core:jar:2.15.0:test
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.7.11:test
[INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.7.11:test
[INFO] |  |  \- org.objenesis:objenesis:jar:2.6:test
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  +- org.springframework:spring-test:jar:5.0.6.RELEASE:test
[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.5.1:test
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:2.0.2.RELEASE:runtime (optional) 
[INFO] |  +- org.springframework.boot:spring-boot:jar:2.0.2.RELEASE:compile
[INFO] |  \- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.2.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.2.RELEASE:compile
[INFO] |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.31:compile
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.31:compile
[INFO] |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.31:compile
[INFO] +- org.apache.tomcat.embed:tomcat-embed-jasper:jar:9.0.40:compile
[INFO] |  \- org.eclipse.jdt:ecj:jar:3.18.0:compile
[INFO] +- org.springframework:spring-core:jar:5.0.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-jcl:jar:5.0.6.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:5.0.6.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:5.0.6.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:5.0.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-expression:jar:5.0.6.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:5.0.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-jdbc:jar:5.0.6.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:5.0.6.RELEASE:compile
[INFO] +- org.json:json:jar:20180813:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.12.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.12.0:compile
[INFO] +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.12.0:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.20:provided
[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.2.0:compile
[INFO] |  +- org.apiguardian:apiguardian-api:jar:1.0.0:compile
[INFO] |  +- org.opentest4j:opentest4j:jar:1.1.0:compile
[INFO] |  \- org.junit.platform:junit-platform-commons:jar:1.2.0:compile
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.2.0:test
[INFO] |  \- org.junit.platform:junit-platform-engine:jar:1.2.0:test
[INFO] +- org.junit.platform:junit-platform-runner:jar:1.2.0:test
[INFO] |  +- org.junit.platform:junit-platform-launcher:jar:1.2.0:test
[INFO] |  +- org.junit.platform:junit-platform-suite-api:jar:1.2.0:test
[INFO] |  \- junit:junit:jar:4.12:test
[INFO] +- org.junit.jupiter:junit-jupiter-params:jar:5.2.0:test
[INFO] +- pl.pragmatists:JUnitParams:jar:1.1.1:test
[INFO] \- org.hamcrest:hamcrest-junit:jar:2.0.0.0:test
[INFO]    \- org.hamcrest:java-hamcrest:jar:2.0.0.0:test
yuujinleee commented 3 years ago

수정 후 - org.springframework

[INFO] --- maven-dependency-plugin:3.0.2:tree (default-cli) @ cse364-project ---
[INFO] Group11:cse364-project:jar:1.0-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.0.2.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.0.2.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.2.RELEASE:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.19:runtime
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.0.2.RELEASE:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.12.0:compile
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.12.0:compile
[INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.9.Final:compile
[INFO] |  |  +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] |  |  \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] |  +- org.springframework:spring-web:jar:5.0.6.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-beans:jar:5.0.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:5.0.6.RELEASE:compile
[INFO] |     +- org.springframework:spring-aop:jar:5.0.6.RELEASE:compile
[INFO] |     +- org.springframework:spring-context:jar:5.0.6.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:5.0.6.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.0.2.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.0.2.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.2.RELEASE:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] |  |  +- net.minidev:json-smart:jar:2.3:test
[INFO] |  |  |  \- net.minidev:accessors-smart:jar:1.2:test
[INFO] |  |  |     \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] |  +- org.assertj:assertj-core:jar:3.9.1:test
[INFO] |  +- org.mockito:mockito-core:jar:2.15.0:test
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.7.11:test
[INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.7.11:test
[INFO] |  |  \- org.objenesis:objenesis:jar:2.6:test
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  +- org.springframework:spring-core:jar:5.0.6.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-jcl:jar:5.0.6.RELEASE:compile
[INFO] |  +- org.springframework:spring-test:jar:5.0.6.RELEASE:test
[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.5.1:test
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:2.0.2.RELEASE:runtime (optional) 
[INFO] |  +- org.springframework.boot:spring-boot:jar:2.0.2.RELEASE:compile
[INFO] |  \- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.2.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.2.RELEASE:compile
[INFO] |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.31:compile
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.31:compile
[INFO] |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.31:compile
[INFO] +- org.apache.tomcat.embed:tomcat-embed-jasper:jar:9.0.40:compile
[INFO] |  \- org.eclipse.jdt:ecj:jar:3.18.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.12.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.12.0:compile
[INFO] +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.12.0:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.20:provided
[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.2.0:compile
[INFO] |  +- org.apiguardian:apiguardian-api:jar:1.0.0:compile
[INFO] |  +- org.opentest4j:opentest4j:jar:1.1.0:compile
[INFO] |  \- org.junit.platform:junit-platform-commons:jar:1.2.0:compile
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.2.0:test
[INFO] |  \- org.junit.platform:junit-platform-engine:jar:1.2.0:test
[INFO] +- org.junit.platform:junit-platform-runner:jar:1.2.0:test
[INFO] |  +- org.junit.platform:junit-platform-launcher:jar:1.2.0:test
[INFO] |  +- org.junit.platform:junit-platform-suite-api:jar:1.2.0:test
[INFO] |  \- junit:junit:jar:4.12:test
[INFO] +- org.junit.jupiter:junit-jupiter-params:jar:5.2.0:test
[INFO] +- pl.pragmatists:JUnitParams:jar:1.1.1:test
[INFO] \- org.hamcrest:hamcrest-junit:jar:2.0.0.0:test
[INFO]    \- org.hamcrest:java-hamcrest:jar:2.0.0.0:test
yuujinleee commented 3 years ago

https://stackoverflow.com/questions/39787328/junit-unit-test-cases-java-lang-noclassdeffounderror-org-apache-commons-logg

yuujinleee commented 3 years ago

https://stackoverflow.com/questions/18316857/maven-package-works-but-intellijs-build-fails mvn idea::idea ^_^

yuujinleee commented 3 years ago

image https://rok93.tistory.com/entry/cannot-access-javaxservletServletException-class-file-for-javaxservletServletException-not-found

yuujinleee commented 3 years ago

NoSuchMethodError always means that there are 2 libs with inconsistent versions.

yuujinleee commented 3 years ago

https://n1tjrgns.tistory.com/224 image

eventRepository 를 Mocking하지않는다. @SpringBootTest 로 변경 @WebMvcTest 는 Web과 관련된 빈들만 등록되기 때문에 EventRepository는 Bean으로 등록되지않는다. EventRepository 를 주입받을수 없다. WebEnvironment 속성의 기본값이 MOCK 이기 때문에 mocking된 Dispatcher Servlet을 만들도록 되어있다. MockMvc 를 사용하여 테스트가 가능하다.

@AutoConfigureMockMvc @WebMvcTest는 MockMvc설정을 자동으로 해주지만 @SpringBootTest는 그렇지않다. MockMvc 를 자동으로 등록해주는 @AutoConfigureMockMvc 를 사용한다. Web과 관련된 테스트시 @SpringBootTest를 사용하자 @WebMvcTest 를 사용하면 Mocking해야할 객체가 너무 많다.

https://ncucu.me/64