Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.compendium.tests/src/org')
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/compendium/tests/Activator.java84
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/compendium/tests/AllTests.java26
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/event/tests/AllTests.java22
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/event/tests/EventAdminTest.java153
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/event/tests/EventHandlerHelper.java32
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java22
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java141
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/SameOcdPidFactoryPidTest.java59
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/AllTests.java26
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/GroupTest.java70
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/UserAdminEventAdapterTest.java78
-rw-r--r--bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/UserTest.java134
12 files changed, 0 insertions, 847 deletions
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/compendium/tests/Activator.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/compendium/tests/Activator.java
deleted file mode 100644
index 728a103b7..000000000
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/compendium/tests/Activator.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.compendium.tests;
-
-import org.osgi.framework.*;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator implements BundleActivator {
- public static String BUNDLE_EVENT = "org.eclipse.equinox.event"; //$NON-NLS-1$
- public static String BUNDLE_METATYPE = "org.eclipse.equinox.metatype"; //$NON-NLS-1$
- public static String BUNDLE_USERADMIN = "org.eclipse.equinox.useradmin"; //$NON-NLS-1$
-
- private static Activator plugin;
- private static BundleContext context;
-
- private ServiceTracker packageAdminTracker;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext bc) throws Exception {
- plugin = this;
- packageAdminTracker = new ServiceTracker(bc, PackageAdmin.class.getName(), null);
- packageAdminTracker.open();
- Activator.context = bc;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext bc) throws Exception {
- if (packageAdminTracker != null) {
- packageAdminTracker.close();
- packageAdminTracker = null;
- }
- plugin = null;
- }
-
- private static Activator getDefault() {
- return plugin;
- }
-
- public static synchronized BundleContext getBundleContext() {
- return context;
- }
-
- public static synchronized Bundle getBundle(String symbolicName) {
- PackageAdmin packageAdmin = Activator.getDefault().getPackageAdmin();
- if (packageAdmin == null)
- return null;
-
- Bundle[] bundles = packageAdmin.getBundles(symbolicName, null);
- if (bundles == null)
- return null;
- for (int i = 0; i < bundles.length; i++) {
- if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
- return bundles[i];
- }
- }
- return null;
- }
-
- private PackageAdmin getPackageAdmin() {
- if (packageAdminTracker == null) {
- return null;
- }
- return (PackageAdmin) packageAdminTracker.getService();
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/compendium/tests/AllTests.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/compendium/tests/AllTests.java
deleted file mode 100644
index b2aeee971..000000000
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/compendium/tests/AllTests.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.compendium.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Tests for Equinox Compendium"); //$NON-NLS-1$
- suite.addTest(org.eclipse.equinox.metatype.tests.AllTests.suite());
- suite.addTest(org.eclipse.equinox.useradmin.tests.AllTests.suite());
- suite.addTest(org.eclipse.equinox.event.tests.AllTests.suite());
- return suite;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/event/tests/AllTests.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/event/tests/AllTests.java
deleted file mode 100644
index 274e9813f..000000000
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/event/tests/AllTests.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.event.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTests {
- public static Test suite() {
- TestSuite suite = new TestSuite("Tests for Equinox EventAdmin"); //$NON-NLS-1$
- suite.addTestSuite(EventAdminTest.class);
- return suite;
- }
-}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/event/tests/EventAdminTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/event/tests/EventAdminTest.java
deleted file mode 100644
index 2da46fbe5..000000000
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/event/tests/EventAdminTest.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.event.tests;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import junit.framework.TestCase;
-import org.eclipse.equinox.compendium.tests.Activator;
-import org.osgi.framework.*;
-import org.osgi.service.event.*;
-
-public class EventAdminTest extends TestCase {
- private EventAdmin eventAdmin;
- private ServiceReference eventAdminReference;
-
- protected void setUp() throws Exception {
- Activator.getBundle(Activator.BUNDLE_EVENT).start();
- eventAdminReference = Activator.getBundleContext().getServiceReference(EventAdmin.class.getName());
- eventAdmin = (EventAdmin) Activator.getBundleContext().getService(eventAdminReference);
- }
-
- protected void tearDown() throws Exception {
- Activator.getBundleContext().ungetService(eventAdminReference);
- Activator.getBundle(Activator.BUNDLE_EVENT).stop();
- }
-
- /*
- * Ensures EventAdmin does not deliver an event published on topic "a/b/c"
- * to an EventHandler listening to topic a/b/c/*.
- *
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=325064.
- */
- public void testEventDeliveryForWildcardTopic1() {
- Dictionary properties = new Hashtable();
- properties.put(EventConstants.EVENT_TOPIC, "a/b/c/*"); //$NON-NLS-1$
- BundleContext bundleContext = Activator.getBundleContext();
- EventHandlerHelper handler = new EventHandlerHelper();
- ServiceRegistration handlerRegistration = bundleContext.registerService(EventHandler.class, handler, properties);
- Event event = new Event("a/b/c", (Dictionary) null); //$NON-NLS-1$
- eventAdmin.sendEvent(event);
- assertNull("Received event published to topic 'a/b/c' while listening to 'a/b/c/*'", handler.lastEvent()); //$NON-NLS-1$
- handlerRegistration.unregister();
- }
-
- /*
- * Ensures EventAdmin does not deliver an event published on topic "a/b" to
- * an EventHandler listening to topic a/b/c/*.
- */
- public void testEventDeliveryForWildcardTopic2() {
- Dictionary properties = new Hashtable();
- properties.put(EventConstants.EVENT_TOPIC, "a/b/c/*"); //$NON-NLS-1$
- BundleContext bundleContext = Activator.getBundleContext();
- EventHandlerHelper handler = new EventHandlerHelper();
- ServiceRegistration handlerRegistration = bundleContext.registerService(EventHandler.class, handler, properties);
- Event event = new Event("a/b", (Dictionary) null); //$NON-NLS-1$
- eventAdmin.sendEvent(event);
- assertNull("Received event published to topic 'a/b' while listening to 'a/b/c/*'", handler.lastEvent()); //$NON-NLS-1$
- handlerRegistration.unregister();
- }
-
- /*
- * Ensures EventAdmin does not deliver an event published on topic "a" to
- * an EventHandler listening to topic a/b/c/*.
- */
- public void testEventDeliveryForWildcardTopic3() {
- Dictionary properties = new Hashtable();
- properties.put(EventConstants.EVENT_TOPIC, "a/b/c/*"); //$NON-NLS-1$
- BundleContext bundleContext = Activator.getBundleContext();
- EventHandlerHelper handler = new EventHandlerHelper();
- ServiceRegistration handlerRegistration = bundleContext.registerService(EventHandler.class, handler, properties);
- Event event = new Event("a", (Dictionary) null); //$NON-NLS-1$
- eventAdmin.sendEvent(event);
- assertNull("Received event published to topic 'a' while listening to 'a/b/c/*'", handler.lastEvent()); //$NON-NLS-1$
- handlerRegistration.unregister();
- }
-
- /*
- * Ensures EventAdmin delivers an event published on topic "a/b/c/d" to an
- * EventHandler listening to topic "a/b/c/*".
- */
- public void testEventDeliveryForWildcardTopic4() {
- Dictionary properties = new Hashtable();
- properties.put(EventConstants.EVENT_TOPIC, "a/b/c/*"); //$NON-NLS-1$
- BundleContext bundleContext = Activator.getBundleContext();
- EventHandlerHelper handler = new EventHandlerHelper();
- ServiceRegistration handlerRegistration = bundleContext.registerService(EventHandler.class, handler, properties);
- Event event = new Event("a/b/c/d", (Dictionary) null); //$NON-NLS-1$
- eventAdmin.sendEvent(event);
- assertNotNull("Did not receive event published to topic 'a/b/c/d' while listening to 'a/b/c/*'", handler.lastEvent()); //$NON-NLS-1$
- handlerRegistration.unregister();
- }
-
- /*
- * Ensures EventAdmin delivers an event published on topic "a/b/c/d/e" to
- * an EventHandler listening to topic "a/b/c/*".
- */
- public void testEventDeliveryForWildcardTopic5() {
- Dictionary properties = new Hashtable();
- properties.put(EventConstants.EVENT_TOPIC, "a/b/c/*"); //$NON-NLS-1$
- BundleContext bundleContext = Activator.getBundleContext();
- EventHandlerHelper handler = new EventHandlerHelper();
- ServiceRegistration handlerRegistration = bundleContext.registerService(EventHandler.class, handler, properties);
- Event event = new Event("a/b/c/d/e", (Dictionary) null); //$NON-NLS-1$
- eventAdmin.sendEvent(event);
- assertNotNull("Did not receive event published to topic 'a/b/c/d/e' while listening to 'a/b/c/*'", handler.lastEvent()); //$NON-NLS-1$
- handlerRegistration.unregister();
- }
-
- /*
- * Ensures EventAdmin delivers an event published on topic "a/b/c/d/e/f" to
- * an EventHandler listening to topic "a/b/c/*".
- */
- public void testEventDeliveryForWildcardTopic6() {
- Dictionary properties = new Hashtable();
- properties.put(EventConstants.EVENT_TOPIC, "a/b/c/*"); //$NON-NLS-1$
- BundleContext bundleContext = Activator.getBundleContext();
- EventHandlerHelper handler = new EventHandlerHelper();
- ServiceRegistration handlerRegistration = bundleContext.registerService(EventHandler.class, handler, properties);
- Event event = new Event("a/b/c/d/e/f", (Dictionary) null); //$NON-NLS-1$
- eventAdmin.sendEvent(event);
- assertNotNull("Did not receive event published to topic 'a/b/c/d/e/f' while listening to 'a/b/c/*'", handler.lastEvent()); //$NON-NLS-1$
- handlerRegistration.unregister();
- }
-
- /*
- * Ensures EventAdmin delivers an event published to topics "a/b/c" and
- * "a/b/c/d" to an EventHandler listening to topics "a/b/c" and "a/b/c/*".
- *
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=325064.
- */
- public void testEventDeliveryForWildcardTopic7() {
- Dictionary properties = new Hashtable();
- properties.put(EventConstants.EVENT_TOPIC, new String[] {"a/b/c", "a/b/c/*"}); //$NON-NLS-1$ //$NON-NLS-2$
- BundleContext bundleContext = Activator.getBundleContext();
- EventHandlerHelper handler = new EventHandlerHelper();
- ServiceRegistration handlerRegistration = bundleContext.registerService(EventHandler.class, handler, properties);
- Event event = new Event("a/b/c", (Dictionary) null); //$NON-NLS-1$
- eventAdmin.sendEvent(event);
- assertNotNull("Did not receive event published to topic 'a/b/c' while listening to 'a/b/c'", handler.clearLastEvent()); //$NON-NLS-1$
- event = new Event("a/b/c/d", (Dictionary) null); //$NON-NLS-1$
- eventAdmin.sendEvent(event);
- assertNotNull("Did not receive event published to topic 'a/b/c/d' while listening to 'a/b/c/*'", handler.lastEvent()); //$NON-NLS-1$
- handlerRegistration.unregister();
- }
-}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/event/tests/EventHandlerHelper.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/event/tests/EventHandlerHelper.java
deleted file mode 100644
index e9b4e0862..000000000
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/event/tests/EventHandlerHelper.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.event.tests;
-
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventHandler;
-
-public class EventHandlerHelper implements EventHandler {
- private volatile Event lastEvent;
-
- public Event clearLastEvent() {
- Event result = lastEvent;
- lastEvent = null;
- return result;
- }
-
- public void handleEvent(Event event) {
- lastEvent = event;
- }
-
- public Event lastEvent() {
- return lastEvent;
- }
-}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java
deleted file mode 100644
index 3217cede5..000000000
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTests {
- public static Test suite() {
- TestSuite suite = new TestSuite("Tests for Equinox MetaType"); //$NON-NLS-1$
- suite.addTestSuite(AttributeTypePasswordTest.class);
- return suite;
- }
-}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java
deleted file mode 100644
index fd661ebed..000000000
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype.tests;
-
-import junit.framework.TestCase;
-import org.eclipse.equinox.compendium.tests.Activator;
-import org.eclipse.osgi.tests.bundles.BundleInstaller;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.metatype.*;
-
-public class AttributeTypePasswordTest extends TestCase {
- private Bundle bundle;
- private BundleInstaller bundleInstaller;
- private MetaTypeService metaType;
- private ServiceReference metaTypeReference;
-
- protected void setUp() throws Exception {
- Activator.getBundle(Activator.BUNDLE_METATYPE).start();
- metaTypeReference = Activator.getBundleContext().getServiceReference(MetaTypeService.class.getName());
- metaType = (MetaTypeService) Activator.getBundleContext().getService(metaTypeReference);
- bundleInstaller = new BundleInstaller("bundle_tests/metatype", Activator.getBundleContext()); //$NON-NLS-1$
- bundleInstaller.refreshPackages(null);
- bundle = bundleInstaller.installBundle("tb1"); //$NON-NLS-1$
- bundle.start();
- }
-
- protected void tearDown() throws Exception {
- bundleInstaller.shutdown();
- Activator.getBundleContext().ungetService(metaTypeReference);
- Activator.getBundle(Activator.BUNDLE_METATYPE).stop();
- }
-
- /*
- * Ensures the PASSWORD type is recognized.
- */
- public void testAttributeTypePassword1() {
- MetaTypeInformation mti = metaType.getMetaTypeInformation(bundle);
- ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$
- AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
- for (int i = 0; i < ads.length; i++) {
- if (ads[i].getID().equals("password1")) { //$NON-NLS-1$
- assertEquals("Attribute type is not PASSWORD", AttributeDefinition.PASSWORD, ads[i].getType()); //$NON-NLS-1$
- }
- }
- }
-
- /*
- * Ensures the PASSWORD type is treated the same as the STRING type.
- * Validation should not be present when min and max are not specified and
- * their are no enumerated constraints.
- */
- public void testAttributeTypePassword2() {
- MetaTypeInformation mti = metaType.getMetaTypeInformation(bundle);
- ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$
- AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
- for (int i = 0; i < ads.length; i++) {
- if (ads[i].getID().equals("password1")) { //$NON-NLS-1$
- assertNull("Validation should not be present when min and max are not specified and their are no enumerated constraints", ads[i].validate("1234abcd")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
- /*
- * Ensures the PASSWORD type is treated the same as the STRING type.
- * Validation should be present when min and max are not specified and
- * their are enumerated constraints.
- */
- public void testAttributeTypePassword3() {
- MetaTypeInformation mti = metaType.getMetaTypeInformation(bundle);
- ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$
- AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
- for (int i = 0; i < ads.length; i++) {
- if (ads[i].getID().equals("password2")) { //$NON-NLS-1$
- assertNotNull("Validation should be present when min and max are not specified and their are enumerated constraints", ads[i].validate("password")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Value 'password' should have been valid", 0, ads[i].validate("password").length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Value '1234abcd' should not have been valid", ads[i].validate("1234abcd").length() > 0); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
- /*
- * Ensures the PASSWORD type is treated the same as the STRING type.
- * PASSWORD length should be no less than min.
- */
- public void testAttributeTypePassword4() {
- MetaTypeInformation mti = metaType.getMetaTypeInformation(bundle);
- ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$
- AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
- for (int i = 0; i < ads.length; i++) {
- if (ads[i].getID().equals("password3")) { //$NON-NLS-1$
- assertEquals("Value '12345678' should have been valid", 0, ads[i].validate("12345678").length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Value '123456789' should have been valid", 0, ads[i].validate("123456789").length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Value '1234567' should not have been valid", ads[i].validate("1234567").length() > 0); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
- /*
- * Ensures the PASSWORD type is treated the same as the STRING type.
- * PASSWORD length should be no greater than max.
- */
- public void testAttributeTypePassword5() {
- MetaTypeInformation mti = metaType.getMetaTypeInformation(bundle);
- ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$
- AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
- for (int i = 0; i < ads.length; i++) {
- if (ads[i].getID().equals("password4")) { //$NON-NLS-1$
- assertEquals("Value '12345' should have been valid", 0, ads[i].validate("12345").length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Value '1234' should have been valid", 0, ads[i].validate("1234").length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Value '123456' should not have been valid", ads[i].validate("123456").length() > 0); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
- /*
- * Ensures the PASSWORD type is treated the same as the STRING type.
- * PASSWORD length should be no less than min and no greater than max.
- */
- public void testAttributeTypePassword6() {
- MetaTypeInformation mti = metaType.getMetaTypeInformation(bundle);
- ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$
- AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
- for (int i = 0; i < ads.length; i++) {
- if (ads[i].getID().equals("password5")) { //$NON-NLS-1$
- assertEquals("Value '123' should have been valid", 0, ads[i].validate("123").length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Value '12' should not have been valid", ads[i].validate("12").length() > 0); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Value '123456' should have been valid", 0, ads[i].validate("123456").length()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Value '1234567' should not have been valid", ads[i].validate("1234567").length() > 0); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/SameOcdPidFactoryPidTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/SameOcdPidFactoryPidTest.java
deleted file mode 100644
index c2ed2e9f6..000000000
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/SameOcdPidFactoryPidTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype.tests;
-
-import junit.framework.TestCase;
-import org.eclipse.equinox.compendium.tests.Activator;
-import org.eclipse.osgi.tests.bundles.BundleInstaller;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.metatype.MetaTypeInformation;
-import org.osgi.service.metatype.MetaTypeService;
-
-public class SameOcdPidFactoryPidTest extends TestCase {
- private Bundle bundle;
- private BundleInstaller bundleInstaller;
- private MetaTypeService metaType;
- private ServiceReference metaTypeReference;
-
- protected void setUp() throws Exception {
- Activator.getBundle(Activator.BUNDLE_METATYPE).start();
- metaTypeReference = Activator.getBundleContext().getServiceReference(MetaTypeService.class.getName());
- metaType = (MetaTypeService) Activator.getBundleContext().getService(metaTypeReference);
- bundleInstaller = new BundleInstaller("bundle_tests/metatype", Activator.getBundleContext()); //$NON-NLS-1$
- bundleInstaller.refreshPackages(null);
- bundle = bundleInstaller.installBundle("tb2"); //$NON-NLS-1$
- bundle.start();
- }
-
- protected void tearDown() throws Exception {
- bundleInstaller.shutdown();
- Activator.getBundleContext().ungetService(metaTypeReference);
- Activator.getBundle(Activator.BUNDLE_METATYPE).stop();
- }
-
- /*
- * Ensures the same OCD referred to by two Designate elements, one using
- * the factoryPid attribute and the other only the pid attribute, is
- * accessible via both getPids() and getFactoryPids().
- */
- public void test1() {
- MetaTypeInformation mti = metaType.getMetaTypeInformation(bundle);
- String[] pids = mti.getPids();
- assertNotNull("The pid 'singleton' was not present.", pids); //$NON-NLS-1$
- assertEquals("Not the expected number of pids.", 1, pids.length); //$NON-NLS-1$
- assertEquals("Expected pid was not present.", "singleton", pids[0]); //$NON-NLS-1$ //$NON-NLS-2$
- String[] factoryPids = mti.getFactoryPids();
- assertNotNull("The factory pid 'factory' was not present.", factoryPids); //$NON-NLS-1$
- assertEquals("Not the expected number of factory pids.", 1, factoryPids.length); //$NON-NLS-1$
- assertEquals("Expected factory pid was not present.", "factory", factoryPids[0]); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/AllTests.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/AllTests.java
deleted file mode 100644
index ceddb5e99..000000000
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/AllTests.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Tests for Equinox UserAdmin"); //$NON-NLS-1$
- suite.addTestSuite(UserTest.class);
- suite.addTestSuite(GroupTest.class);
- suite.addTestSuite(UserAdminEventAdapterTest.class);
- return suite;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/GroupTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/GroupTest.java
deleted file mode 100644
index e93506010..000000000
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/GroupTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin.tests;
-
-import junit.framework.TestCase;
-import org.eclipse.equinox.compendium.tests.Activator;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.useradmin.*;
-
-public class GroupTest extends TestCase {
-
- private UserAdmin userAdmin;
- private ServiceReference userAdminReference;
-
- boolean locked = false;
- Object lock = new Object();
-
- protected void setUp() throws Exception {
- Activator.getBundle(Activator.BUNDLE_USERADMIN).start();
- userAdminReference = Activator.getBundleContext().getServiceReference(UserAdmin.class.getName());
- userAdmin = (UserAdmin) Activator.getBundleContext().getService(userAdminReference);
- }
-
- protected void tearDown() throws Exception {
- Activator.getBundleContext().ungetService(userAdminReference);
- Activator.getBundle(Activator.BUNDLE_USERADMIN).stop();
- }
-
- public void testGroupCreateAndRemove() throws Exception {
- Group group = (Group) userAdmin.createRole("testGroupCreateAndRemove", Role.GROUP); //$NON-NLS-1$
- assertNotNull(group);
- assertEquals("testGroupCreateAndRemove", group.getName()); //$NON-NLS-1$
- assertTrue(group.getType() == Role.GROUP);
- assertTrue(userAdmin.removeRole("testGroupCreateAndRemove")); //$NON-NLS-1$
- assertNull(userAdmin.getRole("testGroupCreateAndRemove")); //$NON-NLS-1$
- }
-
- public void testGroupAddingAndRemovingMembers() throws Exception {
- Group group = (Group) userAdmin.createRole("testGroupAddingAndRemovingMembers", Role.GROUP); //$NON-NLS-1$
- assertNotNull(group);
- assertEquals("testGroupAddingAndRemovingMembers", group.getName()); //$NON-NLS-1$
- assertTrue(group.getType() == Role.GROUP);
- assertNull(group.getMembers());
-
- User user = (User) userAdmin.createRole("testRole1", Role.USER); //$NON-NLS-1$
- assertNotNull(user);
-
- group.addMember(user);
- assertEquals(group.getMembers().length, 1);
- assertNull(group.getRequiredMembers());
- group.removeMember(user);
- assertNull(group.getMembers());
- assertNull(group.getRequiredMembers());
- group.addRequiredMember(user);
- assertNull(group.getMembers());
- assertEquals(group.getRequiredMembers().length, 1);
-
- userAdmin.removeRole("testRole1"); //$NON-NLS-1$
- assertNull(userAdmin.getRole("testRole1")); //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/UserAdminEventAdapterTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/UserAdminEventAdapterTest.java
deleted file mode 100644
index d88ef0f74..000000000
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/UserAdminEventAdapterTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin.tests;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import junit.framework.TestCase;
-import org.eclipse.equinox.compendium.tests.Activator;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.event.*;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.UserAdmin;
-
-public class UserAdminEventAdapterTest extends TestCase {
-
- private UserAdmin userAdmin;
- private ServiceReference userAdminReference;
-
- boolean locked = false;
- Object lock = new Object();
-
- protected void setUp() throws Exception {
- Activator.getBundle(Activator.BUNDLE_EVENT).start();
- Activator.getBundle(Activator.BUNDLE_USERADMIN).start();
- userAdminReference = Activator.getBundleContext().getServiceReference(UserAdmin.class.getName());
- userAdmin = (UserAdmin) Activator.getBundleContext().getService(userAdminReference);
- }
-
- protected void tearDown() throws Exception {
- Activator.getBundleContext().ungetService(userAdminReference);
- Activator.getBundle(Activator.BUNDLE_USERADMIN).stop();
- Activator.getBundle(Activator.BUNDLE_EVENT).stop();
- }
-
- public void testUserAdminEvent() throws Exception {
-
- EventHandler handler = new EventHandler() {
- public void handleEvent(Event event) {
- synchronized (lock) {
- locked = false;
- lock.notify();
- }
- }
-
- };
- String[] topics = new String[] {"org/osgi/service/useradmin/UserAdmin/*"}; //$NON-NLS-1$
- Dictionary handlerProps = new Hashtable();
-
- handlerProps.put(EventConstants.EVENT_TOPIC, topics);
- ServiceRegistration reg = Activator.getBundleContext().registerService(EventHandler.class.getName(), handler, handlerProps);
-
- synchronized (lock) {
- userAdmin.createRole("testRole", Role.USER); //$NON-NLS-1$
- locked = true;
- lock.wait(5000);
- assertFalse(locked);
- }
-
- synchronized (lock) {
- userAdmin.removeRole("testRole"); //$NON-NLS-1$
- locked = true;
- lock.wait(5000);
- assertFalse(locked);
- }
-
- reg.unregister();
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/UserTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/UserTest.java
deleted file mode 100644
index f0f53f359..000000000
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/useradmin/tests/UserTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin.tests;
-
-import java.util.Dictionary;
-import junit.framework.TestCase;
-import org.eclipse.equinox.compendium.tests.Activator;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.useradmin.*;
-
-public class UserTest extends TestCase {
-
- private UserAdmin userAdmin;
- private ServiceReference userAdminReference;
-
- boolean locked = false;
- Object lock = new Object();
-
- protected void setUp() throws Exception {
- Activator.getBundle(Activator.BUNDLE_USERADMIN).start();
- userAdminReference = Activator.getBundleContext().getServiceReference(UserAdmin.class.getName());
- userAdmin = (UserAdmin) Activator.getBundleContext().getService(userAdminReference);
- }
-
- protected void tearDown() throws Exception {
- Activator.getBundleContext().ungetService(userAdminReference);
- Activator.getBundle(Activator.BUNDLE_USERADMIN).stop();
- }
-
- public void testCreate() throws Exception {
- User user = (User) userAdmin.createRole("testUserCreate1", Role.USER); //$NON-NLS-1$
- assertNotNull(user);
- assertEquals("testUserCreate1", user.getName()); //$NON-NLS-1$
- assertTrue(user.getType() == Role.USER);
- user.getProperties().put("test", "valu"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testGetUser() {
- User user = userAdmin.getUser("test", "valu"); //$NON-NLS-1$ //$NON-NLS-2$
- assertNotNull(user);
- assertEquals("testUserCreate1", user.getName()); //$NON-NLS-1$
- assertTrue(user.getType() == Role.USER);
- try {
- Role[] roles = userAdmin.getRoles("(test=valu)"); //$NON-NLS-1$
- assertNotNull(roles);
- assertEquals("number of roles", 1, roles.length); //$NON-NLS-1$
- } catch (InvalidSyntaxException e) {
- fail(e.getMessage());
- }
- userAdmin.removeRole(user.getName());
- }
-
- public void testRemovedUser() {
- assertNull(userAdmin.getRole("testUserCreate1")); //$NON-NLS-1$
- }
-
- public void testCreate02() throws Exception {
- User user = (User) userAdmin.createRole("testUserCreate2", Role.USER); //$NON-NLS-1$
- assertNotNull(user);
- assertEquals("testUserCreate2", user.getName()); //$NON-NLS-1$
- assertTrue(user.getType() == Role.USER);
- user.getProperties().put("test1", "valu"); //$NON-NLS-1$ //$NON-NLS-2$
- user.getProperties().put("test2", "xxxyyyzzz"); //$NON-NLS-1$ //$NON-NLS-2$
- user.getProperties().put("test3", new byte[] {1, 2, 3}); //$NON-NLS-1$
-
- user.getCredentials().put("test1", "valu"); //$NON-NLS-1$ //$NON-NLS-2$
- user.getCredentials().put("test2", "xxxyyyzzz"); //$NON-NLS-1$ //$NON-NLS-2$
- user.getCredentials().put("test3", new byte[] {1, 2, 3}); //$NON-NLS-1$
- }
-
- public void testGetUser02() {
- Role user = userAdmin.getRole("testUserCreate2"); //$NON-NLS-1$
- assertNotNull(user);
- assertEquals("testUserCreate2", user.getName()); //$NON-NLS-1$
- assertTrue(user.getType() == Role.USER);
-
- Object test1 = user.getProperties().get("test1"); //$NON-NLS-1$
- assertEquals("test1", "valu", test1); //$NON-NLS-1$ //$NON-NLS-2$
- Object test2 = user.getProperties().get("test2"); //$NON-NLS-1$
- assertEquals("test2", "xxxyyyzzz", test2); //$NON-NLS-1$ //$NON-NLS-2$
- Object test3 = user.getProperties().get("test3"); //$NON-NLS-1$
- assertTrue("test3 not byte[]", test3 instanceof byte[]); //$NON-NLS-1$
- byte[] bytes = (byte[]) test3;
- assertEquals("wrong size", 3, bytes.length); //$NON-NLS-1$
- assertEquals("1", 1, bytes[0]); //$NON-NLS-1$
- assertEquals("2", 2, bytes[1]); //$NON-NLS-1$
- assertEquals("3", 3, bytes[2]); //$NON-NLS-1$
-
- Dictionary creds = ((User) user).getCredentials();
- test1 = creds.get("test1"); //$NON-NLS-1$
- assertEquals("test1", "valu", test1); //$NON-NLS-1$ //$NON-NLS-2$
- test2 = creds.get("test2"); //$NON-NLS-1$
- assertEquals("test2", "xxxyyyzzz", test2); //$NON-NLS-1$ //$NON-NLS-2$
- test3 = creds.get("test3"); //$NON-NLS-1$
- assertTrue("test3 not byte[]", test3 instanceof byte[]); //$NON-NLS-1$
- bytes = (byte[]) test3;
- assertEquals("wrong size", 3, bytes.length); //$NON-NLS-1$
- assertEquals("1", 1, bytes[0]); //$NON-NLS-1$
- assertEquals("2", 2, bytes[1]); //$NON-NLS-1$
- assertEquals("3", 3, bytes[2]); //$NON-NLS-1$
-
- try {
- Role[] roles = userAdmin.getRoles("(test3=1)"); //$NON-NLS-1$
- assertNotNull(roles);
- assertEquals("number of roles", 1, roles.length); //$NON-NLS-1$
- } catch (InvalidSyntaxException e) {
- fail(e.getMessage());
- }
- userAdmin.removeRole(user.getName());
- }
-
- public void testRemovedUser02() {
- assertNull(userAdmin.getRole("testUserCreate2")); //$NON-NLS-1$
- }
-
- public void testUserCreateAndRemove() throws Exception {
- User user = (User) userAdmin.createRole("testUserCreateAndRemove", Role.USER); //$NON-NLS-1$
- assertNotNull(user);
- assertEquals("testUserCreateAndRemove", user.getName()); //$NON-NLS-1$
- assertTrue(user.getType() == Role.USER);
- assertTrue(userAdmin.removeRole("testUserCreateAndRemove")); //$NON-NLS-1$
- assertNull(userAdmin.getRole("testUserCreateAndRemove")); //$NON-NLS-1$
- }
-
-}

Back to the top