Android PointF constructor not working in JUnit test

I have just stumbled on this while trying to write a JUnit test. Admittedly this is my first unit test in JUnit, but I do find the behaviour very puzzling.

package com.example.dom.pointfbugrepro;

import org.junit.Test;
import static org.junit.Assert.*;

public class ExampleUnitTest {
    public void pointf_isCorrect() throws Exception {
        PointF foo = new PointF(5, 0);
        assertEquals(5, foo.x, 0.0001f);

Running this test in a brand new Android Project results in an assertion failure:

Expected :5.0
Actual   :0.0

One thing I found out while investigating this problem is that assigning to the PointF instance’s x field directly does work.

So what is the problem here? Why doesn’t the constructor set the fields properly? and how should I be testing classes which use the PointF Android class?



When you run unit tests, you are using a dummy version of the android jar. Typically you will see “Method … not mocked.”exceptions, but since you are directly accessing public fields, these are simply default values.

Depending on your requirements, you could just use a fake: your own subclass extending PointF

    public static class FakePointF extends PointF {
        FakePointF(float x, float y) {
            this.x = x;
            this.y = y;

but in a more complex test you’ll probably end up having to mock a whole lot of other methods.

The solution isnt pretty: you need to run instrumented tests against an emulator or device, or move to using something like Robolectric where the test runner will substitute ‘shadows‘ for you.

Also see this StackOverflow answer: all methods are stubs.


Using JDBI @BindBean with AutoValue

TLDR; The JDBI @BindBean annotation generates an IllegalAccessException with AutoValue generated types because the generated types are package private and by default can’t be accessed by default using reflection.

Is JDBI inflexible or is there a workaround via AutoValue? (Full questions below)

Quick Background

I’m attempting to use the JDBI @BindBean annotation with a type whose source is generated using AutoValue.

package com.example;

public abstract class Foo {
  public String getBar();

The issue is that the generated code looks like:

package com.example;

class AutoValue_Foo extends Foo {
  private final String bar;

  public String getBar() {

  // toString, equals, hashCode

Notice the class is package private!

Now if I attempt to use @BindBean, for example:

@SqlQuery("select * from baz where bar =")
Condition find(@BindBean("foo") Foo foo);

Because AutoValue_Foo is package private, and BindBeanFactory uses reflection, if an attempt is made to call find with an AutoValue_Foo type, the result is:

java.lang.IllegalAccessException: ... can not access a member of class com.example.Foo with modifiers "public"

The relevant JDBI code is here. I understand from a Java reflection perspective, this could be resolved using setAccessible(true) but that would require a PR to JDBI.

So the questions are as follow:

  1. Is there a way to restructure my code where I can bind a Foo of type AutoValue_Foo using @BindBean without creating a new JDBI mapper?

  2. Is there a way to have @AutoValue generate classes that are public. I understand why this would generally not be desirable (push people to use the interface and not the implementation).

  3. Is the BindBeanFactory too inflexible? Should it utilize setAccessible(true) on methods that are otherwise available outside of their originating package?


Version 2.71 of JDBI will include the ability to specify a type token to @BindBean using the type field. This type token will allow for specifying the type used to make the reflective call against the provided argument.

@SqlQuery("select * from baz where bar =") Condition find(@BindBean(value="foo", type=Foo.class) Foo foo);

Using this technique you can eliminate the IllegalAccessException described above.


Protractor e2e Tests Login Redirection

Currently have a partial end-to-end test that enters a username/password and clicks ‘sign in’.

It does that successfully, but concludes at a “thanks you’re logged in” page, instead of being redirected to the ‘account portal’ or ‘dashboard’, the way it would if I logged in through the browser.

New to this project but we are using OAuth.

Main question: Does this sound like a need for http mocking?

Further details:


describe('login page', function() {
    it('should render login page', function() {

      // Checking the current url
      var currentUrl = browser.driver.getCurrentUrl();
    it('should sign in', function() {

      // Find page elements
      var userNameField = browser.driver.findElement('username'));
      var userPassField = browser.driver.findElement('password'));
      var userLoginBtn  = browser.driver.findElement('loginbtn'));

      // Fill input fields

      // Ensure fields contain what we've entered

      // Click to sign in - waiting for Angular as it is manually bootstrapped. {
      }, 10000);

If I quickly click on the testing window, I can see it successfully reaches the ‘success’ page – but it does not redirect to the dashboard (it redirects when you manually sign in, through the browser). How can I continue this test to remain signed in and access the dashboard like a user would?

// New to the project, angular and and protractor.

EDIT – Summarizing this a bit:

  • I would like protractor to begin tests on the /login page
  • Protractor should find and fill out the username and password fields, then click Login
  • Protractor successfully log in, to see a /thankyou page, then immediately redirect to the user’s /dashboard page
  • Maybe I’m missing a step, do we need to manually redirect in Protractor tests?

(When a user manually logs in through the browser, they don’t see the /thankyou page – it’s a quick redirect to /dashboard . Protractor does not reach the dashboard page.


Your post lacks information but I’ll try to make an assumption:

I suspect that your “thanks you’re logged in” page makes javascript redirect after a timeout.

So after you click “Login”, the browser loads “thanks you’re logged in” page, and since the second parameter to .then() does nothing, browser.waitForAngular() fails because there is no angular on that page.

You should try to use something like browser.driver.wait() with a reasonable timeout to detect url change (described here: and trigger browser.waitForAngular() after the browser get to /success page.


getFrameAtTime() returns Same Frame

I`m trying to retrieve frames from video files which are captured by camera. I wrote a function to do so and i use it in a loop with different times ,receiving frames every 100000(micro sec) :

public static Bitmap getVideoFrame(long time) {
        MediaMetadataRetriever mdr = new MediaMetadataRetriever();
        try {
            return mdr.getFrameAtTime((time),MediaMetadataRetriever.OPTION_CLOSEST);
        } catch (IllegalArgumentException ex) {
        } catch (RuntimeException ex) {
        } finally {
            try {
            } catch (RuntimeException ex) {

        return null;

I know that given time must be in microseconds and i tried that.No matter what , getFrameAtTime() returns same frame all the time .


I ran into the same problem but I could not find a solution using the MediaMetadataRetriever.

However, I did using this:

Hope it helps.


How to resolve issue of “” ActivityNotFoundException in google signin integration

I have integrated google signin in android app but when run app I getting exception like:

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example/};

have you declared this activity in your AndroidManifest.xml?

Can you please tell how I declare SignInHubActivity in AndroidManifest.xml file


Really I was doing very silly mistake. I just declare activity see below…

android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />

Now my problem solved. Google signin working fine…. Thank you

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..