1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.operations.extended;
21
22
23 import javax.naming.CommunicationException;
24 import javax.naming.NamingException;
25 import javax.naming.ldap.ExtendedRequest;
26 import javax.naming.ldap.ExtendedResponse;
27 import javax.naming.ldap.LdapContext;
28
29 import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContext;
30
31 import org.apache.directory.server.core.integ.Level;
32 import org.apache.directory.server.core.integ.annotations.CleanupLevel;
33 import org.apache.directory.server.integ.SiRunner;
34 import org.apache.directory.server.ldap.LdapService;
35 import org.junit.Test;
36 import org.junit.runner.RunWith;
37
38 import static org.junit.Assert.fail;
39
40
41
42
43
44
45
46
47 @RunWith ( SiRunner.class )
48 @CleanupLevel ( Level.SUITE )
49 public class ExtendedIT
50 {
51 public static LdapService ldapService;
52
53
54
55
56
57
58
59
60
61
62 @Test
63 public void testUnknownExtendedOperation() throws Exception
64 {
65 LdapContext ctx = ( LdapContext ) getWiredContext( ldapService ).lookup( "ou=system" );
66 try
67 {
68 ctx.extendedOperation( new UnknownExtendedOperationRequest() );
69 fail( "Calling an unknown extended operation should fail." );
70 }
71 catch ( CommunicationException ce )
72 {
73
74 }
75 }
76
77
78
79
80
81 private class UnknownExtendedOperationRequest implements ExtendedRequest
82 {
83
84 private static final long serialVersionUID = 1L;
85
86
87 public String getID()
88 {
89 return "1.1";
90 }
91
92
93 public byte[] getEncodedValue()
94 {
95 return null;
96 }
97
98
99 public ExtendedResponse createExtendedResponse( String id, byte[] berValue, int offset, int length )
100 throws NamingException
101 {
102 return null;
103 }
104 }
105
106 }