[jboss-cvs] JBossAS SVN: r82772 - in projects/jboss-osgi/trunk/osgi-int/src: main/java/org/jboss/osgi/plugins/facade/helpers and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 12 09:49:33 EST 2009
Author: alesj
Date: 2009-01-12 09:49:33 -0500 (Mon, 12 Jan 2009)
New Revision: 82772
Added:
projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/facade/
projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/facade/BundleImplTestCase.java
projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/facade/FacadeTestSuite.java
Removed:
projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/BundleImplTestCase.java
Modified:
projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/BundleImpl.java
projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/helpers/BundleEntryHelper.java
projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/helpers/BundleEntryVisitor.java
projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleStateMapper.java
projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/BundleTestSuite.java
projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/AbstractBundleEntryTestCase.java
projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleEntryHelperTestCase.java
projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleEntryVisitorTestCase.java
projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleHeaderTestCase.java
projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleHelperTestSuite.java
projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/metadata/AbstractManifestTestCase.java
projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/metadata/VersionRangeTestCase.java
Log:
Dilonize tests.
Modified: projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/BundleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/BundleImpl.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/BundleImpl.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -228,7 +228,6 @@
* @param name a class name
* @return the class
* @throws ClassNotFoundException If the class can not be loaded by DeploymentUnit ClassLoader
- * @throws IllegalStateException If the DeploymentUnit is NOT_INSTALLED
* @throws IllegalStateException If the DeploymentUnit classloader is not set
*/
public Class<?> loadClass(String name) throws ClassNotFoundException
@@ -258,7 +257,6 @@
* @param name a resource name
* @return Enumeration of URLs to resources
*/
- @SuppressWarnings("unchecked")
public Enumeration getResources(String name) throws IOException
{
checkPermission(AdminPermission.RESOURCE);
@@ -269,10 +267,9 @@
/**
* Get paths to entries in Bundle for a given directory
*
- * @param name name of entry
+ * @param dirPath the dir path
* @return Enumeration of URLs to entries in Bundle
*/
- @SuppressWarnings("unchecked")
public Enumeration getEntryPaths(String dirPath)
{
checkPermission(AdminPermission.RESOURCE);
@@ -304,7 +301,6 @@
* @param recurse should search recurse directories
* @return Enumeration of URLs to matched entries
*/
- @SuppressWarnings("unchecked")
public Enumeration findEntries(String path, String filePattern, boolean recurse)
{
checkPermission(AdminPermission.RESOURCE);
Modified: projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/helpers/BundleEntryHelper.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/helpers/BundleEntryHelper.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/helpers/BundleEntryHelper.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -41,19 +41,17 @@
*/
public class BundleEntryHelper
{
-
/** The log */
private static final Logger log = Logger.getLogger(BundleEntryHelper.class);
/**
* Get paths to entries in DeploymentUnit for a given directory
*
- * @param unit DeploymentUnit
- * @param name name of entry
+ * @param unit the deployment unit
+ * @param dirPath the directory path
* @return Enumeration of URLs to entries in Bundle
*/
- @SuppressWarnings("unchecked")
- public static Enumeration getEntryPaths(DeploymentUnit unit, String dirPath)
+ public static Enumeration<String> getEntryPaths(DeploymentUnit unit, String dirPath)
{
VirtualFile file = getVirtualFile(unit, dirPath);
if (file != null)
@@ -84,6 +82,7 @@
/**
* Get an entry from the DeploymentUnit
*
+ * @param unit the deployment unit
* @param path path to entry
* @return URL to entry
*/
@@ -107,13 +106,13 @@
/**
* Search DeploymentUnit for entries
*
+ * @param unit the deployment unit
* @param path base path in Bundle
* @param filePattern pattern used to select files
* @param recurse should search recurse directories
* @return Enumeration of URLs to matched entries
*/
- @SuppressWarnings("unchecked")
- public static Enumeration findEntries(DeploymentUnit unit, String path, String filePattern, boolean recurse)
+ public static Enumeration<URL> findEntries(DeploymentUnit unit, String path, String filePattern, boolean recurse)
{
VirtualFile file = getVirtualFile(unit, path);
if (file != null)
@@ -143,7 +142,8 @@
/**
* Get the root VirtualFile from the DeploymentUnit
*
- * @param unit DeploymentUnit
+ * @param unit the deployment unit
+ * @param filePath the file path
* @return root VirtualFile from DeploymentUnit
*/
private static VirtualFile getVirtualFile(DeploymentUnit unit, String filePath)
@@ -156,5 +156,4 @@
}
return returnFile;
}
-
}
Modified: projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/helpers/BundleEntryVisitor.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/helpers/BundleEntryVisitor.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/helpers/BundleEntryVisitor.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -114,7 +114,7 @@
/**
* Convert file pattern (RFC 1960-based Filter) into a RegEx pattern
*
- * @param filePattern
+ * @param filePattern the file pattern
* @return Regular expressions pattern
*/
private Pattern convertToPattern(String filePattern)
Modified: projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleStateMapper.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleStateMapper.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleStateMapper.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -64,5 +64,4 @@
}
return BundleState.UNINSTALLED;
}
-
}
Deleted: projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/BundleImplTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/BundleImplTestCase.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/BundleImplTestCase.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -1,337 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.bundle;
-
-import java.net.URL;
-import java.util.Enumeration;
-
-import junit.framework.Test;
-
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.plugins.facade.BundleImpl;
-import org.jboss.test.OSGiTestCase;
-import org.osgi.framework.Bundle;
-
-/**
- * A BundleImplTestCase.
- *
- * @author <a href="baileyje at gmail.com">John Bailey</a>
- * @version $Revision: 1.1 $
- */
-public class BundleImplTestCase extends OSGiTestCase
-{
- private Bundle bundle;
-
- private DeploymentUnit deploymentUnit;
-
- /**
- *
- * Create a new BundleImplTestCase.
- *
- * @param name
- */
- public BundleImplTestCase(String name)
- {
- super(name);
- }
-
- /**
- * Get suite for test
- *
- * @return test suite
- */
- public static Test suite()
- {
- return suite(BundleImplTestCase.class);
- }
-
- /**
- * Setup test
- */
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- deploymentUnit = addDeployment("/bundle", "simple.jar");
- bundle = new BundleImpl(deploymentUnit);
- }
-
- /**
- * Test the getState method. Should correctly call DeploymentStage2BundleStateMapper
- *
- * @throws Exception
- */
- public void testGetBundleState() throws Exception
- {
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
- assertEquals(Bundle.UNINSTALLED, bundle.getState());
-
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.CLASSLOADER);
- assertEquals(Bundle.RESOLVED, bundle.getState());
-
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.REAL);
- assertEquals(Bundle.STARTING, bundle.getState());
-
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.INSTALLED);
- assertEquals(Bundle.ACTIVE, bundle.getState());
- }
-
- /**
- * Returns the DeploymentContext.name as the Unique name
- *
- * @throws Exception
- */
- public void testGetSymbolicName() throws Exception
- {
- assertEquals(deploymentUnit.getName(), bundle.getSymbolicName());
- }
-
- /**
- * Returns the id for a Bundle
- *
- * @throws Exception
- */
- public void testGetBundleId() throws Exception
- {
- assertEquals(deploymentUnit.getName().hashCode(), bundle.getBundleId());
- }
-
- /**
- * Verifies the Bundle.start method calls the MainDeployer.change method with the INSTALL DeploymentStage
- *
- * @throws Exception
- */
- public void testStartBundle() throws Exception
- {
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
- assertStage(deploymentUnit, DeploymentStages.NOT_INSTALLED); // Sanity Check...
- bundle.start();
- assertStage(deploymentUnit, DeploymentStages.INSTALLED);
- }
-
- /**
- * Verifies the Bundle.stop method calls the MainDeployer.change method with the DESCRIBE DeploymentStage
- *
- * @throws Exception
- */
- public void testStopBundle() throws Exception
- {
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.INSTALLED);
- assertStage(deploymentUnit, DeploymentStages.INSTALLED); // Sanity Check...
- bundle.stop();
- assertStage(deploymentUnit, DeploymentStages.DESCRIBE);
- }
-
- /**
- * Verifies the Bundle.uninstall method calls the MainDeployer.change method with the NOT_INSTALLED DeploymentStage
- *
- * @throws Exception
- */
- public void testUninstallBundle() throws Exception
- {
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.INSTALLED);
- assertStage(deploymentUnit, DeploymentStages.INSTALLED); // Sanity Check...
- bundle.uninstall();
- assertStage(deploymentUnit, DeploymentStages.NOT_INSTALLED);
- }
-
- /**
- * Test the Bundle.loadClass method with valid class
- *
- * @throws Exception
- */
- public void testLoadClass() throws Exception
- {
- Class<?> testClass = bundle.loadClass("org.jboss.test.bundle.support.TestActivator");
- assertNotNull(testClass);
- }
-
- /**
- * Test Bundle.loadClass with a missing class. Should throw normal ClassNotFound
- *
- * @throws Exception
- */
- public void testLoadClassNotFound() throws Exception
- {
- try
- {
- bundle.loadClass("org.jboss.test.bundle.support.MissingClass");
- fail("Should have thrown ClassNotFoundException");
- }
- catch (ClassNotFoundException expectedException)
- {
- assertEquals("org.jboss.test.bundle.support.MissingClass", expectedException.getMessage());
- }
- }
-
- /**
- * Test Bundle.loadClass with no ClassLoader. Should throw ClassNotFound with message relating to missing classloader
- *
- * @throws Exception
- */
- public void testLoadClassNoClassLoaderForDeployment() throws Exception
- {
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.DESCRIBE);
- try
- {
- bundle.loadClass("org.jboss.test.bundle.support.MissingClass");
- fail("Should have thrown ClassNotFoundException");
- }
- catch (IllegalStateException expectedException)
- {
- assertEquals("ClassLoader has not been set", expectedException.getMessage());
- }
- }
-
- /**
- * Test Bundle.loadClass with a DeploymentUnit that is in the NOT_INSTALLED stage, should throw IllegalStateException.
- *
- * @throws Exception
- */
- public void testLoadClassBundleUninstalled() throws Exception
- {
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
- try
- {
- bundle.loadClass("org.jboss.test.bundle.support.MissingClass");
- fail("Should have thrown ClassNotFoundException");
- }
- catch (IllegalStateException expectedException)
- {
- assertEquals("Bundle has been uninstalled", expectedException.getMessage());
- }
- }
-
- /**
- * Test the Bundle.getResource method with valid resource
- *
- * @throws Exception
- */
- public void testGetResource() throws Exception
- {
- URL resource = bundle.getResource("org/jboss/test/bundle/metadata/Manifest.mf");
- assertNotNull(resource);
- }
-
- /**
- * Test the Bundle.getResource method with missing resource
- *
- * @throws Exception
- */
- public void testGetResourceMissingResource() throws Exception
- {
- URL resource = bundle.getResource("org/jboss/test/bundle/metadata/Missing.mf");
- assertNull(resource);
- }
-
- /**
- * Test the Bundle.getResource method with missing DeploymentUnit ClassLoader
- *
- * @throws Exception
- */
- public void testGetResourceNoClassLoaderForDeploymentUnit() throws Exception
- {
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.DESCRIBE);
- try {
- bundle.getResource("org/jboss/test/bundle/metadata/Manifest.mf");
- fail("Should have thrown IllegalStateException");
- } catch (IllegalStateException expectedException) {
- assertEquals("ClassLoader has not been set", expectedException.getMessage());
- }
- }
-
- /**
- * Test the Bundle.getResource method for an uninstalled Bundle
- *
- * @throws Exception
- */
- public void testGetResourceBundleUnintalled() throws Exception
- {
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
- try {
- bundle.getResource("org/jboss/test/bundle/metadata/Manifest.mf");
- fail("Should have thrown IllegalStateException");
- } catch (IllegalStateException expectedException) {
- assertEquals("Bundle has been uninstalled", expectedException.getMessage());
- }
- }
-
- /**
- * Test the Bundle.getResources method with valid resource
- *
- * @throws Exception
- */
- @SuppressWarnings("unchecked")
- public void testGetResources() throws Exception
- {
- Enumeration<URL> resources = bundle.getResources("org/jboss/test/bundle/metadata/Manifest.mf");
- assertNotNull(resources);
- assertTrue(resources.hasMoreElements());
- }
-
- /**
- * Test the Bundle.getResources method with missing resource
- *
- * @throws Exception
- */
- @SuppressWarnings("unchecked")
- public void testGetResourceMissingResources() throws Exception
- {
- Enumeration<URL> resources = bundle.getResources("org/jboss/test/bundle/metadata/Missing.mf");
- assertNotNull(resources);
- assertFalse(resources.hasMoreElements());
- }
-
- /**
- * Test the Bundle.getResources method with missing DeploymentUnit ClassLoader
- *
- * @throws Exception
- */
- public void testGetResourcesNoClassLoaderForDeploymentUnit() throws Exception
- {
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.DESCRIBE);
- try {
- bundle.getResources("org/jboss/test/bundle/metadata/Manifest.mf");
- fail("Should have thrown IllegalStateException");
- } catch (IllegalStateException expectedException) {
- assertEquals("ClassLoader has not been set", expectedException.getMessage());
- }
- }
-
- /**
- * Test the Bundle.getResources method with missing DeploymentUnit ClassLoader
- *
- * @throws Exception
- */
- public void testGetResourcesUninstalled() throws Exception
- {
- getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
- try {
- bundle.getResources("org/jboss/test/bundle/metadata/Manifest.mf");
- fail("Should have thrown IllegalStateException");
- } catch (IllegalStateException expectedException) {
- assertEquals("Bundle has been uninstalled", expectedException.getMessage());
- }
- }
-}
Modified: projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/BundleTestSuite.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/BundleTestSuite.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/BundleTestSuite.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -24,7 +24,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
-
+import org.jboss.test.bundle.facade.FacadeTestSuite;
import org.jboss.test.bundle.helper.BundleHelperTestSuite;
import org.jboss.test.bundle.metadata.MetaDataTestSuite;
@@ -45,7 +45,7 @@
{
TestSuite suite = new TestSuite("Bundle Tests");
- suite.addTest(BundleImplTestCase.suite());
+ suite.addTest(FacadeTestSuite.suite());
suite.addTest(MetaDataTestSuite.suite());
suite.addTest(BundleHelperTestSuite.suite());
Copied: projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/facade/BundleImplTestCase.java (from rev 82761, projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/BundleImplTestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/facade/BundleImplTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/facade/BundleImplTestCase.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -0,0 +1,348 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.bundle.facade;
+
+import java.net.URL;
+import java.util.Enumeration;
+
+import junit.framework.Test;
+
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.plugins.facade.BundleImpl;
+import org.jboss.test.OSGiTestCase;
+import org.osgi.framework.Bundle;
+
+/**
+ * A BundleImplTestCase.
+ *
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleImplTestCase extends OSGiTestCase
+{
+ private Bundle bundle;
+
+ private DeploymentUnit deploymentUnit;
+
+ /**
+ * Create a new BundleImplTestCase.
+ *
+ * @param name the test name
+ */
+ public BundleImplTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Get suite for test
+ *
+ * @return test suite
+ */
+ public static Test suite()
+ {
+ return suite(BundleImplTestCase.class);
+ }
+
+ /**
+ * Setup test
+ */
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ deploymentUnit = addDeployment("/bundle", "simple.jar");
+ bundle = new BundleImpl(deploymentUnit);
+ }
+
+ /**
+ * Test the getState method. Should correctly call DeploymentStage2BundleStateMapper
+ *
+ * @throws Exception for any error
+ */
+ public void testGetBundleState() throws Exception
+ {
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
+ assertEquals(Bundle.UNINSTALLED, bundle.getState());
+
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.CLASSLOADER);
+ assertEquals(Bundle.RESOLVED, bundle.getState());
+
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.REAL);
+ assertEquals(Bundle.STARTING, bundle.getState());
+
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.INSTALLED);
+ assertEquals(Bundle.ACTIVE, bundle.getState());
+ }
+
+ /**
+ * Returns the DeploymentContext.name as the Unique name
+ *
+ * @throws Exception for any error
+ */
+ public void testGetSymbolicName() throws Exception
+ {
+ assertEquals(deploymentUnit.getName(), bundle.getSymbolicName());
+ }
+
+ /**
+ * Returns the id for a Bundle
+ *
+ * @throws Exception for any error
+ */
+ public void testGetBundleId() throws Exception
+ {
+ assertEquals(deploymentUnit.getName().hashCode(), bundle.getBundleId());
+ }
+
+ /**
+ * Verifies the Bundle.start method calls the MainDeployer.change method with the INSTALL DeploymentStage
+ *
+ * @throws Exception for any error
+ */
+ public void testStartBundle() throws Exception
+ {
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
+ assertStage(deploymentUnit, DeploymentStages.NOT_INSTALLED); // Sanity Check...
+ bundle.start();
+ assertStage(deploymentUnit, DeploymentStages.INSTALLED);
+ }
+
+ /**
+ * Verifies the Bundle.stop method calls the MainDeployer.change method with the DESCRIBE DeploymentStage
+ *
+ * @throws Exception for any error
+ */
+ public void testStopBundle() throws Exception
+ {
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.INSTALLED);
+ assertStage(deploymentUnit, DeploymentStages.INSTALLED); // Sanity Check...
+ bundle.stop();
+ assertStage(deploymentUnit, DeploymentStages.DESCRIBE);
+ }
+
+ /**
+ * Verifies the Bundle.uninstall method calls the MainDeployer.change method with the NOT_INSTALLED DeploymentStage
+ *
+ * @throws Exception for any error
+ */
+ public void testUninstallBundle() throws Exception
+ {
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.INSTALLED);
+ assertStage(deploymentUnit, DeploymentStages.INSTALLED); // Sanity Check...
+ bundle.uninstall();
+ assertStage(deploymentUnit, DeploymentStages.NOT_INSTALLED);
+ }
+
+ /**
+ * Test the Bundle.loadClass method with valid class
+ *
+ * @throws Exception for any error
+ */
+ public void testLoadClass() throws Exception
+ {
+ Class<?> testClass = bundle.loadClass("org.jboss.test.bundle.support.TestActivator");
+ assertNotNull(testClass);
+ }
+
+ /**
+ * Test Bundle.loadClass with a missing class. Should throw normal ClassNotFound
+ *
+ * @throws Exception for any error
+ */
+ public void testLoadClassNotFound() throws Exception
+ {
+ try
+ {
+ bundle.loadClass("org.jboss.test.bundle.support.MissingClass");
+ fail("Should have thrown ClassNotFoundException");
+ }
+ catch (ClassNotFoundException expectedException)
+ {
+ assertEquals("org.jboss.test.bundle.support.MissingClass", expectedException.getMessage());
+ }
+ }
+
+ /**
+ * Test Bundle.loadClass with no ClassLoader. Should throw ClassNotFound with message relating to missing classloader
+ *
+ * @throws Exception for any error
+ */
+ public void testLoadClassNoClassLoaderForDeployment() throws Exception
+ {
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.DESCRIBE);
+ try
+ {
+ bundle.loadClass("org.jboss.test.bundle.support.MissingClass");
+ fail("Should have thrown ClassNotFoundException");
+ }
+ catch (IllegalStateException expectedException)
+ {
+ assertEquals("ClassLoader has not been set", expectedException.getMessage());
+ }
+ }
+
+ /**
+ * Test Bundle.loadClass with a DeploymentUnit that is in the NOT_INSTALLED stage, should throw IllegalStateException.
+ *
+ * @throws Exception for any error
+ */
+ public void testLoadClassBundleUninstalled() throws Exception
+ {
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
+ try
+ {
+ bundle.loadClass("org.jboss.test.bundle.support.MissingClass");
+ fail("Should have thrown ClassNotFoundException");
+ }
+ catch (IllegalStateException expectedException)
+ {
+ assertEquals("Bundle has been uninstalled", expectedException.getMessage());
+ }
+ }
+
+ /**
+ * Test the Bundle.getResource method with valid resource
+ *
+ * @throws Exception for any error
+ */
+ public void testGetResource() throws Exception
+ {
+ URL resource = bundle.getResource("org/jboss/test/bundle/metadata/Manifest.mf");
+ assertNotNull(resource);
+ }
+
+ /**
+ * Test the Bundle.getResource method with missing resource
+ *
+ * @throws Exception for any error
+ */
+ public void testGetResourceMissingResource() throws Exception
+ {
+ URL resource = bundle.getResource("org/jboss/test/bundle/metadata/Missing.mf");
+ assertNull(resource);
+ }
+
+ /**
+ * Test the Bundle.getResource method with missing DeploymentUnit ClassLoader
+ *
+ * @throws Exception for any error
+ */
+ public void testGetResourceNoClassLoaderForDeploymentUnit() throws Exception
+ {
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.DESCRIBE);
+ try
+ {
+ bundle.getResource("org/jboss/test/bundle/metadata/Manifest.mf");
+ fail("Should have thrown IllegalStateException");
+ }
+ catch (IllegalStateException expectedException)
+ {
+ assertEquals("ClassLoader has not been set", expectedException.getMessage());
+ }
+ }
+
+ /**
+ * Test the Bundle.getResource method for an uninstalled Bundle
+ *
+ * @throws Exception for any error
+ */
+ public void testGetResourceBundleUnintalled() throws Exception
+ {
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
+ try
+ {
+ bundle.getResource("org/jboss/test/bundle/metadata/Manifest.mf");
+ fail("Should have thrown IllegalStateException");
+ }
+ catch (IllegalStateException expectedException)
+ {
+ assertEquals("Bundle has been uninstalled", expectedException.getMessage());
+ }
+ }
+
+ /**
+ * Test the Bundle.getResources method with valid resource
+ *
+ * @throws Exception for any error
+ */
+ @SuppressWarnings("unchecked")
+ public void testGetResources() throws Exception
+ {
+ Enumeration<URL> resources = bundle.getResources("org/jboss/test/bundle/metadata/Manifest.mf");
+ assertNotNull(resources);
+ assertTrue(resources.hasMoreElements());
+ }
+
+ /**
+ * Test the Bundle.getResources method with missing resource
+ *
+ * @throws Exception for any error
+ */
+ @SuppressWarnings("unchecked")
+ public void testGetResourceMissingResources() throws Exception
+ {
+ Enumeration<URL> resources = bundle.getResources("org/jboss/test/bundle/metadata/Missing.mf");
+ assertNotNull(resources);
+ assertFalse(resources.hasMoreElements());
+ }
+
+ /**
+ * Test the Bundle.getResources method with missing DeploymentUnit ClassLoader
+ *
+ * @throws Exception for any error
+ */
+ public void testGetResourcesNoClassLoaderForDeploymentUnit() throws Exception
+ {
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.DESCRIBE);
+ try
+ {
+ bundle.getResources("org/jboss/test/bundle/metadata/Manifest.mf");
+ fail("Should have thrown IllegalStateException");
+ }
+ catch (IllegalStateException expectedException)
+ {
+ assertEquals("ClassLoader has not been set", expectedException.getMessage());
+ }
+ }
+
+ /**
+ * Test the Bundle.getResources method with missing DeploymentUnit ClassLoader
+ *
+ * @throws Exception for any error
+ */
+ public void testGetResourcesUninstalled() throws Exception
+ {
+ getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
+ try
+ {
+ bundle.getResources("org/jboss/test/bundle/metadata/Manifest.mf");
+ fail("Should have thrown IllegalStateException");
+ }
+ catch (IllegalStateException expectedException)
+ {
+ assertEquals("Bundle has been uninstalled", expectedException.getMessage());
+ }
+ }
+}
Property changes on: projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/facade/BundleImplTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/facade/FacadeTestSuite.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/facade/FacadeTestSuite.java (rev 0)
+++ projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/facade/FacadeTestSuite.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.bundle.facade;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Bundle facade test suite.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class FacadeTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Bundle Facade Tests");
+
+ suite.addTest(BundleImplTestCase.suite());
+
+ return suite;
+ }
+}
Modified: projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/AbstractBundleEntryTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/AbstractBundleEntryTestCase.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/AbstractBundleEntryTestCase.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -36,11 +36,10 @@
*/
public abstract class AbstractBundleEntryTestCase extends OSGiTestCase
{
-
/**
* Create a new AbsractBundleEntryTestCase.
*
- * @param name
+ * @param name the test name
*/
public AbstractBundleEntryTestCase(String name)
{
@@ -53,16 +52,14 @@
* @param root Root VirtualFile to get path
* @param virualFilePath a path to a virtual file in the root
* @param entryUrl a URL to an entry to assert same as expected path
- * @throws IOException
- * @throws URISyntaxException
+ * @throws IOException for any io error
+ * @throws URISyntaxException for any uri syntax error
*/
- protected void assertEntry(VirtualFile root, String virualFilePath, URL entryUrl) throws IOException,
- URISyntaxException
+ protected void assertEntry(VirtualFile root, String virualFilePath, URL entryUrl) throws IOException, URISyntaxException
{
VirtualFile expectedEntry = root.getChild(virualFilePath);
assertNotNull("Invalid assertiong. Expected file does not exisist", expectedEntry); // Sanity check
assertEquals(expectedEntry.toURL(), entryUrl);
}
-
}
Modified: projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleEntryHelperTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleEntryHelperTestCase.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleEntryHelperTestCase.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -47,7 +47,7 @@
/**
* Create a new BundleEntryHelperTestCase.
*
- * @param name
+ * @param name the test name
*/
public BundleEntryHelperTestCase(String name)
{
@@ -98,7 +98,7 @@
/**
* Test findEntryMethod
*
- * @throws Exception
+ * @throws Exception for any error
*/
public void testGetEntry() throws Exception
{
@@ -110,7 +110,7 @@
/**
* Test findEntryMethod with no results
*
- * @throws Exception
+ * @throws Exception for any error
*/
public void testGetEntryNoResult() throws Exception
{
@@ -121,7 +121,7 @@
/**
* Test findEntryMethod
*
- * @throws Exception
+ * @throws Exception for any error
*/
@SuppressWarnings("unchecked")
public void testGetEntryPaths() throws Exception
@@ -139,29 +139,29 @@
/**
* Test findEntryMethod with no results
*
- * @throws Exception
+ * @throws Exception for any error
*/
@SuppressWarnings("unchecked")
public void testGetEntryPathsNoResult() throws Exception
{
- // TODO MAKE WORK WITH MAVEN
- assertNull(BundleEntryHelper.getEntryPaths(deploymentUnit, "org/jboss/osgi/empty"));
+ // TODO MAKE WORK WITH MAVEN
+ assertNull(BundleEntryHelper.getEntryPaths(deploymentUnit, "org/jboss/osgi/empty"));
}
/**
* Test findEntryMethod with missing path
*
- * @throws Exception
+ * @throws Exception for any error
*/
public void testGetEntryPathsMissingDirPath() throws Exception
{
- assertNull(BundleEntryHelper.getEntryPaths(deploymentUnit, "mising/path"));
+ assertNull(BundleEntryHelper.getEntryPaths(deploymentUnit, "mising/path"));
}
/**
* Test finding entries without wild cards (*)
*
- * @throws Exception
+ * @throws Exception for any error
*/
@SuppressWarnings("unchecked")
public void testFindEntriesNoWildCard() throws Exception
@@ -191,7 +191,7 @@
/**
* Test finding entries without wild cards (*) or recursion
*
- * @throws Exception
+ * @throws Exception for any error
*/
@SuppressWarnings("unchecked")
public void testFindEntriesNoWildCardOrRecurse() throws Exception
@@ -207,7 +207,7 @@
/**
* Test finding entries with wild cards (*)
*
- * @throws Exception
+ * @throws Exception for any error
*/
@SuppressWarnings("unchecked")
public void testFindEntriesWildCard() throws Exception
@@ -268,5 +268,4 @@
assertEntry(root, "/org/jboss/osgi/test/custom.xml", entries.nextElement());
assertTrue(entries.hasMoreElements() == false);
}
-
}
Modified: projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleEntryVisitorTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleEntryVisitorTestCase.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleEntryVisitorTestCase.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -36,13 +36,13 @@
*/
public class BundleEntryVisitorTestCase extends AbstractBundleEntryTestCase
{
-
+ /** The root */
private VirtualFile root;
/**
* Create a new BundleEntryVisitorTest.
*
- * @param name
+ * @param name the test name
*/
public BundleEntryVisitorTestCase(String name)
{
@@ -52,7 +52,7 @@
/**
* Get Suite for BundleEntryVisitorTest
*
- * @return
+ * @return the test
*/
public static Test suite()
{
@@ -72,11 +72,10 @@
/**
* Test finding entries without wild cards (*)
*
- * @throws Exception
+ * @throws Exception for any error
*/
public void testFindEntriesNoWildCard() throws Exception
{
-
BundleEntryVisitor visitor = new BundleEntryVisitor("Manifest.mf", true);
root.visit(visitor);
assertEquals(1, visitor.getEntries().size());
@@ -104,17 +103,15 @@
visitor = new BundleEntryVisitor("bogus.txt", false);
root.visit(visitor);
assertEquals(0, visitor.getEntries().size());
-
}
/**
* Test finding entries without wild cards (*) or recursion
*
- * @throws Exception
+ * @throws Exception for any error
*/
public void testFindEntriesNoWildCardOrRecurse() throws Exception
{
-
BundleEntryVisitor visitor = new BundleEntryVisitor("Manifest.mf", false);
root.visit(visitor);
assertEquals(0, visitor.getEntries().size());
@@ -132,11 +129,10 @@
/**
* Test finding entries with wild cards (*)
*
- * @throws Exception
+ * @throws Exception for any error
*/
public void testFindEntriesWildCard() throws Exception
{
-
// starts with wildcard
BundleEntryVisitor visitor = new BundleEntryVisitor("*.mf", true);
root.visit(visitor);
@@ -194,7 +190,7 @@
/**
* Test finding entries with wild cards (*) and no recursion
*
- * @throws Exception
+ * @throws Exception for any error
*/
public void testFindEntriesWildCardNoRecurse() throws Exception
{
Modified: projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleHeaderTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleHeaderTestCase.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleHeaderTestCase.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -51,7 +51,7 @@
/**
* Create a new BundleHeaderTestCase.
*
- * @param name
+ * @param name the test name
*/
public BundleHeaderTestCase(String name)
{
@@ -61,7 +61,7 @@
/**
* Get test suite
*
- * @return
+ * @return the test
*/
public static Test suite()
{
@@ -82,8 +82,7 @@
ClassLoadingMetaData clMetaData = new ClassLoadingMetaData();
clMetaData.getCapabilities().addCapability(new PackageCapability("org.jboss.test", new Version(1,2,0)));
clMetaData.getCapabilities().addCapability(new PackageCapability("org.jboss.test.other", new Version(1,5,0)));
-
-
+
clMetaData.getRequirements().addRequirement(new PackageRequirement("org.jboss.test", new VersionRange(new Version(1,2,0))));
clMetaData.getRequirements().addRequirement(new PackageRequirement("org.jboss.test.other", new VersionRange(new Version(1,5,0),new Version(2,0,1))));
deploymentUnit.addAttachment(ClassLoadingMetaData.class, clMetaData);
@@ -93,7 +92,7 @@
/**
* Test getting BundleHeaders as a Dictionary
*
- * @throws Exception
+ * @throws Exception for any error
*/
@SuppressWarnings("unchecked")
public void testToDictionary() throws Exception
Modified: projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleHelperTestSuite.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleHelperTestSuite.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/helper/BundleHelperTestSuite.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -33,11 +33,10 @@
*/
public class BundleHelperTestSuite extends TestSuite
{
-
/**
* Run test using TestRunner
*
- * @param args
+ * @param args the args
*/
public static void main(String[] args)
{
@@ -52,10 +51,11 @@
public static Test suite()
{
TestSuite suite = new TestSuite("Bundle Helper Tests");
+
suite.addTest(BundleHeaderTestCase.suite());
suite.addTest(BundleEntryVisitorTestCase.suite());
suite.addTest(BundleEntryHelperTestCase.suite());
+
return suite;
}
-
}
Modified: projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/metadata/AbstractManifestTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/metadata/AbstractManifestTestCase.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/metadata/AbstractManifestTestCase.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -67,5 +67,4 @@
fail(name + " not found");
return url.openStream();
}
-
}
Modified: projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/metadata/VersionRangeTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/metadata/VersionRangeTestCase.java 2009-01-12 13:46:19 UTC (rev 82771)
+++ projects/jboss-osgi/trunk/osgi-int/src/test/java/org/jboss/test/bundle/metadata/VersionRangeTestCase.java 2009-01-12 14:49:33 UTC (rev 82772)
@@ -5,7 +5,6 @@
import java.util.regex.Pattern;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.jboss.osgi.plugins.metadata.AbstractVersionRange;
import org.jboss.osgi.spi.metadata.VersionRange;
import org.jboss.test.BaseTestCase;
@@ -26,7 +25,7 @@
public static Test suite()
{
- return new TestSuite(VersionRangeTestCase.class);
+ return suite(VersionRangeTestCase.class);
}
public void testRangeSpecRE() throws Exception
More information about the jboss-cvs-commits
mailing list