|
| 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.transform.yui; |
| 17 | + |
| 18 | +import static org.junit.Assert.assertEquals; |
| 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.asset.StringAsset; |
| 24 | +import org.jboss.shrinkwrap.api.spec.WebArchive; |
| 25 | +import org.junit.Test; |
| 26 | +import org.junit.runner.RunWith; |
| 27 | +import org.ocpsoft.rewrite.config.ConfigurationProvider; |
| 28 | +import org.ocpsoft.rewrite.test.HttpAction; |
| 29 | +import org.ocpsoft.rewrite.test.RewriteTest; |
| 30 | + |
| 31 | +/** |
| 32 | + * |
| 33 | + * Integration test for {@link JsCompress}. |
| 34 | + * |
| 35 | + * @author Christian Kaltepoth |
| 36 | + * |
| 37 | + */ |
| 38 | +@RunWith(Arquillian.class) |
| 39 | +public class JsCompressTest extends RewriteTest |
| 40 | +{ |
| 41 | + @Deployment(testable = false) |
| 42 | + public static WebArchive getDeployment() |
| 43 | + { |
| 44 | + return RewriteTest.getDeployment() |
| 45 | + .addAsWebResource(new StringAsset("var text = \"hello\";\n\nalert(text);"), "test.js") |
| 46 | + .addAsServiceProvider(ConfigurationProvider.class, JsCompressTestProvider.class); |
| 47 | + } |
| 48 | + |
| 49 | + @Test |
| 50 | + public void testJavaScriptCompression() throws Exception |
| 51 | + { |
| 52 | + HttpAction<HttpGet> action = get("/test.js"); |
| 53 | + assertEquals(200, action.getResponse().getStatusLine().getStatusCode()); |
| 54 | + assertEquals("var text=\"hello\";alert(text);", action.getResponseContent()); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + public void testNotExistingSourceFile() throws Exception |
| 59 | + { |
| 60 | + HttpAction<HttpGet> action = get("/not-existing.js"); |
| 61 | + assertEquals(404, action.getResponse().getStatusLine().getStatusCode()); |
| 62 | + } |
| 63 | + |
| 64 | +} |
0 commit comments