File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\test\src\test\java\hudson\model\labels\LabelAtomPropertyTest.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2010, InfraDNA, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.model.labels;
25
26 import org.jvnet.hudson.test.HudsonTestCase;
27 import org.jvnet.hudson.test.TestExtension;
28 import org.kohsuke.stapler.DataBoundConstructor;
29
30 /**
31 * @author Kohsuke Kawaguchi
32 */
33 public class LabelAtomPropertyTest extends HudsonTestCase {
34 public static class LabelAtomPropertyImpl extends LabelAtomProperty {
35 public final String abc;
36
37 @DataBoundConstructor
38 public LabelAtomPropertyImpl(String abc) {
39 this.abc = abc;
40 }
41
42 @TestExtension
43 public static class DescriptorImpl extends LabelAtomPropertyDescriptor {
44 @Override
45 public String getDisplayName() {
46 return "Test label atom property";
47 }
48 }
49 }
50
51 /**
52 * Tests the configuration persistence between disk, memory, and UI.
53 */
54 public void testConfigRoundtrip() throws Exception {
55 LabelAtom foo = jenkins.getLabelAtom("foo");
56 LabelAtomPropertyImpl old = new LabelAtomPropertyImpl("value");
57 foo.getProperties().add(old);
58 assertTrue(foo.getConfigFile().exists());
59 foo.load(); // make sure load works
60
61 // it should survive the configuration roundtrip
62 submit(createWebClient().goTo("label/foo/configure").getFormByName("config"));
63 assertEquals(1,foo.getProperties().size());
64 assertEqualDataBoundBeans(old, foo.getProperties().get(LabelAtomPropertyImpl.class));
65 }
66 }
67