control a JOptionPane from assertJ Swing

I have a code calling JOptionPane.showInputDialog() and I would like to control this windows via assertJ, a swing gui testing framework (see here).

It seems to be possible but apart from the well done official doc, I found no code and I am stuck; it would be nice to control such little windows from my test methods.

here is my system under test:

public void saveChanges() {
    if (bookWindow.getISBN().equals("0")) {
      String s = (String) JOptionPane.showInputDialog(
              "Veuillez entrer l'ISBN du nouveau livre",
              "nouvel ISBN",

      if ((s != null) && (s.length() == 13) && (s.startsWith("978"))) {

In the case I am testing, the ISBN has the value “0”.

here is my test code:

execute(() -> statesManager.getState().saveChanges());

JOptionPaneFixture optionPane = JOptionPaneFinder.findOptionPane().withTimeout
optionPane.textBox(new GenericTypeMatcher<JTextField>(JTextField.class) {
  protected boolean isMatching(JTextField component) {
    return "".equals(component.getText());

I would like to force the JTextField of the JOptionPane with a given value, and then click on the OK button.


Fragment with RecyclerView not showing up

This is probably a stupid error, but didn’t find any solution here on stackoverflow and it’s first time for me using recyclerview

I used the default guide line of android studio for creating the recyclerview

So my problem is, when in MainActivity I click on the button to open new fragment with recyclerview, the fragment is created(my db is called and so on in the newInstance method) but nothing shows up. Seems like OnCreateView method is never called.

In MainActivity (extending appcompatactivity)

private View.OnClickListener onClickListener = new View.OnClickListener() {
    public void onClick(View v) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        Fragment fragment = null;
        switch (v.getId()) {
            case break;
            case fragment = GestioneFragment.newInstance(1);
            case break;
        //fragmentManager.beginTransaction().replace(, fragment).commit();

My fragment containing the recyclerview GestioneFragment

public class GestioneFragment extends Fragment {

// TODO: Customize parameter argument names
private static final String ARG_COLUMN_COUNT = "column-count";
// TODO: Customize parameters
private int mColumnCount = 1;
private OnListGestioneFragmentInteractionListener mListener;
private RecyclerView recyclerView;

public GestioneFragment() {

public static GestioneFragment newInstance(int columnCount) {
    GestioneFragment fragment = new GestioneFragment();
    Bundle args = new Bundle();
    args.putInt(ARG_COLUMN_COUNT, columnCount);
    return fragment;

public void onCreate(Bundle savedInstanceState) {

    if (getArguments() != null) {
        mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
    //stuff with db, so OnCreate is called

public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_gestione_list, container, false);

    // Set the adapter
    if (view instanceof RecyclerView) {
        Context context = view.getContext();
        recyclerView = (RecyclerView) view;
        if (mColumnCount <= 1) {
            recyclerView.setLayoutManager(new LinearLayoutManager(context));
        } else {
            recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
        recyclerView.setAdapter(new GestioneRecyclerViewAdapter(gs, mListener));
    return view;

Activity Main Layout

<?xml version="1.0" encoding="utf-8"?>
< xmlns:android=""

        android:layout_height="match_parent" />

        android:text="Modalità Gestione Giocatori"
        app:layout_constraintTop_toBottomOf="parent" />


GestioneFragment layout fragment_gestione_list

<?xml version="1.0" encoding="utf-8"?>
    tools:listitem="@layout/fragment_gestione_list_item" />

Any idea to solve this?
Thanks in advance

Does my Retrofit/ReactiveX method actually retrieve data asynchronously?

swipeRefreshLayout.setOnRefreshListener(() -> {
 retrieveData(mCardAdapter, db);

For some reason the following method is blocking my main UI thread, but it should be running in the background. For example, the refresh indicator hangs when I run retrieveData(). If I initialize a progress dialog before running, it also hangs and I can’t scroll through my RecyclerView. Am I fundamentally misunderstanding something here?

public void retrieveData(final CardAdapter mCardAdapter, SQLiteHelper db) {
 CausticRetrofitService service = ServiceFactory.createRetrofitService(CausticRetrofitService.class, CausticRetrofitService.SERVICE_ENDPOINT);
  .subscribe(new Subscriber < MediaResponse > () {
   public final void onCompleted() {

    Log.e("CausticRetrofitService", "Caustic Request Completed!");

    /* Cancel all progress indicators after data retrieval complete */

    // TODO: Add media to local data store and then display them one-by-one in real-time
    mCardAdapter.addData(db.getAllMediaImages()); // Add all media images to card views
    Log.d(getClass().toString(), "Added to local database: " + db.getAllMediaImages());

   public final void onError(Throwable e) {
    /* Cancel all progress indicators on data retrieval error */

    Toast.makeText(getApplicationContext(), "Cannot retrieve data. Please try again later.", Toast.LENGTH_SHORT).show();
    Log.e("CausticRetrofitService", e.getMessage());

   public final void onNext(MediaResponse mediaResponse) {
    if (mediaResponse != null) {

     Log.e("CausticRetrofitService", "Returned objects: " + mediaResponse.getResults());

     for (String mediaId: mediaResponse.getResults()) {
      Log.e("CausticRetrofitService", mediaId);

     List < String > mediaIds = mediaResponse.getResults();
     Log.d(getClass().toString(), "All Media IDs: " + mediaIds);

     if (mediaIds.isEmpty()) {
      Toast.makeText(getApplicationContext(), "Cannot retrieve data. Please try again later.", Toast.LENGTH_SHORT).show();


     /* Store objects from remote web service to local database */
     for (String mediaId: mediaIds) {
      // TODO: Why are these null?
      Log.d(getClass().toString(), "Media Id: " + mediaId);
      MediaImage newMediaImage = new MediaImage();
      db.addMediaImage(newMediaImage); // Add media image to local database

    } else {
     Log.e("CausticRetrofitService", "Object returned is null.");



I’m thinking that adding the remote data to the local data store in the onNext() method might be the thing that’s blocking, although I’m not certain.

Maven packaging – build an environment file?

I use maven to build some java project and compile it to Jar
along with this jar I have some configuration file that is environment specific
Is it possible to have maven create multiple configuration files
given additional “environment files”

configuration file content:


environment file1 (for dev)


environment file2 (for qa)


So the output will be:


Java readLine() returns null


public class MountainView {
    public static void main(String[] args) throws IOException {
        String TextData = "";
        BufferedReader Read = new BufferedReader(new FileReader("E:\Practise\Round 1\DATA\DATA32.txt")); //File contains text

        while(true) {
            String Line = Read.readLine();
            if (Line == null) break;
            TextData += Line;


I am trying to read the contents of a text file and store it in a string. However, even though the file contains text, Read.readLine() always returns null, and the program terminates.

if (Line == null) break;

Weirdly, if I change the above line to:

if (Line != null) break;

The program prints the first line, which is “5”, then terminates.

Taking the URL of an image within a Button

Essentially, I’m comparing two buttons to check if they have the same image (each button is essentially just an image) – in java swing.

To do this, I believe the best way is to compare if the file location of each image is the same, so my question is how can I program it to take the image URL from the button and then convert it to a String to compare it to the other?

Java-How to modify the code so it also matches html tags with attributes?

So this is the code I’m using to match HTML tags; it works when i use tags such as <body> </body> but not with <table border = "3"> </table>. How do I modify it so that it also works with attributes? Part of the code is below:

public class MatchDel {
public static boolean isHTMLMatched(String html) {
    LinkedStack<String> buffer = new LinkedStack<>();
    int j = html.indexOf('<');
    while(j != -1) {
        int k = html.indexOf('>', j+1);
        if(k == -1) {
            return false;
        String tag = html.substring(j+1, k);
        if(!tag.startsWith("/")) {
        else {
            if(buffer.isEmpty()) {
                return false;
            if(!tag.substring(1).equals(buffer.pop())) {
                return false;
        j = html.indexOf('<', k+1);
    return buffer.isEmpty();

    public static void main(String[] args) {
        System.out.println(isHTMLMatched("<body> </body>"));

Java Trails example TimeClient errors

For some reason I get an error about it cannot find symbol: class TimeClient

I copied this code from the java trails on
Here is

import java.time.*; 

public interface TimeClient {
    void setTime(int hour, int minute, int second);
    void setDate(int day, int month, int year);
    void setDateAndTime(int day, int month, int year,
    int hour, int minute, int second); LocalDateTime getLocalDateTime();

Here is the file:

package defaultmethods;

import java.time.*;
import java.lang.*;
import java.util.*;

public class SimpleTimeClient implements TimeClient {

    private LocalDateTime dateAndTime;

    public SimpleTimeClient() {
        dateAndTime =;

    public void setTime(int hour, int minute, int second) {
        LocalDate currentDate = LocalDate.from(dateAndTime);
        LocalTime timeToSet = LocalTime.of(hour, minute, second);
        dateAndTime = LocalDateTime.of(currentDate, timeToSet);

    public void setDate(int day, int month, int year) {
        LocalDate dateToSet = LocalDate.of(day, month, year);
        LocalTime currentTime = LocalTime.from(dateAndTime);
        dateAndTime = LocalDateTime.of(dateToSet, currentTime);

    public void setDateAndTime(int day, int month, int year,
          int hour, int minute, int second) {
        LocalDate dateToSet = LocalDate.of(day, month, year);
        LocalTime timeToSet = LocalTime.of(hour, minute, second); 
        dateAndTime = LocalDateTime.of(dateToSet, timeToSet);

    public LocalDateTime getLocalDateTime() {
        return dateAndTime;

    public String toString() {
        return dateAndTime.toString();

    public static void main(String... args) {
        TimeClient myTimeClient = new SimpleTimeClient();

Here are the errors:

javac error: cannot find symbol
public class SimpleTimeClient implements TimeClient {
  symbol: class TimeClient error: cannot find symbol
        TimeClient myTimeClient = new SimpleTimeClient();
  symbol:   class TimeClient
  location: class SimpleTimeClient
2 errors

I have the files in the same directory so why can it not find Is it something so simple that I am missing?

What is causing my jsoup eror [on hold]

enter image description here

I cant figure out what the problem is with this I have linked Jsoup into my Project.

Any Help would be great

package webScrapping;


import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

public class WebScrapper {

    public void doScrapping(String url) {
    Document website = null;
    try {
        website = Jsoup.connect(url).get();
    } catch (IOException ioe) {
    Elements tbody = website.getElementsByTag("tbody");
    Elements rows = tbody.get(0).select("tr");
    for (Element row : row) {
        Elements colums = row.getElementsByTag("td");
        for (int i = 1; i < 3; i++) {



public static void main(String[] args) {
    String url="";
    WebScapper scapper = new WebScrapper();



The problem with the code is jsoup aspect I believe that I have set up the reference correctly