From 091db50c09d9d42a6d30bd58e745ff473ea099a4 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 14 Feb 2024 17:28:08 -0500 Subject: [PATCH] Basic `ProxyConfigurationManagerTest` (#8952) --- .../hudson/ProxyConfigurationManagerTest.java | 50 +++++++++++++++++++ .../ProxyConfigurationManagerTest/proxy.xml | 5 ++ 2 files changed, 55 insertions(+) create mode 100644 test/src/test/java/hudson/ProxyConfigurationManagerTest.java create mode 100644 test/src/test/resources/hudson/ProxyConfigurationManagerTest/proxy.xml diff --git a/test/src/test/java/hudson/ProxyConfigurationManagerTest.java b/test/src/test/java/hudson/ProxyConfigurationManagerTest.java new file mode 100644 index 000000000000..d68cc1986496 --- /dev/null +++ b/test/src/test/java/hudson/ProxyConfigurationManagerTest.java @@ -0,0 +1,50 @@ +/* + * The MIT License + * + * Copyright 2024 CloudBees, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package hudson; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Rule; +import org.junit.Test; +import org.jvnet.hudson.test.JenkinsRule; +import org.jvnet.hudson.test.recipes.LocalData; + +public class ProxyConfigurationManagerTest { + + @Rule public JenkinsRule r = new JenkinsRule(); + + @LocalData + @Test public void serialForm() throws Exception { + /* Set up this way: + r.jenkins.proxy = new ProxyConfiguration("proxy.mycorp", 80); + r.jenkins.proxy.save(); + */ + ProxyConfiguration pc = r.jenkins.proxy; + assertNotNull(pc); + assertEquals("proxy.mycorp", pc.name); + } + +} diff --git a/test/src/test/resources/hudson/ProxyConfigurationManagerTest/proxy.xml b/test/src/test/resources/hudson/ProxyConfigurationManagerTest/proxy.xml new file mode 100644 index 000000000000..c61d552a51f7 --- /dev/null +++ b/test/src/test/resources/hudson/ProxyConfigurationManagerTest/proxy.xml @@ -0,0 +1,5 @@ + + + proxy.mycorp + 80 + \ No newline at end of file