summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Liebig2008-03-12 09:13:43 (EDT)
committerStefan Liebig2008-03-12 09:13:43 (EDT)
commit7a4f56b8b9ec4910b00d7ddb238f7b93442da428 (patch)
tree8f90503b18cce046c2d473ba72217f0ff6c8c28d
parentdad2cd6ebd4c90446f727a99aa6ae970536655d4 (diff)
downloadorg.eclipse.riena-7a4f56b8b9ec4910b00d7ddb238f7b93442da428.zip
org.eclipse.riena-7a4f56b8b9ec4910b00d7ddb238f7b93442da428.tar.gz
org.eclipse.riena-7a4f56b8b9ec4910b00d7ddb238f7b93442da428.tar.bz2
uses getContext() helper
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/core/config/ConfigTest.java5
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/core/exception/ExceptionHandlerManagerTest.java92
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/core/logging/ConsoleLoggerTest.java7
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/core/service/InjectorTest.java61
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/AuthorizationTest.java7
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/SentinelTest.java17
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authentication/AuthenticationClientITest.java17
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authentication/AuthenticationLoginModuleITest.java12
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authorization/AuthorizationServiceITest.java33
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/session/SessionServiceITest.java20
10 files changed, 131 insertions, 140 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/core/config/ConfigTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/core/config/ConfigTest.java
index 25d3e3f..0f6ebcf 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/core/config/ConfigTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/core/config/ConfigTest.java
@@ -12,7 +12,6 @@ package org.eclipse.riena.core.config;
import junit.framework.AssertionFailedError;
-import org.eclipse.riena.internal.tests.Activator;
import org.eclipse.riena.tests.RienaTestCase;
/**
@@ -47,7 +46,7 @@ public class ConfigTest extends RienaTestCase {
assertTrue(bc.getName().equals("default"));
// wrap with proxy
- ConfigUtility cu = new ConfigUtility(Activator.getContext());
+ ConfigUtility cu = new ConfigUtility(getContext());
cu.createConfigProxy(bc, "org.eclipse.riena.business.pid");
Thread t = new Thread() {
@@ -89,7 +88,7 @@ public class ConfigTest extends RienaTestCase {
assertTrue(bc.getName().equals("default"));
// wrap with proxy
- ConfigUtility cu = new ConfigUtility(Activator.getContext());
+ ConfigUtility cu = new ConfigUtility(getContext());
cu.createConfigProxy(bc, "org.eclipse.riena.business.pid");
Thread t = new Thread() {
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/core/exception/ExceptionHandlerManagerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/core/exception/ExceptionHandlerManagerTest.java
index 6b6926b..521b736 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/core/exception/ExceptionHandlerManagerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/core/exception/ExceptionHandlerManagerTest.java
@@ -14,9 +14,6 @@ import java.util.Hashtable;
import junit.framework.Assert;
-import org.eclipse.riena.core.exception.IExceptionHandler;
-import org.eclipse.riena.core.exception.IExceptionHandlerManager;
-import org.eclipse.riena.internal.tests.Activator;
import org.eclipse.riena.tests.RienaTestCase;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -27,69 +24,68 @@ import org.osgi.framework.ServiceReference;
*/
public class ExceptionHandlerManagerTest extends RienaTestCase {
- public void setUp() throws BundleException {
- startBundles("org\\.eclipse\\.riena\\.exception.*",null);
+ public void setUp() throws BundleException {
+ startBundles("org\\.eclipse\\.riena\\.exception.*", null);
}
+ public void testGetManager() {
+ BundleContext context = getContext();
- public void testGetManager() {
- BundleContext context = Activator.getContext();
+ ServiceReference managerRef = context.getServiceReference(IExceptionHandlerManager.ID);
+ Assert.assertNotNull(managerRef);
- ServiceReference managerRef = context.getServiceReference(IExceptionHandlerManager.ID);
- Assert.assertNotNull(managerRef);
+ IExceptionHandlerManager manager = (IExceptionHandlerManager) context.getService(managerRef);
+ Assert.assertNotNull(manager);
- IExceptionHandlerManager manager = (IExceptionHandlerManager) context.getService(managerRef);
- Assert.assertNotNull(manager);
-
- }
+ }
- public void testAddHandler() {
- BundleContext context = Activator.getContext();
- TestExceptionHandler test = new TestExceptionHandler();
- test.name = "test.scp.handler1";
+ public void testAddHandler() {
+ BundleContext context = getContext();
+ TestExceptionHandler test = new TestExceptionHandler();
+ test.name = "test.scp.handler1";
- Hashtable<String, String> properties = new Hashtable<String, String>(0);
- context.registerService(IExceptionHandler.ID, test, properties);
+ Hashtable<String, String> properties = new Hashtable<String, String>(0);
+ context.registerService(IExceptionHandler.ID, test, properties);
- ServiceReference managerRef = context.getServiceReference(IExceptionHandlerManager.ID);
- Assert.assertNotNull(managerRef);
+ ServiceReference managerRef = context.getServiceReference(IExceptionHandlerManager.ID);
+ Assert.assertNotNull(managerRef);
- IExceptionHandlerManager manager = (IExceptionHandlerManager) context.getService(managerRef);
- Assert.assertNotNull(manager);
+ IExceptionHandlerManager manager = (IExceptionHandlerManager) context.getService(managerRef);
+ Assert.assertNotNull(manager);
- Exception exception = new Exception("test");
- manager.handleCaught(exception);
+ Exception exception = new Exception("test");
+ manager.handleCaught(exception);
- Assert.assertEquals("expected exception", test.throwable, exception);
- }
+ Assert.assertEquals("expected exception", test.throwable, exception);
+ }
- public void testAddHandlerChain() {
- BundleContext context = Activator.getContext();
- TestExceptionHandler test1 = new TestExceptionHandler();
- test1.name = "test.scp.handler1";
+ public void testAddHandlerChain() {
+ BundleContext context = getContext();
+ TestExceptionHandler test1 = new TestExceptionHandler();
+ test1.name = "test.scp.handler1";
- Hashtable<String, String> properties = new Hashtable<String, String>(0);
- context.registerService(IExceptionHandler.ID, test1, properties);
+ Hashtable<String, String> properties = new Hashtable<String, String>(0);
+ context.registerService(IExceptionHandler.ID, test1, properties);
- TestExceptionHandler test2 = new TestExceptionHandler();
- test2.name = "test.scp.handler2";
- test2.before = "test.scp.handler1";
- test2.action = IExceptionHandlerManager.Action.Ok;
+ TestExceptionHandler test2 = new TestExceptionHandler();
+ test2.name = "test.scp.handler2";
+ test2.before = "test.scp.handler1";
+ test2.action = IExceptionHandlerManager.Action.Ok;
- properties = new Hashtable<String, String>(0);
- context.registerService(IExceptionHandler.ID, test2, properties);
+ properties = new Hashtable<String, String>(0);
+ context.registerService(IExceptionHandler.ID, test2, properties);
- ServiceReference managerRef = context.getServiceReference(IExceptionHandlerManager.ID);
- Assert.assertNotNull(managerRef);
+ ServiceReference managerRef = context.getServiceReference(IExceptionHandlerManager.ID);
+ Assert.assertNotNull(managerRef);
- IExceptionHandlerManager manager = (IExceptionHandlerManager) context.getService(managerRef);
- Assert.assertNotNull(manager);
+ IExceptionHandlerManager manager = (IExceptionHandlerManager) context.getService(managerRef);
+ Assert.assertNotNull(manager);
- Exception exception = new Exception("test");
- manager.handleCaught(exception);
+ Exception exception = new Exception("test");
+ manager.handleCaught(exception);
- Assert.assertEquals("expected exception", test2.throwable, exception);
- Assert.assertNull("expected no exception", test1.throwable);
- }
+ Assert.assertEquals("expected exception", test2.throwable, exception);
+ Assert.assertNull("expected no exception", test1.throwable);
+ }
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/core/logging/ConsoleLoggerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/core/logging/ConsoleLoggerTest.java
index 1c6500a..9df71ca 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/core/logging/ConsoleLoggerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/core/logging/ConsoleLoggerTest.java
@@ -13,10 +13,9 @@ package org.eclipse.riena.core.logging;
import java.io.IOException;
import junit.framework.Assert;
-import junit.framework.TestCase;
import org.eclipse.equinox.log.Logger;
-import org.eclipse.riena.internal.tests.Activator;
+import org.eclipse.riena.tests.RienaTestCase;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -25,7 +24,7 @@ import org.osgi.service.log.LogService;
/**
*
*/
-public class ConsoleLoggerTest extends TestCase {
+public class ConsoleLoggerTest extends RienaTestCase {
private Logger logger;
@@ -57,7 +56,7 @@ public class ConsoleLoggerTest extends TestCase {
public void testWithServiceReference() throws InvalidSyntaxException {
String stringService = "Very simple service";
- ServiceRegistration sr = Activator.getContext().registerService(String.class.getName(), stringService, null);
+ ServiceRegistration sr = getContext().registerService(String.class.getName(), stringService, null);
Assert.assertTrue(sr.getReference() != null);
logger.log(sr.getReference(), LogService.LOG_INFO, "Message with context.");
sr.unregister();
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/core/service/InjectorTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/core/service/InjectorTest.java
index e28a539..79e0d53 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/core/service/InjectorTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/core/service/InjectorTest.java
@@ -13,9 +13,7 @@ package org.eclipse.riena.core.service;
import java.util.Dictionary;
import java.util.Hashtable;
-import org.eclipse.riena.internal.tests.Activator;
import org.eclipse.riena.tests.RienaTestCase;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
@@ -24,26 +22,23 @@ import org.osgi.framework.ServiceRegistration;
*/
public class InjectorTest extends RienaTestCase {
- private BundleContext context;
-
@Override
protected void setUp() throws Exception {
super.setUp();
- context = Activator.getContext();
}
@Override
protected void tearDown() throws Exception {
- context = null;
super.tearDown();
}
public void scribble() {
Object target = null;
- new ServiceId("serviceId").injectInto(target).andStart(context);
- new ServiceId("serviceId").injectInto(target).bind("bind").unbind("unbind").andStart(context);
- new ServiceId("serviceId").useFilter("").injectInto(target).bind("bind").unbind("unbind").andStart(context);
+ new ServiceId("serviceId").injectInto(target).andStart(getContext());
+ new ServiceId("serviceId").injectInto(target).bind("bind").unbind("unbind").andStart(getContext());
+ new ServiceId("serviceId").useFilter("").injectInto(target).bind("bind").unbind("unbind")
+ .andStart(getContext());
}
public void testInjectDepOneObviousBindUnbindError() {
@@ -51,10 +46,10 @@ public class InjectorTest extends RienaTestCase {
Target target = new Target();
DepOne depOne = new DepOne();
- ServiceRegistration reg = context.registerService(DepOne.class.getName(), depOne, null);
+ ServiceRegistration reg = getContext().registerService(DepOne.class.getName(), depOne, null);
try {
- new ServiceId(DepOne.class.getName()).injectInto(target).bind("baind").andStart(context);
+ new ServiceId(DepOne.class.getName()).injectInto(target).bind("baind").andStart(getContext());
fail("Well, that should not have happended");
} catch (IllegalArgumentException e) {
assertTrue(true);
@@ -68,10 +63,11 @@ public class InjectorTest extends RienaTestCase {
Target target = new Target();
DepTwo depTwo = new DepTwo();
- ServiceRegistration reg = context.registerService(DepTwo.class.getName(), depTwo, null);
+ ServiceRegistration reg = getContext().registerService(DepTwo.class.getName(), depTwo, null);
try {
- new ServiceId(DepOne.class.getName()).injectInto(target).bind("binde").unbind("entbinde").andStart(context);
+ new ServiceId(DepOne.class.getName()).injectInto(target).bind("binde").unbind("entbinde").andStart(
+ getContext());
} catch (IllegalArgumentException e) {
assertTrue(true);
}
@@ -84,9 +80,9 @@ public class InjectorTest extends RienaTestCase {
Target target = new Target();
DepOne depOne = new DepOne();
- ServiceRegistration reg = context.registerService(DepOne.class.getName(), depOne, null);
+ ServiceRegistration reg = getContext().registerService(DepOne.class.getName(), depOne, null);
- Injector shot = new ServiceId(DepOne.class.getName()).injectInto(target).andStart(context);
+ Injector shot = new ServiceId(DepOne.class.getName()).injectInto(target).andStart(getContext());
assertEquals(1, target.count("bind", DepOne.class));
shot.stop();
@@ -100,15 +96,15 @@ public class InjectorTest extends RienaTestCase {
Target target = new Target();
DepOne depOne = new DepOne();
- ServiceRegistration reg1 = context.registerService(DepOne.class.getName(), depOne, null);
+ ServiceRegistration reg1 = getContext().registerService(DepOne.class.getName(), depOne, null);
- Injector shot1 = new ServiceId(DepOne.class.getName()).injectInto(target).andStart(context);
+ Injector shot1 = new ServiceId(DepOne.class.getName()).injectInto(target).andStart(getContext());
assertEquals(1, target.count("bind", DepOne.class));
- Injector shot2 = new ServiceId(DepTwo.class.getName()).injectInto(target).andStart(context);
+ Injector shot2 = new ServiceId(DepTwo.class.getName()).injectInto(target).andStart(getContext());
DepTwo depTwo = new DepTwo();
- ServiceRegistration reg2 = context.registerService(DepTwo.class.getName(), depTwo, null);
+ ServiceRegistration reg2 = getContext().registerService(DepTwo.class.getName(), depTwo, null);
assertEquals(1, target.count("bind", DepTwo.class));
@@ -127,10 +123,10 @@ public class InjectorTest extends RienaTestCase {
Target target = new Target();
DepOne depOne = new DepOne();
- ServiceRegistration reg = context.registerService(DepOne.class.getName(), depOne, null);
+ ServiceRegistration reg = getContext().registerService(DepOne.class.getName(), depOne, null);
Injector shot = new ServiceId(DepOne.class.getName()).injectInto(target).bind("binde").unbind("entbinde")
- .andStart(context);
+ .andStart(getContext());
assertEquals(1, target.count("binde", DepOne.class));
shot.stop();
@@ -144,14 +140,14 @@ public class InjectorTest extends RienaTestCase {
Target target = new Target();
IRanking rank1 = new RankingOne(0);
- ServiceRegistration reg1 = context.registerService(IRanking.class.getName(), rank1, null);
+ ServiceRegistration reg1 = getContext().registerService(IRanking.class.getName(), rank1, null);
IRanking rank2 = new RankingTwo(100);
Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(Constants.SERVICE_RANKING, Integer.valueOf(100));
- ServiceRegistration reg2 = context.registerService(IRanking.class.getName(), rank2, dict);
+ ServiceRegistration reg2 = getContext().registerService(IRanking.class.getName(), rank2, dict);
- Injector shot = new ServiceId(IRanking.class.getName()).useRanking().injectInto(target).andStart(context);
+ Injector shot = new ServiceId(IRanking.class.getName()).useRanking().injectInto(target).andStart(getContext());
assertEquals(1, target.count("bind", IRanking.class));
assertEquals(100, target.getDepRanking());
@@ -168,16 +164,16 @@ public class InjectorTest extends RienaTestCase {
Target target = new Target();
IRanking rank1 = new RankingOne(0);
- ServiceRegistration reg1 = context.registerService(IRanking.class.getName(), rank1, null);
+ ServiceRegistration reg1 = getContext().registerService(IRanking.class.getName(), rank1, null);
- Injector shot = new ServiceId(IRanking.class.getName()).useRanking().injectInto(target).andStart(context);
+ Injector shot = new ServiceId(IRanking.class.getName()).useRanking().injectInto(target).andStart(getContext());
assertEquals(1, target.count("bind", IRanking.class));
assertEquals(0, target.getDepRanking());
IRanking rank2 = new RankingTwo(100);
Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(Constants.SERVICE_RANKING, Integer.valueOf(100));
- ServiceRegistration reg2 = context.registerService(IRanking.class.getName(), rank2, dict);
+ ServiceRegistration reg2 = getContext().registerService(IRanking.class.getName(), rank2, dict);
assertEquals(1, target.count("bind", IRanking.class));
@@ -189,7 +185,7 @@ public class InjectorTest extends RienaTestCase {
assertEquals(0, target.getDepRanking());
- ServiceRegistration reg3 = context.registerService(IRanking.class.getName(), rank2, dict);
+ ServiceRegistration reg3 = getContext().registerService(IRanking.class.getName(), rank2, dict);
assertEquals(1, target.count("bind", IRanking.class));
@@ -207,9 +203,9 @@ public class InjectorTest extends RienaTestCase {
Target target = new Target();
DepOne depOne = new DepOneOne();
- ServiceRegistration reg = context.registerService(DepOne.class.getName(), depOne, null);
+ ServiceRegistration reg = getContext().registerService(DepOne.class.getName(), depOne, null);
- Injector shot = new ServiceId(DepOne.class.getName()).injectInto(target).andStart(context);
+ Injector shot = new ServiceId(DepOne.class.getName()).injectInto(target).andStart(getContext());
assertEquals(1, target.count("bind", DepOneOne.class));
assertEquals(0, target.count("bind", DepOne.class));
@@ -226,9 +222,10 @@ public class InjectorTest extends RienaTestCase {
DepOne depOne = new DepOneOne();
Hashtable<String, String> props = new Hashtable<String, String>();
props.put("x", "y");
- ServiceRegistration reg = context.registerService(DepOne.class.getName(), depOne, props);
+ ServiceRegistration reg = getContext().registerService(DepOne.class.getName(), depOne, props);
- Injector shot = new ServiceId(DepOne.class.getName()).useFilter("(x=y)").injectInto(target).andStart(context);
+ Injector shot = new ServiceId(DepOne.class.getName()).useFilter("(x=y)").injectInto(target).andStart(
+ getContext());
assertEquals(1, target.count("bind", DepOneOne.class));
shot.stop();
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/AuthorizationTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/AuthorizationTest.java
index bd38cc2..404f78f 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/AuthorizationTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/AuthorizationTest.java
@@ -15,7 +15,6 @@ import java.security.PrivilegedAction;
import javax.security.auth.Subject;
-import org.eclipse.riena.internal.tests.Activator;
import org.eclipse.riena.security.common.authentication.SimplePrincipal;
import org.eclipse.riena.security.common.authorization.IAuthorizationService;
import org.eclipse.riena.security.common.authorization.RienaPolicy;
@@ -36,13 +35,13 @@ public class AuthorizationTest extends RienaTestCase {
// permissions for this test TODO
InputStream inputStream = this.getClass().getResourceAsStream("policy-def-test.xml"); //$NON-NLS-1$
FilePermissionStore store = new FilePermissionStore(inputStream);
- fileStoreReg = Activator.getContext().registerService(IPermissionStore.ID, store, null);
- ServiceReference ref = Activator.getContext().getServiceReference(IAuthorizationService.ID);
+ fileStoreReg = getContext().registerService(IPermissionStore.ID, store, null);
+ ServiceReference ref = getContext().getServiceReference(IAuthorizationService.ID);
// if (ref != null) {
// ref.getBundle().stop();
// }
// authorizationServiceReg =
- // Activator.getContext().registerService(IAuthorizationService.ID,
+ // getContext().registerService(IAuthorizationService.ID,
// new AuthorizationService(), null);
RienaPolicy.init();
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/SentinelTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/SentinelTest.java
index bed2572..c899fcc 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/SentinelTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/SentinelTest.java
@@ -15,7 +15,6 @@ import java.io.InputStream;
import javax.security.auth.Subject;
import org.eclipse.riena.internal.security.authorizationservice.AuthorizationService;
-import org.eclipse.riena.internal.tests.Activator;
import org.eclipse.riena.security.common.ISubjectHolderService;
import org.eclipse.riena.security.common.authentication.SimplePrincipal;
import org.eclipse.riena.security.common.authorization.IAuthorizationService;
@@ -46,13 +45,13 @@ public class SentinelTest extends RienaTestCase {
// permissions for this test TODO
InputStream inputStream = this.getClass().getResourceAsStream("policy-def-test.xml"); //$NON-NLS-1$
FilePermissionStore store = new FilePermissionStore(inputStream);
- fileStoreReg = Activator.getContext().registerService(IPermissionStore.ID, store, null);
- ServiceReference ref = Activator.getContext().getServiceReference(IAuthorizationService.ID);
+ fileStoreReg = getContext().registerService(IPermissionStore.ID, store, null);
+ ServiceReference ref = getContext().getServiceReference(IAuthorizationService.ID);
if (ref != null) {
ref.getBundle().stop();
}
- authorizationServiceReg = Activator.getContext().registerService(IAuthorizationService.ID,
- new AuthorizationService(), null);
+ authorizationServiceReg = getContext().registerService(IAuthorizationService.ID, new AuthorizationService(),
+ null);
}
/*
@@ -74,8 +73,8 @@ public class SentinelTest extends RienaTestCase {
public void testValidUser() {
Subject subject = new Subject();
subject.getPrincipals().add(new SimplePrincipal("testuser"));
- ISubjectHolderService subjectHolderService = (ISubjectHolderService) Activator.getContext().getService(
- Activator.getContext().getServiceReference(ISubjectHolderService.ID));
+ ISubjectHolderService subjectHolderService = (ISubjectHolderService) getContext().getService(
+ getContext().getServiceReference(ISubjectHolderService.ID));
subjectHolderService.fetchSubjectHolder().setSubject(subject);
boolean result = Sentinel.checkAccess(new TestcasePermission("testPerm"));
@@ -85,8 +84,8 @@ public class SentinelTest extends RienaTestCase {
public void testValidUserMissingPermissions() {
Subject subject = new Subject();
subject.getPrincipals().add(new SimplePrincipal("anotheruser"));
- ISubjectHolderService subjectHolderService = (ISubjectHolderService) Activator.getContext().getService(
- Activator.getContext().getServiceReference(ISubjectHolderService.ID));
+ ISubjectHolderService subjectHolderService = (ISubjectHolderService) getContext().getService(
+ getContext().getServiceReference(ISubjectHolderService.ID));
subjectHolderService.fetchSubjectHolder().setSubject(subject);
boolean result = Sentinel.checkAccess(new TestcasePermission("testPerm"));
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authentication/AuthenticationClientITest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authentication/AuthenticationClientITest.java
index 8ba8450..3c3dc14 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authentication/AuthenticationClientITest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authentication/AuthenticationClientITest.java
@@ -71,8 +71,8 @@ public class AuthenticationClientITest extends RienaTestCase {
public void testLogin() throws Exception {
trace("Looking up Authentication Service...: ");
- ServiceReference ref = Activator.getContext().getServiceReference(IAuthenticationService.ID);
- IAuthenticationService authenticationService = (IAuthenticationService) Activator.getContext().getService(ref);
+ ServiceReference ref = getContext().getServiceReference(IAuthenticationService.ID);
+ IAuthenticationService authenticationService = (IAuthenticationService) getContext().getService(ref);
trace("Service looked up: " + authenticationService.getClass().getName());
@@ -104,9 +104,8 @@ public class AuthenticationClientITest extends RienaTestCase {
public void testInvalidLogin() throws Exception {
try {
- ServiceReference ref = Activator.getContext().getServiceReference(IAuthenticationService.ID);
- IAuthenticationService authenticationService = (IAuthenticationService) Activator.getContext().getService(
- ref);
+ ServiceReference ref = getContext().getServiceReference(IAuthenticationService.ID);
+ IAuthenticationService authenticationService = (IAuthenticationService) getContext().getService(ref);
AbstractCredential[] creds = new AbstractCredential[2];
NameCredential nc = new NameCredential("username: ", "xx");
nc.setName("john");
@@ -122,8 +121,8 @@ public class AuthenticationClientITest extends RienaTestCase {
}
public void testSubjectLogin() throws Exception {
- ServiceReference ref = Activator.getContext().getServiceReference(IAuthenticationService.ID);
- IAuthenticationService authenticationService = (IAuthenticationService) Activator.getContext().getService(ref);
+ ServiceReference ref = getContext().getServiceReference(IAuthenticationService.ID);
+ IAuthenticationService authenticationService = (IAuthenticationService) getContext().getService(ref);
trace("Service looked up: " + authenticationService.getClass().getName());
@@ -142,8 +141,8 @@ public class AuthenticationClientITest extends RienaTestCase {
for (Principal p : ticket.getPrincipals()) {
subject.getPrincipals().add(p);
}
- ServiceReference ref2 = Activator.getContext().getServiceReference(ISubjectHolderService.ID);
- ISubjectHolderService subHolderService = (ISubjectHolderService) Activator.getContext().getService(ref2);
+ ServiceReference ref2 = getContext().getServiceReference(ISubjectHolderService.ID);
+ ISubjectHolderService subHolderService = (ISubjectHolderService) getContext().getService(ref2);
subHolderService.fetchSubjectHolder().setSubject(subject);
assertTrue(subHolderService.fetchSubjectHolder().getSubject() == subject);
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authentication/AuthenticationLoginModuleITest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authentication/AuthenticationLoginModuleITest.java
index 98f4e74..b807616 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authentication/AuthenticationLoginModuleITest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authentication/AuthenticationLoginModuleITest.java
@@ -15,7 +15,6 @@ import javax.security.auth.login.LoginException;
import org.eclipse.riena.communication.core.IRemoteServiceRegistration;
import org.eclipse.riena.communication.core.factory.RemoteServiceFactory;
-import org.eclipse.riena.internal.tests.Activator;
import org.eclipse.riena.security.common.authentication.IAuthenticationService;
import org.eclipse.riena.security.common.session.ISessionHolderService;
import org.eclipse.riena.security.services.itest.MyCallbackHandler;
@@ -37,7 +36,8 @@ public class AuthenticationLoginModuleITest extends RienaTestCase {
startBundles("org\\.eclipse\\.riena.communication.factory.hessian", null);
startBundles("org\\.eclipse\\.riena.communication.registry", null);
authenticationService = new RemoteServiceFactory().createAndRegisterProxy(IAuthenticationService.class,
- "http://localhost:8080/hessian/AuthenticationService", "hessian", "org.eclipse.riena.authenticationservice");
+ "http://localhost:8080/hessian/AuthenticationService", "hessian",
+ "org.eclipse.riena.authenticationservice");
}
@Override
@@ -56,12 +56,12 @@ public class AuthenticationLoginModuleITest extends RienaTestCase {
public void testRemoteLogin() throws LoginException {
LoginContext lc = new LoginContext("Remote", new MyCallbackHandler("testuser", "testpass"));
lc.login();
- ServiceReference ref = Activator.getContext().getServiceReference(IAuthenticationService.ID);
- IAuthenticationService as = (IAuthenticationService) Activator.getContext().getService(ref);
+ ServiceReference ref = getContext().getServiceReference(IAuthenticationService.ID);
+ IAuthenticationService as = (IAuthenticationService) getContext().getService(ref);
System.out.println("subject:" + lc.getSubject());
System.out.println("login in sucessful");
- ISessionHolderService shs = (ISessionHolderService) Activator.getContext().getService(
- Activator.getContext().getServiceReference(ISessionHolderService.ID));
+ ISessionHolderService shs = (ISessionHolderService) getContext().getService(
+ getContext().getServiceReference(ISessionHolderService.ID));
as.logout(shs.fetchSessionHolder().getSession());
System.out.println("logoff sucessful");
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authorization/AuthorizationServiceITest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authorization/AuthorizationServiceITest.java
index 7d4656b..14c19b3 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authorization/AuthorizationServiceITest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/authorization/AuthorizationServiceITest.java
@@ -16,7 +16,6 @@ import javax.security.auth.login.LoginContext;
import org.eclipse.riena.communication.core.IRemoteServiceRegistration;
import org.eclipse.riena.communication.core.factory.RemoteServiceFactory;
-import org.eclipse.riena.internal.tests.Activator;
import org.eclipse.riena.sample.app.common.model.Customer;
import org.eclipse.riena.sample.app.common.model.ICustomerSearch;
import org.eclipse.riena.security.common.authentication.IAuthenticationService;
@@ -42,11 +41,13 @@ public class AuthorizationServiceITest extends RienaTestCase {
startBundles("org\\.eclipse\\.riena.communication.factory.hessian", null);
startBundles("org\\.eclipse\\.riena.communication.registry", null);
authenticationService = new RemoteServiceFactory().createAndRegisterProxy(IAuthenticationService.class,
- "http://localhost:8080/hessian/AuthenticationService", "hessian", "org.eclipse.riena.authenticationservice");
+ "http://localhost:8080/hessian/AuthenticationService", "hessian",
+ "org.eclipse.riena.authenticationservice");
authorizationService = new RemoteServiceFactory().createAndRegisterProxy(IAuthorizationService.class,
- "http://localhost:8080/hessian/AuthorizationService", "hessian", "org.eclipse.riena.authorizationservice");
- customerService = new RemoteServiceFactory().createAndRegisterProxy(ICustomerSearch.class, "http://localhost:8080/hessian/CustomerSearchWS", "hessian",
- "org.eclipse.riena.customersearchservice");
+ "http://localhost:8080/hessian/AuthorizationService", "hessian",
+ "org.eclipse.riena.authorizationservice");
+ customerService = new RemoteServiceFactory().createAndRegisterProxy(ICustomerSearch.class,
+ "http://localhost:8080/hessian/CustomerSearchWS", "hessian", "org.eclipse.riena.customersearchservice");
}
@Override
@@ -61,15 +62,16 @@ public class AuthorizationServiceITest extends RienaTestCase {
public void testLoginWithUserWithRights() throws Exception {
LoginContext lc = new LoginContext("Remote", new MyCallbackHandler("testuser", "testpass"));
lc.login();
- ServiceReference ref = Activator.getContext().getServiceReference(IAuthenticationService.ID);
- IAuthenticationService as = (IAuthenticationService) Activator.getContext().getService(ref);
+ ServiceReference ref = getContext().getServiceReference(IAuthenticationService.ID);
+ IAuthenticationService as = (IAuthenticationService) getContext().getService(ref);
System.out.println("subject:" + lc.getSubject());
System.out.println("login in sucessful");
- ISessionHolderService shs = (ISessionHolderService) Activator.getContext().getService(
- Activator.getContext().getServiceReference(ISessionHolderService.ID));
+ ISessionHolderService shs = (ISessionHolderService) getContext().getService(
+ getContext().getServiceReference(ISessionHolderService.ID));
// call the customerService
- ICustomerSearch cs = (ICustomerSearch) Activator.getContext().getService(Activator.getContext().getServiceReference(ICustomerSearch.ID));
+ ICustomerSearch cs = (ICustomerSearch) getContext().getService(
+ getContext().getServiceReference(ICustomerSearch.ID));
Customer cust = new Customer();
cust.setLastName("Solo");
cust.setFirstName("Han");
@@ -86,16 +88,17 @@ public class AuthorizationServiceITest extends RienaTestCase {
public void testLoginWithUserWithoutRights() throws Exception {
LoginContext lc = new LoginContext("Remote", new MyCallbackHandler("testuser2", "testpass2"));
lc.login();
- ServiceReference ref = Activator.getContext().getServiceReference(IAuthenticationService.ID);
- IAuthenticationService as = (IAuthenticationService) Activator.getContext().getService(ref);
+ ServiceReference ref = getContext().getServiceReference(IAuthenticationService.ID);
+ IAuthenticationService as = (IAuthenticationService) getContext().getService(ref);
System.out.println("subject:" + lc.getSubject());
System.out.println("login in sucessful");
- ISessionHolderService shs = (ISessionHolderService) Activator.getContext().getService(
- Activator.getContext().getServiceReference(ISessionHolderService.ID));
+ ISessionHolderService shs = (ISessionHolderService) getContext().getService(
+ getContext().getServiceReference(ISessionHolderService.ID));
try {
// call the customerService
- ICustomerSearch cs = (ICustomerSearch) Activator.getContext().getService(Activator.getContext().getServiceReference(ICustomerSearch.ID));
+ ICustomerSearch cs = (ICustomerSearch) getContext().getService(
+ getContext().getServiceReference(ICustomerSearch.ID));
Customer cust = new Customer();
cust.setLastName("Solo");
cust.setFirstName("Han");
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/session/SessionServiceITest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/session/SessionServiceITest.java
index 6be2070..cf79b31 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/session/SessionServiceITest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/session/SessionServiceITest.java
@@ -13,14 +13,12 @@ package org.eclipse.riena.security.services.itest.session;
import java.security.Principal;
import org.eclipse.riena.communication.core.factory.RemoteServiceFactory;
-import org.eclipse.riena.internal.tests.Activator;
import org.eclipse.riena.security.common.authentication.SimplePrincipal;
import org.eclipse.riena.security.common.session.Session;
import org.eclipse.riena.security.server.session.ISessionService;
import org.eclipse.riena.tests.RienaTestCase;
import org.osgi.framework.ServiceReference;
-
/**
* Tests the SessionService with single user. There is also a disabled multiuser
* test. Its disabled because it seems to fail for problem laying the webservice
@@ -47,8 +45,8 @@ public class SessionServiceITest extends RienaTestCase {
startBundles("org\\.eclipse\\.riena.communication.core", null);
startBundles("org\\.eclipse\\.riena.communication.factory.hessian", null);
startBundles("org\\.eclipse\\.riena.communication.registry", null);
- new RemoteServiceFactory().createAndRegisterProxy(ISessionService.class, "http://localhost:8080/hessian/SessionService", "hessian",
- "org.eclipse.riena.sessionservice");
+ new RemoteServiceFactory().createAndRegisterProxy(ISessionService.class,
+ "http://localhost:8080/hessian/SessionService", "hessian", "org.eclipse.riena.sessionservice");
}
/*
@@ -62,8 +60,8 @@ public class SessionServiceITest extends RienaTestCase {
* @throws Exception
*/
public void testController1() throws Exception {
- ServiceReference ref = Activator.getContext().getServiceReference(ISessionService.ID);
- ISessionService sessionService = (ISessionService) Activator.getContext().getService(ref);
+ ServiceReference ref = getContext().getServiceReference(ISessionService.ID);
+ ISessionService sessionService = (ISessionService) getContext().getService(ref);
assertNotNull("SessionControllerAccessor returns null", sessionService);
Session session = sessionService.generateSession(new Principal[] { new SimplePrincipal("testuid") });
assertNotNull("generateSession returns null", session);
@@ -126,8 +124,8 @@ public class SessionServiceITest extends RienaTestCase {
private int loopCounter;
Threader(int loopCounter) {
- ServiceReference ref = Activator.getContext().getServiceReference(ISessionService.ID);
- sessionService = (ISessionService) Activator.getContext().getService(ref);
+ ServiceReference ref = getContext().getServiceReference(ISessionService.ID);
+ sessionService = (ISessionService) getContext().getService(ref);
this.loopCounter = loopCounter;
assertNotNull("SessionServiceAccessor returns null", sessionService);
}
@@ -141,12 +139,14 @@ public class SessionServiceITest extends RienaTestCase {
assertNotNull("generateSession returns null", session);
Principal[] principals = sessionService.findPrincipals(session);
- assertTrue("returned userid is not equal to the correct one", principals == null || principals[0].getName().equals("testuid"));
+ assertTrue("returned userid is not equal to the correct one", principals == null
+ || principals[0].getName().equals("testuid"));
sessionService.invalidateSession(session);
Principal[] temp = sessionService.findPrincipals(session);
- assertTrue("no user should be found for invalid session", temp == null || temp[0].getName().equals("testuid"));
+ assertTrue("no user should be found for invalid session", temp == null
+ || temp[0].getName().equals("testuid"));
}
// SessionServiceITest.this.trace("K");
}