Skip to content

Commit

Permalink
Define port number when the main method is started
Browse files Browse the repository at this point in the history
  • Loading branch information
asomov committed Oct 4, 2012
1 parent e11d829 commit e7ef88a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
Expand Up @@ -21,19 +21,15 @@

/**
* Main entry point to start the {@link GnipServer}
*
* @author Guido Marucci Blas
* @since 11/11/2011
*/
public final class Main {

private static final int DEFAUL_SERVER_PORT = 8080;

private static final InputStream ACTIVITIES = Main.class.getClassLoader().getResourceAsStream(
//"com/zaubersoftware/gnip4j/server/activity/activities.json");
"com/zaubersoftware/gnip4j/server/activity/unlimitedActivity.json");

public static void main(final String[] args) throws InterruptedException {
final MockServer mockServer = new MockServer();
final MockServer mockServer = new MockServer(DEFAUL_SERVER_PORT);
mockServer.start(ACTIVITIES);
}

Expand Down
Expand Up @@ -33,7 +33,7 @@ public final class LimitedNettyChunkedInputFactory extends NettyChunkedInputFact
*
* Creates the NettyHandlerAggregator.
* @param limitedActivities
* @param timesToStart the times that the mock server will start and shutdown client's connections.
* @param numberOfChunks
*/
public LimitedNettyChunkedInputFactory(final InputStream limitedActivities,
final int numberOfChunks) {
Expand Down
Expand Up @@ -24,28 +24,28 @@
*
* Implementation of Mock Server
*
*
* @author Ignacio De Maio
* @since Jan 4, 2012
*/
public class MockServer {

private static GnipServer gnipServer;
private final int DEFAUL_SERVER_PORT = 8080;


private NettyChunkedInputFactory chunkedInputFactory;

private int portNumber;

/**
*
*/
public MockServer(){
public MockServer(int portNumber){
this.portNumber = portNumber;
}

void start() {
final GnipServerFactory gnipServerFactory = new NettyGnipServerFactory();
gnipServer = gnipServerFactory.createServer(DEFAUL_SERVER_PORT, chunkedInputFactory);
gnipServer = gnipServerFactory.createServer(portNumber, chunkedInputFactory);

gnipServer.start();
System.out.println("Gnip server started at port " + DEFAUL_SERVER_PORT);
System.out.println("Gnip mock server started at port " + portNumber);
}

public void start(final InputStream activities) {
Expand Down
Expand Up @@ -35,7 +35,6 @@ public final class SlowNettyChunkedInputFactory extends NettyChunkedInputFactory
*
* Creates the NettyHandlerAggregator.
* @param limitedActivities
* @param timesToStart the times that the mock server will start and shutdown client's connections.
*/
public SlowNettyChunkedInputFactory(final InputStream limitedActivities,
final int timeBetweenChunks) {
Expand Down

0 comments on commit e7ef88a

Please sign in to comment.