geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject cvs commit: incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/jmx JMXExceptionDecoderTest.java MBeanProxyExceptionTest.java
Date Sun, 07 Dec 2003 02:54:12 GMT
adc         2003/12/06 18:54:12

  Added:       modules/common/src/test/org/apache/geronimo/common
                        CloneableObjectTest.java
                        NotCoercibleExceptionTest.java StopWatchTest.java
               modules/common/src/test/org/apache/geronimo/common/jmx
                        JMXExceptionDecoderTest.java
                        MBeanProxyExceptionTest.java
  Log:
  Unit tests from Brent Worden.
  
  Revision  Changes    Path
  1.1                  incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/CloneableObjectTest.java
  
  Index: CloneableObjectTest.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.common;
  
  import junit.framework.TestCase;
  
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/12/07 02:54:12 $
   */
  public class CloneableObjectTest extends TestCase {
      public void testClone() {
          CloneableObject co = new CloneableObject();
          try {
              co.clone();
          } catch (InternalError ex) {
              fail("object should be cloneable");
          }
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/NotCoercibleExceptionTest.java
  
  Index: NotCoercibleExceptionTest.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http:www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http:www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.common;
  
  import junit.framework.TestCase;
  
  
  /**
   *
   * @version $Revision: 1.1 $ $Date: 2003/12/07 02:54:12 $
   */
  public class NotCoercibleExceptionTest extends TestCase {
      public void testConstructor() {
          NotCoercibleException ex = new NotCoercibleException();
          assertNull(ex.getMessage());
          assertNull(ex.getCause());
      }
  
      public void testConstructorNullMessage() {
          NotCoercibleException ex = new NotCoercibleException((String) null);
          assertNull(ex.getMessage());
          assertNull(ex.getCause());
      }
  
      public void testConstructorNullCause() {
          NotCoercibleException ex = new NotCoercibleException((Throwable) null);
          assertNull(ex.getMessage());
          assertNull(ex.getCause());
      }
  
      public void testConstructorNullNull() {
          NotCoercibleException ex = new NotCoercibleException(null, null);
          assertNull(ex.getMessage());
          assertNull(ex.getCause());
      }
  
      public void testConstructorMessage() {
          String expected = "message";
          NotCoercibleException ex = new NotCoercibleException(expected);
          assertEquals(expected, ex.getMessage());
          assertNull(ex.getCause());
      }
  
      public void testConstructorCause() {
          Exception expected = new Exception();
          NotCoercibleException ex = new NotCoercibleException(expected);
          assertEquals(expected, ex.getCause());
          assertNotNull(ex.getMessage());
      }
  
      public void testConstructorMessageCause() {
          String message = "message";
          Exception cause = new Exception();
          NotCoercibleException ex = new NotCoercibleException(message, cause);
          assertEquals(message, ex.getMessage());
          assertEquals(cause, ex.getCause());
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/StopWatchTest.java
  
  Index: StopWatchTest.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http:www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http:www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.common;
  
  import junit.framework.TestCase;
  
  
  /**
   *
   * @version $Revision: 1.1 $ $Date: 2003/12/07 02:54:12 $
   */
  public class StopWatchTest extends TestCase {
  
      public void testConstructor() {
          StopWatch sw = new StopWatch();
          assertFalse(sw.isRunning());
      }
  
      public void testConstructorRunning() {
          StopWatch sw = new StopWatch(true);
          assertTrue(sw.isRunning());
  
          sw = new StopWatch(false);
          assertFalse(sw.isRunning());
      }
  
      public void testStartStop() {
          StopWatch sw = new StopWatch();
  
          sw.start();
          assertTrue(sw.isRunning());
          try {
              Thread.sleep(1000);
          } catch (Exception ex) {
          }
          sw.stop();
          assertFalse(sw.isRunning());
  
          assertEquals(1, sw.getLapCount());
          assertTrue(sw.getLapTime() >= 1000L);
          assertTrue(sw.getTime() >= 1000L);
          assertEquals(sw.getLapTime(), sw.getAverageLapTime());
      }
  
      public void testTwoStarts() {
          StopWatch sw = new StopWatch();
  
          sw.start();
          assertTrue(sw.isRunning());
          sw.start();
          assertTrue(sw.isRunning());
          try {
              Thread.sleep(1000);
          } catch (Exception ex) {
          }
          sw.stop();
          assertFalse(sw.isRunning());
  
          assertEquals(1, sw.getLapCount());
          assertTrue(sw.getLapTime() >= 1000L);
          assertTrue(sw.getTime() >= 1000L);
          assertEquals(sw.getLapTime(), sw.getAverageLapTime());
      }
  
      public void testTwoStops() {
          StopWatch sw = new StopWatch();
  
          sw.start();
          assertTrue(sw.isRunning());
          try {
              Thread.sleep(1000);
          } catch (Exception ex) {
          }
          sw.stop();
          assertFalse(sw.isRunning());
          sw.stop();
          assertFalse(sw.isRunning());
  
          assertEquals(1, sw.getLapCount());
          assertTrue(sw.getLapTime() >= 1000L);
          assertTrue(sw.getTime() >= 1000L);
          assertEquals(sw.getLapTime(), sw.getAverageLapTime());
      }
  
      public void testTwoLaps() {
          StopWatch sw = new StopWatch();
  
          sw.start();
          try {
              Thread.sleep(1000);
          } catch (Exception ex) {
          }
          sw.stop();
  
          assertEquals(1, sw.getLapCount());
          assertTrue(sw.getLapTime() >= 1000L);
          assertTrue(sw.getTime() >= 1000L);
          assertEquals(sw.getLapTime(), sw.getAverageLapTime());
  
          sw.start();
          try {
              Thread.sleep(1000);
          } catch (Exception ex) {
          }
          sw.stop();
  
          assertEquals(2, sw.getLapCount());
          assertTrue(sw.getLapTime() >= 1000L);
          assertTrue(sw.getTime() >= 2000L);
      }
  
      public void testReset() {
          StopWatch sw = new StopWatch();
  
          sw.start();
          try {
              Thread.sleep(1000);
          } catch (Exception ex) {
          }
          sw.stop();
  
          assertEquals(1, sw.getLapCount());
          assertTrue(sw.getLapTime() >= 1000L);
          assertTrue(sw.getTime() >= 1000L);
          assertEquals(sw.getLapTime(), sw.getAverageLapTime());
  
          sw.reset();
  
          assertEquals(0, sw.getLapCount());
          assertEquals(0L, sw.getLapTime());
          assertEquals(0L, sw.getTime());
      }
  
      public void testToDuration() {
          StopWatch sw = new StopWatch();
  
          sw.start();
          try {
              Thread.sleep(1000);
          } catch (Exception ex) {
          }
          sw.stop();
  
          Duration d = sw.toDuration();
          assertTrue(d.compareTo(1000) >= 0);
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/jmx/JMXExceptionDecoderTest.java
  
  Index: JMXExceptionDecoderTest.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http:www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http:www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.common.jmx;
  
  import junit.framework.TestCase;
  
  import javax.management.ReflectionException;
  import javax.management.MBeanException;
  import javax.management.RuntimeOperationsException;
  import javax.management.RuntimeErrorException;
  import javax.management.RuntimeMBeanException;
  
  
  /**
   *
   * @version $Revision: 1.1 $ $Date: 2003/12/07 02:54:12 $
   */
  public class JMXExceptionDecoderTest extends TestCase {
      private void testDecode(Throwable t, Throwable expected) {
          assertEquals(expected, JMXExceptionDecoder.decode(t));
      }
  
      public void testDecodeMBeanException() {
          Exception nested = new Exception();
          MBeanException ex = new MBeanException(nested);
          testDecode(ex, nested);
      }
  
      public void testDecodeReflectionException() {
          Exception nested = new Exception();
          ReflectionException ex = new ReflectionException(nested);
          testDecode(ex, nested);
      }
  
      public void testDecodeRuntimeOperationsException() {
          RuntimeException nested = new RuntimeException();
          RuntimeOperationsException ex = new RuntimeOperationsException(nested);
          testDecode(ex, nested);
      }
  
      public void testDecodeRuntimeMBeanException() {
          RuntimeException nested = new RuntimeException();
          RuntimeMBeanException ex = new RuntimeMBeanException(nested);
          testDecode(ex, nested);
      }
  
      public void testDecodeRuntimeErrorException() {
          Error nested = new Error();
          RuntimeErrorException ex = new RuntimeErrorException(nested);
          testDecode(ex, nested);
      }
  
      public void testDecodeOther() {
          Exception ex = new Exception();
          testDecode(ex, ex);
      }
  
      private void testRethrow(Exception t, Throwable expected) {
          try {
              JMXExceptionDecoder.rethrow(t);
              fail();
          } catch (Throwable ex) {
              assertEquals(expected, ex);
          }
      }
  
      public void testRethrowMBeanException() {
          Exception nested = new Exception();
          MBeanException ex = new MBeanException(nested);
          testRethrow(ex, nested);
      }
  
      public void testRethrowReflectionException() {
          Exception nested = new Exception();
          ReflectionException ex = new ReflectionException(nested);
          testRethrow(ex, nested);
      }
  
      public void testRethrowRuntimeOperationsException() {
          RuntimeException nested = new RuntimeException();
          RuntimeOperationsException ex = new RuntimeOperationsException(nested);
          testRethrow(ex, nested);
      }
  
      public void testRethrowRuntimeMBeanException() {
          RuntimeException nested = new RuntimeException();
          RuntimeMBeanException ex = new RuntimeMBeanException(nested);
          testRethrow(ex, nested);
      }
  
      public void testRethrowRuntimeErrorException() {
          Error nested = new Error();
          RuntimeErrorException ex = new RuntimeErrorException(nested);
          testRethrow(ex, nested);
      }
  
      public void testRethrowOther() {
          Exception ex = new Exception();
          testRethrow(ex, ex);
      }
  
  }
  
  
  
  1.1                  incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/jmx/MBeanProxyExceptionTest.java
  
  Index: MBeanProxyExceptionTest.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http:www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http:www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.common.jmx;
  
  import junit.framework.TestCase;
  
  
  /**
   *
   * @version $Revision: 1.1 $ $Date: 2003/12/07 02:54:12 $
   */
  public class MBeanProxyExceptionTest extends TestCase {
      public void testConstructor() {
          MBeanProxyException ex = new MBeanProxyException();
          assertNull(ex.getMessage());
          assertNull(ex.getCause());
      }
  
      public void testConstructorNullMessage() {
          MBeanProxyException ex = new MBeanProxyException((String) null);
          assertNull(ex.getMessage());
          assertNull(ex.getCause());
      }
  
      public void testConstructorNullCause() {
          MBeanProxyException ex = new MBeanProxyException((Throwable) null);
          assertNull(ex.getMessage());
          assertNull(ex.getCause());
      }
  
      public void testConstructorNullNull() {
          MBeanProxyException ex = new MBeanProxyException(null, null);
          assertNull(ex.getMessage());
          assertNull(ex.getCause());
      }
  
      public void testConstructorMessage() {
          String expected = "message";
          MBeanProxyException ex = new MBeanProxyException(expected);
          assertEquals(expected, ex.getMessage());
          assertNull(ex.getCause());
      }
  
      public void testConstructorCause() {
          Exception expected = new Exception();
          MBeanProxyException ex = new MBeanProxyException(expected);
          assertEquals(expected, ex.getCause());
          assertNotNull(ex.getMessage());
      }
  
      public void testConstructorMessageCause() {
          String message = "message";
          Exception cause = new Exception();
          MBeanProxyException ex = new MBeanProxyException(message, cause);
          assertEquals(message, ex.getMessage());
          assertEquals(cause, ex.getCause());
      }
  }
  
  
  

Mime
View raw message