[jboss-cvs] JBossAS SVN: r60750 - trunk/testsuite/src/main/org/jboss/test/profileservice/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 21 00:49:01 EST 2007


Author: scott.stark at jboss.org
Date: 2007-02-21 00:49:01 -0500 (Wed, 21 Feb 2007)
New Revision: 60750

Modified:
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
Change the fake datasource type to FakeDataSource and start DataSource tests

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2007-02-21 05:48:22 UTC (rev 60749)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2007-02-21 05:49:01 UTC (rev 60750)
@@ -109,16 +109,45 @@
    }
 
    /**
-    * Query for the ComponentType("DataSource", "LocalTx") testAddDataSource-dsf.xml
+    * test api usage only
+    * @throws Exception
+    */   
+   public void testRemoveComponent () throws Exception
+   {
+	   String componentName = "defaultDS";
+	   ManagementView mgtView = getManagementView();
+	   
+	   ComponentType type = new ComponentType("DataSource", "LocalTx");
+	   Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
+	   
+	   // maybe a mgtView.getComponentByNameAndType(type, componentName) would be helpful
+	   // i'm assuming componentName and type will be unique in a given profile.
+	   
+	   if (comps != null) 
+	   {
+		   for (ManagedComponent comp : comps)
+		   {
+			  if (componentName.equals(comp.getName()))
+			  {
+				  ManagedDeployment deployment = comp.getDeployment();
+				  deployment.removeComponent(comp); 
+				  break;
+			  }		 
+		   }
+	   }
+   }
+
+   /**
+    * Query for the ComponentType("DataSource", "LocalTx")
     * and validate the expected property names.
     * @throws Exception
     */
    public void testListDataSourceComponents() throws Exception
    {
-	   ManagementView mgtView = getManagementView();
-	   
-      ManagedComponent testAddDataSource = getTestDataSource(mgtView);
-      Map<String,ManagedProperty> props = testAddDataSource.getProperties();
+      ManagementView mgtView = getManagementView();
+      
+      ManagedComponent ds = getDataSource(mgtView);
+      Map<String,ManagedProperty> props = ds.getProperties();
       log.info("testAddDataSource.props: "+props);
       // Validate the property names
       ManagedProperty p = props.get("datasource-type");
@@ -142,38 +171,38 @@
    }
 
    /**
-    * test api usage only
+    * Test adding a new hsql DataSource deployment
     * @throws Exception
-    */   
-   public void testRemoveComponent () throws Exception
+    */
+   public void testAddDataSource() throws Exception
    {
-	   String componentName = "defaultDS";
-	   ManagementView mgtView = getManagementView();
-	   
-	   ComponentType type = new ComponentType("DataSource", "LocalTx");
-	   Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
-	   
-	   // maybe a mgtView.getComponentByNameAndType(type, componentName) would be helpful
-	   // i'm assuming componentName and type will be unique in a given profile.
-	   
-	   if (comps != null) 
-	   {
-		   for (ManagedComponent comp : comps)
-		   {
-			  if (componentName.equals(comp.getName()))
-			  {
-				  ManagedDeployment deployment = comp.getDeployment();
-				  deployment.removeComponent(comp); 
-				  break;
-			  }		 
-		   }
-	   }
+      ManagementView mgtView = getManagementView();
+      log.info("Templates: "+mgtView.getTemplateNames());
+      DeploymentTemplateInfo dsInfo = mgtView.getTemplate("DsXmlDataSourceTemplate");
+      Map<String, ManagedProperty> props = dsInfo.getProperties();
+      log.info("ManagedPropertys: "+props);
+
+      ManagedProperty jndiName = props.get("jndi-name");
+      jndiName.setValue("TestDS");
+      ManagedProperty connURL = props.get("connection-url");
+      connURL.setValue("jdbc:hsqldb:.");
+      ManagedProperty driverClass = props.get("driver-class");
+      driverClass.setValue("org.hsqldb.jdbcDriver");
+      ManagedProperty username = props.get("user-name");
+      username.setValue("sa");
+      ManagedProperty password = props.get("password");
+      password.setValue("");
+      
+      mgtView.applyTemplate(DeploymentPhase.APPLICATION,
+            "testAddDataSource", dsInfo);
+      mgtView.process();
    }
+
    /**
-    * Test adding a new hsql DataSource deployment
+    * Test adding a new FakeDataSource deployment
     * @throws Exception
     */
-   public void testAddDataSource() throws Exception
+   public void testAddFakeDataSource() throws Exception
    {
       ManagementView mgtView = getManagementView();
       log.info("Templates: "+mgtView.getTemplateNames());
@@ -197,11 +226,11 @@
       mgtView.process();
    }
 
-   public void testUpdateDataSource()
+   public void testUpdateFakeDataSource()
       throws Exception
    {
       ManagementView mgtView = getManagementView();
-      ManagedComponent testAddDataSource = getTestDataSource(mgtView);
+      ManagedComponent testAddDataSource = getTestFakeDataSource(mgtView);
       Map<String,ManagedProperty> props = testAddDataSource.getProperties();
       log.info("testAddDataSource.props: "+props);
       // Update properties
@@ -222,7 +251,40 @@
       // 
    }
 
-   public void testRemoveDataSource()
+   /**
+    * Query for the ComponentType("FakeDataSource", "LocalTx") testAddDataSource-dsf.xml
+    * and validate the expected property names.
+    * @throws Exception
+    */
+   public void testListFakeDataSourceComponents() throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      
+      ManagedComponent testAddDataSource = getTestFakeDataSource(mgtView);
+      Map<String,ManagedProperty> props = testAddDataSource.getProperties();
+      log.info("testAddDataSource.props: "+props);
+      // Validate the property names
+      ManagedProperty p = props.get("datasource-type");
+      assertNotNull("datasource-type", p);
+      p = props.get("jndi-name");
+      assertNotNull("jndi-name", p);
+      p = props.get("driver-class");
+      assertNotNull("driver-class", p);
+      p = props.get("connection-url");
+      assertNotNull("connection-url", p);
+      p = props.get("user-name");
+      assertNotNull("user-name", p);
+      p = props.get("password");
+      assertNotNull("password", p);
+      p = props.get("min-pool-size");
+      assertNotNull("min-pool-size", p);
+      p = props.get("max-pool-size");
+      assertNotNull("max-pool-size", p);
+      p = props.get("security-domain");
+      assertNotNull("security-domain", p);
+   }
+
+   public void testRemoveFakeDataSource()
       throws Exception
    {
       ManagementView mgtView = getManagementView();
@@ -253,10 +315,16 @@
       return activeView;
    }
 
-   protected ManagedComponent getTestDataSource(ManagementView mgtView)
+   /**
+    * 
+    * @param mgtView
+    * @return
+    * @throws Exception
+    */
+   protected ManagedComponent getTestFakeDataSource(ManagementView mgtView)
       throws Exception
    {
-      ComponentType dsType = new ComponentType("DataSource", "LocalTx");
+      ComponentType dsType = new ComponentType("FakeDataSource", "LocalTx");
       Set<ManagedComponent> dsComps = mgtView.getComponentsForType(dsType);
       ManagedComponent testAddDataSource = null;
       for (ManagedComponent comp : dsComps)
@@ -270,4 +338,22 @@
       assertNotNull("testAddDataSource", testAddDataSource);
       return testAddDataSource;
    }
+
+   protected ManagedComponent getDataSource(ManagementView mgtView)
+      throws Exception
+   {
+      ComponentType dsType = new ComponentType("DataSource", "LocalTx");
+      Set<ManagedComponent> dsComps = mgtView.getComponentsForType(dsType);
+      ManagedComponent hsqldb = null;
+      for (ManagedComponent comp : dsComps)
+      {
+        String name = comp.getName();
+        if( name.equals("hsqldb-ds.xml") )
+        {
+           hsqldb = comp;
+        }
+      }
+      assertNotNull("hsqldb", hsqldb);
+      return hsqldb;
+   }
 }




More information about the jboss-cvs-commits mailing list