1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.id.uuid.state;
19  
20  import junit.framework.TestCase;
21  
22  /**
23   * Unit tests for {@link InMemoryStateImpl}.
24   *
25   * @version $Revision: 480488 $ $Date: 2006-11-29 08:57:26 +0000 (Wed, 29 Nov 2006) $
26   * @author Commons-Id team
27   */
28  public class InMemoryStateImplTest extends TestCase {
29  
30      protected void setUp() throws Exception {
31          super.setUp();
32      }
33  
34      protected void tearDown() throws Exception {
35          super.tearDown();
36      }
37  
38      /**
39       * <p>Test the InMemoryStateImpl constructor.</p>
40       */
41      public void testInMemoryStateImpl() {
42          InMemoryStateImpl impl = new InMemoryStateImpl();
43          assertNotNull(impl);
44      }
45  
46      /**
47       * <p>Test the void load method.</p>
48       *
49       * @throws Exception a test exception.
50       */
51      public void testLoad() throws Exception {
52          InMemoryStateImpl impl = new InMemoryStateImpl();
53          impl.load();
54          assertEquals(1, impl.getNodes().size());
55      }
56  
57      /**
58       * <p>Test the void load method.</p>
59       */
60      public void testGetSynchInterval() {
61          InMemoryStateImpl impl = new InMemoryStateImpl();
62          assertEquals(impl.getSynchInterval(), Long.MAX_VALUE);
63      }
64  
65      /**
66       * <p>Test the Set getNodes method.</p>
67       */
68      public void testGetNodes() {
69          InMemoryStateImpl impl = new InMemoryStateImpl();
70          impl.load();
71          assertNotNull(impl.getNodes());
72      }
73  
74      /**
75       * <p>Test the void store method.</p>
76       */
77      public void testStore() {
78          // No operation, just make sure no exception is raised
79          InMemoryStateImpl impl = new InMemoryStateImpl();
80          impl.load();
81          impl.store(impl.getNodes());
82          impl.store(impl.getNodes(), 100L);
83      }
84  }