View Javadoc

1   /**
2    * Copyright (c) 2012, University of Konstanz, Distributed Systems Group
3    * All rights reserved.
4    * 
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are met:
7    * * Redistributions of source code must retain the above copyright
8    * notice, this list of conditions and the following disclaimer.
9    * * Redistributions in binary form must reproduce the above copyright
10   * notice, this list of conditions and the following disclaimer in the
11   * documentation and/or other materials provided with the distribution.
12   * * Neither the name of the University of Konstanz nor the
13   * names of its contributors may be used to endorse or promote products
14   * derived from this software without specific prior written permission.
15   * 
16   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18   * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19   * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20   * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26   */
27  package org.perfidix;
28  
29  import static org.junit.Assert.assertArrayEquals;
30  import static org.junit.Assert.assertEquals;
31  import static org.junit.Assert.fail;
32  
33  import org.junit.Test;
34  import org.perfidix.benchmarktests.ToTestConfig;
35  import org.perfidix.meter.AbstractMeter;
36  import org.perfidix.ouput.AbstractOutput;
37  
38  /**
39   * Testcase for {@link Perfidix}
40   * 
41   * @author Sebastian Graf, University of Konstanz
42   */
43  public class PerfidixTest {
44  
45      /**
46       * Test method for {@link org.perfidix.Perfidix#runBenchs(java.lang.String[])}.
47       */
48      @Test
49      public void testRunBenchs() {
50          final String[] benchs = {
51              "org.perfidix.benchmarktests.NormalCompleteBench"
52          };
53          try {
54              Perfidix.runBenchs(benchs);
55          } catch (final ClassNotFoundException e) {
56              fail(e.toString());
57          } catch (final InstantiationException e) {
58              fail(e.toString());
59          } catch (final IllegalAccessException e) {
60              fail(e.toString());
61          }
62      }
63  
64      /**
65       * Test method for
66       * {@link org.perfidix.Perfidix#setUpBenchmark(java.lang.String[], org.perfidix.Benchmark)} .
67       */
68      @Test
69      public void testSetUpBenchmark() {
70          final String[] benchs = {
71              "org.perfidix.benchmarktests.NormalCompleteBench"
72          };
73          final Benchmark bench = new Benchmark();
74          try {
75              Perfidix.setUpBenchmark(benchs, bench);
76          } catch (final ClassNotFoundException e) {
77              fail(e.toString());
78          }
79      }
80  
81      /**
82       * Test method for {@link org.perfidix.Perfidix#getConfiguration(java.lang.String[])}.
83       */
84      @Test
85      public void testGetConfiguration() {
86          final String[] confs = {
87              "org.perfidix.benchmarktests.ToTestConfig"
88          };
89          try {
90              final AbstractConfig conf = Perfidix.getConfiguration(confs);
91              assertEquals("runs must be the same", conf.getRuns(), ToTestConfig.TESTRUNS);
92              assertArrayEquals("meters must be the same", conf.getMeters(), ToTestConfig.TESTMETERS
93                  .toArray(new AbstractMeter[ToTestConfig.TESTMETERS.size()]));
94              assertArrayEquals("listeners must be the same", conf.getListener(), ToTestConfig.TESTLISTENER
95                  .toArray(new AbstractOutput[ToTestConfig.LISTENERS.size()]));
96              assertEquals("arrangement must be the same", conf.getArrangement(), ToTestConfig.TESTARR);
97              assertEquals("gc prob must be the same", conf.getGcProb(), ToTestConfig.TESTGC, 0);
98          } catch (final ClassNotFoundException e) {
99              fail(e.toString());
100         } catch (final InstantiationException e) {
101             fail(e.toString());
102         } catch (final IllegalAccessException e) {
103             fail(e.toString());
104         }
105     }
106 
107     /**
108      * Test method for {@link org.perfidix.Perfidix#main(java.lang.String[])}.
109      */
110     @Test
111     public void testMain() {
112         final String[] benchs = {
113             "org.perfidix.benchmarktests.NormalCompleteBench"
114         };
115         try {
116             Perfidix.runBenchs(benchs);
117         } catch (final ClassNotFoundException e) {
118             fail(e.toString());
119         } catch (final InstantiationException e) {
120             fail(e.toString());
121         } catch (final IllegalAccessException e) {
122             fail(e.toString());
123         }
124     }
125 }