1 /* 2 * Copyright (c) 2011, 2015, 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. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 package com.sun.hotspot.igv.data; 26 27 import java.util.Arrays; 28 import java.util.LinkedHashSet; 29 import static org.junit.Assert.assertEquals; 30 import org.junit.*; 31 32 /** 33 * 34 * @author Thomas 35 */ 36 public class SourceTest { 37 SourceTest()38 public SourceTest() { 39 } 40 41 @BeforeClass setUpClass()42 public static void setUpClass() throws Exception { 43 } 44 45 @AfterClass tearDownClass()46 public static void tearDownClass() throws Exception { 47 } 48 49 @Before setUp()50 public void setUp() { 51 } 52 53 @After tearDown()54 public void tearDown() { 55 } 56 57 /** 58 * Test of getSourceNodes method, of class Source. 59 */ 60 @Test testBase()61 public void testBase() { 62 final Source s = new Source(); 63 64 final InputNode N1 = new InputNode(1); 65 final InputNode N2 = new InputNode(2); 66 67 s.addSourceNode(N1); 68 assertEquals(s.getSourceNodes(), Arrays.asList(N1)); 69 assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<>(Arrays.asList(1))); 70 71 s.addSourceNode(N2); 72 assertEquals(s.getSourceNodes(), Arrays.asList(N1, N2)); 73 assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<>(Arrays.asList(1, 2))); 74 75 s.addSourceNode(N1); 76 assertEquals(s.getSourceNodes(), Arrays.asList(N1, N2)); 77 assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<>(Arrays.asList(1, 2))); 78 } 79 } 80