1. create service
2. deploy it on Tomcat or run locally in Eclipse "Run on server"
3. test by SoapUI
add REST project in SoapUI
send request like
http://localhost:8080/RESTCalculator/rest/calc/add/10/10
4. test by client
public class CalculatorTest {
private static Logger LOG = Logger.getLogger(CalculatorTest.class);
@BeforeClass
public static void setUp() throws Exception {
BasicConfigurator.configure();
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CalculatorRS.class);
sf.setResourceProvider(CalculatorRS.class,
new SingletonResourceProvider(new CalculatorRS()));
sf.setAddress("http://localhost:8080/RESTCalculator/rest?_wadl");
Server server = sf.create();
System.out.println("Client was created");
}
@Test
public void testAdd() throws Exception {
LOG.info("The test was started");
CalculatorRS calculatorService = new CalculatorRS();
System.out.println("Calculate Sum operation on calculate Service");
int suma = calculatorService.add(4, 6);
System.out.println("Sum of 4 and 6 is " + suma);
assertEquals(10, suma);
}
}


Немає коментарів:
Дописати коментар