blob: 39f0feddcddbcbbfb42ac0c1d01fed57a56f6650 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2011, 2013 RĂ¼diger Herrmann and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* RĂ¼diger Herrmann - initial API and implementation
* EclipseSource - ongoing development
******************************************************************************/
package org.eclipse.rap.tools.launch.rwt.internal.config;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.eclipse.rap.tools.launch.rwt.internal.config.RWTLaunchConfig;
import org.eclipse.rap.tools.launch.rwt.internal.config.ValidationResult;
import org.eclipse.rap.tools.launch.rwt.internal.config.Validator;
import org.eclipse.rap.tools.launch.rwt.internal.config.WebXmlLocationValidator;
import org.eclipse.rap.tools.launch.rwt.internal.config.RWTLaunchConfig.LaunchTarget;
import org.eclipse.rap.tools.launch.rwt.internal.tests.Fixture;
import org.eclipse.rap.tools.launch.rwt.internal.tests.TestProject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class WebXmlLocationValidator_Test {
private RWTLaunchConfig launchConfig;
private Validator validator;
private ValidationResult validationResult;
@Before
public void setUp() throws Exception {
launchConfig = new RWTLaunchConfig( Fixture.createRWTLaunchConfig() );
validationResult = new ValidationResult();
validator = new WebXmlLocationValidator( launchConfig, validationResult );
}
@After
public void tearDown() throws Exception {
launchConfig.getUnderlyingLaunchConfig().delete();
TestProject.deleteAll();
}
@Test
public void testValidate_withEmptyWebXmlLocation() {
launchConfig.setLaunchTarget( LaunchTarget.WEB_XML );
launchConfig.setWebXmlLocation( "" );
validator.validate();
assertTrue( validationResult.contains( WebXmlLocationValidator.ERR_WEB_XML_LOCATION_EMPTY ) );
}
@Test
public void testValidate_withNonExistentWebXmlLocation() {
launchConfig.setLaunchTarget( LaunchTarget.WEB_XML );
launchConfig.setWebXmlLocation( "does/not/exist/web.xml" );
validator.validate();
assertFalse( validationResult.contains( WebXmlLocationValidator.ERR_WEB_XML_LOCATION_EMPTY ) );
assertTrue( validationResult.contains( WebXmlLocationValidator.ERR_WEB_XML_LOCATION_NOT_FOUND ) );
}
@Test
public void testValidate_withUnusedWebXml() {
launchConfig.setLaunchTarget( LaunchTarget.ENTRY_POINT );
launchConfig.setWebXmlLocation( "does.not.exist" );
validator.validate();
assertFalse( validationResult.contains( WebXmlLocationValidator.ERR_WEB_XML_LOCATION_EMPTY ) );
assertFalse( validationResult.contains( WebXmlLocationValidator.ERR_WEB_XML_LOCATION_NOT_FOUND ) );
}
}