From 2f43458a5a3391633a0b45ff59b0cef34a7db34f Mon Sep 17 00:00:00 2001 From: vamsic007 Date: Thu, 6 Nov 2008 15:26:29 +0000 Subject: Package processor for war files. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@711879 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/modules/contribution-jee/pom.xml | 5 ++ .../jee/impl/WarContributionProcessor.java | 36 +++++++++++++ .../jee/WarContributionProcessorTestCase.java | 57 +++++++++++++++++++++ .../src/test/resources/sample-web-app.war | Bin 0 -> 12454 bytes 4 files changed, 98 insertions(+) create mode 100644 java/sca/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/WarContributionProcessor.java create mode 100644 java/sca/modules/contribution-jee/src/test/java/org/apache/tuscany/sca/contribution/jee/WarContributionProcessorTestCase.java create mode 100644 java/sca/modules/contribution-jee/src/test/resources/sample-web-app.war (limited to 'java/sca/modules') diff --git a/java/sca/modules/contribution-jee/pom.xml b/java/sca/modules/contribution-jee/pom.xml index d7ad035d82..f89e41edcf 100644 --- a/java/sca/modules/contribution-jee/pom.xml +++ b/java/sca/modules/contribution-jee/pom.xml @@ -34,6 +34,11 @@ tuscany-contribution 1.4-SNAPSHOT + + org.apache.tuscany.sca + tuscany-contribution-impl + 1.4-SNAPSHOT + org.apache.tuscany.sca diff --git a/java/sca/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/WarContributionProcessor.java b/java/sca/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/WarContributionProcessor.java new file mode 100644 index 0000000000..17974e831f --- /dev/null +++ b/java/sca/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/WarContributionProcessor.java @@ -0,0 +1,36 @@ +/* + * 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.apache.tuscany.sca.contribution.jee.impl; + +import org.apache.tuscany.sca.contribution.PackageType; +import org.apache.tuscany.sca.contribution.processor.PackageProcessor; +import org.apache.tuscany.sca.contribution.processor.impl.JarContributionProcessor; + +/** + * War Contribution package processor. + * + * @version $Rev$ $Date$ + */ +public class WarContributionProcessor extends JarContributionProcessor implements PackageProcessor { + @Override + public String getPackageType() { + return PackageType.WAR; + } +} diff --git a/java/sca/modules/contribution-jee/src/test/java/org/apache/tuscany/sca/contribution/jee/WarContributionProcessorTestCase.java b/java/sca/modules/contribution-jee/src/test/java/org/apache/tuscany/sca/contribution/jee/WarContributionProcessorTestCase.java new file mode 100644 index 0000000000..e315c417b9 --- /dev/null +++ b/java/sca/modules/contribution-jee/src/test/java/org/apache/tuscany/sca/contribution/jee/WarContributionProcessorTestCase.java @@ -0,0 +1,57 @@ +/* + * 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.apache.tuscany.sca.contribution.jee; + +import java.io.InputStream; +import java.net.URI; +import java.net.URL; +import java.util.List; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.contribution.jee.impl.WarContributionProcessor; +import org.apache.tuscany.sca.contribution.service.util.IOHelper; +import org.junit.Test; + +/** + * War Contribution package processor test case. + * Verifies proper handling of WAR contributions. + * + * @version $Rev$ $Date$ + */ +public class WarContributionProcessorTestCase { + private static final String WAR_CONTRIBUTION = "/sample-web-app.war"; + + @Test + public void testProcessPackageArtifacts() throws Exception { + WarContributionProcessor warProcessor = new WarContributionProcessor(); + + URL warURL = getClass().getResource(WAR_CONTRIBUTION); + InputStream warStream = warURL.openStream(); + List artifacts = null; + try { + artifacts = warProcessor.getArtifacts(warURL, warStream); + } finally { + IOHelper.closeQuietly(warStream); + } + + Assert.assertNotNull(artifacts); + } +} diff --git a/java/sca/modules/contribution-jee/src/test/resources/sample-web-app.war b/java/sca/modules/contribution-jee/src/test/resources/sample-web-app.war new file mode 100644 index 0000000000..681b203fab Binary files /dev/null and b/java/sca/modules/contribution-jee/src/test/resources/sample-web-app.war differ -- cgit v1.2.3