Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruslan #3

Open
wants to merge 4 commits into
base: hw_1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ repositories {

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.springframework', name: 'spring-test', version: '5.1.9.RELEASE'

compile group: 'org.projectlombok', name: 'lombok', version: '1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.8'
compile "org.springframework:spring-context:5.1.9.RELEASE"
Expand Down
23 changes: 16 additions & 7 deletions src/test/java/com/epam/spring/ContextTest.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
package com.epam.spring;

import com.epam.spring.config.TestConfig;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

/**
* hw1
* Load test application context
*
* hints: module - spring test, test runner classes
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = TestConfig.class)
public class ContextTest {

@Test
public void testContextLoads() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("testContext.xml");
assertNotNull(context);
}
@Autowired
private ApplicationContext ctx;

@Test
public void testContextLoads() {
assertTrue("There is no bean with testConfig name", ctx.containsBean("testConfig"));
}
}
7 changes: 7 additions & 0 deletions src/test/java/com/epam/spring/config/TestConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.epam.spring.config;

import org.springframework.context.annotation.Configuration;

@Configuration
public class TestConfig {
}