944901935975540e952488f8402c0d4806e83217
[vpp.git] / plugins / acl-plugin / acl / jvpp / io / fd / vpp / jvpp / acl / test / FutureApiTest.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package io.fd.vpp.jvpp.acl.test;
18
19 import static io.fd.vpp.jvpp.acl.test.AclExpectedDumpData.verifyAclDump;
20 import static io.fd.vpp.jvpp.acl.test.AclExpectedDumpData.verifyAclInterfaceList;
21 import static io.fd.vpp.jvpp.acl.test.AclExpectedDumpData.verifyMacIpDump;
22 import static io.fd.vpp.jvpp.acl.test.AclTestRequests.sendAclAddRequest;
23 import static io.fd.vpp.jvpp.acl.test.AclTestRequests.sendAclDelRequest;
24 import static io.fd.vpp.jvpp.acl.test.AclTestRequests.sendAclDumpRequest;
25 import static io.fd.vpp.jvpp.acl.test.AclTestRequests.sendAclInterfaceDeleteList;
26 import static io.fd.vpp.jvpp.acl.test.AclTestRequests.sendAclInterfaceListDumpRequest;
27 import static io.fd.vpp.jvpp.acl.test.AclTestRequests.sendAclInterfaceSetAclList;
28 import static io.fd.vpp.jvpp.acl.test.AclTestRequests.sendMacIpAddRequest;
29 import static io.fd.vpp.jvpp.acl.test.AclTestRequests.sendMacIpDelRequest;
30 import static io.fd.vpp.jvpp.acl.test.AclTestRequests.sendMacIpDumpRequest;
31
32 import io.fd.vpp.jvpp.JVppRegistry;
33 import io.fd.vpp.jvpp.JVppRegistryImpl;
34 import io.fd.vpp.jvpp.acl.JVppAclImpl;
35 import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade;
36
37 public class FutureApiTest {
38
39     public static void main(String[] args) throws Exception {
40         testCallbackApi();
41     }
42
43     private static void testCallbackApi() throws Exception {
44         System.out.println("Testing Java callback API for acl plugin");
45         try (final JVppRegistry registry = new JVppRegistryImpl("macipAclAddTest");
46              final FutureJVppAclFacade jvpp = new FutureJVppAclFacade(registry, new JVppAclImpl())) {
47
48             // adds,dump and verifies  Mac-Ip acl
49             sendMacIpAddRequest(jvpp);
50             verifyMacIpDump(sendMacIpDumpRequest(jvpp).macipAclDetails.get(0));
51
52             // adds,dumps and verifies Acl acl
53             sendAclAddRequest(jvpp);
54             verifyAclDump(sendAclDumpRequest(jvpp).aclDetails.get(0));
55
56             // adds,dumps and verifies Interface for acl
57             sendAclInterfaceSetAclList(jvpp);
58             verifyAclInterfaceList(sendAclInterfaceListDumpRequest(jvpp).aclInterfaceListDetails.get(0));
59
60             // deletes all created data
61             sendAclInterfaceDeleteList(jvpp);
62             sendAclDelRequest(jvpp);
63             sendMacIpDelRequest(jvpp);
64
65             System.out.println("Disconnecting...");
66         }
67     }
68 }