Make some changes to MultimapBuilderTest to make it build in GWT (2.5.0-rc1, which Guava is using currently). ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=58497528

Make some changes to MultimapBuilderTest to make it build in GWT (2.5.0-rc1, which Guava is using currently). ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=58497528

АвторColin Decker
КоммитерColin Decker
12 лет назад
Файлов изменено: 3
+94
–5
00caedb
guava-gwt/test-super/.../MultimapBuilderTest.java
0 100644
@@ -0,0 +1,69 @@
/*
 * Copyright (C) 2013 The Guava Authors
 *
 * Licensed 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 com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.MultimapBuilder.MultimapBuilderWithKeys;
import com.google.common.testing.SerializableTester;
import junit.framework.TestCase;
import java.math.RoundingMode;
import java.util.SortedMap;
import java.util.SortedSet;
/**
 * Tests for {@link MultimapBuilder}.
 *
 * @author Louis Wasserman
 */
@GwtCompatible(emulated = true)
public class MultimapBuilderTest extends TestCase {
  public void testGenerics_gwtCompatible() {
    ListMultimap<String, Integer> a =
        MultimapBuilder.hashKeys().arrayListValues().<String, Integer>build();
    SortedSetMultimap<String, Integer> b =
        MultimapBuilder.linkedHashKeys().treeSetValues().<String, Integer>build();
    SetMultimap<String, Integer> c = MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER)
        .hashSetValues().<String, Integer>build();
  }
  public void testTreeKeys_gwtCompatible() {
    ListMultimap<String, Integer> multimap =
        MultimapBuilder.treeKeys().arrayListValues().<String, Integer>build();
    assertTrue(multimap.keySet() instanceof SortedSet);
    assertTrue(multimap.asMap() instanceof SortedMap);
  }
  public void testSerialization() {
    for (MultimapBuilderWithKeys<?> builderWithKeys : ImmutableList.of(
        MultimapBuilder.hashKeys(), MultimapBuilder.linkedHashKeys(), MultimapBuilder.treeKeys(),
        MultimapBuilder.enumKeys(RoundingMode.class))) {
      for (MultimapBuilder<?, ?> builder : ImmutableList.of(
          builderWithKeys.arrayListValues(),
          builderWithKeys.linkedListValues(),
          builderWithKeys.hashSetValues(),
          builderWithKeys.linkedHashSetValues(),
          builderWithKeys.treeSetValues(),
          builderWithKeys.enumSetValues(RoundingMode.class))) {
        SerializableTester.reserializeAndAssert(builder.build());
      }
    }
  }
}
guava-gwt/test/.../MultimapBuilderTest_gwt.java
@@ -18,9 +18,9 @@
@Override public String getModuleName() {
  return "com.google.common.collect.testModule";
}
public void testGenerics() throws Exception {
public void testGenerics_gwtCompatible() throws Exception {
  com.google.common.collect.MultimapBuilderTest testCase = new com.google.common.collect.MultimapBuilderTest();
  testCase.testGenerics();
  testCase.testGenerics_gwtCompatible();
}
public void testSerialization() throws Exception {
@@ -28,8 +28,8 @@
  testCase.testSerialization();
}
public void testTreeKeys() throws Exception {
public void testTreeKeys_gwtCompatible() throws Exception {
  com.google.common.collect.MultimapBuilderTest testCase = new com.google.common.collect.MultimapBuilderTest();
  testCase.testTreeKeys();
  testCase.testTreeKeys_gwtCompatible();
}
}
guava-tests/test/.../MultimapBuilderTest.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.MultimapBuilder.MultimapBuilderWithKeys;
import com.google.common.testing.SerializableTester;
@@ -31,8 +32,10 @@
 *
 * @author Louis Wasserman
 */
@GwtCompatible
@GwtCompatible(emulated = true)
public class MultimapBuilderTest extends TestCase {
  @GwtIncompatible("doesn't build without explicit type parameters on build() methods")
  public void testGenerics() {
    ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build();
    SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build();
@@ -40,12 +43,29 @@
        MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build();
  }
  public void testGenerics_gwtCompatible() {
    ListMultimap<String, Integer> a =
        MultimapBuilder.hashKeys().arrayListValues().<String, Integer>build();
    SortedSetMultimap<String, Integer> b =
        MultimapBuilder.linkedHashKeys().treeSetValues().<String, Integer>build();
    SetMultimap<String, Integer> c = MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER)
        .hashSetValues().<String, Integer>build();
  }
  @GwtIncompatible("doesn't build without explicit type parameters on build() methods")
  public void testTreeKeys() {
    ListMultimap<String, Integer> multimap = MultimapBuilder.treeKeys().arrayListValues().build();
    assertTrue(multimap.keySet() instanceof SortedSet);
    assertTrue(multimap.asMap() instanceof SortedMap);
  }
  public void testTreeKeys_gwtCompatible() {
    ListMultimap<String, Integer> multimap =
        MultimapBuilder.treeKeys().arrayListValues().<String, Integer>build();
    assertTrue(multimap.keySet() instanceof SortedSet);
    assertTrue(multimap.asMap() instanceof SortedMap);
  }
  public void testSerialization() {
    for (MultimapBuilderWithKeys<?> builderWithKeys : ImmutableList.of(
        MultimapBuilder.hashKeys(), MultimapBuilder.linkedHashKeys(), MultimapBuilder.treeKeys(),

Cherry-pick

Команда cherry-pick позволяет выбрать отдельные коммиты из одной ветки и применить их к другой.