Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completes simple version of notification api
* notifications can be PUT, and if an matching email is provided a notification is stored for the user. refs #202
- Loading branch information
Showing
5 changed files
with
186 additions
and
64 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
56 changes: 56 additions & 0 deletions
56
...src/test/java/eu/scape_project/planning/services/notification/NotificationResourceIT.java
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,56 @@ | ||
package eu.scape_project.planning.services.notification; | ||
|
||
import java.io.StringWriter; | ||
|
||
import org.apache.http.HttpResponse; | ||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.client.methods.HttpPut; | ||
import org.apache.http.entity.StringEntity; | ||
import org.apache.http.impl.client.DefaultHttpClient; | ||
import org.codehaus.jackson.map.ObjectMapper; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
import eu.scape_project.planning.annotation.IntegrationTest; | ||
|
||
@Category(IntegrationTest.class) | ||
public class NotificationResourceIT { | ||
|
||
/** | ||
* adds a test notification. | ||
* - to user scape.pw@gmail.com | ||
* - the server must be running on localhost:8080 | ||
* | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void addNotificationTest() throws Exception{ | ||
DefaultHttpClient httpClient = new DefaultHttpClient(); | ||
|
||
WatchNotification n = new WatchNotification(null, "test message", null, null, "scape.pw@gmail.com"); | ||
|
||
StringWriter writer = new StringWriter(); | ||
|
||
ObjectMapper mapper = new ObjectMapper(); | ||
mapper.writeValue(writer, n); | ||
|
||
HttpPut putRequest = new HttpPut("http://localhost:8080/plato/rest/notification"); | ||
putRequest.addHeader("content-type", "application/json"); | ||
|
||
putRequest.setEntity(new StringEntity(writer.getBuffer().toString())); | ||
|
||
try { | ||
HttpResponse response = httpClient.execute(putRequest); | ||
|
||
int statusCode = response.getStatusLine().getStatusCode(); | ||
|
||
Assert.assertEquals(200, statusCode); | ||
|
||
} finally { | ||
httpClient.getConnectionManager().shutdown(); | ||
} | ||
|
||
} | ||
|
||
} |