axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bu...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl/ram RamServiceTestCase.java RamSoapBindingImpl.java
Date Thu, 25 Jul 2002 16:14:12 GMT
butek       2002/07/25 09:14:12

  Modified:    java/test/wsdl/addrNoImplSEI AddressBookTestCase.java
                        Main.java
               java/test/wsdl/datatypes DataTypesTestCase.java
               java/test/wsdl/extensibility
                        ExtensibilityQueryBindingImpl.java
                        ExtensibilityQueryTestCase.java
               java/test/wsdl/multiref MultiRefTestCase.java
               java/test/wsdl/nested Nested2ServiceTestCase.java
               java/test/wsdl/ram RamServiceTestCase.java
                        RamSoapBindingImpl.java
  Log:
  Since we all agreed that the tests should only generate info on errors, I've
  removed some of the extra stuff from the tests:
  - some places getting rid of System.err.println/System.out.println
  - some places replacing them with assertTrue
  - test/wsdl/addrNoImplSEI/Main took a bit more effort
      - Removed all the System.err.printlns
      - Removed the try blocks which kept exceptions from propagating out.
        (this test could NEVER fail!)
      - The catch block check - "if (e.detail instanceof IllegalArgumentException)"
         was wrong.  AxisFaults coming across the wire don't have e.detail
         initialized.  (Question:  should they?)
      - Set the level on the logger to FATAL for the duration of this test,
        effectively turning off logging so we don't see the IllegalArgumentException.
  
  Revision  Changes    Path
  1.7       +7 -9      xml-axis/java/test/wsdl/addrNoImplSEI/AddressBookTestCase.java
  
  Index: AddressBookTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/addrNoImplSEI/AddressBookTestCase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AddressBookTestCase.java	3 Jul 2002 18:47:09 -0000	1.6
  +++ AddressBookTestCase.java	25 Jul 2002 16:14:12 -0000	1.7
  @@ -58,15 +58,13 @@
   import junit.framework.TestCase;
   import org.apache.axis.AxisFault;
   
  -import org.apache.axis.components.logger.LogFactory;
  -import org.apache.commons.logging.Log;
  +import org.apache.log4j.Level;
  +import org.apache.log4j.Logger;
   
   
   /** Test the address book sample code.
    */
   public class AddressBookTestCase extends TestCase {
  -    static Log log =
  -            LogFactory.getLog(AddressBookTestCase.class.getName());
   
       public AddressBookTestCase(String name) {
           super(name);
  @@ -78,14 +76,14 @@
       }
   
       public void testAddressBookService () throws Exception {
  +        Logger root = Logger.getRootLogger();
  +        Level origLevel = root.getEffectiveLevel();
  +        root.setLevel(Level.FATAL);
           try {
  -            log.info("Testing address book sample.");
               doTest();
  -            log.info("Test complete.");
           }
  -        catch( Exception e ) {
  -            e.printStackTrace();
  -            throw new Exception("Fault returned from test: "+e);
  +        finally {
  +            root.setLevel(origLevel);
           }
       }
   }
  
  
  
  1.5       +27 -43    xml-axis/java/test/wsdl/addrNoImplSEI/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/addrNoImplSEI/Main.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Main.java	19 Jun 2002 19:11:50 -0000	1.4
  +++ Main.java	25 Jul 2002 16:14:12 -0000	1.5
  @@ -107,27 +107,20 @@
       }
       
       private static Object doit (AddressBookNoImplSEI ab) throws Exception {
  -        System.err.println (">> Storing address for '" + name1 + "'");
           ab.addEntry (name1, addr1);
  -        System.err.println (">> Querying address for '" + name1 + "'");
           Address resp = ab.getAddressFromName (name1);
  -        System.err.println (">> Response is:");
  -        printAddress (resp);
           
           // if we are NOT maintaining session, resp must be == null.
           // If we ARE, resp must be != null.
           
  -        System.err.println (">> Querying address for '" + name1 + "' again");
           resp = ab.getAddressFromName (name1);
  -        System.err.println (">> Response is:");
  -        printAddress (resp);
           
           // Test NPE
           try {
               ab.addEntry(null, null);
               throw new Exception("Expected exception when calling addEntry with null params");
  -        } catch (java.rmi.RemoteException e) {
  -            if (e.detail instanceof java.lang.IllegalArgumentException) {
  +        } catch (org.apache.axis.AxisFault e) {
  +            if ("java.lang.IllegalArgumentException".equals(e.getFaultString())) {
                   // Good! Expected this!
               } else {
                   throw e;  // This is not right!
  @@ -138,44 +131,35 @@
       }
       
       public static void main (String[] args) throws Exception {
  -        try {
  -            Options opts = new Options(args);
  -
  -            System.err.println ("Using proxy without session maintenance.");
  -            System.err.println ("(queries without session should say:  \"ADDRESS NOT FOUND!\")");
  +        Options opts = new Options(args);
   
  -            AddressBookNoImplSEIService abs = new AddressBookNoImplSEIServiceLocator();
  -            opts.setDefaultURL( abs.getAddressBookNoImplSEIAddress() );
  -            URL serviceURL = new URL(opts.getURL());
  +        AddressBookNoImplSEIService abs = new AddressBookNoImplSEIServiceLocator();
  +        opts.setDefaultURL( abs.getAddressBookNoImplSEIAddress() );
  +        URL serviceURL = new URL(opts.getURL());
   
  -            AddressBookNoImplSEI ab1 = null;
  -            if (serviceURL == null) {
  -                ab1 = abs.getAddressBookNoImplSEI();
  -            }
  -            else {
  -                ab1 = abs.getAddressBookNoImplSEI(serviceURL);
  -            }
  -            Object ret = doit (ab1);
  -            if (ret != null) {
  -                throw new Exception("non-session test expected null response, got "+ret);
  -            }
  +        AddressBookNoImplSEI ab1 = null;
  +        if (serviceURL == null) {
  +            ab1 = abs.getAddressBookNoImplSEI();
  +        }
  +        else {
  +            ab1 = abs.getAddressBookNoImplSEI(serviceURL);
  +        }
  +        Object ret = doit (ab1);
  +        if (ret != null) {
  +            throw new Exception("non-session test expected null response, got "+ret);
  +        }
   
  -            System.err.println ("\n\nUsing proxy with session maintenance.");
  -            AddressBookNoImplSEI ab2 = null;
  -            if (serviceURL == null) {
  -                ab2 = abs.getAddressBookNoImplSEI();
  -            }
  -            else {
  -                ab2 = abs.getAddressBookNoImplSEI(serviceURL);
  -            }
  -            ((AddressBookNoImplSEISoapBindingStub) ab2).setMaintainSession (true);
  -            ret = doit (ab2);
  -            if (ret == null) {
  -                throw new Exception("session test expected non-null response, got "+ret);
  -            }
  +        AddressBookNoImplSEI ab2 = null;
  +        if (serviceURL == null) {
  +            ab2 = abs.getAddressBookNoImplSEI();
  +        }
  +        else {
  +            ab2 = abs.getAddressBookNoImplSEI(serviceURL);
           }
  -        catch (Exception e) {
  -            e.printStackTrace();
  +        ((AddressBookNoImplSEISoapBindingStub) ab2).setMaintainSession (true);
  +        ret = doit (ab2);
  +        if (ret == null) {
  +            throw new Exception("session test expected non-null response, got "+ret);
           }
       }
   }
  
  
  
  1.4       +18 -12    xml-axis/java/test/wsdl/datatypes/DataTypesTestCase.java
  
  Index: DataTypesTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/datatypes/DataTypesTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DataTypesTestCase.java	18 Jul 2002 20:55:11 -0000	1.3
  +++ DataTypesTestCase.java	25 Jul 2002 16:14:12 -0000	1.4
  @@ -24,7 +24,7 @@
           try {
               java.lang.String value = null;
               value = binding.sayHello();
  -            System.out.println("sayHello: " + value);
  +            assertTrue("sayHello should be \"Hello World!\", but instead is " + value,
"Hello World!".equals(value));
           }
           catch (java.rmi.RemoteException re) {
               throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
  @@ -44,7 +44,7 @@
           try {
               java.lang.String value = null;
               value = binding.sayHelloName(new java.lang.String("Axis"));
  -            System.out.println("sayHelloName: " + value);
  +            assertTrue("sayHelloName should be \"Hello Axis\", but instead is " + value,
"Hello Axis".equals(value));
           }
           catch (java.rmi.RemoteException re) {
               throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
  @@ -65,13 +65,9 @@
               ArrayOfInt value = null;
               value = binding.getIntArray();
               int[] array = value.get_int();
  -            System.out.print("getIntArray: {");
  +            assertTrue("getIntArray size should be 5, instead is " + array.length, array.length
== 5);
               for(int i=0;i<array.length;i++) {
  -                System.out.print(array[i]);
  -                if((i+1) != array.length)
  -                    System.out.print(",");
  -                else
  -                    System.out.println("}");
  +                assertTrue("getIntArray[" + i + "] should be " + (i * 10) + ", instead
is " + array[i], array[i] == i * 10);
               }
           }
           catch (java.rmi.RemoteException re) {
  @@ -92,7 +88,7 @@
           try {
               Mode value = null;
               value = binding.getMode();
  -            System.out.println("getMode: " + value.toString());
  +            assertTrue("getMode should be Off, instead it is " + value.toString(), "Off".equals(value.toString()));
           }
           catch (java.rmi.RemoteException re) {
               throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
  @@ -112,7 +108,8 @@
           try {
               Order value = null;
               value = binding.getOrder();
  -            System.out.println("getOrder: {" + value.getOrderID() + "," + value.getPrice()
+ "}");
  +            assertTrue("getOrder.getOrderID should be 323232, instead it is " + value.getOrderID(),
value.getOrderID() == 323232);
  +            assertTrue("getOrder.getPrice should be 34.5, instead it is " + value.getPrice(),
value.getPrice() == 34.5);
           }
           catch (java.rmi.RemoteException re) {
               throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
  @@ -133,8 +130,17 @@
               ArrayOfOrder value = null;
               value = binding.getOrders();
               Order[] orders = value.getOrder();
  -            for(int i=0;i<orders.length;i++)
  -                System.out.println("getOrder["+i+"]: {" + orders[i].getOrderID() + ","
+ orders[i].getPrice() + "}");
  +            assertTrue("getOrders size should be 2, instead is " + orders.length, orders.length
== 2);
  +            for(int i=0;i<orders.length;i++) {
  +                if (i == 0) {
  +                    assertTrue("getOrders[0].getOrderID should be 323232, instead it is
" + orders[i].getOrderID(), orders[i].getOrderID() == 323232);
  +                    assertTrue("getOrders[0].getPrice should be 34.5, instead it is " +
orders[i].getPrice(), orders[i].getPrice() == 34.5);
  +                }
  +                else if (i == 1) {
  +                    assertTrue("getOrders[1].getOrderID should be 645645, instead it is
" + orders[i].getOrderID(), orders[i].getOrderID() == 645645);
  +                    assertTrue("getOrders[1].getPrice should be 99.4, instead it is " +
orders[i].getPrice(), orders[i].getPrice() == 99.4);
  +                }
  +            }
           }
           catch (java.rmi.RemoteException re) {
               throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
  
  
  
  1.13      +3 -2      xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryBindingImpl.java
  
  Index: ExtensibilityQueryBindingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryBindingImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ExtensibilityQueryBindingImpl.java	23 Jul 2002 12:54:01 -0000	1.12
  +++ ExtensibilityQueryBindingImpl.java	25 Jul 2002 16:14:12 -0000	1.13
  @@ -49,8 +49,9 @@
           if (obj instanceof BookType) {
               BookType bookQuery = (BookType) obj;
               String subject = bookQuery.getSubject();
  -            System.out.println("ExtensibilityQueryBindingImpl: Found book subject query
" + subject);
  -  
  +            if (!"all".equals(subject)) {
  +                throw new RemoteException("ExtensibilityQueryBindingImpl: Book subject
query should be all, instead was " + subject);
  +            }
               QueryResultElement resultElement = new QueryResultElement();
               ResultListType resultList = new ResultListType();
               resultElement.setResultList(resultList);
  
  
  
  1.9       +1 -9      xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryTestCase.java
  
  Index: ExtensibilityQueryTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryTestCase.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ExtensibilityQueryTestCase.java	23 Jul 2002 12:54:01 -0000	1.8
  +++ ExtensibilityQueryTestCase.java	25 Jul 2002 16:14:12 -0000	1.9
  @@ -60,19 +60,11 @@
       }
   
       private void isValid(QueryResultType result, String name, String value) {
  -        System.out.println("ExtensibilityQueryTestCase: Result name: [" + result.getName()
+ "] value: [" + 
  -                           result.getValue() + "] date: [" + result.getTime().getTime()
+ "] type: [" + 
  -                           result.getQueryType() + "]");
  -                               
           assertTrue(result.getName().equals(name));
           assertTrue(result.getValue().equals(value));
           Calendar now = Calendar.getInstance();
           Calendar then = result.getTime();
  -        if (!then.before(now)) {
  -            System.out.println("Time check failed. Result time = " + then + ", current
time = "
  -                               + now);
  -        }
  -        assertTrue(then.before(now));
  +        assertTrue("Time check failed.  Result time = " + then + ", current time = " +
now, then.before(now));
           assertTrue(result.getQueryType().getNamespaceURI().equals("urn:QueryType"));
           assertTrue(result.getQueryType().getLocalPart().equals("BookQuery"));
       }
  
  
  
  1.9       +0 -4      xml-axis/java/test/wsdl/multiref/MultiRefTestCase.java
  
  Index: MultiRefTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/multiref/MultiRefTestCase.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MultiRefTestCase.java	3 Jul 2002 18:47:09 -0000	1.8
  +++ MultiRefTestCase.java	25 Jul 2002 16:14:12 -0000	1.9
  @@ -67,8 +67,6 @@
   /** Test the multiref sample code.
    */
   public class MultiRefTestCase extends TestCase {
  -    static Log log =
  -            LogFactory.getLog(MultiRefTestCase.class.getName());
   
       public MultiRefTestCase(String name) {
           super(name);
  @@ -81,9 +79,7 @@
   
       public void testMultiRefService () throws Exception {
           try {
  -            log.info("Testing multiref sample.");
               doTest();
  -            log.info("Test complete.");
           }
           catch( Exception e ) {
               e.printStackTrace();
  
  
  
  1.5       +0 -2      xml-axis/java/test/wsdl/nested/Nested2ServiceTestCase.java
  
  Index: Nested2ServiceTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/nested/Nested2ServiceTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Nested2ServiceTestCase.java	1 Jul 2002 19:37:52 -0000	1.4
  +++ Nested2ServiceTestCase.java	25 Jul 2002 16:14:12 -0000	1.5
  @@ -35,9 +35,7 @@
                                  rETURN);
               PE_ADDRESS address = pE_ADDRESS.value;
               RETURN ret = rETURN.value;
  -            System.out.println("NAME:" + address.getNAME());
               assertTrue("NAME is wrong", address.getNAME().equals("Becker Berlin"));
  -            System.out.println("LOGMSGNO:" + ret.getLOG_MSG_NO());
               assertTrue("LOGMSGNO is wrong", ret.getLOG_MSG_NO().equals("123456"));
           }
           catch (java.rmi.RemoteException re) {
  
  
  
  1.2       +3 -1      xml-axis/java/test/wsdl/ram/RamServiceTestCase.java
  
  Index: RamServiceTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/ram/RamServiceTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RamServiceTestCase.java	19 Jun 2002 19:11:50 -0000	1.1
  +++ RamServiceTestCase.java	25 Jul 2002 16:14:12 -0000	1.2
  @@ -49,7 +49,9 @@
               input[0].setSalePostingReferenceText("SPRT");
   
               Response[] output = binding.validate(input);
  -            System.out.println("Accounting Date:" + output[0].getAccountingDate());
  +            java.util.Date resDate = output[0].getAccountingDate();
  +            java.util.Date now = new java.util.Date();
  +            assertTrue("Time check failed.  Result date = " + resDate + ", current time
= " + now, resDate.before(now));
           }
           catch (java.rmi.RemoteException re) {
               throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
  
  
  
  1.2       +5 -1      xml-axis/java/test/wsdl/ram/RamSoapBindingImpl.java
  
  Index: RamSoapBindingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/ram/RamSoapBindingImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RamSoapBindingImpl.java	19 Jun 2002 19:11:50 -0000	1.1
  +++ RamSoapBindingImpl.java	25 Jul 2002 16:14:12 -0000	1.2
  @@ -9,7 +9,11 @@
   
   public class RamSoapBindingImpl implements Ram{
       public Response[] validate(RamData[] in0) throws java.rmi.RemoteException {
  -        System.out.println("Date:" + in0[0].getCreditCard().getExpires());
  +        java.util.Date inDate = in0[0].getCreditCard().getExpires();
  +        java.util.Date now = new java.util.Date();
  +        if (!inDate.before(now)) {
  +            throw new java.rmi.RemoteException("Time check failed.  Expires date = " +
inDate + ", current time = " + now);
  +        }
           Response[] response = new Response[1];
           response[0] = new Response();
           response[0].setAccountingDate(new java.util.Date());
  
  
  

Mime
View raw message