1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ide.common.resources.configuration; 18 19 import junit.framework.TestCase; 20 21 public class RegionQualifierTest extends TestCase { 22 23 private RegionQualifier rq; 24 private FolderConfiguration config; 25 26 @Override 27 protected void setUp() throws Exception { 28 super.setUp(); 29 30 rq = new RegionQualifier(); 31 config = new FolderConfiguration(); 32 } 33 34 @Override 35 protected void tearDown() throws Exception { 36 super.tearDown(); 37 rq = null; 38 config = null; 39 } 40 41 public void testCheckAndSet() { 42 assertEquals(true, rq.checkAndSet("rUS", config));//$NON-NLS-1$ 43 assertTrue(config.getRegionQualifier() != null); 44 assertEquals("US", config.getRegionQualifier().getValue()); //$NON-NLS-1$ 45 assertEquals("rUS", config.getRegionQualifier().toString()); //$NON-NLS-1$ 46 } 47 48 public void testFailures() { 49 assertEquals(false, rq.checkAndSet("", config));//$NON-NLS-1$ 50 assertEquals(false, rq.checkAndSet("rus", config));//$NON-NLS-1$ 51 assertEquals(false, rq.checkAndSet("rUSA", config));//$NON-NLS-1$ 52 assertEquals(false, rq.checkAndSet("abc", config));//$NON-NLS-1$ 53 } 54 } 55