geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/config LocalConfigStoreTest.java
Date Wed, 14 Jan 2004 20:41:56 GMT
djencks     2004/01/14 12:41:56

  Modified:    modules/kernel/src/test/org/apache/geronimo/kernel
                        ConfigTest.java MockGBean.java
               modules/kernel/src/java/org/apache/geronimo/gbean/jmx
                        GMBeanEndpoint.java
               modules/kernel/src/test/org/apache/geronimo/kernel/config
                        LocalConfigStoreTest.java
  Added:       modules/kernel/src/test/org/apache/geronimo/kernel
                        MockEndpoint.java
  Log:
  add endpoint test (failure commented out), use GBeanInfoFactory
  
  Revision  Changes    Path
  1.3       +23 -18    incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
  
  Index: ConfigTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConfigTest.java	14 Jan 2004 08:31:07 -0000	1.2
  +++ ConfigTest.java	14 Jan 2004 20:41:56 -0000	1.3
  @@ -55,27 +55,23 @@
    */
   package org.apache.geronimo.kernel;
   
  -import java.io.ByteArrayOutputStream;
   import java.io.File;
  -import java.io.ObjectOutputStream;
   import java.net.URI;
   import java.net.URL;
  -import java.util.Iterator;
   import java.util.Collections;
  -import java.util.Map;
   import java.util.HashMap;
  +import java.util.Map;
   
   import javax.management.InstanceNotFoundException;
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
   
  +import junit.framework.TestCase;
  +import org.apache.geronimo.gbean.GBeanInfo;
  +import org.apache.geronimo.gbean.jmx.GMBean;
   import org.apache.geronimo.kernel.config.Configuration;
   import org.apache.geronimo.kernel.config.LocalConfigStore;
   import org.apache.geronimo.kernel.management.State;
  -import org.apache.geronimo.gbean.GBeanInfo;
  -import org.apache.geronimo.gbean.GAttributeInfo;
  -import org.apache.geronimo.gbean.jmx.GMBean;
  -import junit.framework.TestCase;
   
   /**
    *
  @@ -83,13 +79,14 @@
    * @version $Revision$ $Date$
    */
   public class ConfigTest extends TestCase {
  -    private ObjectName gbeanName;
  +    private ObjectName gbeanName1;
       private File configRoot;
       private File tmpDir;
       private GBeanInfo storeInfo;
       private Kernel kernel;
       private MBeanServer mbServer;
       private byte[] state;
  +    private ObjectName gbeanName2;
   
       public void testOfflineConfig() throws Exception {
           GMBean config = new GMBean(Configuration.GBEAN_INFO);
  @@ -109,12 +106,14 @@
           assertEquals(new Integer(State.RUNNING.toInt()), mbServer.getAttribute(configName,
"state"));
           assertNotNull(mbServer.getAttribute(configName, "ClassLoader"));
   
  -        assertEquals(new Integer(State.RUNNING.toInt()), mbServer.getAttribute(gbeanName,
"state"));
  -        assertEquals("1234", mbServer.getAttribute(gbeanName, "Value"));
  +        assertEquals(new Integer(State.RUNNING.toInt()), mbServer.getAttribute(gbeanName1,
"state"));
  +        assertEquals("1234", mbServer.getAttribute(gbeanName1, "Value"));
  +        assertEquals("no endpoint", mbServer.invoke(gbeanName1, "checkEndpoint", null,
null));
  +        //assertEquals("endpointCheck", mbServer.invoke(gbeanName2, "checkEndpoint", null,
null));
   
           mbServer.invoke(configName, "stop", null, null);
           try {
  -            mbServer.getAttribute(gbeanName, "Value");
  +            mbServer.getAttribute(gbeanName1, "Value");
               fail();
           } catch (InstanceNotFoundException e) {
               // ok
  @@ -134,13 +133,19 @@
           kernel.boot();
           mbServer = kernel.getMBeanServer();
   
  -        gbeanName = new ObjectName("geronimo.test:name=MyMockGMBean");
  -        GMBean mockBean = new GMBean(MockGBean.getGBeanInfo());
  -        mockBean.setAttribute("Value", "1234");
  -        mockBean.setAttribute("Name", "Name");
  +        gbeanName1 = new ObjectName("geronimo.test:name=MyMockGMBean1");
  +        GMBean mockBean1 = new GMBean(MockGBean.getGBeanInfo());
  +        mockBean1.setAttribute("Value", "1234");
  +        mockBean1.setAttribute("Name", "child");
  +        gbeanName2 = new ObjectName("geronimo.test:name=MyMockGMBean2");
  +        GMBean mockBean2 = new GMBean(MockGBean.getGBeanInfo());
  +        mockBean2.setAttribute("Value", "5678");
  +        mockBean2.setAttribute("Name", "Parent");
  +        mockBean2.setEndpointPatterns("MockEndpoint", Collections.singleton(gbeanName1));
   
           Map gbeans = new HashMap();
  -        gbeans.put(gbeanName, mockBean);
  +        gbeans.put(gbeanName1, mockBean1);
  +        gbeans.put(gbeanName2, mockBean2);
           state = Configuration.storeGBeans(gbeans);
       }
   
  
  
  
  1.2       +33 -11    incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/MockGBean.java
  
  Index: MockGBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/MockGBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MockGBean.java	12 Jan 2004 01:40:08 -0000	1.1
  +++ MockGBean.java	14 Jan 2004 20:41:56 -0000	1.2
  @@ -56,12 +56,12 @@
   package org.apache.geronimo.kernel;
   
   import java.util.Collections;
  -import java.util.HashSet;
  -import java.util.Set;
   
   import org.apache.geronimo.gbean.GAttributeInfo;
   import org.apache.geronimo.gbean.GBeanInfo;
  +import org.apache.geronimo.gbean.GBeanInfoFactory;
   import org.apache.geronimo.gbean.GConstructorInfo;
  +import org.apache.geronimo.gbean.GEndpointInfo;
   import org.apache.geronimo.gbean.GOperationInfo;
   
   /**
  @@ -69,23 +69,26 @@
    *
    * @version $Revision$ $Date$
    */
  -public class MockGBean {
  +public class MockGBean implements MockEndpoint {
       private static final GBeanInfo GBEAN_INFO;
       private final String name;
       private String value;
   
  +    private MockEndpoint endpoint;
  +
       public static GBeanInfo getGBeanInfo() {
           return GBEAN_INFO;
       }
   
       static {
  -        Set attrs = new HashSet();
  -        attrs.add(new GAttributeInfo("Name", true));
  -        attrs.add(new GAttributeInfo("Value", true));
  -        Set operations = new HashSet();
  -        operations.add(new GOperationInfo("checkResource", new String[] {"name"}, new String[]
{"java.lang.String"}));
  -        GConstructorInfo constructor = new GConstructorInfo(Collections.singletonList("Name"),
Collections.singletonList(String.class));
  -        GBEAN_INFO = new GBeanInfo(MockGBean.class.getName(), attrs, constructor, operations,
Collections.EMPTY_SET, Collections.EMPTY_SET);
  +        GBeanInfoFactory infoFactory = new GBeanInfoFactory("MockGBean", "test description",
MockGBean.class.getName());
  +        infoFactory.addAttribute(new GAttributeInfo("Name", true));
  +        infoFactory.addAttribute(new GAttributeInfo("Value", true));
  +        infoFactory.addOperation(new GOperationInfo("checkResource", new String[]{"name"},
new String[]{"java.lang.String"}));
  +        infoFactory.addOperation(new GOperationInfo("checkEndpoint"));
  +        infoFactory.addEndpoint(new GEndpointInfo("MockEndpoint", MockEndpoint.class.getName()));
  +        infoFactory.setConstructor(new GConstructorInfo(Collections.singletonList("Name"),
Collections.singletonList(String.class)));
  +        GBEAN_INFO = infoFactory.getBeanInfo();
       }
   
       public MockGBean(String name) {
  @@ -104,8 +107,27 @@
           this.value = value;
       }
   
  +    public MockEndpoint getMockEndpoint() {
  +        return endpoint;
  +    }
  +
  +    public void setMockEndpoint(MockEndpoint endpoint) {
  +        this.endpoint = endpoint;
  +    }
  +
       public boolean checkResource(String name) {
           ClassLoader cl = Thread.currentThread().getContextClassLoader();
           return cl.getResource(name) != null;
  +    }
  +
  +    public String doSomething(String name) {
  +        return name;
  +    }
  +
  +    public String checkEndpoint() {
  +        if (endpoint == null) {
  +            return "no endpoint";
  +        }
  +        return endpoint.doSomething("endpointCheck");
       }
   }
  
  
  
  1.1                  incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/MockEndpoint.java
  
  Index: MockEndpoint.java
  ===================================================================
  package org.apache.geronimo.kernel;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/14 20:41:56 $
   *
   * */
  public interface MockEndpoint {
  
      String doSomething(String name);
  
  }
  
  
  
  1.2       +5 -1      incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GMBeanEndpoint.java
  
  Index: GMBeanEndpoint.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GMBeanEndpoint.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GMBeanEndpoint.java	12 Jan 2004 01:38:55 -0000	1.1
  +++ GMBeanEndpoint.java	14 Jan 2004 20:41:56 -0000	1.2
  @@ -249,6 +249,10 @@
       }
   
       public synchronized void offline() {
  +        if (proxy == null) {
  +            //we weren't fully online
  +            return;
  +        }
           // get the targets from the proxy because we are listening to them
           Set registeredTargets = proxy.getTargets();
   
  
  
  
  1.3       +3 -7      incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/config/LocalConfigStoreTest.java
  
  Index: LocalConfigStoreTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/config/LocalConfigStoreTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LocalConfigStoreTest.java	14 Jan 2004 08:31:07 -0000	1.2
  +++ LocalConfigStoreTest.java	14 Jan 2004 20:41:56 -0000	1.3
  @@ -59,17 +59,13 @@
   import java.io.File;
   import java.io.FileOutputStream;
   import java.io.ObjectOutputStream;
  -import java.net.URL;
   import java.net.URI;
  +import java.net.URL;
   import java.util.jar.JarOutputStream;
   import java.util.zip.ZipEntry;
  -import java.util.Iterator;
   
  -import org.apache.geronimo.kernel.config.LocalConfigStore;
  -import org.apache.geronimo.kernel.config.Configuration;
  -import org.apache.geronimo.gbean.GAttributeInfo;
  -import org.apache.geronimo.gbean.jmx.GMBean;
   import junit.framework.TestCase;
  +import org.apache.geronimo.gbean.jmx.GMBean;
   
   /**
    *
  
  
  

Mime
View raw message