예제 #1
0
  @Test
  public void testRequestScope() {
    // Create global scope
    int nPrev = AbstractScopeSPI.getBegin();
    int nPrevT = AbstractThrowingScopeSPI.getBegin();
    ScopeManager.onGlobalBegin("global");
    assertEquals(nPrev + 1, AbstractScopeSPI.getBegin());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getBegin());

    // Create request scope
    nPrev = AbstractScopeSPI.getBegin();
    nPrevT = AbstractThrowingScopeSPI.getBegin();
    ScopeManager.onRequestBegin("appid", "scopeid", "sessionid");
    assertEquals(nPrev + 1, AbstractScopeSPI.getBegin());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getBegin());

    // End request scope
    nPrev = AbstractScopeSPI.getEnd();
    nPrevT = AbstractThrowingScopeSPI.getEnd();
    ScopeManager.onRequestEnd();
    assertEquals(nPrev + 1, AbstractScopeSPI.getEnd());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getEnd());

    // End global scope
    nPrev = AbstractScopeSPI.getEnd();
    nPrevT = AbstractThrowingScopeSPI.getEnd();
    ScopeManager.onGlobalEnd();
    assertEquals(nPrev + 1, AbstractScopeSPI.getEnd());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getEnd());
  }
예제 #2
0
  @Test
  public void testSessionScopes() {
    // Create global scope
    int nPrev = AbstractScopeSPI.getBegin();
    int nPrevT = AbstractThrowingScopeSPI.getBegin();
    ScopeManager.onGlobalBegin("global");
    assertEquals(nPrev + 1, AbstractScopeSPI.getBegin());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getBegin());

    // Create request scope
    nPrev = AbstractScopeSPI.getBegin();
    nPrevT = AbstractThrowingScopeSPI.getBegin();
    ScopeManager.onRequestBegin("appid", "scopeid", "sessionid");
    assertEquals(nPrev + 1, AbstractScopeSPI.getBegin());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getBegin());

    // Create application scope
    nPrev = AbstractScopeSPI.getBegin();
    nPrevT = AbstractThrowingScopeSPI.getBegin();
    ScopeManager.getApplicationScope();
    assertEquals(nPrev + 1, AbstractScopeSPI.getBegin());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getBegin());

    // Create second application scope
    nPrev = AbstractScopeSPI.getBegin();
    nPrevT = AbstractThrowingScopeSPI.getBegin();
    ScopeManager.getApplicationScope("any other blabla");
    assertEquals(nPrev + 1, AbstractScopeSPI.getBegin());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getBegin());

    // Begin session scope
    nPrev = AbstractScopeSPI.getBegin();
    nPrevT = AbstractThrowingScopeSPI.getBegin();
    final ISessionScope aSessionScope = ScopeManager.getSessionScope();
    assertEquals(nPrev + 1, AbstractScopeSPI.getBegin());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getBegin());

    // End request scope
    nPrev = AbstractScopeSPI.getEnd();
    nPrevT = AbstractThrowingScopeSPI.getEnd();
    ScopeManager.onRequestEnd();
    assertEquals(nPrev + 1, AbstractScopeSPI.getEnd());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getEnd());

    // End session scope
    nPrev = AbstractScopeSPI.getEnd();
    nPrevT = AbstractThrowingScopeSPI.getEnd();
    ScopeManager.destroySessionScope(aSessionScope);
    assertEquals(nPrev + 1, AbstractScopeSPI.getEnd());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getEnd());

    // End global scope and application scopes
    nPrev = AbstractScopeSPI.getEnd();
    nPrevT = AbstractThrowingScopeSPI.getEnd();
    ScopeManager.onGlobalEnd();
    assertEquals(nPrev + 3, AbstractScopeSPI.getEnd());
    assertEquals(nPrevT + 3, AbstractThrowingScopeSPI.getEnd());
  }
예제 #3
0
  @Test
  public void testGlobalScope() {
    // Create global scope only
    int nPrev = AbstractScopeSPI.getBegin();
    int nPrevT = AbstractThrowingScopeSPI.getBegin();
    ScopeManager.onGlobalBegin("global");
    assertEquals(nPrev + 1, AbstractScopeSPI.getBegin());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getBegin());

    // End global scope
    nPrev = AbstractScopeSPI.getEnd();
    nPrevT = AbstractThrowingScopeSPI.getEnd();
    ScopeManager.onGlobalEnd();
    assertEquals(nPrev + 1, AbstractScopeSPI.getEnd());
    assertEquals(nPrevT + 1, AbstractThrowingScopeSPI.getEnd());
  }