KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > transport > util > JoramConfigurationBuilderTest


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: JoramConfigurationBuilderTest.java 10:28:12 AM ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.jbi.transport.util;
23
24 import java.io.DataInputStream JavaDoc;
25 import java.io.File JavaDoc;
26 import java.io.FileInputStream JavaDoc;
27 import java.io.IOException JavaDoc;
28
29 import org.objectweb.petals.jbi.transport.util.JoramConfigurationBuilder;
30
31 import junit.framework.TestCase;
32
33 /**
34  * Tests of the JoramConfigurationBuilder
35  *
36  * @author ddesjardins - eBMWebsourcing
37  */

38 public class JoramConfigurationBuilderTest extends TestCase {
39
40     public void testBuildFullMasterConf() throws IOException JavaDoc {
41         String JavaDoc conf = JoramConfigurationBuilder.buildFullMasterConf("test",
42             "0", "0", "127.0.0.1", "petals", "petals", "16200", "16300", "001");
43         String JavaDoc baseDir = this.getClass().getResource(".").toString();
44         baseDir = baseDir.substring(0, baseDir.indexOf("target"));
45         baseDir = baseDir.substring(baseDir.indexOf(":") + 1);
46         DataInputStream JavaDoc dis = new DataInputStream JavaDoc(new FileInputStream JavaDoc(baseDir
47             + "src" + File.separator + "test-data" + File.separator + "joram"
48             + File.separator + "joram-conf.xml"));
49         byte[] content = new byte[dis.available()];
50         dis.readFully(content);
51         assertEquals(conf, new String JavaDoc(content));
52     }
53
54     public void testBuildFullConfiguration() throws IOException JavaDoc {
55         String JavaDoc conf = JoramConfigurationBuilder.buildFullMasterConf("test",
56             "0", "0", "127.0.0.1", "petals", "petals", "16200", "16300", "001");
57         String JavaDoc fullConf = JoramConfigurationBuilder.buildFullConfiguration(
58             conf, "test", "1", "1", "127.0.0.1", "petals", "petals", "16201",
59             "16301", "002");
60         String JavaDoc baseDir = this.getClass().getResource(".").toString();
61         baseDir = baseDir.substring(0, baseDir.indexOf("target"));
62         baseDir = baseDir.substring(baseDir.indexOf(":") + 1);
63         DataInputStream JavaDoc dis = new DataInputStream JavaDoc(new FileInputStream JavaDoc(baseDir
64             + "src" + File.separator + "test-data" + File.separator + "joram"
65             + File.separator + "joram-conf-dist.xml"));
66         byte[] content = new byte[dis.available()];
67         dis.readFully(content);
68         assertEquals(fullConf, new String JavaDoc(content));
69     }
70 }
71
Popular Tags