• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
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 android.net.ipsec.ike.ike3gpp;
18 
19 import static org.junit.Assert.assertEquals;
20 
21 import android.net.ipsec.ike.ike3gpp.Ike3gppExtension.Ike3gppDataListener;
22 
23 import org.junit.Test;
24 
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.List;
28 
29 public class Ike3gppDataListenerTest {
30     @Test
testOnIke3gppDataReceived()31     public void testOnIke3gppDataReceived() {
32         List<Ike3gppData> ike3gppData =
33                 Arrays.asList(Ike3gppN1ModeInformationTest.newN1ModeInformation());
34 
35         TestIke3gppDataListener dataListener = new TestIke3gppDataListener();
36         dataListener.onIke3gppDataReceived(ike3gppData);
37 
38         assertEquals(ike3gppData, dataListener.lastDataList);
39     }
40 
41     public static class TestIke3gppDataListener implements Ike3gppDataListener {
42         public final List<Ike3gppData> lastDataList = new ArrayList<>();
43 
44         @Override
onIke3gppDataReceived(List<Ike3gppData> ike3gppDataList)45         public void onIke3gppDataReceived(List<Ike3gppData> ike3gppDataList) {
46             lastDataList.clear();
47             lastDataList.addAll(ike3gppDataList);
48         }
49     }
50 }
51