Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
add additional sanity checks for optional components we're wiring int…
…o kitchen sink
- Loading branch information
Showing
5 changed files
with
114 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.fcrepo.integration; | ||
|
||
import org.apache.http.client.ClientProtocolException; | ||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.client.methods.HttpUriRequest; | ||
import org.apache.http.impl.client.DefaultHttpClient; | ||
import org.apache.http.impl.conn.PoolingClientConnectionManager; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class MetricsIT { | ||
|
||
/** | ||
* The server port of the application, set as system property by | ||
* maven-failsafe-plugin. | ||
*/ | ||
private static final String SERVER_PORT = System.getProperty("test.port"); | ||
|
||
/** | ||
* The context path of the application (including the leading "/"), set as | ||
* system property by maven-failsafe-plugin. | ||
*/ | ||
private static final String CONTEXT_PATH = System | ||
.getProperty("test.context.path"); | ||
|
||
protected Logger logger; | ||
|
||
@Before | ||
public void setLogger() { | ||
logger = LoggerFactory.getLogger(this.getClass()); | ||
} | ||
|
||
protected static final String HOSTNAME = "localhost"; | ||
|
||
protected static final String serverAddress = "http://" + HOSTNAME + ":" + | ||
SERVER_PORT + CONTEXT_PATH; | ||
|
||
protected static final PoolingClientConnectionManager connectionManager = | ||
new PoolingClientConnectionManager(); | ||
|
||
protected static HttpClient client; | ||
|
||
static { | ||
connectionManager.setMaxTotal(Integer.MAX_VALUE); | ||
connectionManager.setDefaultMaxPerRoute(5); | ||
connectionManager.closeIdleConnections(3, TimeUnit.SECONDS); | ||
client = new DefaultHttpClient(connectionManager); | ||
} | ||
|
||
@Test | ||
public void doASanityCheck() throws IOException { | ||
assertEquals(200, getStatus(new HttpGet(serverAddress + | ||
"metrics/"))); | ||
} | ||
|
||
|
||
|
||
protected int getStatus(final HttpUriRequest method) | ||
throws ClientProtocolException, IOException { | ||
logger.debug("Executing: " + method.getMethod() + " to " + | ||
method.getURI()); | ||
return client.execute(method).getStatusLine().getStatusCode(); | ||
} | ||
} |