Added Tests for BidiSubstituter
-------------------------------

                 Key: SHINDIG-262
                 URL: https://issues.apache.org/jira/browse/SHINDIG-262
             Project: Shindig
          Issue Type: Improvement
          Components: Common Components (Java)
         Environment: Place in test folder in org.apache.shindig.gadgets package
            Reporter: Ralph Jocham


/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
package org.apache.shindig.gadgets;

import junit.framework.TestCase;

public class BidiSubstituterTest extends TestCase {

  private static final String REVERSE_DIR = "REVERSE_DIR";
  private static final String START_EDGE = "START_EDGE";
  private static final String END_EDGE = "END_EDGE";
  private static final String DIR = "DIR";
  private static final String LTR = "ltr";
  private static final String RIGHT = "right";
  private static final String LEFT = "left";
  private static final String RTL = "rtl";

  private Substitutions substitions;

  @Override
  public void setUp() {
    substitions = new Substitutions();
  }

  public void testBidiWithRtl() {
    BidiSubstituter.addSubstitutions(substitions, RTL);

    assertSubstitutions(substitions,
                        new String[][] {{LTR, REVERSE_DIR}, {RIGHT,  
START_EDGE},
                                        {LEFT, END_EDGE}, {RTL, DIR}});
  }

  public void testBidiWithLtr() {
    BidiSubstituter.addSubstitutions(substitions, LTR);

    assertSubstitutions(substitions,
                        new String[][] {{RTL, REVERSE_DIR}, {LEFT,  START_EDGE},
                                        {RIGHT, END_EDGE}, {LTR, DIR}});
  }

  public void testBidiWithEmpty() {
    BidiSubstituter.addSubstitutions(substitions, "");

    assertSubstitutions(substitions,
                        new String[][] {{LTR, REVERSE_DIR}, {RIGHT,  
START_EDGE},
                                        {LEFT, END_EDGE}, {RTL, DIR}});
  }

  public void testBidiWithNull() {
    BidiSubstituter.addSubstitutions(substitions, null);

    assertSubstitutions(substitions,
                        new String[][] {{LTR, REVERSE_DIR}, {RIGHT,  
START_EDGE},
                                        {LEFT, END_EDGE}, {RTL, DIR}});
  }

  private void assertSubstitutions(Substitutions substitutions, String[][] 
mappings) {
    for (String[] mapping : mappings) {
      assertEquals(mapping[0], 
substitutions.getSubstitution(Substitutions.Type.BIDI, mapping[1]));
    }
  }
}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to