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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
package org.apache.directory.studio.test.integration.ui;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.CONTEXT_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRALS_DN;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.name.Rdn;
import org.apache.directory.studio.test.integration.junit5.SkipTestIfLdapServerIsNotAvailableInterceptor;
import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.bots.ApacheDSServersViewBot;
import org.apache.directory.studio.test.integration.ui.bots.BrowserViewBot;
import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
import org.apache.directory.studio.test.integration.ui.bots.ModificationLogsViewBot;
import org.apache.directory.studio.test.integration.ui.bots.SearchLogsViewBot;
import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
import org.apache.directory.studio.test.integration.ui.utils.Assertions;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.junit5.SWTBotJunit5Extension;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
@ExtendWith(
{ SWTBotJunit5Extension.class, SkipTestIfLdapServerIsNotAvailableInterceptor.class })
public class AbstractTestBase
{
protected SWTWorkbenchBot bot;
protected StudioBot studioBot;
protected ConnectionsViewBot connectionsViewBot;
protected BrowserViewBot browserViewBot;
protected SearchLogsViewBot searchLogsViewBot;
protected ModificationLogsViewBot modificationLogsViewBot;
protected ApacheDSServersViewBot serversViewBot;
@BeforeEach
final void setUpBase() throws Exception
{
bot = new SWTWorkbenchBot();
studioBot = new StudioBot();
studioBot.resetLdapPerspective();
connectionsViewBot = studioBot.getConnectionView();
browserViewBot = studioBot.getBrowserView();
searchLogsViewBot = studioBot.getSearchLogsViewBot();
modificationLogsViewBot = studioBot.getModificationLogsViewBot();
serversViewBot = studioBot.getApacheDSServersViewBot();
}
@AfterEach
final void tearDownBase() throws Exception
{
connectionsViewBot.deleteTestConnections();
serversViewBot.deleteTestServers();
Assertions.genericTearDownAssertions();
}
public static final String[] ROOT_DSE_PATH =
{ "DIT", "Root DSE" };
public static final String[] CONTEXT_PATH = path( ROOT_DSE_PATH, CONTEXT_DN.getName() );
public static String[] path( String[] parents, String leaf )
{
return ArrayUtils.addAll( parents, leaf );
}
/**
* Gets the path to the DN in the LDAP browser tree.
* The path starts with "DIT", "Root DSE", and the context entry.
*/
public static String[] path( Dn dn )
{
List<String> l = new ArrayList<>();
l.addAll( Arrays.asList( CONTEXT_PATH ) );
List<Rdn> rdns = dn.getRdns();
for ( int i = rdns.size() - 3; i >= 0; i-- )
{
l.add( rdns.get( i ).getName() );
}
return l.toArray( new String[0] );
}
/**
* Gets the path to the RDN below the DN in the LDAP browser tree.
* The path starts with "DIT", "Root DSE", and the context entry.
*/
public static String[] path( Dn dn, Rdn rdn )
{
return path( dn, rdn.getName() );
}
/**
* Gets the path to the leaf below the DN in the LDAP browser tree.
* The path starts with "DIT", "Root DSE", and the context entry.
*/
public static String[] path( Dn dn, String... leaf )
{
return ArrayUtils.addAll( path( dn ), leaf );
}
public static String[] pathWithRefLdapUrl( TestLdapServer ldapServer, Dn dn )
{
String leaf = ldapServer.getLdapUrl() + "/" + dn.getName();
return path( REFERRALS_DN, leaf );
}
}
|