Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

POC implementation of iOS Extension for Arquillian

  • Loading branch information...
commit d78aa69897b1008d2e8a4476c8e42188c77e6cac 1 parent 88e4ece
@papousek papousek authored
Showing with 1,607 additions and 0 deletions.
  1. +1 −0  .gitignore
  2. +68 −0 README.md
  3. +20 −0 api/pom.xml
  4. +28 −0 api/src/main/java/org/jboss/arquillian/ios/api/Application.java
  5. +28 −0 api/src/main/java/org/jboss/arquillian/ios/api/ApplicationLauncher.java
  6. +94 −0 bom/pom.xml
  7. +87 −0 build/pom.xml
  8. +31 −0 depchain/pom.xml
  9. +53 −0 drone/pom.xml
  10. +31 −0 drone/src/main/java/org/jboss/arquillian/ios/drone/IOSDroneExtension.java
  11. +64 −0 drone/src/main/java/org/jboss/arquillian/ios/drone/impl/IOSDroneConfiguration.java
  12. +86 −0 drone/src/main/java/org/jboss/arquillian/ios/drone/impl/IOSDroneRegistrar.java
  13. +94 −0 drone/src/main/java/org/jboss/arquillian/ios/drone/impl/IPhoneDriverApplication.java
  14. +1 −0  drone/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
  15. +35 −0 drone/src/test/java/org/jboss/arquillian/ios/drone/impl/IPhoneDriverApplicationTestCase.java
  16. +42 −0 ftest/pom.xml
  17. +41 −0 ftest/src/test/java/org/jboss/arquillian/ios/ftest/DroneTestCase.java
  18. +34 −0 ftest/src/test/resources/arquillian.xml
  19. +57 −0 impl/pom.xml
  20. +31 −0 impl/src/main/java/org/jboss/arquillian/ios/IOSExtension.java
  21. +83 −0 impl/src/main/java/org/jboss/arquillian/ios/impl/ApplicationLauncherRegistrar.java
  22. +71 −0 impl/src/main/java/org/jboss/arquillian/ios/impl/IOSConfiguration.java
  23. +83 −0 impl/src/main/java/org/jboss/arquillian/ios/impl/WaxSim.java
  24. +73 −0 impl/src/main/java/org/jboss/arquillian/ios/impl/WaxSimApplicationLauncher.java
  25. +1 −0  impl/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
  26. +34 −0 impl/src/test/java/org/jboss/arquillian/ios/impl/WaxSimTestCase.java
  27. +50 −0 pom.xml
  28. +20 −0 resources/pom.xml
  29. +14 −0 resources/src/main/resources/license/arquillian-extension-ios-license-header.txt
  30. +19 −0 spi/pom.xml
  31. +23 −0 spi/src/main/java/org/jboss/arquillian/ios/spi/event/IOSConfigured.java
  32. +23 −0 spi/src/main/java/org/jboss/arquillian/ios/spi/event/IOSDroneConfigured.java
  33. +23 −0 spi/src/main/java/org/jboss/arquillian/ios/spi/event/IOSDroneReady.java
  34. +23 −0 spi/src/main/java/org/jboss/arquillian/ios/spi/event/IOSReady.java
  35. +19 −0 util/pom.xml
  36. +122 −0 util/src/main/java/org/jboss/arquillian/ios/util/ProcessExecutor.java
View
1  .gitignore
@@ -0,0 +1 @@
+target
View
68 README.md
@@ -0,0 +1,68 @@
+# Arquillian Extension for the iOS Platform
+
+This extensions allows you to bring Arquillian Drone WebDriver based testing to iOS simulators.
+
+## Usage
+
+
+You have to do following steps, expecting your project was already set up to use Drone.
+
+### Add iOS extension to dependencies
+
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-depchain</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+
+### Set up WebDriver in `arquillian.xml`
+
+ <extension qualifier="webdriver">
+ <!-- this is optional if you set -->
+ <property name="browserCapabilities">iphone</property>
+ <!-- this makes WebDriver connect hub on iOS simulator -->
+ <property name="remoteAddress">http://localhost:3001/wd/hub</property>
+ </extension>
+
+### Set up iOS in `arquillian.xml`
+
+You should be aware that following might change in the future. You've been warned!
+
+ <extension qualifier="ios">
+ <!--
+ this is optional - the extension can do `git clone` and build
+ the project automatically, but it can take a long time
+ -->
+ <property name="waxsimBinary">path to your WaxSim binary</property>
+ </extension>
+
+Properties explained, required in **bold**:
+
+* `family` - (iphone) determines whether iPhone or iPad is used, available values: `ipad`, `iphone`
+* `sdk` - SDK version
+* `skip` - (false) skip execution
+* `verbose` - (false) enables printing of additional information
+* `waxsimBinary` - path to WaxSim binary used to start iOS simulator
+* `waxsimGitRepository` - (git://github.com/jonathanpenn/WaxSim.git) WaxSim GIT repository
+
+### Set up iOS Drone in `arquillian.xml`
+
+You should be aware that following might change in the future. You've been warned!
+
+ <extension qualifier="ios-drone">
+ <!--
+ this is optional - the extension can do svn checkout automatically,
+ but it can take a long time
+ -->
+ <property name="localSeleniumCopy">path to your local copy of Selenium repository</property>
+ </extension>
+
+Properties explained, required in **bold**:
+
+* `localSeleniumCopy` - path to your local copy of Selenium SVN repository
+* `seleniumSvnRepository` - (http://selenium.googlecode.com/svn/trunk/) URL of remote SVN repository used to 'svn checkout'
+* `skip` - (false) skip execution
+* `timeoutInSeconds` - (10) maximal time to get Selenium support on iOS simulator started
+* `verbose` - (false) enables printing of additional information
View
20 api/pom.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <!-- Model version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Artifact Configuration -->
+ <artifactId>arquillian-ios-api</artifactId>
+ <packaging>jar</packaging>
+
+ <name>arquillian-ios-api</name>
+
+</project>
View
28 api/src/main/java/org/jboss/arquillian/ios/api/Application.java
@@ -0,0 +1,28 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.api;
+
+import java.io.File;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public interface Application {
+
+ File getLocation();
+
+}
View
28 api/src/main/java/org/jboss/arquillian/ios/api/ApplicationLauncher.java
@@ -0,0 +1,28 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.api;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public interface ApplicationLauncher {
+
+ void launch(Application application) throws IOException;
+
+}
View
94 bom/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <!-- Model version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Configuration -->
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-bom</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>arquillian-ios-bom</name>
+
+ <properties>
+ <version.arquillian>1.0.2.Final</version.arquillian>
+ <version.drone>1.1.0.Final-SNAPSHOT</version.drone>
+ <version.jgit>2.0.0.201206130900-r</version.jgit>
+ <version.svnkit>1.7.5-v1</version.svnkit>
+ </properties>
+
+ <developers>
+ <developer>
+ <name>Jan Papousek</name>
+ <email>jpapouse@redhat.com</email>
+ </developer>
+ </developers>
+
+ <scm>
+ <connection>scm:git:git://git@github.com:arquillian/arquillian-extension-ios.git</connection>
+ <developerConnection>scm:git:ssh://github.com/arquillian/arquillian-extension-ios.git</developerConnection>
+ <url>git://github.com/arquillian/arquillian-extension-ios.git</url>
+ </scm>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-bom</artifactId>
+ <version>${version.arquillian}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-drone-bom</artifactId>
+ <version>${version.drone}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-spi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-drone</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-depchain</artifactId>
+ <type>pom</type>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit</artifactId>
+ <version>${version.jgit}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.tmatesoft.svnkit</groupId>
+ <artifactId>svnkit-cli</artifactId>
+ <version>${version.svnkit}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
View
87 build/pom.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <!-- Model version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-aggregator</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <!-- Artifact Configuration -->
+ <artifactId>arquillian-ios-build</artifactId>
+ <packaging>pom</packaging>
+
+ <name>arquillian-ios-build</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.mycila.maven-license-plugin</groupId>
+ <artifactId>maven-license-plugin</artifactId>
+ <version>1.9.0</version>
+ <configuration>
+ <basedir>${basedir}</basedir>
+ <header>license/arquillian-extension-ios-license-header.txt</header>
+ <quiet>false</quiet>
+ <failIfMissing>false</failIfMissing>
+ <strictCheck>true</strictCheck>
+ <aggregate>false</aggregate>
+ <includes>
+ <include>src/**</include>
+ <include>**/test/**</include>
+ </includes>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ <excludes>
+ <exclude>.gitignore</exclude>
+ </excludes>
+ <properties>
+ <year>2012</year>
+ </properties>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ <executions>
+ <execution>
+ <id>graphene-license-check</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>format</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-resources</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
View
31 depchain/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <!-- Model version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Artifact Configuration -->
+ <artifactId>arquillian-ios-depchain</artifactId>
+ <packaging>pom</packaging>
+
+ <name>arquillian-ios-depchain</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-drone</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
View
53 drone/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <!-- Model version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Artifact Configuration -->
+ <artifactId>arquillian-ios-drone</artifactId>
+ <packaging>jar</packaging>
+
+ <name>arquillian-ios-drone</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.tmatesoft.svnkit</groupId>
+ <artifactId>svnkit-cli</artifactId>
+ </dependency>
+
+ <!-- Arquillian dependencies -->
+ <dependency>
+ <groupId>org.jboss.arquillian.core</groupId>
+ <artifactId>arquillian-core-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.config</groupId>
+ <artifactId>arquillian-config-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-drone-configuration</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
View
31 drone/src/main/java/org/jboss/arquillian/ios/drone/IOSDroneExtension.java
@@ -0,0 +1,31 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.drone;
+
+import org.jboss.arquillian.core.spi.LoadableExtension;
+import org.jboss.arquillian.ios.drone.impl.IOSDroneRegistrar;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class IOSDroneExtension implements LoadableExtension {
+
+ public void register(ExtensionBuilder builder) {
+ builder.observer(IOSDroneRegistrar.class);
+ }
+
+}
View
64 drone/src/main/java/org/jboss/arquillian/ios/drone/impl/IOSDroneConfiguration.java
@@ -0,0 +1,64 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.drone.impl;
+
+import java.io.File;
+import java.lang.annotation.Annotation;
+import org.jboss.arquillian.config.descriptor.api.ArquillianDescriptor;
+import org.jboss.arquillian.drone.configuration.ConfigurationMapper;
+import org.jboss.arquillian.drone.spi.DroneConfiguration;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class IOSDroneConfiguration implements DroneConfiguration<IOSDroneConfiguration> {
+
+ private String localSeleniumCopy;
+ private String seleniumSvnRepository = IPhoneDriverApplication.SELENIUM_SVN_REPOSITORY;
+ private boolean skip = false;
+ private int timeoutInSeconds = 10;
+ private boolean verbose;
+
+ public String getConfigurationName() {
+ return "ios-drone";
+ }
+
+ public File getLocalSeleniumCopy() {
+ return localSeleniumCopy == null ? null : new File(localSeleniumCopy);
+ }
+
+ public String getSeleniumSvnRepository() {
+ return seleniumSvnRepository;
+ }
+
+ public int getTimeoutInSeconds() {
+ return timeoutInSeconds;
+ }
+
+ public boolean isSkip() {
+ return skip;
+ }
+
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ public IOSDroneConfiguration configure(ArquillianDescriptor descriptor, Class<? extends Annotation> qualifier) {
+ return ConfigurationMapper.fromArquillianDescriptor(descriptor, this, qualifier);
+ }
+
+}
View
86 drone/src/main/java/org/jboss/arquillian/ios/drone/impl/IOSDroneRegistrar.java
@@ -0,0 +1,86 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.drone.impl;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.concurrent.TimeUnit;
+import org.jboss.arquillian.config.descriptor.api.ArquillianDescriptor;
+import org.jboss.arquillian.core.api.Event;
+import org.jboss.arquillian.core.api.InstanceProducer;
+import org.jboss.arquillian.core.api.annotation.Inject;
+import org.jboss.arquillian.core.api.annotation.Observes;
+import org.jboss.arquillian.drone.api.annotation.Default;
+import org.jboss.arquillian.ios.api.Application;
+import org.jboss.arquillian.ios.api.ApplicationLauncher;
+import org.jboss.arquillian.ios.spi.event.IOSDroneConfigured;
+import org.jboss.arquillian.ios.spi.event.IOSDroneReady;
+import org.jboss.arquillian.ios.spi.event.IOSReady;
+import org.jboss.arquillian.test.spi.annotation.SuiteScoped;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class IOSDroneRegistrar {
+
+ @Inject
+ private Event<IOSDroneReady> ready;
+ @Inject
+ private Event<IOSDroneConfigured> configured;
+ @Inject
+ @SuiteScoped
+ private InstanceProducer<IOSDroneConfiguration> configuration;
+
+ public void configure(@Observes IOSReady event, ArquillianDescriptor descriptor) {
+ configuration.set(new IOSDroneConfiguration().configure(descriptor, Default.class));
+ configured.fire(new IOSDroneConfigured());
+ }
+
+ public void register(@Observes IOSDroneConfigured event, ApplicationLauncher launcher) throws IOException, InterruptedException {
+ if (configuration.get().isSkip()) {
+ return;
+ }
+ Application application = new IPhoneDriverApplication(configuration.get().getLocalSeleniumCopy(), IPhoneDriverApplication.SVN_TRUNK);
+ launcher.launch(application);
+ // wait until selenium is reachable
+ boolean reachable = false;
+ long expectedTimeout = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(configuration.get().getTimeoutInSeconds());
+ while (!reachable) {
+ HttpURLConnection connection = null;
+ try {
+ connection = (HttpURLConnection) new URL("http://localhost:3001/wd/hub").openConnection();
+ if (connection.getResponseCode() == 200) {
+ reachable = true;
+ } else {
+ Thread.sleep(100);
+ }
+ } catch(Exception ignored) {
+ Thread.sleep(100);
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ if (expectedTimeout < System.currentTimeMillis()) {
+ throw new IllegalStateException("Can't start application for Selenium support.");
+ }
+ }
+ ready.fire(new IOSDroneReady());
+ }
+
+}
View
94 drone/src/main/java/org/jboss/arquillian/ios/drone/impl/IPhoneDriverApplication.java
@@ -0,0 +1,94 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.drone.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.jboss.arquillian.ios.api.Application;
+import org.jboss.arquillian.ios.util.ProcessExecutor;
+import org.tmatesoft.svn.core.SVNDepth;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNRevision;
+import org.tmatesoft.svn.core.wc.SVNUpdateClient;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class IPhoneDriverApplication implements Application {
+
+ public static final String SELENIUM_SVN_REPOSITORY = "http://selenium.googlecode.com/svn";
+ public static final String SVN_TRUNK = SELENIUM_SVN_REPOSITORY + "/trunk/";
+ private final File location;
+ private static final Logger LOG = Logger.getLogger(IPhoneDriverApplication.class.getName());
+
+ public IPhoneDriverApplication() throws IOException {
+ this(SVN_TRUNK);
+ }
+
+ public IPhoneDriverApplication(File localRepository, String svnRepository) throws IOException {
+ this.location = init(svnRepository, localRepository);
+ }
+
+ public IPhoneDriverApplication(String svnRepository) throws IOException {
+ this.location = init(svnRepository, null);
+ }
+
+ public IPhoneDriverApplication(File location) {
+ this.location = location;
+ }
+
+ public File getLocation() {
+ return location;
+ }
+
+ private File init(String svnRepository, File target) throws IOException {
+ File repository = target;
+ try {
+ if (repository == null) {
+ repository = File.createTempFile("arq-ios", "selenium");
+ repository.delete();
+ }
+ if (!repository.exists()) {
+ LOG.log(Level.INFO, "svn checkout <{0}> to <{1}>. It can take a long time.", new Object[]{svnRepository, repository.getAbsolutePath()});
+ repository.mkdirs();
+ repository.deleteOnExit();
+ SVNUpdateClient svn = SVNClientManager.newInstance().getUpdateClient();
+ svn.doCheckout(SVNURL.parseURIEncoded(svnRepository), repository, SVNRevision.UNDEFINED, SVNRevision.HEAD, SVNDepth.INFINITY, true);
+ }
+ } catch (Exception ex) {
+ throw new IOException("Can't checkout <" + svnRepository + ">.");
+ }
+ File app = new File(repository, "iphone" + File.separator + "build" + File.separator + "Release-iphonesimulator" + File.separator + "iWebDriver.app");
+ if (!app.exists()) {
+ LOG.log(Level.INFO, "<{0}> doesn''t exist, so building selenium.", app.getAbsolutePath());
+ List<String> goOutput = ProcessExecutor.execute(repository, "./go", "iphone");
+ for (String line : goOutput) {
+ System.out.println(line);
+ }
+ List<String> xcodebuildOutput = ProcessExecutor.execute(new File(repository, "iphone"), "xcodebuild", "clean", "build", "CODE_SIGN_IDENTITY=\"\"", "CODE_SIGNING_REQUIRED=NO", "ONLY_ACTIVE_ARCHS=NO", "-arch", "i386", "-project", "iWebDriver.xcodeproj");
+ // FIXME: xcodebuild fails, but iWebDriver is built successfully
+// for (String line : xcodebuildOutput) {
+// System.out.println(line);
+// }
+ }
+ return app;
+ }
+}
View
1  drone/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
@@ -0,0 +1 @@
+org.jboss.arquillian.ios.drone.IOSDroneExtension
View
35 drone/src/test/java/org/jboss/arquillian/ios/drone/impl/IPhoneDriverApplicationTestCase.java
@@ -0,0 +1,35 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.drone.impl;
+
+import java.io.IOException;
+import org.jboss.arquillian.ios.api.Application;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class IPhoneDriverApplicationTestCase {
+
+ @Test
+ public void testInit() throws IOException {
+ Application application = new IPhoneDriverApplication();
+ Assert.assertTrue(application.getLocation().exists());
+ }
+
+}
View
42 ftest/pom.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <!-- Model version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Artifact Configuration -->
+ <artifactId>arquillian-ios-ftest</artifactId>
+ <packaging>jar</packaging>
+
+ <name>arquillian-ios-ftest</name>
+
+ <dependencies>
+ <!-- Arquillian JUnit -->
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-standalone</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- Drone -->
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-drone-webdriver-depchain</artifactId>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <!-- IPhone -->
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-depchain</artifactId>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
View
41 ftest/src/test/java/org/jboss/arquillian/ios/ftest/DroneTestCase.java
@@ -0,0 +1,41 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.ftest;
+
+import junit.framework.Assert;
+import org.jboss.arquillian.drone.api.annotation.Drone;
+import org.jboss.arquillian.junit.Arquillian;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.iphone.IPhoneDriver;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+@RunWith(Arquillian.class)
+public class DroneTestCase {
+
+ @Drone
+ private IPhoneDriver browser;
+
+ @Test
+ public void open() {
+ browser.get("http://google.com");
+ Assert.assertTrue(browser.getTitle().contains("Google"));
+ }
+
+}
View
34 ftest/src/test/resources/arquillian.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--
+
+ JBoss, Home of Professional Open Source
+ Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ 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.
+
+-->
+<arquillian xmlns="http://jboss.com/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+
+ <extension qualifier="ios">
+ </extension>
+
+ <extension qualifier="ios-drone">
+ <property name="localSeleniumCopy">/Users/jboss/Workspace/selenium-read-only</property>
+ </extension>
+
+ <extension qualifier="webdriver">
+ <property name="remoteAddress">http://localhost:3001/wd/hub</property>
+ </extension>
+
+</arquillian>
View
57 impl/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <!-- Model version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Artifact Configuration -->
+ <artifactId>arquillian-ios-impl</artifactId>
+ <packaging>jar</packaging>
+
+ <name>arquillian-ios-impl</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit</artifactId>
+ </dependency>
+
+ <!-- Arquillian dependencies -->
+ <dependency>
+ <groupId>org.jboss.arquillian.core</groupId>
+ <artifactId>arquillian-core-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.test</groupId>
+ <artifactId>arquillian-test-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.config</groupId>
+ <artifactId>arquillian-config-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-drone-configuration</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
View
31 impl/src/main/java/org/jboss/arquillian/ios/IOSExtension.java
@@ -0,0 +1,31 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios;
+
+import org.jboss.arquillian.core.spi.LoadableExtension;
+import org.jboss.arquillian.ios.impl.ApplicationLauncherRegistrar;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class IOSExtension implements LoadableExtension {
+
+ public void register(ExtensionBuilder builder) {
+ builder.observer(ApplicationLauncherRegistrar.class);
+ }
+
+}
View
83 impl/src/main/java/org/jboss/arquillian/ios/impl/ApplicationLauncherRegistrar.java
@@ -0,0 +1,83 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.impl;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.jboss.arquillian.config.descriptor.api.ArquillianDescriptor;
+import org.jboss.arquillian.core.api.Event;
+import org.jboss.arquillian.core.api.InstanceProducer;
+import org.jboss.arquillian.core.api.annotation.Inject;
+import org.jboss.arquillian.core.api.annotation.Observes;
+import org.jboss.arquillian.drone.api.annotation.Default;
+import org.jboss.arquillian.ios.api.ApplicationLauncher;
+import org.jboss.arquillian.ios.spi.event.IOSConfigured;
+import org.jboss.arquillian.ios.spi.event.IOSReady;
+import org.jboss.arquillian.ios.util.ProcessExecutor;
+import org.jboss.arquillian.test.spi.annotation.SuiteScoped;
+import org.jboss.arquillian.test.spi.event.suite.AfterSuite;
+import org.jboss.arquillian.test.spi.event.suite.BeforeSuite;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class ApplicationLauncherRegistrar {
+
+ @Inject
+ @SuiteScoped
+ private InstanceProducer<ApplicationLauncher> applicationLauncher;
+ @Inject
+ @SuiteScoped
+ private InstanceProducer<IOSConfiguration> configuration;
+ @Inject
+ private Event<IOSConfigured> configured;
+ @Inject
+ private Event<IOSReady> ready;
+
+ private static final Logger LOG = Logger.getLogger(ApplicationLauncherRegistrar.class.getName());
+
+ public void configure(@Observes BeforeSuite event, ArquillianDescriptor descriptor) {
+ configuration.set(new IOSConfiguration().configure(descriptor, Default.class));
+ configured.fire(new IOSConfigured());
+ }
+
+ public void register(@Observes IOSConfigured event) throws IOException {
+ if (configuration.get().isSkip()) {
+ return;
+ }
+ WaxSim waxSim;
+ if (configuration.get().getWaxsimBinary() != null) {
+ LOG.log(Level.INFO, "path to waxsim binary has been specified <{0}>", configuration.get().getWaxsimBinary().getAbsolutePath());
+ waxSim = new WaxSim(configuration.get().getWaxsimBinary());
+ } else {
+ LOG.info("path to waxsim binary hasn't been specified");
+ waxSim = new WaxSim(configuration.get().getWaxsimGitRepository(), configuration.get().isVerbose());
+ LOG.log(Level.INFO, "path to waxsim binary has bee set to <{0}>", waxSim.getBinary().getAbsolutePath());
+ }
+ applicationLauncher.set(new WaxSimApplicationLauncher(configuration.get(), waxSim.getBinary()));
+ ready.fire(new IOSReady());
+ }
+
+ public void killall(@Observes AfterSuite event) throws IOException {
+ if (configuration.get().isSkip()) {
+ return;
+ }
+ ProcessExecutor.execute("killall", "iPhone Simulator");
+ }
+
+}
View
71 impl/src/main/java/org/jboss/arquillian/ios/impl/IOSConfiguration.java
@@ -0,0 +1,71 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.impl;
+
+import java.io.File;
+import java.lang.annotation.Annotation;
+import org.jboss.arquillian.config.descriptor.api.ArquillianDescriptor;
+import org.jboss.arquillian.drone.configuration.ConfigurationMapper;
+import org.jboss.arquillian.drone.spi.DroneConfiguration;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class IOSConfiguration implements DroneConfiguration<IOSConfiguration> {
+
+ private String family = "iphone";
+ private String sdk;
+ private boolean skip = false;
+ private boolean verbose = false;
+ private String waxsimBinary;
+ private String waxsimGitRepository = WaxSim.WAXSIM_GIT_REPOSITORY;
+
+ private static final String NAME = "ios";
+
+ public String getFamily() {
+ return family;
+ }
+
+ public String getSdk() {
+ return sdk;
+ }
+
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ public boolean isSkip() {
+ return skip;
+ }
+
+ public File getWaxsimBinary() {
+ return waxsimBinary == null ? null : new File(waxsimBinary);
+ }
+
+ public String getWaxsimGitRepository() {
+ return waxsimGitRepository;
+ }
+
+ public String getConfigurationName() {
+ return NAME;
+ }
+
+ public IOSConfiguration configure(ArquillianDescriptor descriptor, Class<? extends Annotation> qualifier) {
+ return ConfigurationMapper.fromArquillianDescriptor(descriptor, this, qualifier);
+ }
+
+}
View
83 impl/src/main/java/org/jboss/arquillian/ios/impl/WaxSim.java
@@ -0,0 +1,83 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.transport.CredentialsProvider;
+import org.jboss.arquillian.ios.util.ProcessExecutor;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class WaxSim {
+
+ public static final String WAXSIM_GIT_REPOSITORY = "git://github.com/jonathanpenn/WaxSim.git";
+ private static final Logger LOG = Logger.getLogger(WaxSim.class.getName());
+ private final File binary;
+
+ public WaxSim() throws IOException {
+ this(WAXSIM_GIT_REPOSITORY);
+ }
+
+ public WaxSim(boolean verbose) throws IOException {
+ this(WAXSIM_GIT_REPOSITORY, verbose);
+ }
+
+ public WaxSim(File binary) {
+ this.binary = binary;
+ }
+
+ public WaxSim(String gitRemote) throws IOException {
+ this(gitRemote, false);
+ }
+
+ public WaxSim(String gitRemote, boolean verbose) throws IOException {
+ this.binary = prepareBinary(gitRemote, verbose);
+ }
+
+ public File getBinary() {
+ return binary;
+ }
+
+ private File prepareBinary(String gitRemote, boolean verbose) throws IOException {
+ File repository = null;
+ try {
+ repository = File.createTempFile("arq-ios", "waxsim");
+ repository.delete();
+ repository.mkdirs();
+ repository.deleteOnExit();
+ LOG.log(Level.INFO, "git clone <{0}>.", gitRemote);
+ Git.cloneRepository().setDirectory(repository).setURI(gitRemote).setCredentialsProvider(CredentialsProvider.getDefault()).call();
+
+ } catch (Exception e) {
+ throw new IOException("Can't clone <" + gitRemote + ">", e);
+ }
+ LOG.info("building waxsim");
+ List<String> output = ProcessExecutor.execute(repository, "xcodebuild", "-project", "WaxSim.xcodeproj");
+ if (verbose) {
+ for (String line : output) {
+ System.out.println(line);
+ }
+ }
+ return new File(repository, "build" + File.separator + "Release" + File.separator + "waxsim");
+ }
+}
View
73 impl/src/main/java/org/jboss/arquillian/ios/impl/WaxSimApplicationLauncher.java
@@ -0,0 +1,73 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.jboss.arquillian.ios.api.Application;
+import org.jboss.arquillian.ios.api.ApplicationLauncher;
+import org.jboss.arquillian.ios.util.ProcessExecutor;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class WaxSimApplicationLauncher implements ApplicationLauncher {
+
+ private static final String DEFAULT_COMMAND = "waxsim";
+
+ private final String command;
+ private final IOSConfiguration configuration;
+
+ public WaxSimApplicationLauncher(IOSConfiguration configuration) {
+ this.command = DEFAULT_COMMAND;
+ this.configuration = configuration;
+ }
+
+ public WaxSimApplicationLauncher(IOSConfiguration configuration, File binary) {
+ if (!binary.exists()) {
+ throw new IllegalArgumentException("<" + binary.getAbsolutePath() + "> doesn't exist.");
+ }
+ this.command = binary.getAbsolutePath();
+ this.configuration = configuration;
+ }
+
+ @Override
+ public void launch(Application application) throws IOException {
+ if (!application.getLocation().exists()) {
+ throw new IllegalArgumentException("<" + application.getLocation().getAbsolutePath() + "> doesn't exist.");
+ }
+ List<String> commands = new ArrayList<String>();
+ commands.add(command);
+ if (configuration.getSdk() != null) {
+ commands.add("-s");
+ commands.add(configuration.getSdk());
+ }
+ if (configuration.getFamily().equals("ipad")) {
+ commands.add("-f");
+ commands.add("ipad");
+ } else if (!configuration.getFamily().equals("iphone")) {
+ throw new IllegalArgumentException("Given family '" + configuration.getFamily() + "' is not supported. Supported famalies are 'iphone' and 'ipad'.");
+ }
+ commands.add(application.getLocation().getAbsolutePath());
+ String[] commandsArray = new String[commands.size()];
+
+ ProcessExecutor.spawn(commands.toArray(commandsArray));
+ }
+
+}
View
1  impl/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
@@ -0,0 +1 @@
+org.jboss.arquillian.ios.IOSExtension
View
34 impl/src/test/java/org/jboss/arquillian/ios/impl/WaxSimTestCase.java
@@ -0,0 +1,34 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.impl;
+
+import java.io.IOException;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class WaxSimTestCase {
+
+ @Test
+ public void testBuild() throws IOException {
+ WaxSim waxSim = new WaxSim(true);
+ Assert.assertTrue(waxSim.getBinary().exists());
+ }
+
+}
View
50 pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>9</version>
+ <relativePath/>
+ </parent>
+
+ <!-- Model version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Configuration -->
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-aggregator</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>arquillian-ios-aggregator</name>
+
+ <developers>
+ <developer>
+ <name>Jan Papousek</name>
+ <email>jpapouse@redhat.com</email>
+ </developer>
+ </developers>
+
+ <scm>
+ <connection>scm:git:git://git@github.com:arquillian/arquillian-extension-ios.git</connection>
+ <developerConnection>scm:git:ssh://github.com/arquillian/arquillian-extension-ios.git</developerConnection>
+ <url>git://github.com/arquillian/arquillian-extension-ios.git</url>
+ </scm>
+
+ <!-- Modules -->
+ <modules>
+ <module>api</module>
+ <module>bom</module>
+ <module>build</module>
+ <module>depchain</module>
+ <module>drone</module>
+ <module>ftest</module>
+ <module>impl</module>
+ <module>resources</module>
+ <module>spi</module>
+ <module>util</module>
+ </modules>
+
+</project>
View
20 resources/pom.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <!-- Model version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-aggregator</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <!-- Artifact Configuration -->
+ <artifactId>arquillian-ios-resources</artifactId>
+ <packaging>jar</packaging>
+
+ <name>arquillian-ios-resources</name>
+
+</project>
View
14 resources/src/main/resources/license/arquillian-extension-ios-license-header.txt
@@ -0,0 +1,14 @@
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+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.
View
19 spi/pom.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <!-- Model version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Artifact Configuration -->
+ <artifactId>arquillian-ios-spi</artifactId>
+ <packaging>jar</packaging>
+
+ <name>arquillian-ios-spi</name>
+</project>
View
23 spi/src/main/java/org/jboss/arquillian/ios/spi/event/IOSConfigured.java
@@ -0,0 +1,23 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.spi.event;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class IOSConfigured {
+}
View
23 spi/src/main/java/org/jboss/arquillian/ios/spi/event/IOSDroneConfigured.java
@@ -0,0 +1,23 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.spi.event;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class IOSDroneConfigured {
+}
View
23 spi/src/main/java/org/jboss/arquillian/ios/spi/event/IOSDroneReady.java
@@ -0,0 +1,23 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.spi.event;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class IOSDroneReady {
+}
View
23 spi/src/main/java/org/jboss/arquillian/ios/spi/event/IOSReady.java
@@ -0,0 +1,23 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.spi.event;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class IOSReady {
+}
View
19 util/pom.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <!-- Model version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-ios-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Artifact Configuration -->
+ <artifactId>arquillian-ios-util</artifactId>
+ <packaging>jar</packaging>
+
+ <name>arquillian-ios-util</name>
+</project>
View
122 util/src/main/java/org/jboss/arquillian/ios/util/ProcessExecutor.java
@@ -0,0 +1,122 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+package org.jboss.arquillian.ios.util;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class ProcessExecutor {
+
+ public static Process spawn(String... commands) throws IOException {
+ final Process process = new ProcessBuilder(commands).start();
+ new Thread(new ConsoleConsumer(process, System.out)).start();
+ Thread shutdownThread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ if (process != null) {
+ process.destroy();
+ try {
+ process.waitFor();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ });
+ return process;
+ }
+
+ public static List<String> execute(String... commands) throws IOException {
+ return execute(null, commands);
+ }
+
+ public static List<String> execute(File workingDirectory, String... commands) throws IOException {
+ ProcessBuilder pb = new ProcessBuilder(commands).redirectErrorStream(true);
+ if (workingDirectory != null) {
+ pb.directory(workingDirectory);
+ }
+ final Process process = pb.start();
+ ConsoleConsumer consumer = new ConsoleConsumer(process);
+ Thread consumerThread = new Thread(consumer);
+ consumerThread.start();
+ try {
+ process.waitFor();
+ consumerThread.join();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ return consumer.getOutputList();
+ }
+
+ private static class ConsoleConsumer implements Runnable {
+
+ private final Process process;
+ private final PrintStream log;
+ private final List<String> outputList = new ArrayList<String>();
+ private static final String NL = System.getProperty("line.separator");
+
+ public ConsoleConsumer(Process process) {
+ this.process = process;
+ this.log = null;
+ }
+
+ public ConsoleConsumer(Process process, PrintStream log) {
+ this.process = process;
+ this.log = log;
+ }
+
+ public List<String> getOutputList() {
+ return outputList;
+ }
+
+ public void run() {
+ final InputStream stream = process.getInputStream();
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+
+ int i;
+ StringBuilder line = new StringBuilder();
+ try {
+ while ((i = reader.read()) != -1) {
+ char c = (char) i;
+ // add the character
+ line.append(c);
+ if (log != null) {
+ log.print(c);
+ }
+ // save output
+ if (line.indexOf(NL) != -1) {
+ outputList.add(line.toString());
+ line = new StringBuilder();
+ }
+ }
+ if (line.length() > 1) {
+ outputList.add(line.toString());
+ }
+ } catch (IOException ignored) {
+ }
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.