Nethravathitcs / unitt

Automatically exported from code.google.com/p/unitt
0 stars 0 forks source link

Unitt does not run on Android < 2.3 #29

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a simple Android app using unitt to connect to a WS server
2. Run it on Android 1.0 - 2.2.x

What is the expected output?
It should work, but it fails with ClassNotFoundException for 
java.util.ArrayDeque

That class was not added to Android until API Level 9 (Android 2.3)

This can be fixed by replacing the ArrayDeque class with a Buffer from Apache 
commons-collections though it does add an additional library dependency 
(commons-collections, 3.2.1) to unitt.  Also, the commons-collections classes 
don't use generics so the result does require some explicit casts, but the 
changes are pretty minimal.  

Attached is a patch for WebSocketConnection that seems to work (tests pass, 
haven't run into any issues yet).

Original issue reported on code.google.com by mmjoh...@gmail.com on 28 Oct 2011 at 12:43

Attachments:

GoogleCodeExporter commented 8 years ago
I'm a little premature on this.  Still run into an issue in the 
WebSocketHandshake class when actually running on Android due to the use of 
String.getBytes(Charset) which also wasn't added until API Level 9.

This can be easily replaced with one of the other getBytes options.

Original comment by mmjoh...@gmail.com on 28 Oct 2011 at 1:13

GoogleCodeExporter commented 8 years ago
I will take a look at this over the weekend. Good find!

Original comment by joshuadmorris@gmail.com on 28 Oct 2011 at 5:28

GoogleCodeExporter commented 8 years ago
Could ArrayDeque be replaced by LinkedList instead? For what you're doing it 
appears to be a functional equivalent and means there's less dependencies! :)

Original comment by jazzake...@gmail.com on 1 Nov 2011 at 5:20

GoogleCodeExporter commented 8 years ago
That is a great idea. I should have some fixes out by next week.

Original comment by joshuadmorris@gmail.com on 14 Nov 2011 at 3:14

GoogleCodeExporter commented 8 years ago
When do u fix this error?

Original comment by benjamin...@gmail.com on 27 Jan 2012 at 11:02

GoogleCodeExporter commented 8 years ago
Hey, this two patches enables <2.3 support for me. The only task to do is 
handling the exceptions. What do u think?

Original comment by benjamin...@gmail.com on 27 Jan 2012 at 12:40

Attachments:

GoogleCodeExporter commented 8 years ago
that looks alright. :)

My only suggestion would be (in WebsocketConection.java) to use:
 private Queue<WebSocketFragment> pendingFragments = new LinkedList<WebSocketFragment>();

instead of:
 private LinkedList<WebSocketFragment> pendingFragments = new LinkedList<WebSocketFragment>();

because we only need to see the Queue methods of the linked list object.

...Oh, also you will need to adjust usage of the 'utf8Charset' variable in 
WebsocketConection.java. (See attached for my quick hack of those files).

Original comment by jazzake...@gmail.com on 30 Jan 2012 at 3:49

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by joshuadmorris@gmail.com on 30 Jan 2012 at 9:43

GoogleCodeExporter commented 8 years ago
Thank you so much for the patch! It is now checked in. If you are interested, 
you can use the http://www.slf4j.org/android/ library for Android. It's great. 
Uses the SLF4J facade and just logs to the Android console.

Original comment by joshuadmorris@gmail.com on 30 Jan 2012 at 10:11

GoogleCodeExporter commented 8 years ago
thanks for the link :)

Original comment by jazzake...@gmail.com on 31 Jan 2012 at 12:13

GoogleCodeExporter commented 8 years ago
Thanks, but what are are the advantages regarding the standard Log-class?

Original comment by benjamin...@gmail.com on 31 Jan 2012 at 9:48

GoogleCodeExporter commented 8 years ago
SLF4J gives you a single facade that allows you to plug in most standard log 
implementations (Log4J, JDK4, etc) without any code changes. This makes the 
code easy to use in a mobile situation or in any other Java platform or 
project. There is no real, new whizbangy thing it does though. It's just about 
raw portability. :)

Original comment by joshuadmorris@gmail.com on 31 Jan 2012 at 6:32

GoogleCodeExporter commented 8 years ago

Original comment by joshuadmorris@gmail.com on 31 Jan 2012 at 6:32