~ubuntu-branches/ubuntu/trusty/jenkins/trusty

« back to all changes in this revision

Viewing changes to core/src/test/java/jenkins/model/lazy/SortedListTest.java

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-13 12:35:19 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20130813123519-tizgfxcr70trl7r0
Tags: 1.509.2+dfsg-1
* New upstream release (Closes: #706725):
  - d/control: Update versioned BD's:
    * jenkins-executable-war >= 1.28.
    * jenkins-instance-identity >= 1.3.
    * libjenkins-remoting-java >= 2.23.
    * libjenkins-winstone-java >= 0.9.10-jenkins-44.
    * libstapler-java >= 1.207.
    * libjenkins-json-java >= 2.4-jenkins-1.
    * libstapler-adjunct-timeline-java >= 1.4.
    * libstapler-adjunct-codemirror-java >= 1.2.
    * libmaven-hpi-plugin-java >= 1.93.
    * libjenkins-xstream-java >= 1.4.4-jenkins-3.
  - d/maven.rules: Map to older version of animal-sniffer-maven-plugin.
  - Add patch for compatibility with guava >= 0.14.
  - Add patch to exclude asm4 dependency via jnr-posix.
  - Fixes the following security vulnerabilities:
    CVE-2013-2034, CVE-2013-2033, CVE-2013-2034, CVE-2013-1808
* d/patches/*: Switch to using git patch-queue for managing patches.
* De-duplicate jars between libjenkins-java and jenkins-external-job-monitor
  (Closes: #701163):
  - d/control: Add dependency between jenkins-external-job-monitor ->
    libjenkins-java.
  - d/rules: 
    Drop installation of jenkins-core in jenkins-external-job-monitor.
  - d/jenkins-external-job-monitor.{links,install}: Link to jenkins-core
    in /usr/share/java instead of included version.
* Wait longer for jenkins to stop during restarts (Closes: #704848):
  - d/jenkins.init: Re-sync init script from upstream codebase.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * The MIT License
 
3
 *
 
4
 * Copyright (c) 2012, CloudBees, 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 jenkins.model.lazy;
 
25
 
 
26
import org.junit.Assert;
 
27
import org.junit.Test;
 
28
 
 
29
import java.util.ArrayList;
 
30
import java.util.Arrays;
 
31
 
 
32
/**
 
33
 * @author Kohsuke Kawaguchi
 
34
 */
 
35
public class SortedListTest extends Assert {
 
36
    SortedList<String> l = new SortedList<String>(new ArrayList<String>(Arrays.asList("B","D","F")));
 
37
 
 
38
    @Test
 
39
    public void testCeil() {
 
40
        assertEquals(0,l.ceil("A"));
 
41
        assertEquals(0,l.ceil("B"));
 
42
        assertEquals(1,l.ceil("C"));
 
43
        assertEquals(1,l.ceil("D"));
 
44
        assertEquals(2,l.ceil("E"));
 
45
        assertEquals(2,l.ceil("F"));
 
46
        assertEquals(3,l.ceil("G"));
 
47
    }
 
48
    
 
49
    @Test
 
50
    public void testFloor() {
 
51
        assertEquals(-1,l.floor("A"));
 
52
        assertEquals(0,l.floor("B"));
 
53
        assertEquals(0,l.floor("C"));
 
54
        assertEquals(1,l.floor("D"));
 
55
        assertEquals(1,l.floor("E"));
 
56
        assertEquals(2,l.floor("F"));
 
57
        assertEquals(2,l.floor("G"));
 
58
    }
 
59
 
 
60
    @Test
 
61
    public void testLower() {
 
62
        assertEquals(-1,l.lower("A"));
 
63
        assertEquals(-1,l.lower("B"));
 
64
        assertEquals(0,l.lower("C"));
 
65
        assertEquals(0,l.lower("D"));
 
66
        assertEquals(1,l.lower("E"));
 
67
        assertEquals(1,l.lower("F"));
 
68
        assertEquals(2,l.lower("G"));
 
69
    }
 
70
 
 
71
    @Test
 
72
    public void testHigher() {
 
73
        assertEquals(0,l.higher("A"));
 
74
        assertEquals(1,l.higher("B"));
 
75
        assertEquals(1,l.higher("C"));
 
76
        assertEquals(2,l.higher("D"));
 
77
        assertEquals(2,l.higher("E"));
 
78
        assertEquals(3,l.higher("F"));
 
79
        assertEquals(3,l.higher("G"));
 
80
    }
 
81
 
 
82
    @Test
 
83
    public void testRange() {
 
84
        assertTrue(l.isInRange(0));
 
85
        assertTrue(l.isInRange(1));
 
86
        assertTrue(l.isInRange(2));
 
87
 
 
88
        assertFalse(l.isInRange(-1));
 
89
        assertFalse(l.isInRange(3));
 
90
    }
 
91
 
 
92
    @Test
 
93
    public void remove() {
 
94
        l.remove("nosuchthing");
 
95
        assertEquals(3,l.size());
 
96
 
 
97
        l.remove("B");
 
98
        assertEquals(2, l.size());
 
99
        assertEquals("D",l.get(0));
 
100
        assertEquals("F",l.get(1));
 
101
    }
 
102
 
 
103
    @Test
 
104
    public void testClone() {
 
105
        final int originalSize = l.size();
 
106
        SortedList<String> l2 = new SortedList<String>(l);
 
107
        assertEquals(originalSize, l2.size());
 
108
        assertEquals(originalSize, l.size());
 
109
        for (int i = 0; i < originalSize; i++) {
 
110
            assertEquals(l.get(i), l2.get(i));
 
111
        }
 
112
        l.remove(0);
 
113
        assertEquals(originalSize - 1, l.size());
 
114
        assertEquals(originalSize, l2.size());
 
115
        l2.remove(1);
 
116
        l2.remove(1);
 
117
        assertEquals(originalSize - 1, l.size());
 
118
        assertEquals(originalSize - 2, l2.size());
 
119
    }
 
120
}