blob: 3c89de34631bb7eb935348f974be310a26cc9385 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.web.freeform;
import org.netbeans.modules.web.api.webmodule.*;
import org.openide.filesystems.FileObject;
/**
* Check that the web module is found for various files and has correct properties.
* @author Pavel Buzek
*/
public class ModulesWebTest extends TestBaseWeb {
public ModulesWebTest (String name) {
super(name);
}
public void testGetWebModule() throws Exception {
WebModule forJsp = WebModule.getWebModule (helloWorldJsp);
assertNotNull ("find web module for:" + helloWorldJsp.getPath (), forJsp);
FileObject dd = jakarta.getProjectDirectory ().getFileObject ("web/WEB-INF/web.xml");
WebModule forDD = WebModule.getWebModule (dd);
assertNotNull ("find web module for:" + dd.getPath (), forDD);
WebModule forServlet = WebModule.getWebModule (helloWorldServlet);
assertNotNull ("find web module for:" + helloWorldServlet.getPath (), forServlet);
assertEquals ("same web modules for servlet ("+ forServlet.getDocumentBase ()+") and jsp ("+forJsp.getDocumentBase ()+")", forServlet.getDocumentBase (), forJsp.getDocumentBase ());
assertEquals ("same web modules for servlet ("+ forServlet.getDocumentBase ()+") and we.xml ("+forDD.getDocumentBase ()+")", forServlet.getDocumentBase (), forDD.getDocumentBase ());
assertEquals ("same web modules for jsp ("+ forJsp.getDocumentBase ()+") and web.xml ("+forDD.getDocumentBase ()+")", forJsp.getDocumentBase (), forDD.getDocumentBase ());
WebModule forBuildXml = WebModule.getWebModule (jakarta.getProjectDirectory ().getFileObject ("build.xml"));
assertNull ("WebModule found for build.xml which does not belong to web module", forBuildXml);
}
public void testWebModuleProperties () throws Exception {
WebModule wm = WebModule.getWebModule (jakarta.getProjectDirectory ().getFileObject ("web"));
assertNotNull ("find web module for doc root", wm);
assertEquals ("correct j2ee version", WebModule.J2EE_14_LEVEL, wm.getJ2eePlatformVersion ());
assertEquals ("correct context path", "/myapp", wm.getContextPath ());
assertEquals ("correct context path", jakarta.getProjectDirectory ().getFileObject ("web"), wm.getDocumentBase ());
}
}