<!--
	~ Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
	~
	~ Licensed 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

	<parent>
		<groupId>org.wso2.mashup</groupId>
		<artifactId>org.wso2.mashup</artifactId>
		<version>0.2-RC1</version>
	</parent>

	<modelVersion>4.0.0</modelVersion>
	<artifactId>wso2mashup-integration</artifactId>
	<packaging>jar</packaging>
	<version>0.2-RC1</version>
	<name>WSO2 Mashup Server - Integration Tests</name>

	<dependencies>
		<dependency>
			<groupId>org.wso2.mashup</groupId>
			<artifactId>wso2mashup-hostobjects</artifactId>
			<version>${pom.version}</version>
		</dependency>

		<dependency>
			<groupId>org.wso2.mashup</groupId>
			<artifactId>wso2mashup-javascriptdeployer</artifactId>
			<version>${pom.version}</version>
		</dependency>

		<dependency>
			<groupId>org.wso2.mashup</groupId>
			<artifactId>wso2mashup-core</artifactId>
			<version>${pom.version}</version>
		</dependency>

		<dependency>
			<groupId>httpunit</groupId>
			<artifactId>httpunit</artifactId>
			<version>${httpunit.version}</version>
			<exclusions>
				<exclusion>
					<groupId>rhino</groupId>
					<artifactId>js</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>tidy</groupId>
			<artifactId>tidy</artifactId>
			<version>${tidy.version}</version>
		</dependency>
	</dependencies>

	<build>
		<sourceDirectory>src</sourceDirectory>
		<testSourceDirectory>test</testSourceDirectory>
		<resources>
			<resource>
				<directory>src</directory>
				<includes>
					<include>**/*.xml</include>
				</includes>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<version>2.0-alpha-1-SNAPSHOT</version>
				<executions>
					<execution>
						<id>download-addressing</id>
						<phase>initialize</phase>
						<goals>
							<goal>copy</goal>
						</goals>
						<configuration>
							<artifactItems>
								<artifactItem>
									<groupId>org.apache.axis2</groupId>
									<artifactId>addressing</artifactId>
									<version>${addressing.version}</version>
									<type>mar</type>
									<overWrite>true</overWrite>
									<outputDirectory>${testResources.dir}/repo/modules</outputDirectory>
								</artifactItem>
								<artifactItem>
									<groupId>org.wso2.wsas</groupId>
									<artifactId>wso2wsas</artifactId>
									<version>${wso2wsas.version}</version>
									<type>zip</type>
									<overWrite>true</overWrite>
									<outputDirectory>target/zips</outputDirectory>
								</artifactItem>
								<artifactItem>
									<groupId>org.wso2.dynamiccodegen</groupId>
									<artifactId>wso2dynamic-codegen</artifactId>
									<version>${dynamicCodegen.version}</version>
									<type>zip</type>
									<overWrite>true</overWrite>
									<outputDirectory>target/zips</outputDirectory>
								</artifactItem>
								<artifactItem>
									<groupId>yui</groupId>
									<artifactId>yui</artifactId>
									<version>${yui.version}</version>
									<type>zip</type>
									<overWrite>true</overWrite>
									<outputDirectory>target/zips</outputDirectory>
								</artifactItem>
			    				<artifactItem>
									<groupId>yui-ext</groupId>
									<artifactId>yui-ext</artifactId>
									<version>${yui.ext.version}</version>
									<type>zip</type>
									<overWrite>true</overWrite>
									<outputDirectory>target/zips</outputDirectory>
								</artifactItem>
								<artifactItem>
									<groupId>org.wso2.wsf.javascript.native</groupId>
									<artifactId>wsrequest</artifactId>
									<version>${wsrequest.version}</version>
									<type>zip</type>
									<overWrite>true</overWrite>
									<outputDirectory>target/zips</outputDirectory>
								</artifactItem>
							</artifactItems>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.1</version>
				<executions>
					<execution>
						<id>create-test-resources</id>
						<phase>initialize</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<tasks>
								<tstamp>
									<format property="release_date" pattern="MMMM d, yyyy  hh:mm aa 'GMT'" locale="en" timezone="GMT"/>
								</tstamp>
								<filter token="release_date" value="${release_date}" />
								
								<condition property="nightly" else="false">
  									<contains string="${wso2mashup.version}" substring="SNAPSHOT"/>
								</condition>
								<filter token="is_nightly" value="${nightly}" />
								<filter token="mashup_version_number" value="${wso2mashup.version.number}" />
								<filter token="mashup_version" value="${wso2mashup.version}" />
								
								<filter token="HTTP_PORT" value="11001" />
								<filter token="HTTPS_PORT" value="11002" />
								<filter token="COMMAND_PORT" value="11003" />
								
								<echo message="### Unzip and move WSAS Standalone Edition ###" />
								<unzip src="target/zips/wso2wsas-${wso2wsas.version}.zip" dest="target/temp" />
								<move file="target/temp/wso2wsas-${wso2wsas.version}" tofile="${testwsas.dir}" />

								<!--  move the services & modules directories to the root level -->
								<move todir="${testwsas.dir}/services">
									<fileset dir="${testwsas.dir}/repository/services">
										<include name="*.*" />
									</fileset>
								</move>
								<move todir="${testwsas.dir}/modules">
									<fileset dir="${testwsas.dir}/repository/modules">
										<include name="*.*" />
									</fileset>
								</move>
								<delete dir="${testwsas.dir}/repository" />

								<!--  move the WSAS admin web app -->
								<move todir="${testwsas.dir}/lib/tomcat/webapps/wsasadmin">
									<fileset dir="${testwsas.dir}/lib/tomcat/webapps/ROOT" />
								</move>

								<!-- remove unwanted resources from WSAS dist -->
								<delete file="${testwsas.dir}/conf/axis2.xml" />
								<delete file="${testwsas.dir}/conf/server.xml" />
								<delete file="${testwsas.dir}/services/version.aar" />
								<delete file="${testwsas.dir}/services/echo.aar" />
								<delete file="${testwsas.dir}/lib/tomcat/webapps/wsasadmin/WEB-INF/web.xml" />

								<echo message="### Unzip and move Dynamic Codegen Stylesheets ###" />
								<unzip src="target/zips/wso2dynamic-codegen-${dynamicCodegen.version}.zip" dest="target/temp/dynamic-codegen" />
								<move todir="target/test-classes">
									<fileset dir="target/temp/dynamic-codegen">
										<include name="*.xsl" />
										<include name="*.xslt" />
									</fileset>
								</move>

								<!-- copy the mashup UI -->
								<mkdir dir="${testwsas.dir}/lib/tomcat/webapps/ROOT" />
								<copy todir="${testwsas.dir}/lib/tomcat/webapps/ROOT">
									<fileset dir="../www">
										<include name="**/*.js" />
										<include name="**/*.gif" />
										<include name="**/*.jpg" />
										<include name="**/*.png" />
										<include name="**/*.html" />
										<include name="**/*.css" />
										<include name="**/*.xslt" />
										<include name="**/*.xsl" />
									</fileset>
								</copy>
								<unzip src="target/zips/yui-${yui.version}.zip" dest="target/temp" />
								<move file="target/temp/yui" tofile="${testwsas.dir}/lib/tomcat/webapps/ROOT/js/yui" />
								<unzip src="target/zips/yui-ext-${yui.ext.version}.zip" dest="target/temp" />
								<move file="target/temp/ext-1.0.1/adapter/yui/yui-utilities.js" todir="${testwsas.dir}/lib/tomcat/webapps/ROOT/js/yui-ext" />
								<move file="target/temp/ext-1.0.1/adapter/yui/ext-yui-adapter.js" todir="${testwsas.dir}/lib/tomcat/webapps/ROOT/js/yui-ext" />
								<move file="target/temp/ext-1.0.1/ext-all.js" todir="${testwsas.dir}/lib/tomcat/webapps/ROOT/js/yui-ext" />
								<move file="target/temp/ext-1.0.1/ext-back-compat.js" todir="${testwsas.dir}/lib/tomcat/webapps/ROOT/js/yui-ext" />
								<unzip src="target/zips/wsrequest-${wsrequest.version}.zip" dest="target/temp/wsrequest" />
								<move file="target/temp/wsrequest/WSRequest.js" todir="${testwsas.dir}/lib/tomcat/webapps/ROOT/js/wso2" />

								<!-- copy the server configuration files -->
								<copy todir="${testwsas.dir}/conf" filtering="on">
									<fileset dir="../core/conf">
										<include name="*.xml" />
										<exclude name="web*.xml" />
									</fileset>
								</copy>
								<copy file="../core/conf/web_root.xml" tofile="${testwsas.dir}/lib/tomcat/webapps/ROOT/WEB-INF/web.xml" />
								<copy file="../core/conf/web_wsasadmin.xml" tofile="${testwsas.dir}/lib/tomcat/webapps/wsasadmin/WEB-INF/web.xml" />

								<move file="${testwsas.dir}/conf/log4j.properties" todir="target/test-classes" />
								<move file="${testwsas.dir}/conf/ui-extensions-config.xml" todir="target/test-classes" />
								<move file="${testwsas.dir}/conf/wso2wsas.hibernate.cfg.xml" todir="target/test-classes" />
								<move file="${testwsas.dir}/conf/wso2wsas.hbm.xml" todir="target/test-classes" />
								<move file="${testwsas.dir}/conf/wso2wsas.properties" todir="target/test-classes" />

								<copy todir="${testwsas.dir}/scripts">
									<fileset dir="test-resources/scripts" />
								</copy>

                                <echo message="### Copy the core services ###"/>

                                <copy toFile="${testwsas.dir}/services/wso2mashup-scraperService.aar" filtering="off">
									<fileset file="../coreservices/scraperservice/target/wso2mashup-scraperService.aar" />
								</copy>

                                <copy toFile="${testwsas.dir}/services/wso2mashup-coreservices-servicesharinghelper.aar" filtering="off">
									<fileset file="../coreservices/servicesharinghelper/target/wso2mashup-coreservices-servicesharinghelper-${wso2mashup.version}.aar" />
								</copy>

                                <copy toFile="${testwsas.dir}/services/wso2mashup-coreservices-servicemetadatalister.aar" filtering="off">
									<fileset file="../coreservices/servicemetadatalister/target/wso2mashup-coreservices-servicemetadatalister-${wso2mashup.version}.aar" />
								</copy>

                                <copy toFile="${testwsas.dir}/services/wso2mashup-coreservices-sharingservice.aar" filtering="off">
									<fileset file="../coreservices/sharingservice/target/wso2mashup-coreservices-sharingservice-${wso2mashup.version}.aar" />
								</copy>

                                <copy file="../core/scripts/services/version.js" todir="${testwsas.dir}/scripts" filtering="on"/>
                                <copy toDir="${testwsas.dir}/scripts/version.resources" filtering="on">
									<fileset dir="../core/scripts/services/version.resources" />
								</copy>
							</tasks>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-surefire-plugin</artifactId>
				<inherited>false</inherited>
				<configuration>
                    <!--<forkMode>pertest</forkMode>-->
					<argLine>-enableassertions</argLine>
					<testFailureIgnore>false</testFailureIgnore>
					<skip>false</skip>
					<includes>
						<include>**/*IntegrationTestSuite.java</include>
					</includes>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<properties>
		<testResources.dir>target</testResources.dir>
		<testwsas.dir>target/wsas</testwsas.dir>
	</properties>
</project>
