1

So some are confused about what exactly is the requirement. Here is a full description.
I have 2 machines.
Machine 1 - Server : A Virtual machine where Fitnesse is deployed.
Machine 2 - A local machine where I have to access all the information in a java project.

Now, I have 1 Test Page with the content in form of:
|Import|
|Fixtures|

|AdditionTestPageFixture|
|a|b|doAddition?|
|1|2| 4 |

in the server machine. I access this page from my machine using the URL : http://x.x.x.x:xxxx/FrontPage.ArithmeticSuite1.AdditionTestPage

Coming back to my local machine.
I have a JAVA project created where I need to know which class is being used in this Fixture so basically I want to read this content and extract word "AdditionTestPageFixture".
I can't go to server through putty and access files there, that should not be done. Whatever I can do, I should do through Fitnesse only. So,
1. I cant go to directory where the pages are stored on that server machine and extract content.
2. I can't use URLConnetion to send HTTP requests because the response is a HTML response and parsing that whole content will be tedious.

  • The url is to a local host. not very useful for us. What about sending a HTTP request? what form is the data? – elyashiv Aug 11 '16 at 10:59
  • 1
    Possible duplicate of [Using java.net.URLConnection to fire and handle HTTP requests](http://stackoverflow.com/questions/2793150/using-java-net-urlconnection-to-fire-and-handle-http-requests) – elyashiv Aug 11 '16 at 11:00
  • Your question is not really clear to me? What exactly do you mean by 'data of a fitnesse page'? Are you trying to access the wiki page-source (the content when editing the page)? From where are you trying to access the data (what do you want to do)? – Fried Hoeben Aug 11 '16 at 20:46
  • @FriedHoeben Please check the edit now. – Himanshu Gupta Aug 12 '16 at 05:50
  • Are you only interested in the Java class (and possibly methods in them) that are called? Are you using slim and/or fit? – Fried Hoeben Aug 12 '16 at 07:03
  • Those requirements sound batshit crazy. What I'd expect is a fitnesse server, which has fixtures. Part of the startup is a compile of the fixtures, and then startup fitnesse, so it is approachable through http. Fitnesse could possibly setup stubs before executing its tests, but those are all available from Fitnesse, and static. What are you trying to accomplish? – Koos Gadellaa Aug 13 '16 at 17:01

2 Answers2

1

In the FitNesseRoot subfolder of your FitNesse installation, you will find a set of folders containing content.txt files. These are the FitNesse pages and you can read these and process them as required.

On a remote FitNesse installation, you can issue an HTTP request that will return the page in raw wiki format, e.g.

http://remotehost:8090/MyPage?pageData

You can see the full set of options for accessing FitNesse at:

http://fitnesse.org/FitNesse.UserGuide.AdministeringFitNesse.RestfulServices

Mike Stockdale
  • 5,201
  • 3
  • 27
  • 33
0

You can use a HttpURLConnection; Example:

public String getPage(URL url) {
    try {
        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

        BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
        String inputLine;
        StringBuilder response = new StringBuilder();

        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();

        return response.toString();
    } catch (IOException e) {
        e.printStackTrace();
    }
}