Hello,
I'm trying to create a JUnit test case for my infamous "DoubleIt" web
service (http://www.jroller.com/gmazza/date/20080417), and would like to:
(1) create the endpoint,
(2) make several test SOAP requests against it, and
(3) close the endpoint.
My test case is below--I want to make sure I'm doing this correctly (it
seems to work--and correctly returns errors when I intentionally place wrong
values in for the expected results), in particular the setUp() and
tearDown()--is it really as simple as I have it below?
Thanks,
Glen
package com.mycompany.webservice.service;
import static org.junit.Assert.assertEquals;
import java.math.BigInteger;
import javax.xml.ws.Endpoint;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import com.mycompany.webservice.service.DoubleItPortTypeImpl;
import org.example.doubleit.DoubleItPortType;
public class DoubleItPortTypeImplTest {
protected static Endpoint ep;
protected static DoubleItPortTypeImpl port;
@BeforeClass
public static void setUp() throws Exception {
port = new DoubleItPortTypeImpl();
String address =
"http://localhost:8080/cxf/services/DoubleItPortType";
Endpoint ep = Endpoint.publish(address, port);
}
@AfterClass
public static void tearDown() {
try {
ep.stop();
} catch (Throwable t) {
System.out.println("Error thrown: " + t.getMessage());
}
}
@Test
public void doubleItWorksForPositiveNumbers() {
BigInteger resp = port.doubleIt(new BigInteger("10"));
assertEquals("Double-It not doubling positive numbers",
resp.toString(), "20");
}
@Test
public void doubleItWorksForNegativeNumbers() {
BigInteger resp = port.doubleIt(new BigInteger("-10"));
assertEquals("Double-It not doubling negative numbers",
resp.toString(), "-20");
}
}
--
View this message in context:
http://www.nabble.com/Need-code-check----JUnit-test-cases-using-endpoint.publish%28%29-tp18925599p18925599.html
Sent from the cxf-user mailing list archive at Nabble.com.