Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/apache/hivemind/schema/rules/TestIdTranslators.java


1   // Copyright 2004, 2005 The Apache Software Foundation
2   //
3   // Licensed under the Apache License, Version 2.0 (the "License");
4   // you may not use this file except in compliance with the License.
5   // You may obtain a copy of the License at
6   //
7   //     http://www.apache.org/licenses/LICENSE-2.0
8   //
9   // Unless required by applicable law or agreed to in writing, software
10  // distributed under the License is distributed on an "AS IS" BASIS,
11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  // See the License for the specific language governing permissions and
13  // limitations under the License.
14  
15  package org.apache.hivemind.schema.rules;
16  
17  import org.apache.hivemind.internal.Module;
18  import org.apache.hivemind.schema.Translator;
19  import org.apache.hivemind.test.HiveMindTestCase;
20  import org.easymock.MockControl;
21  
22  /**
23   * Tests for {@link org.apache.hivemind.schema.rules.QualifiedIdTranslator}
24   * and {@link org.apache.hivemind.schema.rules.IdListTranslator}.
25   *
26   * @author Howard Lewis Ship
27   */
28  public class TestIdTranslators extends HiveMindTestCase
29  {
30      public void testNullId()
31      {
32          Translator t = new QualifiedIdTranslator();
33  
34          assertNull(t.translate(null, null, null, null));
35      }
36  
37      private Module getModule()
38      {
39          MockControl c = newControl(Module.class);
40          Module result = (Module) c.getMock();
41  
42          result.getModuleId();
43          c.setReturnValue("foo.bar");
44  
45          return result;
46      }
47  
48      public void testNonNullId()
49      {
50          Module m = getModule();
51  
52          replayControls();
53  
54          Translator t = new QualifiedIdTranslator();
55  
56          assertEquals("foo.bar.Baz", t.translate(m, null, "Baz", null));
57  
58          verifyControls();
59      }
60  
61      public void testNullList()
62      {
63          Translator t = new IdListTranslator();
64  
65          assertEquals(null, t.translate(null, null, null, null));
66      }
67  
68      public void testNonNullList()
69      {
70          Module m = getModule();
71  
72          replayControls();
73  
74          Translator t = new IdListTranslator();
75  
76          assertEquals("foo.bar.Baz,zip.Zap", t.translate(m, null, "Baz,zip.Zap", null));
77  
78          verifyControls();
79      }
80  }