diff options
32 files changed, 320 insertions, 69 deletions
diff --git a/AndroidAsync/.classpath b/AndroidAsync/.classpath index a4763d1..bb0c759 100644 --- a/AndroidAsync/.classpath +++ b/AndroidAsync/.classpath @@ -4,5 +4,6 @@ <classpathentry kind="src" path="gen"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> + <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> <classpathentry kind="output" path="bin/classes"/> </classpath> diff --git a/AndroidAsync/AndroidAsync.iml b/AndroidAsync/AndroidAsync.iml new file mode 100644 index 0000000..d49f218 --- /dev/null +++ b/AndroidAsync/AndroidAsync.iml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="FacetManager"> + <facet type="android" name="Android"> + <configuration> + <option name="LIBRARY_PROJECT" value="true" /> + <notImportedProperties> + <property>MANIFEST_FILE_PATH</property> + <property>RESOURCES_DIR_PATH</property> + <property>ASSETS_DIR_PATH</property> + <property>NATIVE_LIBS_DIR_PATH</property> + </notImportedProperties> + </configuration> + </facet> + </component> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + </content> + <orderEntry type="jdk" jdkName="Android 4.2.2" jdkType="Android SDK" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> + diff --git a/AndroidAsync/AndroidManifest.xml b/AndroidAsync/AndroidManifest.xml index 8f09a5b..848749e 100644 --- a/AndroidAsync/AndroidManifest.xml +++ b/AndroidAsync/AndroidManifest.xml @@ -5,7 +5,7 @@ <uses-sdk android:minSdkVersion="8" - android:targetSdkVersion="15" /> + android:targetSdkVersion="17" /> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_LOGS"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> diff --git a/AndroidAsync/gen/com/koushikdutta/async/BuildConfig.java b/AndroidAsync/gen/com/koushikdutta/async/BuildConfig.java index dd94c94..f4835cb 100644 --- a/AndroidAsync/gen/com/koushikdutta/async/BuildConfig.java +++ b/AndroidAsync/gen/com/koushikdutta/async/BuildConfig.java @@ -1,3 +1,5 @@ +/*___Generated_by_IDEA___*/ + /** Automatically generated file. DO NOT MODIFY */ package com.koushikdutta.async; diff --git a/AndroidAsync/gen/com/koushikdutta/async/Manifest.java b/AndroidAsync/gen/com/koushikdutta/async/Manifest.java new file mode 100644 index 0000000..ebe7bd1 --- /dev/null +++ b/AndroidAsync/gen/com/koushikdutta/async/Manifest.java @@ -0,0 +1,7 @@ +/*___Generated_by_IDEA___*/ + +package com.koushikdutta.async; + +/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ +public final class Manifest { +}
\ No newline at end of file diff --git a/AndroidAsync/gen/com/koushikdutta/async/R.java b/AndroidAsync/gen/com/koushikdutta/async/R.java new file mode 100644 index 0000000..35ea1b4 --- /dev/null +++ b/AndroidAsync/gen/com/koushikdutta/async/R.java @@ -0,0 +1,7 @@ +/*___Generated_by_IDEA___*/ + +package com.koushikdutta.async; + +/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ +public final class R { +}
\ No newline at end of file diff --git a/AndroidAsync/lint.xml b/AndroidAsync/lint.xml new file mode 100644 index 0000000..ee0eead --- /dev/null +++ b/AndroidAsync/lint.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="UTF-8"?> +<lint> +</lint>
\ No newline at end of file diff --git a/AndroidAsync/src/com/koushikdutta/async/AsyncDatagramSocket.java b/AndroidAsync/src/com/koushikdutta/async/AsyncDatagramSocket.java new file mode 100644 index 0000000..94b8e34 --- /dev/null +++ b/AndroidAsync/src/com/koushikdutta/async/AsyncDatagramSocket.java @@ -0,0 +1,58 @@ +package com.koushikdutta.async; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.nio.ByteBuffer; + +public class AsyncDatagramSocket extends AsyncNetworkSocket { + public void disconnect() throws IOException { +// ((DatagramChannelWrapper)getChannel()).disconnect(); + } + + public void connect(SocketAddress address) throws IOException { + ((DatagramChannelWrapper)getChannel()).mChannel.connect(address); + } + + public void send(final String host, final int port, final ByteBuffer buffer) { + if (getServer().getAffinity() != Thread.currentThread()) { + getServer().run(new Runnable() { + @Override + public void run() { + send(host, port, buffer); + } + }); + return; + } + + try { + ((DatagramChannelWrapper)getChannel()).mChannel.send(buffer, new InetSocketAddress(host, port)); + } + catch (IOException e) { + close(); + reportEndPending(e); + //reportClose(e); + } + + } + public void send(final SocketAddress address, final ByteBuffer buffer) { + if (getServer().getAffinity() != Thread.currentThread()) { + getServer().run(new Runnable() { + @Override + public void run() { + send(address, buffer); + } + }); + return; + } + + try { + ((DatagramChannelWrapper)getChannel()).mChannel.send(buffer, address); + } + catch (IOException e) { + close(); + reportEndPending(e); + //reportClose(e); + } + } +} diff --git a/AndroidAsync/src/com/koushikdutta/async/AsyncNetworkSocket.java b/AndroidAsync/src/com/koushikdutta/async/AsyncNetworkSocket.java index 246bcd0..010c3d6 100644 --- a/AndroidAsync/src/com/koushikdutta/async/AsyncNetworkSocket.java +++ b/AndroidAsync/src/com/koushikdutta/async/AsyncNetworkSocket.java @@ -173,7 +173,7 @@ public class AsyncNetworkSocket implements AsyncSocket { } boolean closeReported; - private void reportClose(Exception e) { + protected void reportClose(Exception e) { if (closeReported) return; closeReported = true; @@ -332,4 +332,8 @@ public class AsyncNetworkSocket implements AsyncSocket { public AsyncServer getServer() { return mServer; } + + public int getLocalPort() { + return mChannel.getLocalPort(); + } } diff --git a/AndroidAsync/src/com/koushikdutta/async/AsyncServer.java b/AndroidAsync/src/com/koushikdutta/async/AsyncServer.java index 6ea178a..3d23770 100644 --- a/AndroidAsync/src/com/koushikdutta/async/AsyncServer.java +++ b/AndroidAsync/src/com/koushikdutta/async/AsyncServer.java @@ -477,9 +477,54 @@ public class AsyncServer { } } - public AsyncSocket connectDatagram(final SocketAddress remote) throws IOException { + public AsyncDatagramSocket connectDatagram(final String host, final int port) throws IOException { final DatagramChannel socket = DatagramChannel.open(); - final AsyncNetworkSocket handler = new AsyncNetworkSocket(); + final AsyncDatagramSocket handler = new AsyncDatagramSocket(); + handler.attach(socket); + // ugh.. this should really be post to make it nonblocking... + // but i want datagrams to be immediately writable. + // they're not really used anyways. + run(new Runnable() { + @Override + public void run() { + try { + final SocketAddress remote = new InetSocketAddress(host, port); + handleSocket(handler); + socket.connect(remote); + } + catch (Exception e) { + e.printStackTrace(); + } + } + }); + return handler; + } + + public AsyncDatagramSocket openDatagram() throws IOException { + final DatagramChannel socket = DatagramChannel.open(); + final AsyncDatagramSocket handler = new AsyncDatagramSocket(); + handler.attach(socket); + // ugh.. this should really be post to make it nonblocking... + // but i want datagrams to be immediately writable. + // they're not really used anyways. + run(new Runnable() { + @Override + public void run() { + try { + socket.socket().bind(null); + handleSocket(handler); + } + catch (Exception e) { + e.printStackTrace(); + } + } + }); + return handler; + } + + public AsyncDatagramSocket connectDatagram(final SocketAddress remote) throws IOException { + final DatagramChannel socket = DatagramChannel.open(); + final AsyncDatagramSocket handler = new AsyncDatagramSocket(); handler.attach(socket); // ugh.. this should really be post to make it nonblocking... // but i want datagrams to be immediately writable. diff --git a/AndroidAsync/src/com/koushikdutta/async/ByteBufferList.java b/AndroidAsync/src/com/koushikdutta/async/ByteBufferList.java index 337d9c5..81f0fe9 100644 --- a/AndroidAsync/src/com/koushikdutta/async/ByteBufferList.java +++ b/AndroidAsync/src/com/koushikdutta/async/ByteBufferList.java @@ -1,6 +1,7 @@ package com.koushikdutta.async; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.util.Iterator; import java.util.LinkedList; @@ -9,6 +10,16 @@ import junit.framework.Assert; public class ByteBufferList implements Iterable<ByteBuffer> { LinkedList<ByteBuffer> mBuffers = new LinkedList<ByteBuffer>(); + ByteOrder order = ByteOrder.BIG_ENDIAN; + public ByteOrder order() { + return order; + } + + public ByteBufferList order(ByteOrder order) { + this.order = order; + return this; + } + public ByteBuffer peek() { return mBuffers.peek(); } @@ -93,7 +104,7 @@ public class ByteBufferList implements Iterable<ByteBuffer> { offset += remaining; } - return ret; + return ret.order(order); } public ByteBuffer read(int count) { @@ -106,11 +117,11 @@ public class ByteBufferList implements Iterable<ByteBuffer> { } if (first == null) { - return ByteBuffer.wrap(new byte[0]); + return ByteBuffer.wrap(new byte[0]).order(order); } if (first.remaining() >= count) { - return first; + return first.order(order); } else { // reallocate the count into a single buffer, and return it @@ -130,7 +141,7 @@ public class ByteBufferList implements Iterable<ByteBuffer> { mBuffers.add(0, bb); ByteBuffer ret = ByteBuffer.wrap(bytes); mBuffers.add(0, ret); - return ret; + return ret.order(order); } } diff --git a/AndroidAsync/src/com/koushikdutta/async/ChannelWrapper.java b/AndroidAsync/src/com/koushikdutta/async/ChannelWrapper.java index 68b9ed2..6929d28 100644 --- a/AndroidAsync/src/com/koushikdutta/async/ChannelWrapper.java +++ b/AndroidAsync/src/com/koushikdutta/async/ChannelWrapper.java @@ -40,4 +40,6 @@ abstract class ChannelWrapper implements ReadableByteChannel { public void close() throws IOException { mChannel.close(); } + + public abstract int getLocalPort(); } diff --git a/AndroidAsync/src/com/koushikdutta/async/DataEmitterReader.java b/AndroidAsync/src/com/koushikdutta/async/DataEmitterReader.java index 3477e39..39d5693 100644 --- a/AndroidAsync/src/com/koushikdutta/async/DataEmitterReader.java +++ b/AndroidAsync/src/com/koushikdutta/async/DataEmitterReader.java @@ -32,7 +32,7 @@ public class DataEmitterReader implements com.koushikdutta.async.callback.DataCa @Override public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) { // if we're registered for data, we must be waiting for a read - Assert.assertNotNull(mPendingRead); + assert(mPendingRead != null); do { int need = Math.min(bb.remaining(), mPendingReadLength - mPendingData.remaining()); mPendingData.add(bb.get(need)); diff --git a/AndroidAsync/src/com/koushikdutta/async/DatagramChannelWrapper.java b/AndroidAsync/src/com/koushikdutta/async/DatagramChannelWrapper.java index 4bc5f6b..e2e37c4 100644 --- a/AndroidAsync/src/com/koushikdutta/async/DatagramChannelWrapper.java +++ b/AndroidAsync/src/com/koushikdutta/async/DatagramChannelWrapper.java @@ -1,6 +1,7 @@ package com.koushikdutta.async; import java.io.IOException; +import java.net.SocketAddress; import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; import java.nio.channels.DatagramChannel; @@ -9,13 +10,35 @@ import java.nio.channels.Selector; class DatagramChannelWrapper extends ChannelWrapper { DatagramChannel mChannel; - + + @Override + public int getLocalPort() { + return mChannel.socket().getLocalPort(); + } + + SocketAddress address; + public SocketAddress getRemoteAddress() { + return address; + } + + public void disconnect() throws IOException { + mChannel.disconnect(); + } + DatagramChannelWrapper(DatagramChannel channel) throws IOException { super(channel); mChannel = channel; } @Override public int read(ByteBuffer buffer) throws IOException { + if (!isConnected()) { + int position = buffer.position(); + address = mChannel.receive(buffer); + if (address == null) + return -1; + return buffer.position() - position; + } + address = null; return mChannel.read(buffer); } @Override diff --git a/AndroidAsync/src/com/koushikdutta/async/PushParser.java b/AndroidAsync/src/com/koushikdutta/async/PushParser.java index 271715c..ea2df6f 100644 --- a/AndroidAsync/src/com/koushikdutta/async/PushParser.java +++ b/AndroidAsync/src/com/koushikdutta/async/PushParser.java @@ -2,6 +2,7 @@ package com.koushikdutta.async; import java.lang.reflect.Method; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.util.ArrayList; import java.util.Hashtable; import java.util.LinkedList; @@ -108,6 +109,15 @@ public class PushParser { } } + ByteOrder order = ByteOrder.BIG_ENDIAN; + public ByteOrder order() { + return order; + } + public PushParser order(ByteOrder order) { + this.order = order; + return this; + } + public void tap(TapCallback callback) { Assert.assertNull(mCallback); Assert.assertTrue(mWaiting.size() > 0); @@ -122,6 +132,8 @@ public class PushParser { @Override public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) { try { + if (bb != null) + bb.order(order); while (mWaiting.size() > 0) { Object waiting = mWaiting.peek(); if (waiting == null) diff --git a/AndroidAsync/src/com/koushikdutta/async/ServerSocketChannelWrapper.java b/AndroidAsync/src/com/koushikdutta/async/ServerSocketChannelWrapper.java index ee31298..dbfc3e5 100644 --- a/AndroidAsync/src/com/koushikdutta/async/ServerSocketChannelWrapper.java +++ b/AndroidAsync/src/com/koushikdutta/async/ServerSocketChannelWrapper.java @@ -12,6 +12,11 @@ import junit.framework.Assert; class ServerSocketChannelWrapper extends ChannelWrapper { ServerSocketChannel mChannel; + @Override + public int getLocalPort() { + return mChannel.socket().getLocalPort(); + } + ServerSocketChannelWrapper(ServerSocketChannel channel) throws IOException { super(channel); mChannel = channel; diff --git a/AndroidAsync/src/com/koushikdutta/async/SocketChannelWrapper.java b/AndroidAsync/src/com/koushikdutta/async/SocketChannelWrapper.java index 47feef6..fd3dc1e 100644 --- a/AndroidAsync/src/com/koushikdutta/async/SocketChannelWrapper.java +++ b/AndroidAsync/src/com/koushikdutta/async/SocketChannelWrapper.java @@ -10,6 +10,11 @@ import java.nio.channels.SocketChannel; class SocketChannelWrapper extends ChannelWrapper { SocketChannel mChannel; + @Override + public int getLocalPort() { + return mChannel.socket().getLocalPort(); + } + SocketChannelWrapper(SocketChannel channel) throws IOException { super(channel); mChannel = channel; diff --git a/AndroidAsync/src/com/koushikdutta/async/http/filter/GZIPInputFilter.java b/AndroidAsync/src/com/koushikdutta/async/http/filter/GZIPInputFilter.java index ad01595..a8e2de1 100644 --- a/AndroidAsync/src/com/koushikdutta/async/http/filter/GZIPInputFilter.java +++ b/AndroidAsync/src/com/koushikdutta/async/http/filter/GZIPInputFilter.java @@ -37,7 +37,6 @@ public class GZIPInputFilter extends InflaterInputFilter { return b & 0xFF; } - DataEmitterReader mHeaderParser; @Override @SuppressWarnings("unused") public void onDataAvailable(final DataEmitter emitter, ByteBufferList bb) { diff --git a/AndroidAsyncSample/AndroidAsyncSample.iml b/AndroidAsyncSample/AndroidAsyncSample.iml new file mode 100644 index 0000000..918e7d3 --- /dev/null +++ b/AndroidAsyncSample/AndroidAsyncSample.iml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="FacetManager"> + <facet type="android" name="Android"> + <configuration> + <notImportedProperties> + <property>MANIFEST_FILE_PATH</property> + <property>RESOURCES_DIR_PATH</property> + <property>ASSETS_DIR_PATH</property> + <property>NATIVE_LIBS_DIR_PATH</property> + </notImportedProperties> + </configuration> + </facet> + </component> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + </content> + <orderEntry type="jdk" jdkName="Android 4.2.2" jdkType="Android SDK" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="AndroidAsync" /> + </component> +</module> + diff --git a/AndroidAsyncSample/AndroidManifest.xml b/AndroidAsyncSample/AndroidManifest.xml index 31ae7bd..1cda0a5 100644 --- a/AndroidAsyncSample/AndroidManifest.xml +++ b/AndroidAsyncSample/AndroidManifest.xml @@ -5,7 +5,7 @@ <uses-sdk android:minSdkVersion="8" - android:targetSdkVersion="15" /> + android:targetSdkVersion="17" /> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> @@ -24,5 +24,4 @@ </intent-filter> </activity> </application> - </manifest>
\ No newline at end of file diff --git a/AndroidAsyncSample/gen/com/koushikdutta/async/sample/BuildConfig.java b/AndroidAsyncSample/gen/com/koushikdutta/async/sample/BuildConfig.java index 9429b8f..7e08348 100644 --- a/AndroidAsyncSample/gen/com/koushikdutta/async/sample/BuildConfig.java +++ b/AndroidAsyncSample/gen/com/koushikdutta/async/sample/BuildConfig.java @@ -1,3 +1,5 @@ +/*___Generated_by_IDEA___*/ + /** Automatically generated file. DO NOT MODIFY */ package com.koushikdutta.async.sample; diff --git a/AndroidAsyncSample/gen/com/koushikdutta/async/sample/Manifest.java b/AndroidAsyncSample/gen/com/koushikdutta/async/sample/Manifest.java new file mode 100644 index 0000000..a18afeb --- /dev/null +++ b/AndroidAsyncSample/gen/com/koushikdutta/async/sample/Manifest.java @@ -0,0 +1,7 @@ +/*___Generated_by_IDEA___*/ + +package com.koushikdutta.async.sample; + +/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ +public final class Manifest { +}
\ No newline at end of file diff --git a/AndroidAsyncSample/gen/com/koushikdutta/async/sample/R.java b/AndroidAsyncSample/gen/com/koushikdutta/async/sample/R.java index 849c156..15d1069 100644 --- a/AndroidAsyncSample/gen/com/koushikdutta/async/sample/R.java +++ b/AndroidAsyncSample/gen/com/koushikdutta/async/sample/R.java @@ -1,41 +1,7 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ +/*___Generated_by_IDEA___*/ package com.koushikdutta.async.sample; +/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ public final class R { - public static final class attr { - } - public static final class drawable { - public static final int ic_action_search=0x7f020000; - public static final int ic_launcher=0x7f020001; - } - public static final class id { - public static final int chart=0x7f070004; - public static final int desksms=0x7f070002; - public static final int go=0x7f070000; - public static final int menu_settings=0x7f070005; - public static final int rommanager=0x7f070001; - public static final int tether=0x7f070003; - } - public static final class layout { - public static final int activity_main=0x7f030000; - } - public static final class menu { - public static final int activity_main=0x7f060000; - } - public static final class string { - public static final int app_name=0x7f040000; - public static final int download=0x7f040004; - public static final int hello_world=0x7f040001; - public static final int menu_settings=0x7f040002; - public static final int title_activity_main=0x7f040003; - } - public static final class style { - public static final int AppTheme=0x7f050000; - } -} +}
\ No newline at end of file diff --git a/AndroidAsyncTest/.classpath b/AndroidAsyncTest/.classpath index 653dc7f..6982030 100644 --- a/AndroidAsyncTest/.classpath +++ b/AndroidAsyncTest/.classpath @@ -5,5 +5,6 @@ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="gen"/> + <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> <classpathentry kind="output" path="bin/classes"/> </classpath> diff --git a/AndroidAsyncTest/AndroidAsyncTest.iml b/AndroidAsyncTest/AndroidAsyncTest.iml new file mode 100644 index 0000000..918e7d3 --- /dev/null +++ b/AndroidAsyncTest/AndroidAsyncTest.iml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="FacetManager"> + <facet type="android" name="Android"> + <configuration> + <notImportedProperties> + <property>MANIFEST_FILE_PATH</property> + <property>RESOURCES_DIR_PATH</property> + <property>ASSETS_DIR_PATH</property> + <property>NATIVE_LIBS_DIR_PATH</property> + </notImportedProperties> + </configuration> + </facet> + </component> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + </content> + <orderEntry type="jdk" jdkName="Android 4.2.2" jdkType="Android SDK" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="AndroidAsync" /> + </component> +</module> + diff --git a/AndroidAsyncTest/gen/com/koushikdutta/async/test/BuildConfig.java b/AndroidAsyncTest/gen/com/koushikdutta/async/test/BuildConfig.java index b92f35f..11c34e7 100644 --- a/AndroidAsyncTest/gen/com/koushikdutta/async/test/BuildConfig.java +++ b/AndroidAsyncTest/gen/com/koushikdutta/async/test/BuildConfig.java @@ -1,3 +1,5 @@ +/*___Generated_by_IDEA___*/ + /** Automatically generated file. DO NOT MODIFY */ package com.koushikdutta.async.test; diff --git a/AndroidAsyncTest/gen/com/koushikdutta/async/test/Manifest.java b/AndroidAsyncTest/gen/com/koushikdutta/async/test/Manifest.java new file mode 100644 index 0000000..b296c6f --- /dev/null +++ b/AndroidAsyncTest/gen/com/koushikdutta/async/test/Manifest.java @@ -0,0 +1,7 @@ +/*___Generated_by_IDEA___*/ + +package com.koushikdutta.async.test; + +/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ +public final class Manifest { +}
\ No newline at end of file diff --git a/AndroidAsyncTest/gen/com/koushikdutta/async/test/R.java b/AndroidAsyncTest/gen/com/koushikdutta/async/test/R.java index 3ed3fee..84720c2 100644 --- a/AndroidAsyncTest/gen/com/koushikdutta/async/test/R.java +++ b/AndroidAsyncTest/gen/com/koushikdutta/async/test/R.java @@ -1,19 +1,7 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ +/*___Generated_by_IDEA___*/ package com.koushikdutta.async.test; +/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ public final class R { - public static final class attr { - } - public static final class drawable { - public static final int ic_launcher=0x7f020000; - } - public static final class string { - public static final int app_name=0x7f030000; - } -} +}
\ No newline at end of file diff --git a/AndroidAsyncTest/project.properties b/AndroidAsyncTest/project.properties index a3ee5ab..32fa4ac 100644 --- a/AndroidAsyncTest/project.properties +++ b/AndroidAsyncTest/project.properties @@ -12,3 +12,4 @@ # Project target. target=android-17 +android.library.reference.1=../AndroidAsync diff --git a/AndroidAsyncTest/src/com/koushikdutta/async/test/HttpClientTests.java b/AndroidAsyncTest/src/com/koushikdutta/async/test/HttpClientTests.java index 4408080..309d072 100644 --- a/AndroidAsyncTest/src/com/koushikdutta/async/test/HttpClientTests.java +++ b/AndroidAsyncTest/src/com/koushikdutta/async/test/HttpClientTests.java @@ -34,7 +34,7 @@ public class HttpClientTests extends TestCase { client = new AsyncHttpClient(server); } - private static final long TIMEOUT = 10000L; + private static final long TIMEOUT = 100000L; public void testHomepage() throws Exception { Future<String> ret = client.get("http://google.com", (StringCallback)null); assertNotNull(ret.get(TIMEOUT, TimeUnit.MILLISECONDS)); @@ -69,8 +69,8 @@ public class HttpClientTests extends TestCase { } }); - assertTrue(semaphore.tryAcquire(TIMEOUT, TimeUnit.MILLISECONDS)); - assertTrue(md5.digest().equals(dataNameAndHash)); + assertTrue("timeout", semaphore.tryAcquire(TIMEOUT, TimeUnit.MILLISECONDS)); + assertTrue("md5", md5.digest().equals(dataNameAndHash)); } public void testGithubRandomDataWithFuture() throws Exception { @@ -107,7 +107,7 @@ public class HttpClientTests extends TestCase { }); try { - future.get(3000, TimeUnit.MILLISECONDS); + future.get(TIMEOUT, TimeUnit.MILLISECONDS); // this should never reach here as it was cancelled fail(); } diff --git a/AndroidAsyncTest/src/com/koushikdutta/async/test/MultipartTests.java b/AndroidAsyncTest/src/com/koushikdutta/async/test/MultipartTests.java index 3737026..d2a7725 100644 --- a/AndroidAsyncTest/src/com/koushikdutta/async/test/MultipartTests.java +++ b/AndroidAsyncTest/src/com/koushikdutta/async/test/MultipartTests.java @@ -87,6 +87,7 @@ public class MultipartTests extends TestCase { public void testUpload() throws Exception { File dummy = new File(Environment.getExternalStorageDirectory(), "AndroidAsync/dummy.txt"); final String FIELD_VAL = "bar"; + dummy.getParentFile().mkdirs(); FileOutputStream fout = new FileOutputStream(dummy); byte[] zeroes = new byte[100000]; for (int i = 0; i < 10; i++) { diff --git a/AndroidAsyncTest/src/com/koushikdutta/async/test/SanityChecks.java b/AndroidAsyncTest/src/com/koushikdutta/async/test/SanityChecks.java new file mode 100644 index 0000000..69cc566 --- /dev/null +++ b/AndroidAsyncTest/src/com/koushikdutta/async/test/SanityChecks.java @@ -0,0 +1,15 @@ +package com.koushikdutta.async.test; + +import junit.framework.TestCase; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +/** + * Created by koush on 5/15/13. + */ +public class SanityChecks extends TestCase { + public void testByteOrder() { + assertTrue(ByteBuffer.allocate(0).order().equals(ByteOrder.BIG_ENDIAN)); + } +} |