Go Back   Android Forums > Android Forums Community > The Lounge > Computers & IT

test: Reply
LinkBack Thread Tools
Old June 14th, 2010, 03:29 AM   #1 (permalink)
New Member
Thread Author (OP)
Join Date: Feb 2009
Posts: 6
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default MockResources trouble

Hi all,

I'm having trouble mocking a resource. What I want to do is to parse a web page using Htmlcleaner. Parsing the webpage works but now I want to use mocks. This is what i do:

I have a class MyMockResources which extends from MockResources. MyMockResources has a overriden method openRawResource. I instantiate MyMockResources in a unit. An example file of the web page resides in the test project in 'res/raw/list'. When running the unit test I get a UnsupportedOperationException mock object, not implemented.

Does anybody now what causes this and how to fix the problem? Class example are posted below.



public class MyMockResources extends MockResources{

public InputStream openRawResource(int id) throws NotFoundException {
// TODO Auto-generated method stub
return super.openRawResource(id);

public class MyUnitTest extends AndroidTestCase {

private MyMockResources mockResources;
private FeedParserImpl parser;

public void setUp() {
mockResources = new MyMockResources();
parser = new FeedParserImpl();

public void testClass() throws FileNotFoundException {

MyMockResources resources = AndroidMock.createMock(MyMockResources.class);
parser.parseTrafficInformation(mockResources.openR awResource(R.raw.list));

josipj is offline  
Reply With Quote
sponsored links
mock, mock object, mockresources, not implemented, unsupportedoperationexception

Go Back   Android Forums > Android Forums Community > The Lounge > Computers & IT
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

All times are GMT -5. The time now is 06:05 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.