01: package org.objectweb.celtix.tools.common.toolspec;
02:
03: import junit.framework.TestCase;
04: import org.objectweb.celtix.tools.common.ToolException;
05:
06: public class ToolSpecTest extends TestCase {
07: ToolSpec toolSpec;
08:
09: public void testConstruct() {
10: toolSpec = null;
11: toolSpec = new ToolSpec();
12: assertTrue(toolSpec != null);
13:
14: }
15:
16: public void testConstructFromInputStream() {
17: String tsSource = "parser/resources/testtool.xml";
18: try {
19: toolSpec = new ToolSpec(getClass().getResourceAsStream(
20: tsSource), false);
21: } catch (ToolException e) {
22: throw new RuntimeException(e);
23: }
24: assertTrue(toolSpec.getAnnotation() == null);
25: }
26:
27: public void testGetParameterDefault() throws Exception {
28: String tsSource = "parser/resources/testtool.xml";
29:
30: toolSpec = new ToolSpec(getClass()
31: .getResourceAsStream(tsSource), false);
32:
33: assertTrue(toolSpec.getAnnotation() == null);
34: assertTrue(toolSpec.getParameterDefault("namespace") == null);
35: assertTrue(toolSpec.getParameterDefault("wsdlurl") == null);
36: }
37:
38: public void testGetStreamRefName1() throws Exception {
39: String tsSource = "parser/resources/testtool1.xml";
40: toolSpec = new ToolSpec(getClass()
41: .getResourceAsStream(tsSource), false);
42: assertEquals("test getStreamRefName failed", toolSpec
43: .getStreamRefName("streamref"), "namespace");
44: }
45:
46: public void testGetStreamRefName2() throws Exception {
47: String tsSource = "parser/resources/testtool2.xml";
48: toolSpec = new ToolSpec(getClass()
49: .getResourceAsStream(tsSource), false);
50: assertEquals("test getStreamRefName2 failed", toolSpec
51: .getStreamRefName("streamref"), "wsdlurl");
52: }
53:
54: public void testIsValidInputStream() throws Exception {
55: String tsSource = "parser/resources/testtool1.xml";
56: toolSpec = new ToolSpec(getClass()
57: .getResourceAsStream(tsSource), false);
58: assertTrue(toolSpec.isValidInputStream("testID"));
59: assertTrue(!toolSpec.isValidInputStream("dummyID"));
60: assertTrue(toolSpec.getInstreamIds().size() == 1);
61: }
62:
63: public void testGetHandler() throws Exception {
64: String tsSource = "parser/resources/testtool1.xml";
65: toolSpec = new ToolSpec(getClass()
66: .getResourceAsStream(tsSource), false);
67: assertNotNull(toolSpec.getHandler());
68: assertNotNull(toolSpec.getHandler(this .getClass()
69: .getClassLoader()));
70: }
71:
72: public void testGetOutstreamIds() throws Exception {
73: String tsSource = "parser/resources/testtool2.xml";
74: toolSpec = new ToolSpec(getClass()
75: .getResourceAsStream(tsSource), false);
76: assertTrue(toolSpec.getOutstreamIds().size() == 1);
77: }
78: }
|