Android Pull解析xml
2010-09-17 00:16:00 来源:WEB开发网18. }
19. }
20. }
import java.io.InputStream;
import java.util.List;
import android.test.AndroidTestCase;
import android.util.Log;
import com.xtlh.cn.entity.Book;
import com.xtlh.cn.service.PullParseService;
public class testPullParseService extends AndroidTestCase{
private static final String TAG = "testPullParseService";
public void testPull() throws Exception{
InputStream input = this.getClass().getClassLoader().getResourceAsStream("book.xml");
PullParseService pull = new PullParseService();
List< Book> books = pull.getBooks(input);
for(Book book : books){
Log.i(TAG,book.toString());
}
}
}
要使用android的单元测试,需要在AndroidManifest.xml文件中加入声明,AndroidManifest.xml如下:
Xml代码
1. < ?xml version="1.0" encoding="utf-8"?>
2. < manifest xmlns:android="http://schemas.android.com/apk/res/android"
3. package="com.xlth.cn.demo"
4. android:versionCode="1"
5. android:versionName="1.0">
6. < application android:icon="@drawable/icon" android:label="@string/app_name">
7. < uses-library android:name="android.test.runner" />
8. < activity android:name=".PullParseDemo"
9. android:label="@string/app_name">
10. < intent-filter>
11. < action android:name="android.intent.action.MAIN" />
12. < category android:name="android.intent.category.LAUNCHER" />
13. < /intent-filter>
14. < /activity>
15.
16. < /application>
17. < uses-sdk android:minSdkVersion="7" />
18. < instrumentation android:name="android.test.InstrumentationTestRunner"
更多精彩
赞助商链接