Mercurial > hg > truffle
comparison visualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertyTest.java @ 4512:015fb895586b
Moved visualizer to new directory.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 07 Feb 2012 22:41:09 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4511:6cb549627941 | 4512:015fb895586b |
---|---|
1 /* | |
2 * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. Oracle designates this | |
8 * particular file as subject to the "Classpath" exception as provided | |
9 * by Oracle in the LICENSE file that accompanied this code. | |
10 * | |
11 * This code is distributed in the hope that it will be useful, but WITHOUT | |
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 * version 2 for more details (a copy is included in the LICENSE file that | |
15 * accompanied this code). | |
16 * | |
17 * You should have received a copy of the GNU General Public License version | |
18 * 2 along with this work; if not, write to the Free Software Foundation, | |
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
20 * | |
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
22 * or visit www.oracle.com if you need additional information or have any | |
23 * questions. | |
24 */ | |
25 | |
26 package com.sun.hotspot.igv.data; | |
27 | |
28 import static org.junit.Assert.*; | |
29 import org.junit.*; | |
30 | |
31 /** | |
32 * | |
33 * @author Thomas Wuerthinger | |
34 */ | |
35 public class PropertyTest { | |
36 | |
37 public PropertyTest() { | |
38 } | |
39 | |
40 @BeforeClass | |
41 public static void setUpClass() throws Exception { | |
42 } | |
43 | |
44 @AfterClass | |
45 public static void tearDownClass() throws Exception { | |
46 } | |
47 | |
48 @Before | |
49 public void setUp() { | |
50 } | |
51 | |
52 @After | |
53 public void tearDown() { | |
54 } | |
55 | |
56 /** | |
57 * Test of getName method, of class Property. | |
58 */ | |
59 @Test | |
60 public void testGetNameAndValue() { | |
61 final Property p = new Property("name", "value"); | |
62 assertEquals(p.getName(), "name"); | |
63 assertEquals(p.getValue(), "value"); | |
64 | |
65 try { | |
66 new Property(null, "value"); | |
67 fail(); | |
68 } catch(IllegalArgumentException e) { | |
69 } | |
70 | |
71 | |
72 try { | |
73 new Property("name", null); | |
74 fail(); | |
75 } catch(IllegalArgumentException e) { | |
76 } | |
77 } | |
78 | |
79 /** | |
80 * Test of toString method, of class Property. | |
81 */ | |
82 @Test | |
83 public void testToString() { | |
84 final Property p = new Property("name", "value"); | |
85 assertEquals(p.toString(), "name=value"); | |
86 } | |
87 | |
88 /** | |
89 * Test of equals method, of class Property. | |
90 */ | |
91 @Test | |
92 public void testEquals() { | |
93 final Property p = new Property("name", "value"); | |
94 final Object o = new Object(); | |
95 assertFalse(p.equals(o)); | |
96 assertFalse(p.equals(null)); | |
97 assertTrue(p.equals(p)); | |
98 | |
99 final Property p2 = new Property("name", "value1"); | |
100 assertFalse(p.equals(p2)); | |
101 assertTrue(p.hashCode() != p2.hashCode()); | |
102 | |
103 final Property p3 = new Property("name2", "value"); | |
104 assertFalse(p.equals(p3)); | |
105 assertTrue(p.hashCode() != p3.hashCode()); | |
106 assertTrue(p2.hashCode() != p3.hashCode()); | |
107 | |
108 final Property p4 = new Property("name", "value"); | |
109 assertEquals(p, p4); | |
110 assertEquals(p.hashCode(), p4.hashCode()); | |
111 | |
112 final Property p5 = new Property("value", "name"); | |
113 assertFalse(p.equals(p5)); | |
114 assertTrue(p.hashCode() != p5.hashCode()); | |
115 } | |
116 } |