I'm running a set of integration tests of a jax-rs service using embedded openejb. One of these require to receive a binary file. See the method below:
@POST
@Path("signOff")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void signOffDeliveries(
@Encoded @FormParam("signature") File signature) {
}
Now, this method works fine running it on Websphere, but running a test towards the embedded openejb fails. The signature
gets a file name that contains the whole image binary data(a lot of scrambled signs).
Now reading this file gives a FileNotFoundException
, as expected. My question is then, is this a bug in the embedded openejb, or am I setting up my tests the wrong way? Heres the test code btw:
@RunWith(ApplicationComposer.class)
public class DeliveryServiceIT {
private HttpClient httpClient;
private DeliveryServiceClient client;
@Configuration
public Properties config() throws Exception {
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
properties.setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
return properties;
}
@MockInjector
public Class<?> mockitoInjector() {
return MockitoInjector.class;
}
@Module
public EjbModule createModule() throws Exception {
EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(DeliveryService.class));
EjbModule module = new EjbModule(ejbJar);
return module;
}
@Before
public void setup() {
//this is where I create the http client that makes the actual http request
}
@Test
public void signOffDeliveries_givenSignatureImageAndDeliveries_expectsValidRequest() throws FileNotFoundException, IOException {
File f = new File("/signature.png");
client.signOffDeliveries(file);
//the client will take the file, get the bytes, create
//multipart/form-data request and send the request to the
//service method posted above
}
Since this is working on my websphere, I think its either a problem with the openejb version I'm running my integration tests in(4.5.0) or there is a problem with how the test is setup.