View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.client.bindings.misc;
20  
21  import junit.framework.TestCase;
22  
23  import org.apache.chemistry.opencmis.client.bindings.spi.local.LocalCallContext;
24  import org.apache.chemistry.opencmis.commons.server.CallContext;
25  
26  public class LocalCallContextTest extends TestCase {
27  
28      public void testLocalCallContextSimple() {
29          LocalCallContext lcc = new LocalCallContext("repId", "user", "password");
30  
31          assertEquals(CallContext.BINDING_LOCAL, lcc.getBinding());
32          assertEquals("repId", lcc.getRepositoryId());
33          assertEquals("user", lcc.getUsername());
34          assertEquals("password", lcc.getPassword());
35          assertNull(lcc.get(CallContext.LOCALE_ISO639_LANGUAGE));
36          assertNull(lcc.get(CallContext.LOCALE_ISO3166_COUNTRY));
37          assertNull(lcc.getLocale());
38      }
39  
40      public void testLocalCallContextLang() {
41          LocalCallContext lcc = new LocalCallContext("repId", "user", "password", "de", null);
42  
43          assertEquals(CallContext.BINDING_LOCAL, lcc.getBinding());
44          assertEquals("repId", lcc.getRepositoryId());
45          assertEquals("user", lcc.getUsername());
46          assertEquals("password", lcc.getPassword());
47          assertEquals("de", lcc.get(CallContext.LOCALE_ISO639_LANGUAGE));
48          assertNull(lcc.get(CallContext.LOCALE_ISO3166_COUNTRY));
49          assertEquals("de", lcc.getLocale());
50      }
51  
52      public void testLocalCallContextLangCountry() {
53          LocalCallContext lcc = new LocalCallContext("repId", "user", "password", "de", "ch");
54  
55          assertEquals(CallContext.BINDING_LOCAL, lcc.getBinding());
56          assertEquals("repId", lcc.getRepositoryId());
57          assertEquals("user", lcc.getUsername());
58          assertEquals("password", lcc.getPassword());
59          assertEquals("de", lcc.get(CallContext.LOCALE_ISO639_LANGUAGE));
60          assertEquals("ch", lcc.get(CallContext.LOCALE_ISO3166_COUNTRY));
61          assertEquals("de-ch", lcc.getLocale());
62      }
63  }