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.assertEquals; 20 import static org.junit.Assert.assertNotEquals; 21 22 import android.os.Build; 23 24 import androidx.test.filters.SmallTest; 25 26 import com.android.testutils.DevSdkIgnoreRule; 27 import com.android.testutils.DevSdkIgnoreRunner; 28 29 import org.junit.Test; 30 import org.junit.runner.RunWith; 31 32 /** Unit tests for {@link IpSecTransform}. */ 33 @SmallTest 34 @RunWith(DevSdkIgnoreRunner.class) 35 @DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.R) 36 public class IpSecTransformTest { 37 38 @Test testCreateTransformCopiesConfig()39 public void testCreateTransformCopiesConfig() { 40 // Create a config with a few parameters to make sure it's not empty 41 IpSecConfig config = new IpSecConfig(); 42 config.setSourceAddress("0.0.0.0"); 43 config.setDestinationAddress("1.2.3.4"); 44 config.setSpiResourceId(1984); 45 46 IpSecTransform preModification = new IpSecTransform(null, config); 47 48 config.setSpiResourceId(1985); 49 IpSecTransform postModification = new IpSecTransform(null, config); 50 51 assertNotEquals(preModification, postModification); 52 } 53 54 @Test testCreateTransformsWithSameConfigEqual()55 public void testCreateTransformsWithSameConfigEqual() { 56 // Create a config with a few parameters to make sure it's not empty 57 IpSecConfig config = new IpSecConfig(); 58 config.setSourceAddress("0.0.0.0"); 59 config.setDestinationAddress("1.2.3.4"); 60 config.setSpiResourceId(1984); 61 62 IpSecTransform config1 = new IpSecTransform(null, config); 63 IpSecTransform config2 = new IpSecTransform(null, config); 64 65 assertEquals(config1, config2); 66 } 67 } 68