2
* JBoss, Home of Professional Open Source
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
4
* by the @authors tag. See the copyright.txt in the distribution for a
5
* full listing of individual contributors.
7
* This is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
12
* This software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this software; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
22
package org.jboss.test.remoting.transport.http.ssl;
24
import java.net.InetAddress;
25
import java.util.HashMap;
28
import javax.management.MBeanServer;
30
import junit.framework.TestCase;
32
import org.apache.log4j.ConsoleAppender;
33
import org.apache.log4j.Level;
34
import org.apache.log4j.Logger;
35
import org.apache.log4j.PatternLayout;
36
import org.jboss.remoting.Client;
37
import org.jboss.remoting.InvocationRequest;
38
import org.jboss.remoting.InvokerLocator;
39
import org.jboss.remoting.ServerInvocationHandler;
40
import org.jboss.remoting.ServerInvoker;
41
import org.jboss.remoting.callback.InvokerCallbackHandler;
42
import org.jboss.remoting.transport.PortUtil;
46
* Unit test for JBREM-750.
48
* @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
49
* @version $Revision: 2762 $
51
* Copyright Sep 12, 2007
54
public class StaticLoggerTestCase extends TestCase
56
private static Logger log = Logger.getLogger(StaticLoggerTestCase.class);
57
private static boolean firstTime = true;
58
private InvokerLocator locator;
61
public void setUp() throws Exception
66
Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
67
Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
68
String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
69
PatternLayout layout = new PatternLayout(pattern);
70
ConsoleAppender consoleAppender = new ConsoleAppender(layout);
71
Logger.getRootLogger().addAppender(consoleAppender);
76
public void tearDown()
82
* Verifies that org.jboss.remoting.transport.http.HTTPClientInvoker.log is
83
* declared static so that it is available in HTTPClientInvoker and
84
* HTTPSClientInvoker constructors.
86
public void testStaticLogger() throws Throwable
88
log.info("entering " + getName());
91
String host = InetAddress.getLocalHost().getHostAddress();
92
int port = PortUtil.findFreePort(host);
93
String locatorURI = getTransport() + "://" + host + ":" + port;
94
locator = new InvokerLocator(locatorURI);
95
HashMap config = new HashMap();
96
config.put(InvokerLocator.FORCE_REMOTE, "true");
97
addExtraClientConfig(config);
98
Client client = new Client(locator, config);
100
// client.connect() will fail because of missing truststore url. If
101
// HTTPClientInvoker.log is not static, attempt to log error message will
102
// throw NullPointerException.
104
log.info("###############################################################");
105
log.info("### Expect logged ERROR message for java.io.IOException: ###");
106
log.info("### \"Error creating SSL Socket Factory for client invoker.\" ###");
107
log.info("########################################E######################");
110
log.info(getName() + " PASSES");
114
protected String getTransport()
120
protected void addExtraClientConfig(Map config) {}
121
protected void addExtraServerConfig(Map config) {}
124
static class TestInvocationHandler implements ServerInvocationHandler
126
public void addListener(InvokerCallbackHandler callbackHandler) {}
127
public Object invoke(final InvocationRequest invocation) throws Throwable {return null;}
128
public void removeListener(InvokerCallbackHandler callbackHandler) {}
129
public void setMBeanServer(MBeanServer server) {}
130
public void setInvoker(ServerInvoker invoker) {}
b'\\ No newline at end of file'