aboutsummaryrefslogtreecommitdiff
path: root/v1/src/test/java/com/xtremelabs/robolectric/IncludedDependenciesTest.java
blob: 70d5bf0771ab10337614d3776d7f601acfa43fea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.xtremelabs.robolectric;

import org.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;

import java.io.StringReader;

import static org.junit.Assert.assertEquals;

@RunWith(WithTestDefaultsRunner.class)
public class IncludedDependenciesTest {
    @Test
    public void jsonShouldWork() throws Exception {
        assertEquals("value", new JSONObject("{'name':'value'}").getString("name"));
    }

    @Test
    public void xppShouldWork() throws Exception {
        XmlPullParser xmlPullParser = XmlPullParserFactory.newInstance().newPullParser();
        xmlPullParser.setInput(new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test name=\"value\"/>"));
        assertEquals(XmlPullParser.START_TAG, xmlPullParser.nextTag());
        assertEquals(1, xmlPullParser.getAttributeCount());
        assertEquals("name", xmlPullParser.getAttributeName(0));
        assertEquals("value", xmlPullParser.getAttributeValue(0));
    }
}