/*
 * #%L
 * it-xcode-maven-plugin
 * %%
 * Copyright (C) 2012 SAP AG
 * %%
 * 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.
 * #L%
 */
package com.sap.prd.mobile.ios.mios;

import java.io.File;
import java.util.Properties;

import junit.framework.Assert;

import org.junit.Test;

public class DependencyToZipToCopyTest extends XCodeTest
{

  @Test
  public void testPrepare() throws Exception
  {

    final String testName = getTestName();

    final File remoteRepositoryDirectory = getRemoteRepositoryDirectory(getClass().getName());

    prepareRemoteRepository(remoteRepositoryDirectory);

    final File zipRepository = new File(new File(".").getCanonicalFile(), "src/test/zipRepository");

    Properties pomReplacements = new Properties();
    pomReplacements.setProperty(PROP_NAME_DEPLOY_REPO_DIR, remoteRepositoryDirectory.getAbsolutePath());
    pomReplacements.setProperty(PROP_NAME_DYNAMIC_VERSION, "1.0." + String.valueOf(System.currentTimeMillis()));
    pomReplacements.setProperty(PROP_NAME_ZIP_REPO_DIR, zipRepository.getAbsolutePath());


    test(testName, new File(getTestRootDirectory(), "copy-zip/MyApp"),
          "com.sap.prd.mobile.ios.mios:xcode-maven-plugin:" + getMavenXcodePluginVersion() + ":prepare-xcode-build",
          THE_EMPTY_LIST,
          null, pomReplacements, new NullProjectModifier());

    File tmp = new File(getTestExecutionDirectory(testName, "MyApp"), "target/xcode-deps/additional-copied-artifacts/"
          + Constants.GROUP_ID + "/MyZip/MyZip-1.0.0.zip");

    Assert.assertTrue("File '" + tmp + "' not found", tmp.exists());
  }
}

@@ -713,57 +713,513 @@
 ava.
-util.Properties;%0A%0Aimport junit.framework.Assert;%0A
+io.FileInputStream;%0Aimport java.io.FileOutputStream;%0Aimport java.io.StringReader;%0Aimport java.util.Properties;%0A%0Aimport junit.framework.Assert;%0A%0Aimport org.apache.commons.io.IOUtils;%0Aimport org.apache.maven.model.Dependency;%0Aimport org.apache.maven.model.Model;%0Aimport org.apache.maven.model.Plugin;%0Aimport org.apache.maven.model.io.xpp3.MavenXpp3Reader;%0Aimport org.apache.maven.model.io.xpp3.MavenXpp3Writer;%0Aimport org.codehaus.plexus.util.xml.Xpp3Dom;%0Aimport org.codehaus.plexus.util.xml.Xpp3DomBuilder;
 %0Aimp
@@ -2016,17 +2016,16 @@
 th());%0A%0A
-%0A
     test
@@ -2073,16 +2073,24 @@
 ), %22
-copy-zip
+straight-forward
 /MyA
@@ -2279,12 +2279,8 @@
 new 
-Null
 Proj
@@ -2292,16 +2292,1889 @@
 difier()
+ %7B%0A%0A            @Override%0A            void execute() throws Exception%0A            %7B%0A              final File pom = new File(testExecutionDirectory, %22pom.xml%22);%0A              FileInputStream fis = null;%0A              FileOutputStream fos = null;%0A%0A              try %7B%0A                fis = new FileInputStream(pom);%0A                final Model model = new MavenXpp3Reader().read(fis);%0A                fis.close();%0A                Xpp3Dom configuration = new Xpp3Dom(%22configuration%22);%0A                StringReader reader = new StringReader(%0A                      %22%3Cconfiguration%3E%3CadditionalPackagingTypes%3E%3Chtml5%3ECOPY%3C/html5%3E%3C/additionalPackagingTypes%3E%3C/configuration%3E%22%0A                      ); %0A                configuration.addChild(Xpp3DomBuilder.build(reader));%0A                model.getBuild().getPlugins().get(0).setConfiguration(configuration);%0A                %0A                model.getDependencies().clear();%0A                Dependency dep = new Dependency();%0A                dep.setGroupId(%22com.sap.ondevice.production.ios.tests%22);%0A                dep.setArtifactId(%22MyZipWithDep%22);%0A                dep.setVersion(%221.0.0%22);%0A                dep.setType(%22html5%22);%0A                model.addDependency(dep);%0A                %0A                Plugin plugin = new Plugin();%0A                plugin.setGroupId(%22com.sap.prd.types%22);%0A                plugin.setArtifactId(%22types-maven-plugin%22);%0A                plugin.setVersion(%220.0.1-SNAPSHOT%22);%0A                plugin.setExtensions(true);%0A                model.getBuild().getPlugins().add(plugin);%0A                %0A                Repo%0A                %0A                fos = new FileOutputStream(pom);%0A                new MavenXpp3Writer().write(fos, model);%0A              %7D%0A              finally %7B%0A                IOUtils.closeQuietly(fis);%0A                IOUtils.closeQuietly(fos);%0A              %7D%0A            %7D%0A          %7D
 );%0A%0A    

Save preliminaryResults.