• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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;
18 
19 import static org.junit.Assert.assertFalse;
20 import static org.junit.Assert.assertTrue;
21 
22 import android.support.test.filters.SmallTest;
23 
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.junit.runners.JUnit4;
27 
28 /** Unit tests for {@link IpSecTransform}. */
29 @SmallTest
30 @RunWith(JUnit4.class)
31 public class IpSecTransformTest {
32 
33     @Test
testCreateTransformCopiesConfig()34     public void testCreateTransformCopiesConfig() {
35         // Create a config with a few parameters to make sure it's not empty
36         IpSecConfig config = new IpSecConfig();
37         config.setSourceAddress("0.0.0.0");
38         config.setDestinationAddress("1.2.3.4");
39         config.setSpiResourceId(1984);
40 
41         IpSecTransform preModification = new IpSecTransform(null, config);
42 
43         config.setSpiResourceId(1985);
44         IpSecTransform postModification = new IpSecTransform(null, config);
45 
46         assertFalse(IpSecTransform.equals(preModification, postModification));
47     }
48 
49     @Test
testCreateTransformsWithSameConfigEqual()50     public void testCreateTransformsWithSameConfigEqual() {
51         // Create a config with a few parameters to make sure it's not empty
52         IpSecConfig config = new IpSecConfig();
53         config.setSourceAddress("0.0.0.0");
54         config.setDestinationAddress("1.2.3.4");
55         config.setSpiResourceId(1984);
56 
57         IpSecTransform config1 = new IpSecTransform(null, config);
58         IpSecTransform config2 = new IpSecTransform(null, config);
59 
60         assertTrue(IpSecTransform.equals(config1, config2));
61     }
62 }
63