ScopeObserver implements ScopePublisher { public Scope currentScope() { if (scopes.empty()) { return null; } return scopes.peek(); } ScopeObserver(); void enterScope(final Scope scope); void exitScope(final Scope scope); Scope currentScope(); void addScopeSubscriber(final ScopeSubscriber subscriber); void removeScopeSubscriber(final ScopeSubscriber subscriber);  }
@Test public void testCurrentScope() { Assert.assertNull(observer.currentScope()); observer.enterScope(Scope.SESSION); observer.enterScope(Scope.APPLICATION); Assert.assertEquals(Scope.APPLICATION, observer.currentScope()); observer.exitScope(Scope.APPLICATION); Assert.assertEquals(Scope.SESSION, observer.currentScope()); observer.exitScope(Scope.SESSION); Assert.assertNull(observer.currentScope()); }