Skip to content

Commit c6afe78

Browse files
committed
fix bug where identifyMetadataOnly() ignored postback headers
1 parent 754948b commit c6afe78

File tree

7 files changed

+36
-26
lines changed

7 files changed

+36
-26
lines changed

blitline-image-client-example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.blitline</groupId>
66
<artifactId>blitline-java-parent</artifactId>
7-
<version>0.14.2</version>
7+
<version>0.14.3</version>
88
</parent>
99

1010
<artifactId>blitline-image-client-example</artifactId>

blitline-image-client-spring/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.blitline</groupId>
66
<artifactId>blitline-java-parent</artifactId>
7-
<version>0.14.2</version>
7+
<version>0.14.3</version>
88
</parent>
99

1010
<artifactId>blitline-image-client-spring</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.blitline.image.spring.web;
2+
3+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
4+
5+
import org.springframework.http.MediaType;
6+
import org.springframework.test.web.servlet.MockMvc;
7+
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
8+
9+
public abstract class AbstractBlitlinePostbackControllerTest {
10+
11+
protected MockMvc mockMvc;
12+
13+
public static final String POSTBACK_TO = BlitlinePostbackController.BASE_ENDPOINT + BlitlinePostbackController.IMAGE_PATH;
14+
15+
public static final String SUCCESS_POSTBACK_CONTENT = "{\"results\":"
16+
+ "{\"original_meta\":{\"width\":3740,\"height\":5573,\"date_created\":\"2011:06:07 22:09:30\"},"
17+
+ "\"images\":[{\"image_identifier\":\"6odPpPC9Ayy8Z2ETs9i1Bk-ts\",\"s3_url\":\"http://s3.amazonaws.com/some-bucket/6odPpPC9Ayy8Z2ETs9i1Bk-ts.webp\",\"meta\":{\"width\":43,\"height\":64}}],"
18+
+ "\"job_id\":\"3WkW98qII4EMriH4jV3eAkQ\"}}";
19+
20+
21+
public AbstractBlitlinePostbackControllerTest() {
22+
// TODO Auto-generated constructor stub
23+
}
24+
25+
protected MockHttpServletRequestBuilder postPostback(String content) throws Exception {
26+
return post(POSTBACK_TO).contentType(MediaType.APPLICATION_JSON).content(content);
27+
}
28+
}

blitline-image-client-spring/src/test/java/com/blitline/image/spring/web/BlitlinePostbackControllerTest.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@
1717
import org.mockito.InjectMocks;
1818
import org.mockito.Mock;
1919
import org.mockito.MockitoAnnotations;
20-
import org.springframework.http.MediaType;
21-
import org.springframework.test.web.servlet.MockMvc;
22-
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
2320
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
2421

2522
import com.blitline.image.BlitlinePostback;
2623
import com.blitline.image.spring.BlitlineObjectMapperHolder;
2724
import com.blitline.image.spring.postback.BlitlinePostbackHandler;
2825

29-
public class BlitlinePostbackControllerTest {
26+
public class BlitlinePostbackControllerTest extends AbstractBlitlinePostbackControllerTest {
3027

3128
@Mock
3229
private BlitlinePostbackHandler postbackHandler;
@@ -40,26 +37,13 @@ public class BlitlinePostbackControllerTest {
4037
@InjectMocks
4138
private BlitlinePostbackController controller;
4239

43-
public static final String POSTBACK_TO = BlitlinePostbackController.BASE_ENDPOINT + BlitlinePostbackController.IMAGE_PATH;
44-
45-
private MockMvc mockMvc;
46-
4740
@Before
4841
public void setup() {
4942
MockitoAnnotations.initMocks(this);
5043

5144
mockMvc = MockMvcBuilders.standaloneSetup(controller).setMessageConverters(new BlitlinePostbackHttpMessageConverter(new BlitlineObjectMapperHolder())).build();
5245
}
5346

54-
public static final String SUCCESS_POSTBACK_CONTENT = "{\"results\":"
55-
+ "{\"original_meta\":{\"width\":3740,\"height\":5573,\"date_created\":\"2011:06:07 22:09:30\"},"
56-
+ "\"images\":[{\"image_identifier\":\"6odPpPC9Ayy8Z2ETs9i1Bk-ts\",\"s3_url\":\"http://s3.amazonaws.com/some-bucket/6odPpPC9Ayy8Z2ETs9i1Bk-ts.webp\",\"meta\":{\"width\":43,\"height\":64}}],"
57-
+ "\"job_id\":\"3WkW98qII4EMriH4jV3eAkQ\"}}";
58-
59-
private MockHttpServletRequestBuilder postPostback(String content) throws Exception {
60-
return post(POSTBACK_TO).contentType(MediaType.APPLICATION_JSON).content(content);
61-
}
62-
6347
@Test
6448
public void noContentType() throws Exception {
6549
mockMvc.perform(post(POSTBACK_TO).content("{}")).andExpect(status().isUnsupportedMediaType());

blitline-image-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.blitline</groupId>
66
<artifactId>blitline-java-parent</artifactId>
7-
<version>0.14.2</version>
7+
<version>0.14.3</version>
88
</parent>
99

1010
<artifactId>blitline-image-client</artifactId>

blitline-image-client/src/main/java/com/blitline/image/BlitlineImageJob.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,8 @@ public BlitlineImageJob identifyMetadataOnly() {
283283
* @return a job specification that will only read and return metadata
284284
*/
285285
public BlitlineImageJob identifyMetadataOnly(String identifierPart) {
286-
BlitlineImageJob job = new BlitlineImageJob(applicationId, src, true, postbackUrl);
287-
job.apply(Blitline.noOp().andSkipSave(identifierPart + IDENTIFY_ONLY_SUFFIX));
288-
return job;
286+
this.withExtendedMetadata();
287+
return apply(Blitline.noOp().andSkipSave(identifierPart + IDENTIFY_ONLY_SUFFIX));
289288
}
290-
291289
}
292290
}

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.blitline</groupId>
55
<artifactId>blitline-java-parent</artifactId>
6-
<version>0.14.2</version>
6+
<version>0.14.3</version>
77
<packaging>pom</packaging>
88
<name>Blitline Java client</name>
99
<description>Java client libraries for Blitline</description>
@@ -42,7 +42,7 @@
4242
<properties>
4343
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4444
<java.version>1.6</java.version>
45-
<spring.framework.version>4.1.1.RELEASE</spring.framework.version>
45+
<spring.framework.version>4.1.2.RELEASE</spring.framework.version>
4646
<spring.boot.version>1.1.8.RELEASE</spring.boot.version>
4747
</properties>
4848

0 commit comments

Comments
 (0)