~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfLocationTest.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-05-13 21:43:22 UTC
  • mfrom: (1.2.1) (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130513214322-6frgd9du1n0w2uo7
Tags: 1.2.1-1
* Team upload.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*******************************************************************************
2
2
 * Copyright (c) 2009, 2010, 2012 Ericsson
3
 
 * 
 
3
 *
4
4
 * All rights reserved. This program and the accompanying materials are
5
5
 * made available under the terms of the Eclipse Public License v1.0 which
6
6
 * accompanies this distribution, and is available at
7
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 
 * 
 
8
 *
9
9
 * Contributors:
10
10
 *   Francois Chouinard - Initial API and implementation
11
11
 *******************************************************************************/
21
21
/**
22
22
 * Test suite for the TmfLocation class.
23
23
 */
24
 
@SuppressWarnings("nls")
 
24
@SuppressWarnings({"nls","javadoc"})
25
25
public class TmfLocationTest extends TestCase {
26
26
 
27
27
    // ------------------------------------------------------------------------
154
154
 
155
155
        @Override
156
156
        public boolean equals(Object obj) {
157
 
            if (this == obj)
 
157
            if (this == obj) {
158
158
                return true;
159
 
            if (obj == null)
160
 
                return false;
161
 
            if (!(obj instanceof MyCloneableClass))
162
 
                return false;
 
159
            }
 
160
            if (obj == null) {
 
161
                return false;
 
162
            }
 
163
            if (!(obj instanceof MyCloneableClass)) {
 
164
                return false;
 
165
            }
163
166
            MyCloneableClass other = (MyCloneableClass) obj;
164
167
            if (fName == null) {
165
 
                if (other.fName != null)
 
168
                if (other.fName != null) {
166
169
                    return false;
167
 
            } else if (!fName.equals(other.fName))
 
170
                }
 
171
            } else if (!fName.equals(other.fName)) {
168
172
                return false;
 
173
            }
169
174
            return true;
170
175
        }
171
176
    }
184
189
        }
185
190
    }
186
191
 
187
 
    public static class MyUnCloneableClass implements Comparable<MyUnCloneableClass> {
 
192
    private static class MyUnCloneableClass implements Comparable<MyUnCloneableClass> {
188
193
        private String fName;
189
194
 
190
195
        public MyUnCloneableClass(String name) {
216
221
 
217
222
        @Override
218
223
        public boolean equals(Object obj) {
219
 
            if (this == obj)
 
224
            if (this == obj) {
220
225
                return true;
221
 
            if (obj == null)
222
 
                return false;
223
 
            if (!(obj instanceof MyUnCloneableClass))
224
 
                return false;
 
226
            }
 
227
            if (obj == null) {
 
228
                return false;
 
229
            }
 
230
            if (!(obj instanceof MyUnCloneableClass)) {
 
231
                return false;
 
232
            }
225
233
            MyUnCloneableClass other = (MyUnCloneableClass) obj;
226
234
            if (fName == null) {
227
 
                if (other.fName != null)
 
235
                if (other.fName != null) {
228
236
                    return false;
229
 
            } else if (!fName.equals(other.fName))
 
237
                }
 
238
            } else if (!fName.equals(other.fName)) {
230
239
                return false;
 
240
            }
231
241
            return true;
232
242
        }
233
243
    }
246
256
    // hashCode
247
257
    // ------------------------------------------------------------------------
248
258
 
249
 
    public void testHashCode() throws Exception {
 
259
    public void testHashCode() {
250
260
        TmfLocation<String> location1 = new TmfLocation<String>((String) null);
251
261
        TmfLocation<String> location2 = new TmfLocation<String>(aString);
252
262
        TmfLocation<Long> location3 = new TmfLocation<Long>(aLong);
269
279
        }
270
280
    }
271
281
 
272
 
    public void testEqualsWrongTypes() throws Exception {
 
282
    public void testEqualsWrongTypes() {
273
283
        TmfLocation<String> location1 = new TmfLocation<String>(aString);
274
284
        TmfLocation2 location2 = new TmfLocation2(aString);
275
 
        
 
285
 
276
286
        assertFalse("equals", location1.equals(location2));
277
287
        assertFalse("equals", location2.equals(location1));
278
288
    }
279
289
 
280
 
    public void testEqualsWithNulls() throws Exception {
 
290
    public void testEqualsWithNulls() {
281
291
        TmfLocation<String> location1 = new TmfLocation<String>(aString);
282
292
        TmfLocation<String> location2 = new TmfLocation<String>((String) null);
283
 
        
 
293
 
284
294
        assertFalse("equals", location1.equals(location2));
285
295
        assertFalse("equals", location2.equals(location1));
286
296
    }
287
297
 
288
 
    public void testEqualsReflexivity() throws Exception {
 
298
    public void testEqualsReflexivity() {
289
299
        assertTrue("equals", fLocation2.equals(fLocation2));
290
300
        assertTrue("equals", fLocation3.equals(fLocation3));
291
301
 
293
303
        assertTrue("equals", !fLocation3.equals(fLocation2));
294
304
    }
295
305
 
296
 
    public void testEqualsSymmetry() throws Exception {
 
306
    public void testEqualsSymmetry() {
297
307
        TmfLocation<String> location2 = new TmfLocation<String>(aString);
298
308
        TmfLocation<Long> location3 = new TmfLocation<Long>(aLong);
299
309
 
304
314
        assertTrue("equals", fLocation3.equals(location3));
305
315
    }
306
316
 
307
 
    public void testEqualsTransivity() throws Exception {
 
317
    public void testEqualsTransivity() {
308
318
        TmfLocation<String> location1 = new TmfLocation<String>(aString);
309
319
        TmfLocation<String> location2 = new TmfLocation<String>(aString);
310
320
        TmfLocation<String> location3 = new TmfLocation<String>(aString);
314
324
        assertTrue("equals", location3.equals(location1));
315
325
    }
316
326
 
317
 
    public void testEqualsNull() throws Exception {
 
327
    public void testEqualsNull() {
318
328
        assertTrue("equals", !fLocation2.equals(null));
319
329
        assertTrue("equals", !fLocation2.equals(null));
320
330
    }
323
333
    // toString
324
334
    // ------------------------------------------------------------------------
325
335
 
 
336
    @SuppressWarnings("hiding")
326
337
    public void testToString() {
327
338
        String aString = "some location";
328
339
        Long aLong = 12345L;