Skip to main content
summaryrefslogtreecommitdiffstats
blob: 595023f28d129b8f0d8dbfbc3be48c7ca64eeaf8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// ========================================================================
// Copyright (c) Webtide LLC
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at 
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.apache.org/licenses/LICENSE-2.0.txt
//
// You may elect to redistribute this code under either of these licenses. 
// ========================================================================
package org.eclipse.jetty.deploy.bindings;

import java.io.File;

import junit.framework.Assert;

import org.eclipse.jetty.deploy.providers.ScanningAppProvider;
import org.eclipse.jetty.deploy.test.XmlConfiguredJetty;
import org.eclipse.jetty.toolchain.test.IO;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.eclipse.jetty.webapp.WebAppContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;

/**
 * Tests {@link ScanningAppProvider} as it starts up for the first time.
 */
public class GlobalWebappConfigBindingTest
{
	@Rule
	public TestingDir testdir = new TestingDir();
    private static XmlConfiguredJetty jetty;

    @Before
    public void setupEnvironment() throws Exception
    {
        jetty = new XmlConfiguredJetty(testdir);
        jetty.addConfiguration("jetty.xml");

        // Setup initial context
        jetty.copyContext("foo.xml","foo.xml");
        jetty.copyWebapp("foo-webapp-1.war","foo.war");

    }

    @After
    public void teardownEnvironment() throws Exception
    {
        // Stop jetty.
        jetty.stop();
    }
    
    @Test
    public void testServerAndSystemClassesOverride() throws Exception
    {
        IO.copy(MavenTestingUtils.getTestResourceFile("context-binding-test-1.xml"), new File(jetty.getJettyHome(), "context-binding-test-1.xml"));
        
        jetty.addConfiguration("binding-test-contexts-1.xml");
        jetty.load();
        jetty.start();
        
        WebAppContext context = jetty.getWebAppContexts().get(0);
        
        Assert.assertNotNull(context);
        Assert.assertEquals(context.getDefaultServerClasses().length, context.getServerClasses().length - 1); // added a pattern
        //Assert.assertEquals(context.getDefaultSystemClasses().length,context.getSystemClasses().length + 1); // removed a patter
        
        boolean fooPackage = false;
        
        // we are inserting the foo package into the server classes
        for (String entry : context.getServerClasses())
        {
            if ("org.eclipse.foo.".equals(entry))
            {
                fooPackage = true;
            }
        }
        
        Assert.assertTrue(fooPackage);
        
      //  boolean jndiPackage = false;
        
        // this test overrides and we removed the jndi from the list so it
        // should test false
//        for (String entry : context.getSystemClasses())
//        {
//            if ("org.eclipse.jetty.jndi.".equals(entry))
//            {
//                jndiPackage = true;
//            }
//        }
//        
//        Assert.assertFalse(jndiPackage);
    }
}

Back to the top