Skip to main content
summaryrefslogtreecommitdiffstats
blob: f9c749ca76688dc71927e12c5a2e07fcf1fb4939 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * 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:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.framework.core.server.test.internal.session;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.eclipse.osee.framework.core.enums.StorageState;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.cache.AbstractOseeCache;
import org.eclipse.osee.framework.core.model.cache.IOseeCache;
import org.eclipse.osee.framework.core.model.test.cache.AbstractOseeCacheTest;
import org.eclipse.osee.framework.core.model.test.mocks.MockOseeDataAccessor;
import org.eclipse.osee.framework.core.server.internal.session.Session;
import org.eclipse.osee.framework.core.server.internal.session.SessionCache;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.junit.Assert;
import org.junit.BeforeClass;

/**
 * Test Case for {@link SessionCacheTest}
 * 
 * @author Roberto E. Escobar
 */
public class SessionCacheTest extends AbstractOseeCacheTest<Session> {

   private static AbstractOseeCache<Session> cache;
   private static List<Session> sessionData;

   @BeforeClass
   public static void prepareTestData() throws OseeCoreException {
      sessionData = new ArrayList<Session>();

      SessionDataAccessor accessor = new SessionDataAccessor(sessionData);
      cache = new SessionCache(accessor);
      cache.ensurePopulated();

      Assert.assertTrue(accessor.wasLoaded());
   }

   public SessionCacheTest() {
      super(sessionData, cache);
   }

   private final static class SessionDataAccessor extends MockOseeDataAccessor<Session> {

      private final List<Session> data;

      public SessionDataAccessor(List<Session> data) {
         super();
         this.data = data;
      }

      @Override
      public void load(IOseeCache<Session> cache) throws OseeCoreException {
         super.load(cache);
         int typeId = 100;
         for (int index = 0; index < 10; index++) {

            String guid = GUID.create();
            Session item =
               new Session(guid, guid, "userId", new Date(), "serverX", "clientVersion", "clientMachine",
                  "clientAddress", 4500, new Date(), "Test Data");
            item.setStorageState(StorageState.LOADED);
            data.add(item);
            item.setId(typeId++);
            cache.cache(item);
         }
      }
   }
}

Back to the top