提交 1b7c4295 编写于 作者: S Sam Judd

Remove deprecated ExpectedException calls.

上级 d2d5c4e4
......@@ -13,6 +13,7 @@ dependencies {
// build.gradle file.
testImplementation project(':glide')
testImplementation project(':annotation:compiler')
testImplementation "junit:junit:${JUNIT_VERSION}"
testImplementation "com.squareup:javapoet:${JAVAPOET_VERSION}"
testImplementation "com.google.auto.service:auto-service:${AUTO_SERVICE_VERSION}"
testImplementation "com.google.code.findbugs:jsr305:${JSR_305_VERSION}"
......
......@@ -2,27 +2,29 @@ package com.bumptech.glide.annotation.compiler;
import static com.google.testing.compile.CompilationSubject.assertThat;
import static com.google.testing.compile.Compiler.javac;
import static org.junit.Assert.assertThrows;
import com.google.testing.compile.Compilation;
import com.google.testing.compile.JavaFileObjects;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.function.ThrowingRunnable;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Tests AppGlideModules with invalid usages of the @Excludes annotation.
*/
// Ignore warnings since most methods use ExpectedException
// Ignore warnings since most methods use assertThrows
@SuppressWarnings("ResultOfMethodCallIgnored")
@RunWith(JUnit4.class)
public class InvalidAppGlideModuleWithExcludesTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Test
public void compilation_withMissingExcludedModuleClass_throws() {
expectedException.expect(RuntimeException.class);
assertThrows(
RuntimeException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
javac()
.withProcessors(new GlideAnnotationProcessor())
.compile(
......@@ -37,6 +39,8 @@ public class InvalidAppGlideModuleWithExcludesTest {
"@Excludes(EmptyLibraryModule.class)",
"public final class AppModuleWithExcludes extends AppGlideModule {}"));
}
});
}
@Test
public void compilation_withEmptyExcludes_fails() {
......
......@@ -8,21 +8,17 @@ import static org.junit.Assert.fail;
import com.google.common.truth.Truth;
import com.google.testing.compile.Compilation;
import com.google.testing.compile.JavaFileObjects;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Checks assertions on {@link com.bumptech.glide.annotation.GlideExtension}s themselves.
*/
// Avoid warnings when using ExpectedException.
// Avoid warnings when asserting on exceptions.
@SuppressWarnings("ResultOfMethodCallIgnored")
@RunWith(JUnit4.class)
public class InvalidGlideExtensionTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Test
public void compilation_withPublicConstructor_fails() {
try {
......
......@@ -3,14 +3,14 @@ package com.bumptech.glide.annotation.compiler;
import static com.bumptech.glide.annotation.compiler.test.Util.emptyAppModule;
import static com.google.testing.compile.CompilationSubject.assertThat;
import static com.google.testing.compile.Compiler.javac;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;
import com.google.common.truth.Truth;
import com.google.testing.compile.Compilation;
import com.google.testing.compile.JavaFileObjects;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.function.ThrowingRunnable;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
......@@ -18,15 +18,17 @@ import org.junit.runners.JUnit4;
* Checks assertions on {@link com.bumptech.glide.annotation.GlideExtension}s for methods annotated
* with {@link com.bumptech.glide.annotation.GlideOption}.
*/
// Ignore warnings since most methods use ExpectedException
// Ignore warnings since most methods use assertThrows.
@SuppressWarnings("ResultOfMethodCallIgnored")
@RunWith(JUnit4.class)
public class InvalidGlideOptionsExtensionTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Test
public void compilation_withAnnotatedNonStaticMethod_fails() {
expectedException.expect(RuntimeException.class);
assertThrows(
RuntimeException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
javac()
.withProcessors(new GlideAnnotationProcessor())
.compile(
......@@ -43,6 +45,8 @@ public class InvalidGlideOptionsExtensionTest {
" public void doSomething() {}",
"}"));
}
});
}
@Test
public void compilation_withAnnotatedStaticMethod_withRequestOptionsArgInWrongOrder_fails() {
......@@ -118,7 +122,11 @@ public class InvalidGlideOptionsExtensionTest {
@Test
public void compilation_overridingOptionWithoutAnnotationType_fails() {
expectedException.expect(RuntimeException.class);
assertThrows(
RuntimeException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
javac()
.withProcessors(new GlideAnnotationProcessor())
.compile(
......@@ -135,11 +143,18 @@ public class InvalidGlideOptionsExtensionTest {
" @GlideOption",
" public static void centerCrop(RequestOptions options) {}",
"}"));
}
});
}
@Test
public void compilation_withOverrideExtend_butNotOverridingMethod_fails() {
expectedException.expect(RuntimeException.class);
assertThrows(
RuntimeException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
javac()
.withProcessors(new GlideAnnotationProcessor())
.compile(
......@@ -157,6 +172,8 @@ public class InvalidGlideOptionsExtensionTest {
" public static void something(RequestOptions options) {}",
"}"));
}
});
}
@Test
public void compilation_withOverrideExtend_andOverridingMethod_succeeds() {
......@@ -182,7 +199,11 @@ public class InvalidGlideOptionsExtensionTest {
@Test
public void compilation_withOverrideReplace_butNotOverridingMethod_fails() {
expectedException.expect(RuntimeException.class);
assertThrows(
RuntimeException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
javac()
.withProcessors(new GlideAnnotationProcessor())
.compile(
......@@ -200,6 +221,8 @@ public class InvalidGlideOptionsExtensionTest {
" public static void something(RequestOptions options) {}",
"}"));
}
});
}
@Test
public void compilation_withOverrideReplace_andOverridingMethod_succeeds() {
......
......@@ -5,15 +5,15 @@ import static com.bumptech.glide.annotation.compiler.test.Util.emptyAppModule;
import static com.bumptech.glide.annotation.compiler.test.Util.subpackage;
import static com.google.testing.compile.CompilationSubject.assertThat;
import static com.google.testing.compile.Compiler.javac;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;
import com.google.common.truth.Truth;
import com.google.testing.compile.Compilation;
import com.google.testing.compile.JavaFileObjects;
import java.io.IOException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.function.ThrowingRunnable;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
......@@ -21,15 +21,18 @@ import org.junit.runners.JUnit4;
* Checks assertions on {@link com.bumptech.glide.annotation.GlideExtension}s for methods annotated
* with {@link com.bumptech.glide.annotation.GlideType}.
*/
// Ignore warnings since most methods use ExpectedException
// Ignore warnings since most methods use assertThrows.
@SuppressWarnings("ResultOfMethodCallIgnored")
@RunWith(JUnit4.class)
public class InvalidGlideTypeExtensionTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Test
public void compilation_withAnnotatedNonStaticMethod_fails() {
expectedException.expectMessage("@GlideType methods must be static");
assertThrows(
"@GlideType methods must be static",
RuntimeException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
javac()
.withProcessors(new GlideAnnotationProcessor())
.compile(
......@@ -46,14 +49,19 @@ public class InvalidGlideTypeExtensionTest {
" public void doSomething() {}",
"}"));
}
});
}
@Test
public void compilation_withAnnotatedStaticMethod_withoutRequestBuilderArg_fails() {
expectedException
.expectMessage(
assertThrows(
"@GlideType methods must take a RequestBuilder object as their first and only"
+ " parameter, but given multiple for:"
+ " com.bumptech.glide.test.Extension#doSomething()");
+ " com.bumptech.glide.test.Extension#doSomething()",
RuntimeException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
javac()
.withProcessors(new GlideAnnotationProcessor())
.compile(
......@@ -70,6 +78,8 @@ public class InvalidGlideTypeExtensionTest {
" public static void doSomething() {}",
"}"));
}
});
}
@Test
public void compilation_withAnnotatedStaticMethod_withRequestBuilderArg_succeeds() {
......@@ -121,13 +131,16 @@ public class InvalidGlideTypeExtensionTest {
@Test
public void compilation_withAnnotatedStaticMethod_withRequestBuilderArgAndOtherArg_fails() {
expectedException
.expectMessage(
assertThrows(
"@GlideType methods must take a RequestBuilder object as their first and only"
+ " parameter, but given multiple for:"
+ " com.bumptech.glide.test.Extension#type("
+ "com.bumptech.glide.RequestBuilder<java.lang.Number>,"
+ "java.lang.Object)");
+ "java.lang.Object)",
RuntimeException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
javac()
.withProcessors(new GlideAnnotationProcessor())
.compile(
......@@ -145,11 +158,13 @@ public class InvalidGlideTypeExtensionTest {
" public static void type(RequestBuilder<Number> builder, Object arg2) {}",
"}"));
}
});
}
@Test
public void compilation_withAnnotatedStaticMethod_overridingExistingType_fails()
throws IOException {
Compilation compilation =
final Compilation compilation =
javac()
.withProcessors(new GlideAnnotationProcessor())
.compile(
......@@ -167,12 +182,18 @@ public class InvalidGlideTypeExtensionTest {
" @GlideType(Drawable.class)",
" public static void asDrawable(RequestBuilder<Drawable> builder) {}",
"}"));
expectedException
.expectMessage(
assertThrows(
"error: method asDrawable() is already defined in class"
+ " com.bumptech.glide.test.GlideRequests");
+ " com.bumptech.glide.test.GlideRequests",
RuntimeException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
compilation.generatedSourceFile(subpackage("GlideRequests"));
}
});
}
@Test
public void compilation_withAnnotatedStaticMethod_returningRequestBuilder_succeeds() {
......@@ -266,11 +287,15 @@ public class InvalidGlideTypeExtensionTest {
@Test
public void compilation_withAnnotatedStaticMethod_returningBuilder_andMultipleParams_fails() {
expectedException.expectMessage(
assertThrows(
"@GlideType methods must take a RequestBuilder object as their first and only parameter,"
+ " but given multiple for:"
+ " com.bumptech.glide.test.Extension#asNumber("
+ "com.bumptech.glide.RequestBuilder<java.lang.Number>,java.lang.Object)");
+ "com.bumptech.glide.RequestBuilder<java.lang.Number>,java.lang.Object)",
RuntimeException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
javac()
.withProcessors(new GlideAnnotationProcessor())
.compile(
......@@ -291,6 +316,8 @@ public class InvalidGlideTypeExtensionTest {
" }",
"}"));
}
});
}
@Test
public void compilation_withAnnotatedStaticMethod_returningBuilder_nonBuilderParam_fails() {
......
......@@ -2,6 +2,7 @@ package com.bumptech.glide.annotation.compiler;
import static com.google.testing.compile.CompilationSubject.assertThat;
import static com.google.testing.compile.Compiler.javac;
import static org.junit.Assert.assertThrows;
import com.bumptech.glide.annotation.compiler.test.RegenerateResourcesRule;
import com.bumptech.glide.annotation.compiler.test.Util;
......@@ -9,7 +10,7 @@ import com.google.testing.compile.Compilation;
import javax.tools.JavaFileObject;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.function.ThrowingRunnable;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
......@@ -23,17 +24,22 @@ public class MultipleAppGlideModuleTest {
private static final String SECOND_MODULE = "EmptyAppModule2.java";
@Rule public final RegenerateResourcesRule regenerateResourcesRule =
new RegenerateResourcesRule(getClass());
@Rule public final ExpectedException expectedException = ExpectedException.none();
// Throws.
@SuppressWarnings("ResultOfMethodCallIgnored")
@Test
public void compilation_withTwoAppModules_fails() {
expectedException.expect(RuntimeException.class);
assertThrows(
RuntimeException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
javac()
.withProcessors(new GlideAnnotationProcessor())
.compile(forResource(FIRST_MODULE), forResource(SECOND_MODULE));
}
});
}
@Test
public void compilation_withFirstModuleOnly_succeeds() {
......
......@@ -14,7 +14,6 @@ import javax.tools.JavaFileObject;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
......@@ -25,7 +24,6 @@ import org.junit.runners.JUnit4;
public class MultipleEmptyLibraryGlideModuleTest {
@Rule public final RegenerateResourcesRule regenerateResourcesRule =
new RegenerateResourcesRule(getClass());
@Rule public final ExpectedException expectedException = ExpectedException.none();
private Compilation compilation;
@Before
......
......@@ -17,7 +17,6 @@ import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
......@@ -27,7 +26,6 @@ import org.junit.runner.RunWith;
@RegressionTest
public class CenterInsideRegressionTest {
@Rule public final TestName testName = new TestName();
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final TearDownGlide tearDownGlide = new TearDownGlide();
private BitmapRegressionTester bitmapRegressionTester;
private Context context;
......
......@@ -17,7 +17,6 @@ import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
......@@ -27,7 +26,6 @@ import org.junit.runner.RunWith;
@RegressionTest
public class CircleCropRegressionTest {
@Rule public final TestName testName = new TestName();
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final TearDownGlide tearDownGlide = new TearDownGlide();
private BitmapRegressionTester bitmapRegressionTester;
private Context context;
......
package com.bumptech.glide;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
......@@ -22,15 +23,12 @@ import com.bumptech.glide.test.GlideApp;
import java.util.concurrent.ExecutionException;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.function.ThrowingRunnable;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class DrawableTransformationTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
private Context context;
@Before
......@@ -117,9 +115,13 @@ public class DrawableTransformationTest {
@Test
public void load_withColorDrawable_sizeOriginal_requiredTransform_fails()
throws ExecutionException, InterruptedException {
Drawable colorDrawable = new ColorDrawable(Color.RED);
final Drawable colorDrawable = new ColorDrawable(Color.RED);
expectedException.expect(ExecutionException.class);
assertThrows(
ExecutionException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
Glide.with(context)
.load(colorDrawable)
.apply(new RequestOptions()
......@@ -127,6 +129,8 @@ public class DrawableTransformationTest {
.submit()
.get();
}
});
}
@Test
public void load_withBitmapDrawable_andDoNothingTransformation_doesNotRecycleBitmap()
......
package com.bumptech.glide;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import android.content.Context;
import android.graphics.Bitmap;
......@@ -17,7 +18,7 @@ import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.function.ThrowingRunnable;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
......@@ -27,7 +28,6 @@ import org.junit.runner.RunWith;
@RegressionTest
public class FitCenterRegressionTest {
@Rule public final TestName testName = new TestName();
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final TearDownGlide tearDownGlide = new TearDownGlide();
private BitmapRegressionTester bitmapRegressionTester;
private Context context;
......@@ -108,9 +108,14 @@ public class FitCenterRegressionTest {
public void fitCenter_withHugeRectangle_throwsOOM()
throws ExecutionException, InterruptedException {
float multiplier = Integer.MAX_VALUE / (canonical.getWidth() * canonical.getHeight() * 2);
int overrideWidth = (int) multiplier * canonical.getWidth();
int overrideHeight = (int) multiplier * canonical.getHeight();
expectedException.expect(ExecutionException.class);
final int overrideWidth = (int) multiplier * canonical.getWidth();
final int overrideHeight = (int) multiplier * canonical.getHeight();
assertThrows(
ExecutionException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
GlideApp
.with(context)
.asBitmap()
......@@ -120,4 +125,6 @@ public class FitCenterRegressionTest {
.submit()
.get();
}
});
}
}
......@@ -3,6 +3,7 @@ package com.bumptech.glide;
import static com.bumptech.glide.request.RequestOptions.bitmapTransform;
import static com.bumptech.glide.request.RequestOptions.centerCropTransform;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import android.content.ContentResolver;
import android.content.Context;
......@@ -27,7 +28,7 @@ import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.function.ThrowingRunnable;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
......@@ -36,7 +37,6 @@ import org.mockito.MockitoAnnotations;
public class NonBitmapDrawableResourcesTest {
@Rule public final TestName testName = new TestName();
@Rule public final TearDownGlide tearDownGlide = new TearDownGlide();
@Rule public final ExpectedException expectedException = ExpectedException.none();
private Context context;
......@@ -123,12 +123,19 @@ public class NonBitmapDrawableResourcesTest {
@Test
public void load_withShapeDrawableResourceId_asDrawable_withTransformation_sizeOriginal_fails()
throws ExecutionException, InterruptedException {
expectedException.expect(ExecutionException.class);
assertThrows(
ExecutionException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
Glide.with(context)
.load(ResourceIds.drawable.shape_drawable)
.apply(centerCropTransform())
.submit()
.get();
}
});
}
@Test
......@@ -147,13 +154,19 @@ public class NonBitmapDrawableResourcesTest {
@Test
public void load_withShapeDrawableResourceId_asBitmap_withSizeOriginal_fails()
throws ExecutionException, InterruptedException {
expectedException.expect(ExecutionException.class);
assertThrows(
ExecutionException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
Glide.with(context)
.asBitmap()
.load(ResourceIds.drawable.shape_drawable)
.submit()
.get();
}
});
}
@Test
public void load_withShapeDrawableResourceId_asBitmap_withValidSize_returnsNonNullBitmap()
......
package com.bumptech.glide.load.engine;
import static org.junit.Assert.assertThrows;
import android.support.annotation.NonNull;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.Option;
......@@ -12,9 +14,8 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.function.ThrowingRunnable;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
......@@ -24,7 +25,6 @@ import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 18)
public class EngineKeyTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Mock private Transformation<Object> transformation;
@Before
......@@ -35,7 +35,7 @@ public class EngineKeyTest {
@Test
public void updateDiskCacheKey_throwsException() throws NoSuchAlgorithmException {
// If this test fails, update testEqualsAndHashcode to use KeyTester including regression tests.
EngineKey key = new EngineKey(
final EngineKey key = new EngineKey(
"id",
new ObjectKey("signature"),
100,
......@@ -44,9 +44,15 @@ public class EngineKeyTest {
Object.class,
Object.class,
new Options());
expectedException.expect(UnsupportedOperationException.class);
assertThrows(
UnsupportedOperationException.class,
new ThrowingRunnable() {
@Override
public void run() throws NoSuchAlgorithmException {
key.updateDiskCacheKey(MessageDigest.getInstance("SHA-1"));
}
});
}
@Test
public void testEqualsAndHashCode() {
......
package com.bumptech.glide.load.model;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
......@@ -13,9 +14,8 @@ import com.bumptech.glide.util.pool.FactoryPools;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.function.ThrowingRunnable;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
......@@ -28,8 +28,6 @@ import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 18)
public class MultiModelLoaderFactoryTest {
@Rule public final ExpectedException exception = ExpectedException.none();
@Mock private ModelLoaderFactory<String, String> firstFactory;
@Mock private ModelLoader<String, String> firstModelLoader;
@Mock private MultiModelLoaderFactory.Factory multiModelLoaderFactory;
......@@ -183,17 +181,29 @@ public class MultiModelLoaderFactoryTest {
public void testBuild_withModelAndDataClasses_excludesModelLoadersForOtherDataClasses() {
multiFactory.append(String.class, String.class, firstFactory);
exception.expect(NoModelLoaderAvailableException.class);
assertThrows(
NoModelLoaderAvailableException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
multiFactory.build(String.class, Integer.class);
}
});
}
@Test
public void testBuild_withModelAndDataClasses_excludesModelLoadersForOtherModelClasses() {
multiFactory.append(String.class, String.class, firstFactory);
exception.expect(NoModelLoaderAvailableException.class);
assertThrows(
NoModelLoaderAvailableException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
multiFactory.build(Integer.class, String.class);
}
});
}
@Test
public void testBuild_withModelClass_doesNotMatchSubclassesOfModelClass() {
......@@ -212,16 +222,29 @@ public class MultiModelLoaderFactoryTest {
@Test
public void testBuild_withModelAndDataClass_doesNotMatchSubclassesOfModelClass() {
appendFactoryFor(String.class, Object.class);
exception.expect(NoModelLoaderAvailableException.class);
assertThrows(
NoModelLoaderAvailableException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
multiFactory.build(Object.class, Object.class);
}
});
}
@Test
public void testBuild_withModelAndDataClass_doesNotMatchSubclassesOfDataClass() {
appendFactoryFor(Object.class, String.class);
exception.expect(NoModelLoaderAvailableException.class);
assertThrows(
NoModelLoaderAvailableException.class,
new ThrowingRunnable() {
@Override
public void run() throws Throwable {
multiFactory.build(Object.class, Object.class);
}
});
}
@Test
public void testBuild_withModelAndDataClass_doesMatchSuperclassesOfModelClass() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册