-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSampleIntegrationTest.java
54 lines (44 loc) · 2.2 KB
/
SampleIntegrationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.merkle.oss.magnolia.testing;
import static io.smallrye.common.constraint.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.magnolia.context.MgnlContext;
import info.magnolia.objectfactory.Components;
import info.magnolia.repository.RepositoryConstants;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import com.merkle.oss.magnolia.testing.repository.Repository;
@ExtendWith(MagnoliaIntegrationTestExtension.class)
class SampleIntegrationTest {
@Test
void moduleStart() {
final SomeModule someModule = Components.getComponent(SomeModule.class);
assertTrue(someModule.isStarted());
}
@Repository(workspaces = {@Repository.Workspace(name = RepositoryConstants.WEBSITE, xml = "jcr.xml")})
@Test
void someMethod() throws RepositoryException {
final Session session = MgnlContext.getJCRSession(RepositoryConstants.WEBSITE);
final Node node = session.getRootNode().getNode("0");
final SomeInterface someInterface = Components.getComponent(SomeInterface.class);
assertEquals("some value 42!", someInterface.someMethod(node));
}
@Repository(workspaces = {@Repository.Workspace(name = RepositoryConstants.WEBSITE, xml = "jcr-custom-nodetype.xml")})
@Test
void customNodeType() throws RepositoryException {
final Session session = MgnlContext.getJCRSession(RepositoryConstants.WEBSITE);
final Node node = session.getRootNode().getNode("0");
final SomeInterface someInterface = Components.getComponent(SomeInterface.class);
assertEquals("some value 42!", someInterface.someMethod(node));
}
@Repository(workspaces = {@Repository.Workspace(name = "testing", xml = "jcr.xml")})
@Test
void customWorkspace() throws RepositoryException {
final Session session = MgnlContext.getJCRSession("testing");
final Node node = session.getRootNode().getNode("0");
final SomeInterface someInterface = Components.getComponent(SomeInterface.class);
assertEquals("some value 42!", someInterface.someMethod(node));
}
}