01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tctest.server.appserver.unit;
06:
07: import com.meterware.httpunit.WebConversation;
08: import com.meterware.httpunit.WebResponse;
09: import com.tc.test.server.appserver.deployment.AbstractDeploymentTest;
10: import com.tc.test.server.appserver.deployment.Deployment;
11: import com.tc.test.server.appserver.deployment.DeploymentBuilder;
12: import com.tc.test.server.appserver.deployment.ServerTestSetup;
13: import com.tc.test.server.appserver.deployment.WebApplicationServer;
14: import com.tc.test.server.util.TcConfigBuilder;
15: import com.tc.util.runtime.Vm;
16: import com.tctest.webapp.servlets.OkServlet;
17:
18: import junit.framework.Test;
19:
20: public class InstrumentEverythingInContainerTest extends
21: AbstractDeploymentTest {
22: private static final String CONTEXT = "OkServlet";
23: private Deployment deployment;
24:
25: public static Test suite() {
26: return new ServerTestSetup(
27: InstrumentEverythingInContainerTest.class);
28: }
29:
30: protected boolean isSessionTest() {
31: return false;
32: }
33:
34: public void setUp() throws Exception {
35: super .setUp();
36: if (deployment == null)
37: deployment = makeDeployment();
38: }
39:
40: public void testInstrumentEverything() throws Exception {
41: TcConfigBuilder tcConfigBuilder = new TcConfigBuilder();
42: tcConfigBuilder.addInstrumentedClass("*..*");
43: // These bytes are obfuscated and get verify errors when instrumented by DSO
44: tcConfigBuilder.addExclude("com.sun.crypto.provider..*");
45:
46: WebApplicationServer server = makeWebApplicationServer(tcConfigBuilder);
47: server.addWarDeployment(deployment, CONTEXT);
48: if (!Vm.isIBM()) {
49: // InstrumentEverythingInContainerTest under glassfish needs this
50: server.getServerParameters().appendJvmArgs(
51: "-XX:MaxPermSize=128m");
52: }
53: server.start();
54:
55: WebConversation conversation = new WebConversation();
56: WebResponse response = server.ping("/OkServlet/ok",
57: conversation);
58: assertEquals("OK", response.getText().trim());
59: }
60:
61: private Deployment makeDeployment() throws Exception {
62: DeploymentBuilder builder = makeDeploymentBuilder(CONTEXT
63: + ".war");
64: builder.addServlet("OkServlet", "/ok/*", OkServlet.class, null,
65: false);
66: return builder.makeDeployment();
67: }
68: }
|