View Javadoc

1   /*
2    * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3    * the spring framework, http://el4j.sf.net
4    * Copyright (C) 2005 by ELCA Informatique SA, Av. de la Harpe 22-24,
5    * 1000 Lausanne, Switzerland, http://www.elca.ch
6    *
7    * EL4J is published under the GNU Lesser General Public License (LGPL)
8    * Version 2.1. See http://www.gnu.org/licenses/
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   * GNU Lesser General Public License for more details.
14   *
15   * For alternative licensing, please contact info@elca.ch
16   */
17  package ch.elca.el4j.tests.services.monitoring.jmx;
18  
19  import java.util.Random;
20  
21  import org.junit.Test;
22  
23  import ch.elca.el4j.services.monitoring.jmx.display.HtmlTabulator;
24  
25  /**
26   * JUnit tests for HtmlTabulator.
27   *
28   * @svnLink $Revision: 4010 $;$Date: 2009-12-01 10:59:54 +0100 (Di, 01. Dez 2009) $;$Author: jonasha $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/jmx/src/test/java/ch/elca/el4j/tests/services/monitoring/jmx/HtmlTabulatorTest.java $
29   *
30   * @author David Bernhard (DBD)
31   */
32  public class HtmlTabulatorTest {
33  
34  	@Test
35  	public void testSimpleTableGeneration() {
36  		Random generator = new Random();
37  		
38  		// Cols in [2,10)
39  		int numCols = generator.nextInt(8) + 2;
40  		HtmlTabulator table;
41  		
42  		String[] titleRow = new String[numCols];
43  		for (int i = 0; i < numCols; i++) {
44  			titleRow[i] = "Column " + i;
45  		}
46  		table = new HtmlTabulator(titleRow);
47  		
48  		// Rows in [10, 210)
49  		int numRows = generator.nextInt(100) + 10;
50  		
51  		for (int i = 0; i < numRows; i++) {
52  			String[] row = new String[numCols];
53  			for (int j = 0; j < numCols; j++) {
54  				row[j] = "" + ((i+j) % 1000);
55  			}
56  			table.addRow(row);
57  		}
58  		
59  		// String theTable = table.tabulate();
60  		// TODO: Parse generated table here?
61  	}
62  }