Java Reference
In-Depth Information
package com.soacookbook.ch03.test;
import static org.junit.Assert.*;
import com.soacookbook.ns.bin.*;
import org.apache.log4j.Logger;
import org.junit.Test;
import java.io.*;
/**
* Tests the BinaryData service.
*/
public class BinaryDataTest {
private static final Logger LOGGER =
Logger.getLogger(BinaryDataTest.class);
private static final String FILE_PATH =
"/home/ehewitt/soacookbook/repository/code/" +
"chapters/client/winchesterHouse.jpg";
public BinaryDataTest() { }
/**
* Client has a binary file such as image or PDF it would
* like to send to service for storage or processing.
* This client reads it in and passes to service, which
* generates an ID for it and returns the ID so client
* can get back data later if necessary.
*/
@Test
public void testPutBinaryData(){
LOGGER.debug("");
try {
BinaryDataService svc = new BinaryDataService();
BinaryData port = svc.getBinaryDataPort();
File f = new File(FILE_PATH);
byte[] imageData = getFileAsBytes(f);
LOGGER.debug("*** Read in file of bytes: " +
imageData.length);
S tring id = port.put(imageData);
LOGGER.debug("Got id returned from service: " + id);
assertEquals("007", id);
Search WWH ::




Custom Search