Java Code Examples for org.robolectric.shadows.ShadowLog#stream()

The following examples show how to use org.robolectric.shadows.ShadowLog#stream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseRoboTest.java    From mobile-sdk-android with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
    SDKSettings.setExternalExecutor(null);
    Robolectric.getBackgroundThreadScheduler().reset();
    Robolectric.getForegroundThreadScheduler().reset();
    ShadowLog.stream = System.out;
    activity = Robolectric.buildActivity(MockMainActivity.class).create().start().resume().visible().get();
    shadowOf(activity).grantPermissions("android.permission.INTERNET");
    server= new MockWebServer();
    try {
        server.start();
        HttpUrl url= server.url("/");
        UTConstants.REQUEST_BASE_URL_UT = url.toString();
        System.out.println(UTConstants.REQUEST_BASE_URL_UT);
        ShadowSettings.setTestURL(url.toString());
        TestResponsesUT.setTestURL(url.toString());
    } catch (IOException e) {
        System.out.print("IOException");
    }
    bgScheduler = Robolectric.getBackgroundThreadScheduler();
    uiScheduler = Robolectric.getForegroundThreadScheduler();
    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();
    bgScheduler.pause();
    uiScheduler.pause();
}
 
Example 2
Source File: BaseAndroidTest.java    From kripton with Apache License 2.0 6 votes vote down vote up
/**
 * Setup.
 */
@Before
public void setup() {
	//final String value = System.getProperty(KRIPTON_DEBUG_MODE);
	final String value = System.getProperty(KRIPTON_DEBUG_MODE);
	if ("false".equals(value)) {
		ShadowLog.stream = new PrintStream(new NullOutputStream());
		// we are in test, but we don't see log on System.out
		System.setOut(new PrintStream(new NullOutputStream()));
		System.setErr(new PrintStream(new NullOutputStream()));
	} else {
		ShadowLog.stream = System.out;
	}
			
	

	KriptonLibrary.init(RuntimeEnvironment.application);
}
 
Example 3
Source File: BaseRoboTest.java    From mobile-sdk-android with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
    Robolectric.getBackgroundThreadScheduler().reset();
    Robolectric.getForegroundThreadScheduler().reset();
    ShadowLog.stream = System.out;
    activity = Robolectric.buildActivity(MockMainActivity.class).create().start().resume().visible().get();
    shadowOf(activity).grantPermissions("android.permission.INTERNET");
    server= new MockWebServer();
    try {
        server.start();
        HttpUrl url= server.url("/");
        UTConstants.REQUEST_BASE_URL_UT = url.toString();
        System.out.println(UTConstants.REQUEST_BASE_URL_UT);
        ShadowSettings.setTestURL(url.toString());
    } catch (IOException e) {
        System.out.print("IOException");
    }
    bgScheduler = Robolectric.getBackgroundThreadScheduler();
    uiScheduler = Robolectric.getForegroundThreadScheduler();
    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();
    bgScheduler.pause();
    uiScheduler.pause();
}
 
Example 4
Source File: TransactionCursorAdapterTest.java    From budget-watch with GNU General Public License v3.0 5 votes vote down vote up
@Before
public void setUp()
{
    // Output logs emitted during tests so they may be accessed
    ShadowLog.stream = System.out;

    activity = Robolectric.setupActivity(BudgetViewActivity.class);
    db = new DBHelper(activity);
}
 
Example 5
Source File: ImportExportTest.java    From budget-watch with GNU General Public License v3.0 5 votes vote down vote up
@Before
public void setUp()
{
    // Output logs emitted during tests so they may be accessed
    ShadowLog.stream = System.out;

    activity = Robolectric.setupActivity(BudgetViewActivity.class);
    db = new DBHelper(activity);
}
 
Example 6
Source File: BudgetAdapterTest.java    From budget-watch with GNU General Public License v3.0 5 votes vote down vote up
@Before
public void setUp()
{
    // Output logs emitted during tests so they may be accessed
    ShadowLog.stream = System.out;

    nowMs = System.currentTimeMillis();

    Calendar lastYear = Calendar.getInstance();
    lastYear.set(Calendar.YEAR, lastYear.get(Calendar.YEAR)-1);
    lastYearMs = lastYear.getTimeInMillis();
}
 
Example 7
Source File: OpenWeatherClientTest.java    From MVPAndroidBootstrap with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    ShadowLog.stream = System.out;
    mockWebServer = new MockWebServer();
    mockWebServer.start(9999);
    TestHelper.setFinalStatic(OpenWeatherClient.class.getField("ENDPOINT"), mockWebServer.getUrl("/").toString());
    openWeatherClient = OpenWeatherClient_.getInstance_(RuntimeEnvironment.application);
}
 
Example 8
Source File: ImportExportActivityTest.java    From budget-watch with GNU General Public License v3.0 5 votes vote down vote up
@Before
public void setUp()
{
    // Output logs emitted during tests so they may be accessed
    ShadowLog.stream = System.out;

    activity = Robolectric.setupActivity(ImportExportActivity.class);
    db = new DBHelper(activity);
    sdcardDir = Environment.getExternalStorageDirectory();
}
 
Example 9
Source File: BaseTest.java    From AndroidUtilCode with Apache License 2.0 4 votes vote down vote up
public BaseTest() {
    ShadowLog.stream = System.out;
    Utils.init(RuntimeEnvironment.application);
}
 
Example 10
Source File: BlueReaderTest.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Fetch log output to be able to assert code-paths
 */
@Before
public void initShadowLog() {
    _out = new ByteArrayOutputStream();
    ShadowLog.stream = new PrintStream(_out);
}
 
Example 11
Source File: SystemUtilsTest.java    From android-utilset with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
	ShadowLog.stream = System.out;
}
 
Example 12
Source File: PixelUtilsTest.java    From android-utilset with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
	ShadowLog.stream = System.out;
	this.context = Robolectric.application;
}
 
Example 13
Source File: DiskUtilsTest.java    From android-utilset with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
	ShadowLog.stream = System.out;
	this.context = Robolectric.application;
}
 
Example 14
Source File: MyServiceTest.java    From Awesome-WanAndroid with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    ShadowLog.stream = System.out;
    mServiceController = Robolectric.buildService(MyService.class);
    mMyService = mServiceController.get();
}
 
Example 15
Source File: TransactionActivityTest.java    From budget-watch with GNU General Public License v3.0 4 votes vote down vote up
@Before
public void setUp()
{
    // Output logs emitted during tests so they may be accessed
    ShadowLog.stream = System.out;
}
 
Example 16
Source File: PersonTest.java    From Awesome-WanAndroid with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    ShadowLog.stream = System.out;
}
 
Example 17
Source File: LocalHTTPDTest.java    From fdroidclient with GNU General Public License v3.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    ShadowLog.stream = System.out;
    classLoader = getClass().getClassLoader();

    assertFalse(Utils.isServerSocketInUse(port));

    final Context context = RuntimeEnvironment.application.getApplicationContext();
    webRoot = context.getFilesDir();
    FileUtils.deleteDirectory(webRoot);
    assertTrue(webRoot.mkdir());
    assertTrue(webRoot.isDirectory());

    final File testdir = new File(webRoot, "testdir");
    assertTrue(testdir.mkdir());
    IOUtils.copy(classLoader.getResourceAsStream("test.html"),
            new FileOutputStream(new File(testdir, "test.html")));

    serverStartThread = new Thread(new Runnable() {

        @Override
        public void run() {
            localHttpd = new LocalHTTPD(
                    context,
                    "localhost",
                    port,
                    webRoot,
                    false);
            try {
                localHttpd.start();
            } catch (IOException e) {
                e.printStackTrace();
            }
            assertTrue(localHttpd.isAlive());
        }
    });
    serverStartThread.start();
    // give the server some tine to start.
    do {
        Thread.sleep(100);
    } while (!Utils.isServerSocketInUse(port));
}
 
Example 18
Source File: CipherUtilsTest.java    From android-utilset with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
	ShadowLog.stream = System.out;
}
 
Example 19
Source File: BudgetViewActivityTest.java    From budget-watch with GNU General Public License v3.0 4 votes vote down vote up
@Before
public void setUp()
{
    // Output logs emitted during tests so they may be accessed
    ShadowLog.stream = System.out;
}
 
Example 20
Source File: ActivityUtilsTest.java    From android-utilset with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
	ShadowLog.stream = System.out;
	this.context = Robolectric.application;
}