Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Feb 27, 2015
1 parent 8e28dd6 commit 6397aca
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package net.oneandone.troilus.example.service;

import java.io.IOException;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
Expand All @@ -27,7 +29,7 @@ public class PictureService {
@Path("/{id}")
@GET
@Produces("image/png")
public byte[] getHotelThumbnail() {
return "MyPIcture".getBytes();
public byte[] getHotelThumbnail() throws IOException {
return "MyPIcture".getBytes("UTF-8");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.util.concurrent.CompletableFuture;

import com.google.common.util.concurrent.AbstractFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;

Expand All @@ -36,7 +35,10 @@ public static class Thumbnail {
private final byte[] picture;

public Thumbnail(byte[] picture) {
this.picture = picture;
byte[] bytes = new byte[picture.length];
System.arraycopy(picture, 0, bytes, 0, bytes.length);

this.picture = bytes;
}

Thumbnail size(int length, int height) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@






import net.oneandone.troilus.Dao;
import net.oneandone.troilus.DaoImpl;
import net.oneandone.troilus.example.service.Hotel;
Expand All @@ -42,7 +39,7 @@
import com.google.common.collect.ImmutableSet;



@Ignore
public class HotelServiceTest extends AbstractCassandraBasedTest {

private static WebContainer server;
Expand All @@ -61,9 +58,8 @@ public static void afterClass() throws Exception {
}


@Ignore
@Test
public void testExample() throws Exception {
public void testGetHotel() throws Exception {
Client client = ResteasyClientBuilder.newClient();


Expand All @@ -73,7 +69,8 @@ public void testExample() throws Exception {
Assert.assertEquals("Corinthia Budapest", hotel.getName());
}

@Ignore


@Test
public void testPictureExample() throws Exception {
Client client = ResteasyClientBuilder.newClient();
Expand Down Expand Up @@ -105,28 +102,43 @@ public void testPictureExample() throws Exception {

System.out.println(new String(picture));
Assert.assertArrayEquals(new byte[] { 98, 105, 108, 100 }, picture);
}



@Test
public void testPictureExampleClassic() throws Exception {
Client client = ResteasyClientBuilder.newClient();


// hotel entry does not exits
try {
client.target(server.getBaseUrl() + "/classic/hotels/BUPnotexits/thumbnail")
.request()
.get(byte[].class);
Assert.fail("NotFoundException expected");
} catch (NotFoundException expected) { }


// hotel entry with broken URI
picture = client.target(server.getBaseUrl() + "/classic/hotels/BUP14334/thumbnail")
.request()
.get(byte[].class);
// hotel entry without URI is not supported by the implementation
/* byte[] picture = client.target(server.getBaseUrl() + "/classic/hotels/BUP45544/thumbnail")
.request()
.get(byte[].class);
System.out.println(new String(picture));
Assert.assertArrayEquals(new byte[] { 98, 105, 108, 100 }, picture);
*/


// hotel entry with valid URI
picture = client.target(server.getBaseUrl() + "/classic/hotels/BUP932432/thumbnail")
.request()
.get(byte[].class);
// hotel entry with broken URI
byte[] picture = client.target(server.getBaseUrl() + "/classic/hotels/BUP14334/thumbnail")
.request()
.get(byte[].class);

System.out.println(new String(picture));
Assert.assertArrayEquals(new byte[] { 77, 121, 80, 73, 99, 116, 117, 114, 101 }, picture);

Assert.assertArrayEquals(new byte[] { 98, 105, 108, 100 }, picture);
}




Expand Down

0 comments on commit 6397aca

Please sign in to comment.