Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 15, 2012
@rtyley Revert "Use Application rather than Context in CuriousHostKeyRepository"
This reverts commit 6a90dcc, which seems
to do the opposite of what it's commit message states...
b05a533
@rtyley use simplified toy-ssh-agent
fewer dependencies
22d891d
@rtyley Robolectric 1.0 0e14a8f
@rtyley tidy test, remove unsed ref to RoboUnitTestCase 20cfc45
@rtyley Delete unused roboservicetestcase ab224e3
Commits on May 03, 2012
@rtyley Provide host IP to android device for integration tests
Used so the device can hit a local git server running in the maven-running
host device.
f1aa88c
View
42 agit-integration-tests/pom.xml
@@ -16,7 +16,7 @@
<groupId>com.madgag</groupId>
<artifactId>toy-ssh-agent</artifactId>
<!-- Needs to come before Agit -->
- <version>1.4</version>
+ <version>1.5</version>
<type>apk</type>
</dependency>
<dependency>
@@ -68,6 +68,46 @@
</configuration>
</plugin>
<plugin>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <version>3.0.1</version>
+ <executions>
+ <execution>
+ <id>get-local-ip</id>
+ <phase>initialize</phase>
+ <goals>
+ <goal>script</goal>
+ </goals>
+ <configuration>
+ <scalaVersion>2.9.1</scalaVersion>
+ <script>
+ import scala.collection.JavaConversions._
+ import com.android.ddmlib._
+
+ def run() {
+ val ipAddresses = java.net.NetworkInterface.getNetworkInterfaces().filter { !_.isLoopback }.flatMap { _.getInetAddresses }.map { _.getHostAddress }.mkString(",")
+ AndroidDebugBridge.init(false)
+ val androidDebugBridge = AndroidDebugBridge.createBridge
+ androidDebugBridge.getDevices.filter { !_.isEmulator } foreach { d =>
+ val command = "echo gitserver.host.address="+ipAddresses+" > "+d.getMountPoint(IDevice.MNT_EXTERNAL_STORAGE)+"/agit-integration-test.properties"
+
+ d.executeShellCommand(command, NullOutputReceiver.getReceiver)
+ }
+ println ("Provided host ip addresses : "+ipAddresses)
+ }
+ </script>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>com.android.ddmlib</groupId>
+ <artifactId>ddmlib</artifactId>
+ <version>r16</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
</plugin>
View
21 agit-integration-tests/src/main/java/com/madgag/agit/sync/PeriodicSyncTest.java
@@ -19,35 +19,32 @@
package com.madgag.agit.sync;
+import static android.os.Build.VERSION_CODES.FROYO;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.nullValue;
import android.os.Build;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
-import roboguice.test.RoboUnitTestCase;
import java.lang.reflect.Method;
-import static android.os.Build.VERSION_CODES.FROYO;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.nullValue;
-
public class PeriodicSyncTest extends AndroidTestCase {
- private static final String TAG = "PST";
+ private static final String TAG = "PST";
@SmallTest
- public void testPeriodicSyncMethodAvailable() throws Exception {
+ public void testPeriodicSyncMethodAvailable() throws Exception {
Method m = AccountAuthenticatorService.methodContentResolver_addPeriodicSync;
boolean expectPeriodicSyncAvailable = Build.VERSION.SDK_INT >= FROYO;
- Log.d(TAG,"Expect Periodic-Sync available : "+expectPeriodicSyncAvailable+" method="+m);
+ Log.d(TAG, "Expect Periodic-Sync available : " + expectPeriodicSyncAvailable + " method=" + m);
if (expectPeriodicSyncAvailable) {
assertThat("Required period sync method", m, notNullValue());
assertThat(m.getName(), is("addPeriodicSync"));
} else {
assertThat(m, nullValue());
}
-
- }
+ }
}
View
84 agit-integration-tests/src/main/java/roboguice/test/RoboServiceTestCase.java
@@ -1,84 +0,0 @@
-package roboguice.test;
-
-import android.content.Context;
-import android.test.ServiceTestCase;
-import com.google.inject.Injector;
-import roboguice.application.RoboApplication;
-import roboguice.inject.ContextScope;
-import roboguice.service.RoboService;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.ParameterizedType;
-
-/**
- * Use RoboServiceTestCase to test services.
- *
- * An example:
- *
- * <code>
- * public class MyServiceTest extends RoboServiceTestCase<MyService, MyApplication> {
- *
- * public MyServiceTest() {
- * super(MyService.class);
- * }
- *
- * public void testStartable() {
- * Intent startIntent = new Intent();
- * startIntent.setClass(getContext(), MyService.class);
- * startService(startIntent);
- * }
- *
- * public void testBindable() {
- * Intent startIntent = new Intent();
- * startIntent.setClass(getContext(), MyService.class);
- * IBinder binder = bindService(startIntent);
- * assertNotNull(binder);
- * }
- * }
- * </code>
- *
- * Also, see the notes about your Application class below.
- *
- * @param <AppType> The type of your Application class. This class must have a
- * constructor that accepts a Context argument and calls
- * {@link android.app.Application#attachBaseContext(android.content.Context)}
- */
-public class RoboServiceTestCase<ServiceType extends RoboService, AppType extends RoboApplication> extends ServiceTestCase<ServiceType> {
- protected Injector injector;
- protected Context context;
- protected ContextScope scope;
-
- public RoboServiceTestCase(Class<ServiceType> serviceClass) {
- super(serviceClass);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- context = getContext();
- final Constructor constructor = applicationType().getConstructor(Context.class);
- final RoboApplication app = (RoboApplication)constructor.newInstance(context);
- injector = app.getInjector();
- scope = injector.getInstance(ContextScope.class);
- setApplication(app);
-
- scope.enter(context);
- }
-
- @Override
- protected void tearDown() throws Exception {
- scope.exit(context);
-
- super.tearDown();
- }
-
- protected Injector getInjector() {
- return injector;
- }
-
- protected Class<? extends RoboApplication> applicationType() {
- final ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
- return (Class<? extends RoboApplication>) parameterizedType.getActualTypeArguments()[1];
- }
-}
View
34 agit-test-utils/src/main/java/com/madgag/agit/GitTestUtils.java
@@ -19,12 +19,10 @@
package com.madgag.agit;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
import android.os.Environment;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.lib.RepositoryCache;
-import org.eclipse.jgit.storage.file.FileRepository;
-import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.util.FS;
+import android.util.Log;
import java.io.File;
import java.io.FileNotFoundException;
@@ -35,27 +33,31 @@
import java.net.UnknownHostException;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.RepositoryCache;
+import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.transport.URIish;
+import org.eclipse.jgit.util.FS;
public class GitTestUtils {
public static final String RSA_USER = "rsa_user", DSA_USER = "dsa_user";
+ private static final String TAG = "GitTestUtils";
- public static String gitServerHostAddress() throws IOException,
- FileNotFoundException, UnknownHostException {
+ public static String gitServerHostAddress() throws IOException, UnknownHostException {
File bang = new File(Environment.getExternalStorageDirectory(),
"agit-integration-test.properties");
Properties properties = new Properties();
if (bang.exists()) {
properties.load(new FileReader(bang));
}
- String hostAddress = properties.getProperty("gitserver.host.address",
- "10.0.2.2");
- InetAddress address = InetAddress.getByName(hostAddress);
- assertThat("Test gitserver host " + hostAddress + " is reachable",
- address.isReachable(1000), is(true));
- return hostAddress;
+ String[] hostAddresses = properties.getProperty("gitserver.host.address", "10.0.2.2").split(",");
+ for (String hostAddress : hostAddresses) {
+ if (InetAddress.getByName(hostAddress).isReachable(1000)) {
+ Log.d(TAG, "Using git server host : "+hostAddress);
+ return hostAddress;
+ }
+ }
+ throw new RuntimeException("No reachable addresses in "+hostAddresses);
}
public static URIish integrationGitServerURIFor(String repoPath)
View
2  agit/pom.xml
@@ -70,7 +70,7 @@
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
- <version>1.0-RC1</version>
+ <version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>
View
14 agit/src/main/java/com/madgag/agit/ssh/CuriousHostKeyRepository.java
@@ -21,17 +21,17 @@
import java.util.Arrays;
import java.util.Map;
-import android.content.Context;
+import android.app.Application;
@Singleton
public class CuriousHostKeyRepository implements HostKeyRepository {
Map<String, byte[]> knownKeys = newHashMap();
- private final Context context;
+ private final Application application;
private final Provider<BlockingPromptService> blockingPromptService;
@Inject
- public CuriousHostKeyRepository(Context context, Provider<BlockingPromptService> blockingPromptService) {
- this.context = context;
+ public CuriousHostKeyRepository(Application application, Provider<BlockingPromptService> blockingPromptService) {
+ this.application = application;
this.blockingPromptService = blockingPromptService;
}
@@ -45,8 +45,8 @@ public int check(String host, byte[] key) {
private int userCheckKey(String host, byte[] key) {
String keyFingerprint = "<small>"+code(encodeHex(md5(key)))+"</small><br />";
- String ticker = context.getString(ask_host_key_ok_ticker, code(host));
- String message = context.getString(ask_host_key_ok, code(host)+"<br />", keyFingerprint);
+ String ticker = application.getString(ask_host_key_ok_ticker, code(host));
+ String message = application.getString(ask_host_key_ok, code(host)+"<br />", keyFingerprint);
boolean userConfirmKeyGood = TRUE == blockingPromptService.get().request(promptYesOrNo(alert(fromHtml(ticker), "SSH", centered(message))));
if (userConfirmKeyGood) {
knownKeys.put(host,key);
@@ -75,6 +75,6 @@ public String getKnownHostsRepositoryID() {
}
public HostKey[] getHostKey(String host, String type) {
- return new HostKey[0]; //To change body of implemented methods use File | Settings | File Templates.
+ return new HostKey[0];
}
}

No commit comments for this range

Something went wrong with that request. Please try again.