001/* JUnit test for the example system 002 003 Copyright (c) 2010-2016 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 027 */ 028 029package ptolemy.kernel.test.junit; 030 031import static org.junit.Assert.assertArrayEquals; 032 033import ptolemy.kernel.test.ExampleSystem; 034import ptolemy.kernel.util.IllegalActionException; 035import ptolemy.kernel.util.NameDuplicationException; 036 037/////////////////////////////////////////////////////////////////// 038//// ExampleSystemJUnitTest 039/** 040 * Run the ExampleSystem as a JUnit Test. 041 * @author Christopher Brooks 042 * @version $Id$ 043 * @since Ptolemy II 10.0 044 * @Pt.ProposedRating Green (cxh) 045 * @Pt.AcceptedRating Green (cxh) 046 */ 047public class ExampleSystemJUnitTest { 048 /** 049 * Create the example system and compare the value returned by the 050 * toString() method to the known good results. 051 * @exception IllegalActionException If thrown while constructing 052 * the example system. 053 * @exception NameDuplicationException If there is already an example system 054 * in the default workspace. 055 */ 056 @org.junit.Test 057 public void run() throws IllegalActionException, NameDuplicationException { 058 ExampleSystem example = new ExampleSystem(); 059 060 String knownGood = "----Methods of ComponentRelation----" + _eol 061 + "linkedPorts:" + _eol + "R1: P1 P0 " + _eol + "R2: P1 P4 P3 " 062 + _eol + "R3: P1 P2 " + _eol + "R4: P4 P7 " + _eol 063 + "R5: P4 P5 " + _eol + "R6: P3 P6 " + _eol + "R7: P7 P13 P11 " 064 + _eol + "R8: P9 P8 " + _eol + "R9: P10 P11 " + _eol 065 + "R10: P8 P12 " + _eol + "R11: P12 P13 " + _eol 066 + "R12: P14 P13 " + _eol + "" + _eol + "deepLinkedPorts:" + _eol 067 + "R1: P1 " + _eol + "R2: P1 P9 P14 P10 P5 P3 " + _eol 068 + "R3: P1 P2 " + _eol + "R4: P1 P3 P9 P14 P10 " + _eol 069 + "R5: P1 P3 P5 " + _eol + "R6: P3 P6 " + _eol 070 + "R7: P1 P3 P9 P14 P10 " + _eol + "R8: P9 P1 P3 P10 " + _eol 071 + "R9: P10 P1 P3 P9 P14 " + _eol + "R10: P9 P1 P3 P10 " + _eol 072 + "R11: P9 P1 P3 P10 " + _eol + "R12: P14 P1 P3 P10 " + _eol 073 + "" + _eol + "----Methods of ComponentPort----" + _eol 074 + "connectedPorts:" + _eol + "P0: " + _eol + "P1: P0 P4 P3 P2 " 075 + _eol + "P2: P1 " + _eol + "P3: P1 P4 P6 " + _eol 076 + "P4: P7 P5 " + _eol + "P5: P4 " + _eol + "P6: P3 " + _eol 077 + "P7: P13 P11 " + _eol + "P8: P12 " + _eol + "P9: P8 " + _eol 078 + "P10: P11 " + _eol + "P11: P7 P13 " + _eol + "P12: P8 " + _eol 079 + "P13: P7 P11 " + _eol + "P14: P13 " + _eol + "" + _eol 080 + "deepConnectedPorts:" + _eol + "P0: " + _eol 081 + "P1: P9 P14 P10 P5 P3 P2 " + _eol + "P2: P1 " + _eol 082 + "P3: P1 P9 P14 P10 P5 P6 " + _eol + "P4: P9 P14 P10 P5 " 083 + _eol + "P5: P1 P3 " + _eol + "P6: P3 " + _eol 084 + "P7: P9 P14 P10 " + _eol + "P8: P1 P3 P10 " + _eol 085 + "P9: P1 P3 P10 " + _eol + "P10: P1 P3 P9 P14 " + _eol 086 + "P11: P1 P3 P9 P14 " + _eol + "P12: P9 " + _eol 087 + "P13: P1 P3 P10 " + _eol + "P14: P1 P3 P10 " + _eol; 088 assertArrayEquals(example.toString().getBytes(), knownGood.getBytes()); 089 } 090 091 /** Run the test that creates the example system. 092 * @param args Not used. 093 */ 094 public static void main(String args[]) { 095 org.junit.runner.JUnitCore 096 .main("ptolemy.kernel.test.junit.ExampleSystemJUnitTest"); 097 } 098 099 private static String _eol = System.getProperty("line.separator"); 100 101}