|
| 1 | +/* |
| 2 | + * Copyright 2011 <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.ocpsoft.rewrite.servlet.config; |
| 17 | + |
| 18 | +import junit.framework.Assert; |
| 19 | + |
| 20 | +import org.apache.http.client.methods.HttpGet; |
| 21 | +import org.jboss.arquillian.container.test.api.Deployment; |
| 22 | +import org.jboss.arquillian.junit.Arquillian; |
| 23 | +import org.jboss.shrinkwrap.api.spec.WebArchive; |
| 24 | +import org.junit.Test; |
| 25 | +import org.junit.runner.RunWith; |
| 26 | +import org.ocpsoft.rewrite.config.ConfigurationProvider; |
| 27 | +import org.ocpsoft.rewrite.test.HttpAction; |
| 28 | +import org.ocpsoft.rewrite.test.RewriteTest; |
| 29 | + |
| 30 | +/** |
| 31 | + * @author Christian Kaltepoth |
| 32 | + */ |
| 33 | +@RunWith(Arquillian.class) |
| 34 | +public class ServletMappingConfigurationTest extends RewriteTest |
| 35 | +{ |
| 36 | + |
| 37 | + @Deployment(testable = false) |
| 38 | + public static WebArchive getDeployment() |
| 39 | + { |
| 40 | + return RewriteTest.getDeployment() |
| 41 | + .addPackages(true, ConfigRoot.class.getPackage()) |
| 42 | + .addClass(ServletMappingConfigurationServlet.class) |
| 43 | + .addAsServiceProvider(ConfigurationProvider.class, ServletMappingConfigurationProvider.class); |
| 44 | + } |
| 45 | + |
| 46 | + @Test |
| 47 | + public void testServletMappingConditionMatches() throws Exception |
| 48 | + { |
| 49 | + HttpAction<HttpGet> action = get("/test-with-mapped-url"); |
| 50 | + Assert.assertEquals(210, action.getResponse().getStatusLine().getStatusCode()); |
| 51 | + } |
| 52 | + |
| 53 | + @Test |
| 54 | + public void testServletMappingConditionDoesNotMatch() throws Exception |
| 55 | + { |
| 56 | + HttpAction<HttpGet> action = get("/test-with-unmapped-url"); |
| 57 | + Assert.assertEquals(210, action.getResponse().getStatusLine().getStatusCode()); |
| 58 | + } |
| 59 | + |
| 60 | +} |
0 commit comments