/
TestOpenDjDumber.java
109 lines (89 loc) · 3.59 KB
/
TestOpenDjDumber.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
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
/*
* Copyright (c) 2016-2018 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.provisioning.impl.opendj;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.assertEquals;
import java.io.File;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import com.evolveum.midpoint.schema.internals.InternalCounters;
import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import org.testng.annotations.Test;
/**
* Test for provisioning service implementation using embedded OpenDj instance.
* This is the same test as TestOpenDj, but the OpenDJ resource configuration is
* somehow dumber: no shortcut in associations, explicit duplicity checks, etc.
*
* @author Radovan Semancik
*/
@ContextConfiguration(locations = "classpath:ctx-provisioning-test-main.xml")
@DirtiesContext
public class TestOpenDjDumber extends TestOpenDj {
protected static final File RESOURCE_OPENDJ_DUMBER_FILE = new File(TEST_DIR, "resource-opendj-dumber.xml");
private static Trace LOGGER = TraceManager.getTrace(TestOpenDjDumber.class);
@Override
protected File getResourceOpenDjFile() {
return RESOURCE_OPENDJ_DUMBER_FILE;
}
@Override
protected int getNumberOfBaseContextShadows() {
return 1;
}
@Override
protected void assertConnectorOperationIncrement(int expectedIncrementSmart, int expectedIncrementDumb) {
assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, expectedIncrementDumb);
}
/**
* But "dumber" resource do not have any count simulation for groups.
*/
@Override
protected Integer getExpectedLdapGroupCountTest25x() {
return null;
}
@Override
protected void assertTimestampType(String attrName, ResourceAttributeDefinition<?> def) {
assertEquals("Wrong "+attrName+"type", DOMUtil.XSD_STRING, def.getTypeName());
}
@Override
protected void assertTimestamp(String attrName, Object timestampValue) {
if (!(timestampValue instanceof String)) {
fail("Wrong type of "+attrName+", expected String but was "+timestampValue.getClass());
}
String str = (String)timestampValue;
assertTrue("Timestamp "+attrName+" does not start with 2: "+str, str.startsWith("2"));
assertTrue("Timestamp "+attrName+" does not end with Z: "+str, str.endsWith("Z"));
}
/**
* This resource has disabled "tree delete".
*/
@Test
@Override
public void test489DeleteOuSuperWithSub() throws Exception {
final String TEST_NAME = "test489DeleteOuSuperWithSub";
displayTestTitle(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
createSubOrg();
try {
// WHEN
displayWhen(TEST_NAME);
provisioningService.deleteObject(ShadowType.class, OU_SUPER_OID, null, null, task, result);
assertNotReached();
} catch (IllegalArgumentException e) {
// expected
}
// THEN
displayThen(TEST_NAME);
assertFailure(result);
}
}