Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eclipse Projects
Eclipse openK User Modules
org.eclipse.openk-usermodules.gridFailureInformation.backend
Commits
ebba72ad
Commit
ebba72ad
authored
Mar 23, 2020
by
Simon Reis
Browse files
SI-158 Tests update
parent
91e5c3cf
Changes
5
Hide whitespace changes
Inline
Side-by-side
gfsBackendService/pom.xml
View file @
ebba72ad
...
...
@@ -127,6 +127,10 @@
<groupId>
org.junit.vintage
</groupId>
<artifactId>
junit-vintage-engine
</artifactId>
</exclusion>
<exclusion>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
...
...
gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/EmailControllerTest.java
View file @
ebba72ad
...
...
@@ -15,31 +15,21 @@
package
org.eclipse.openk.gridfailureinformation.controller
;
import
org.eclipse.openk.gridfailureinformation.GridFailureInformationApplication
;
import
org.eclipse.openk.gridfailureinformation.exceptions.InternalServerErrorException
;
import
org.eclipse.openk.gridfailureinformation.service.EmailService
;
import
org.eclipse.openk.gridfailureinformation.service.StatusService
;
import
org.eclipse.openk.gridfailureinformation.support.MockDataHelper
;
import
org.eclipse.openk.gridfailureinformation.viewmodel.StatusDto
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
javax.mail.MessagingException
;
import
java.util.List
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
GridFailureInformationApplication
.
class
)
@AutoConfigureMockMvc
@ActiveProfiles
(
"test"
)
...
...
gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/email/EmailManagerTest.java
View file @
ebba72ad
...
...
@@ -19,28 +19,22 @@ import com.icegreen.greenmail.util.GreenMail;
import
com.icegreen.greenmail.util.ServerSetup
;
import
org.eclipse.openk.gridfailureinformation.GridFailureInformationApplication
;
import
org.eclipse.openk.gridfailureinformation.config.EmailConfig
;
import
org.eclipse.openk.gridfailureinformation.config.TestConfiguration
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
javax.mail.MessagingException
;
import
java.io.IOException
;
import
java.net.ServerSocket
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertThrows
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
GridFailureInformationApplication
.
class
)
@ContextConfiguration
(
classes
=
{
TestConfiguration
.
class
})
@ActiveProfiles
(
"test"
)
public
class
EmailManagerTest
{
...
...
@@ -65,19 +59,19 @@ public class EmailManagerTest {
@Autowired
private
EmailConfig
emailConfig
;
@Before
Class
public
static
void
beforeAll
()
throws
IOException
{
@Before
All
public
static
void
beforeAll
()
{
ServerSetup
serverSetup
=
new
ServerSetup
(
3025
,
"localhost"
,
ServerSetup
.
PROTOCOL_SMTP
);
serverSetup
.
setServerStartupTimeout
(
3000
);
mailServer
=
new
GreenMail
(
serverSetup
);
}
@Before
@Before
Each
public
void
beforeTest
()
{
mailServer
.
start
();
}
@After
@After
Each
public
void
afterTest
()
{
mailServer
.
stop
();
}
...
...
@@ -89,27 +83,27 @@ public class EmailManagerTest {
assertTrue
(
emailSent
);
}
@Test
(
expected
=
MessagingException
.
class
)
@Test
public
void
testSendMail_nok
()
throws
Exception
{
mailServer
.
stop
();
EmailManager
emailManager
=
new
GfiEmail
(
null
,
"emailConfigurationTest/emailTemplates/appliedEmailTemplateTest.txt"
,
false
,
this
.
emailConfig
);
emailManager
.
sendEmail
(
);
assertThrows
(
MessagingException
.
class
,
emailManager
:
:
sendEmail
);
}
@Test
(
expected
=
MessagingException
.
class
)
@Test
public
void
testSendMail_invalidRecipient
()
throws
Exception
{
EmailManager
emailManager
=
new
GfiEmail
(
null
,
"emailConfigurationTest/emailTemplates/emailTemplateTestFehlerRecipient.txt"
,
false
,
this
.
emailConfig
);
emailManager
.
sendEmail
(
);
assertThrows
(
MessagingException
.
class
,
emailManager
:
:
sendEmail
);
}
@Test
(
expected
=
MessagingException
.
class
)
@Test
public
void
testSendMail_invalidSender
()
throws
Exception
{
EmailConfig
emailConfig
=
new
EmailConfig
();
emailConfig
.
setSmtpHost
(
"localhost"
);
emailConfig
.
setEmailPort
(
"3025"
);
emailConfig
.
setSender
(
"testCaseSendertest.de"
);
EmailManager
emailManager
=
new
GfiEmail
(
null
,
"emailConfigurationTest/emailTemplates/emailTemplateTestFehlerRecipient.txt"
,
false
,
emailConfig
);
emailManager
.
sendEmail
(
);
assertThrows
(
MessagingException
.
class
,
emailManager
:
:
sendEmail
);
}
}
gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/EmailServiceTest.java
View file @
ebba72ad
...
...
@@ -16,38 +16,20 @@ package org.eclipse.openk.gridfailureinformation.service;
import
com.icegreen.greenmail.util.GreenMail
;
import
com.icegreen.greenmail.util.ServerSetup
;
import
com.icegreen.greenmail.util.ServerSetupTest
;
import
org.eclipse.openk.gridfailureinformation.GridFailureInformationApplication
;
import
org.eclipse.openk.gridfailureinformation.config.TestConfiguration
;
import
org.eclipse.openk.gridfailureinformation.model.RefBranch
;
import
org.eclipse.openk.gridfailureinformation.repository.BranchRepository
;
import
org.eclipse.openk.gridfailureinformation.support.MockDataHelper
;
import
org.eclipse.openk.gridfailureinformation.viewmodel.BranchDto
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
javax.mail.MessagingException
;
import
java.io.IOException
;
import
java.util.List
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
GridFailureInformationApplication
.
class
)
@ContextConfiguration
(
classes
=
{
TestConfiguration
.
class
})
@ActiveProfiles
(
"test"
)
public
class
EmailServiceTest
{
...
...
@@ -56,19 +38,19 @@ public class EmailServiceTest {
private
static
GreenMail
mailServer
;
@Before
Class
public
static
void
beforeAll
()
throws
IOException
{
@Before
All
public
static
void
beforeAll
()
{
ServerSetup
serverSetup
=
new
ServerSetup
(
3025
,
"localhost"
,
ServerSetup
.
PROTOCOL_SMTP
);
serverSetup
.
setServerStartupTimeout
(
3000
);
mailServer
=
new
GreenMail
(
serverSetup
);
}
@Before
@Before
Each
public
void
beforeTest
()
{
mailServer
.
start
();
}
@After
@After
Each
public
void
afterTest
()
{
mailServer
.
stop
();
}
...
...
gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/util/ResourceLoaderBaseTest.java
View file @
ebba72ad
...
...
@@ -15,7 +15,8 @@
package
org.eclipse.openk.gridfailureinformation.util
;
import
org.junit.Test
;
import
org.junit.jupiter.api.Test
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment