01: /*
02: * BEGIN_HEADER - DO NOT EDIT
03: *
04: * The contents of this file are subject to the terms
05: * of the Common Development and Distribution License
06: * (the "License"). You may not use this file except
07: * in compliance with the License.
08: *
09: * You can obtain a copy of the license at
10: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
11: * See the License for the specific language governing
12: * permissions and limitations under the License.
13: *
14: * When distributing Covered Code, include this CDDL
15: * HEADER in each file and include the License file at
16: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
17: * If applicable add the following below this CDDL HEADER,
18: * with the fields enclosed by brackets "[]" replaced with
19: * your own identifying information: Portions Copyright
20: * [year] [name of copyright owner]
21: */
22:
23: /*
24: * @(#)TestSampleBindingContext.java
25: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
26: *
27: * END_HEADER - DO NOT EDIT
28: */
29: package com.sun.jbi.internal.security;
30:
31: import java.io.File;
32: import org.xml.sax.EntityResolver;
33:
34: public class TestSampleBindingContext extends junit.framework.TestCase {
35:
36: public TestSampleBindingContext(String aTestName) {
37: super (aTestName);
38: }
39:
40: public void setUp() throws Exception {
41: super .setUp();
42:
43: }
44:
45: public void tearDown() throws Exception {
46:
47: }
48:
49: /**
50: * Test to check if the String translator is created properly.
51: *
52: * @throws Exception if an unexpected error occurs
53: */
54: public void testGetStringTranslator() throws Exception {
55: String testname = "testGetStringTranslator";
56: try {
57: SampleBindingContext bndCtx = new SampleBindingContext(
58: "sb-111");
59:
60: com.sun.jbi.StringTranslator st = bndCtx
61: .getStringTranslator(Constants.PACKAGE);
62:
63: assertNotNull(st);
64: } catch (Exception aEx) {
65: aEx.printStackTrace();
66: fail(testname + ": failed due to -" + aEx.getMessage());
67: throw aEx;
68: }
69: }
70:
71: /**
72: * Test to check if the string translator is returning the right values.
73: *
74: * @throws Exception if an unexpected error occurs
75: */
76: public void testGetStringTranslator2() throws Exception {
77: String testname = "testGetStringTranslator";
78: try {
79: SampleBindingContext bndCtx = new SampleBindingContext(
80: "sb-111");
81:
82: com.sun.jbi.StringTranslator st = bndCtx
83: .getStringTranslator("com.sun.jbi.internal.security");
84:
85: String str = st.getString("BC_ERR_INVALID_NS_URI",
86: "testEndpoint");
87: System.out.println(str);
88: assertNotNull(str);
89: assertTrue(str
90: .equals("An invalid targetNamespace URI is specified for Endpoint testEndpoint."));
91: } catch (Exception aEx) {
92: aEx.printStackTrace();
93: fail(testname + ": failed due to -" + aEx.getMessage());
94: throw aEx;
95: }
96: }
97: }
|