Here are the examples of the java api org.springframework.core.ResolvableType.forClass() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
228 Examples
19
View Source File : AbstractJsonMarshalTesterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void createWhenResourceLoadClreplacedIsNullShouldThrowException() {
replacedertThatIllegalArgumentException().isThrownBy(() -> createTester(null, ResolvableType.forClreplaced(ExampleObject.clreplaced))).withMessageContaining("ResourceLoadClreplaced must not be null");
}
19
View Source File : BeanTypeRegistry.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
private ResolvableType getTypeFromAttribute(Object attribute) throws ClreplacedNotFoundException, LinkageError {
if (attribute instanceof Clreplaced<?>) {
return ResolvableType.forClreplaced((Clreplaced<?>) attribute);
}
if (attribute instanceof String) {
return ResolvableType.forClreplaced(ClreplacedUtils.forName((String) attribute, null));
}
return null;
}
19
View Source File : BeanTypeRegistry.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
private ResolvableType getDirectFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory, BeanDefinition definition) throws ClreplacedNotFoundException, LinkageError {
Clreplaced<?> factoryBeanClreplaced = ClreplacedUtils.forName(definition.getBeanClreplacedName(), beanFactory.getBeanClreplacedLoader());
return getFactoryBeanType(definition, ResolvableType.forClreplaced(factoryBeanClreplaced));
}
19
View Source File : RequestPredicateFactory.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
private boolean producesResource(Method method) {
if (Resource.clreplaced.equals(method.getReturnType())) {
return true;
}
if (WebEndpointResponse.clreplaced.isreplacedignableFrom(method.getReturnType())) {
ResolvableType returnType = ResolvableType.forMethodReturnType(method);
if (ResolvableType.forClreplaced(Resource.clreplaced).isreplacedignableFrom(returnType.getGeneric(0))) {
return true;
}
}
return false;
}
19
View Source File : MapBinderTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
private <K, V> Bindable<Map<K, V>> getMapBindable(Clreplaced<K> keyGeneric, ResolvableType valueType) {
ResolvableType keyType = ResolvableType.forClreplaced(keyGeneric);
return Bindable.of(ResolvableType.forClreplacedWithGenerics(Map.clreplaced, keyType, valueType));
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void canConvertWhenHasDefaultEditorShouldReturnTrue() {
BindConverter bindConverter = getPropertyEditorOnlyBindConverter(null);
replacedertThat(bindConverter.canConvert("java.lang.RuntimeException", ResolvableType.forClreplaced(Clreplaced.clreplaced))).isTrue();
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void convertWhenConversionServiceCanConvertShouldConvert() {
BindConverter bindConverter = getBindConverter(new SampleTypeConverter());
SampleType converted = bindConverter.convert("test", ResolvableType.forClreplaced(SampleType.clreplaced));
replacedertThat(converted.getText()).isEqualTo("test");
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void convertWhenNotPropertyEditorAndConversionServiceCannotConvertShouldThrowException() {
BindConverter bindConverter = BindConverter.get(ApplicationConversionService.getSharedInstance(), null);
replacedertThatExceptionOfType(ConverterNotFoundException.clreplaced).isThrownBy(() -> bindConverter.convert("test", ResolvableType.forClreplaced(SampleType.clreplaced)));
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void canConvertWhenNotPropertyEditorAndConversionServiceCannotConvertShouldReturnFalse() {
BindConverter bindConverter = BindConverter.get(ApplicationConversionService.getSharedInstance(), null);
replacedertThat(bindConverter.canConvert("test", ResolvableType.forClreplaced(SampleType.clreplaced))).isFalse();
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void convertWhenHasDefaultEditorShouldConvert() {
BindConverter bindConverter = getPropertyEditorOnlyBindConverter(null);
Clreplaced<?> converted = bindConverter.convert("java.lang.RuntimeException", ResolvableType.forClreplaced(Clreplaced.clreplaced));
replacedertThat(converted).isEqualTo(RuntimeException.clreplaced);
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void canConvertWhenHasEditorForArrayElementShouldReturnTrue() {
BindConverter bindConverter = getPropertyEditorOnlyBindConverter(this::registerSampleTypeEditor);
replacedertThat(bindConverter.canConvert("test", ResolvableType.forClreplaced(SampleType[].clreplaced))).isTrue();
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void canConvertWhenConversionServiceCanConvertShouldReturnTrue() {
BindConverter bindConverter = getBindConverter(new SampleTypeConverter());
replacedertThat(bindConverter.canConvert("test", ResolvableType.forClreplaced(SampleType.clreplaced))).isTrue();
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void convertWhenConvertingToFileShouldExcludeFileEditor() {
// For back compatibility we want true file conversion and not an accidental
// clreplacedpath resource reference. See gh-12163
BindConverter bindConverter = BindConverter.get(new GenericConversionService(), null);
File result = bindConverter.convert(".", ResolvableType.forClreplaced(File.clreplaced));
replacedertThat(result.getPath()).isEqualTo(".");
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void convertWhenHasEditorByConventionShouldConvert() {
BindConverter bindConverter = getPropertyEditorOnlyBindConverter(null);
ConventionType converted = bindConverter.convert("test", ResolvableType.forClreplaced(ConventionType.clreplaced));
replacedertThat(converted.getText()).isEqualTo("test");
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void canConvertWhenHasCustomEditorShouldReturnTrue() {
BindConverter bindConverter = getPropertyEditorOnlyBindConverter(this::registerSampleTypeEditor);
replacedertThat(bindConverter.canConvert("test", ResolvableType.forClreplaced(SampleType.clreplaced))).isTrue();
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void convertWhenHasCustomEditorShouldConvert() {
BindConverter bindConverter = getPropertyEditorOnlyBindConverter(this::registerSampleTypeEditor);
SampleType converted = bindConverter.convert("test", ResolvableType.forClreplaced(SampleType.clreplaced));
replacedertThat(converted.getText()).isEqualTo("test");
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void convertWhenHasEditorForArrayElementShouldConvert() {
BindConverter bindConverter = getPropertyEditorOnlyBindConverter(this::registerSampleTypeEditor);
SampleType[] converted = bindConverter.convert("test", ResolvableType.forClreplaced(SampleType[].clreplaced));
replacedertThat(converted).isNotEmpty();
replacedertThat(converted[0].getText()).isEqualTo("test");
}
19
View Source File : BindConverterTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void canConvertWhenHasEditorByConventionShouldReturnTrue() {
BindConverter bindConverter = getPropertyEditorOnlyBindConverter(null);
replacedertThat(bindConverter.canConvert("test", ResolvableType.forClreplaced(ConventionType.clreplaced))).isTrue();
}
19
View Source File : BindableTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void ofTypeWithExistingValueShouldSetTypeAndExistingValue() {
replacedertThat(Bindable.of(ResolvableType.forClreplaced(String.clreplaced)).withExistingValue("foo").getValue().get()).isEqualTo("foo");
}
19
View Source File : BindableTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void ofInstanceShouldSetTypeAndExistingValue() {
String instance = "foo";
ResolvableType type = ResolvableType.forClreplaced(String.clreplaced);
replacedertThat(Bindable.ofInstance(instance).getType()).isEqualTo(type);
replacedertThat(Bindable.ofInstance(instance).getValue().get()).isEqualTo("foo");
}
19
View Source File : BindableTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void ofTypeShouldSetType() {
ResolvableType type = ResolvableType.forClreplaced(String.clreplaced);
replacedertThat(Bindable.of(type).getType()).isEqualTo(type);
}
19
View Source File : BindableTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void getBoxedTypeWhenNotBoxedShouldReturnType() {
Bindable<String> bindable = Bindable.of(String.clreplaced);
replacedertThat(bindable.getBoxedType()).isEqualTo(ResolvableType.forClreplaced(String.clreplaced));
}
19
View Source File : BindableTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void ofTypeWhenPrimitiveWithExistingValueWrapperShouldNotThrowException() {
Bindable<Integer> bindable = Bindable.<Integer>of(ResolvableType.forClreplaced(int.clreplaced)).withExistingValue(123);
replacedertThat(bindable.getType().resolve()).isEqualTo(int.clreplaced);
replacedertThat(bindable.getValue().get()).isEqualTo(123);
}
19
View Source File : BindableTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void ofClreplacedShouldSetType() {
replacedertThat(Bindable.of(String.clreplaced).getType()).isEqualTo(ResolvableType.forClreplaced(String.clreplaced));
}
19
View Source File : BindableTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void ofTypeWhenExistingValueIsNotInstanceOfTypeShouldThrowException() {
replacedertThatIllegalArgumentException().isThrownBy(() -> Bindable.of(ResolvableType.forClreplaced(String.clreplaced)).withExistingValue(123)).withMessageContaining("ExistingValue must be an instance of " + String.clreplaced.getName());
}
19
View Source File : BindableTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void getBoxedTypeWhenPrimitiveArrayShouldReturnBoxedType() {
Bindable<int[]> bindable = Bindable.of(int[].clreplaced);
replacedertThat(bindable.getType().getComponentType()).isEqualTo(ResolvableType.forClreplaced(int.clreplaced));
replacedertThat(bindable.getBoxedType().isArray()).isTrue();
replacedertThat(bindable.getBoxedType().getComponentType()).isEqualTo(ResolvableType.forClreplaced(Integer.clreplaced));
}
19
View Source File : BindableTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void getBoxedTypeWhenPrimitiveShouldReturnBoxedType() {
Bindable<Integer> bindable = Bindable.of(int.clreplaced);
replacedertThat(bindable.getType()).isEqualTo(ResolvableType.forClreplaced(int.clreplaced));
replacedertThat(bindable.getBoxedType()).isEqualTo(ResolvableType.forClreplaced(Integer.clreplaced));
}
19
View Source File : ConfigurationPropertiesBindingPostProcessor.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
private ResolvableType getBeanType(Object bean, String beanName) {
// 首先获取有没有工厂方法
Method factoryMethod = this.beanFactoryMetadata.findFactoryMethod(beanName);
// 若有工厂方法
if (factoryMethod != null) {
return ResolvableType.forMethodReturnType(factoryMethod);
}
// 没有工厂方法,则说明是普通的配置类
return ResolvableType.forClreplaced(bean.getClreplaced());
}
19
View Source File : Bindable.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
/**
* Create a new {@link Bindable} of the specified type.
* @param <T> the source type
* @param type the type (must not be {@code null})
* @return a {@link Bindable} instance
* @see #of(ResolvableType)
*/
public static <T> Bindable<T> of(Clreplaced<T> type) {
replacedert.notNull(type, "Type must not be null");
return of(ResolvableType.forClreplaced(type));
}
19
View Source File : BodyInserters.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Inserter to write the given {@link Publisher}.
* <p>Alternatively, consider using the {@code body} shortcuts on
* {@link org.springframework.web.reactive.function.client.WebClient WebClient} and
* {@link org.springframework.web.reactive.function.server.ServerResponse ServerResponse}.
* @param publisher the publisher to write with
* @param elementClreplaced the type of elements in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <P> the {@code Publisher} type
* @return the inserter to write a {@code Publisher}
*/
public static <T, P extends Publisher<T>> BodyInserter<P, ReactiveHttpOutputMessage> fromPublisher(P publisher, Clreplaced<T> elementClreplaced) {
replacedert.notNull(publisher, "Publisher must not be null");
replacedert.notNull(elementClreplaced, "Element Clreplaced must not be null");
return (message, context) -> writeWithMessageWriters(message, context, publisher, ResolvableType.forClreplaced(elementClreplaced));
}
19
View Source File : BodyExtractors.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Extractor to decode the input content into {@code Mono<T>}.
* @param elementClreplaced the clreplaced of the element type to decode to
* @param <T> the element type to decode to
* @return {@code BodyExtractor} for {@code Mono<T>}
*/
public static <T> BodyExtractor<Mono<T>, ReactiveHttpInputMessage> toMono(Clreplaced<? extends T> elementClreplaced) {
return toMono(ResolvableType.forClreplaced(elementClreplaced));
}
19
View Source File : BodyExtractors.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Extractor to decode the input content into {@code Flux<T>}.
* @param elementClreplaced the clreplaced of the element type to decode to
* @param <T> the element type to decode to
* @return {@code BodyExtractor} for {@code Flux<T>}
*/
public static <T> BodyExtractor<Flux<T>, ReactiveHttpInputMessage> toFlux(Clreplaced<? extends T> elementClreplaced) {
return toFlux(ResolvableType.forClreplaced(elementClreplaced));
}
19
View Source File : Jaxb2XmlDecoderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void canDecode() {
replacedertTrue(this.decoder.canDecode(ResolvableType.forClreplaced(Pojo.clreplaced), MediaType.APPLICATION_XML));
replacedertTrue(this.decoder.canDecode(ResolvableType.forClreplaced(Pojo.clreplaced), MediaType.TEXT_XML));
replacedertFalse(this.decoder.canDecode(ResolvableType.forClreplaced(Pojo.clreplaced), MediaType.APPLICATION_JSON));
replacedertTrue(this.decoder.canDecode(ResolvableType.forClreplaced(TypePojo.clreplaced), MediaType.APPLICATION_XML));
replacedertFalse(this.decoder.canDecode(ResolvableType.forClreplaced(getClreplaced()), MediaType.APPLICATION_XML));
}
19
View Source File : Jaxb2XmlDecoderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void decodeMultipleXmlTypeElement() throws Exception {
Mono<DataBuffer> source = stringBuffer(POJO_CHILD);
Flux<Object> output = this.decoder.decode(source, ResolvableType.forClreplaced(TypePojo.clreplaced), null, Collections.emptyMap());
StepVerifier.create(output).expectNext(new TypePojo("foo", "bar")).expectNext(new TypePojo("foofoo", "barbar")).expectComplete().verify();
}
19
View Source File : Jaxb2XmlDecoderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void decodeSingleXmlTypeElement() throws Exception {
Mono<DataBuffer> source = stringBuffer(POJO_ROOT);
Mono<Object> output = this.decoder.decodeToMono(source, ResolvableType.forClreplaced(TypePojo.clreplaced), null, Collections.emptyMap());
StepVerifier.create(output).expectNext(new TypePojo("foofoo", "barbar")).expectComplete().verify();
}
19
View Source File : Jaxb2XmlDecoderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void decodeSingleXmlRootElement() throws Exception {
Mono<DataBuffer> source = stringBuffer(POJO_ROOT);
Mono<Object> output = this.decoder.decodeToMono(source, ResolvableType.forClreplaced(Pojo.clreplaced), null, Collections.emptyMap());
StepVerifier.create(output).expectNext(new Pojo("foofoo", "barbar")).expectComplete().verify();
}
19
View Source File : Jaxb2XmlDecoderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void decodeMultipleXmlRootElement() throws Exception {
Mono<DataBuffer> source = stringBuffer(POJO_CHILD);
Flux<Object> output = this.decoder.decode(source, ResolvableType.forClreplaced(Pojo.clreplaced), null, Collections.emptyMap());
StepVerifier.create(output).expectNext(new Pojo("foo", "bar")).expectNext(new Pojo("foofoo", "barbar")).expectComplete().verify();
}
19
View Source File : Jaxb2XmlDecoderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void decodeError() throws Exception {
Flux<DataBuffer> source = Flux.concat(stringBuffer("<pojo>"), Flux.error(new RuntimeException()));
Mono<Object> output = this.decoder.decodeToMono(source, ResolvableType.forClreplaced(Pojo.clreplaced), null, Collections.emptyMap());
StepVerifier.create(output).expectError(RuntimeException.clreplaced).verify();
}
19
View Source File : CodecConfigurerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private void replacedertStringDecoder(Decoder<?> decoder, boolean textOnly) {
replacedertEquals(StringDecoder.clreplaced, decoder.getClreplaced());
replacedertTrue(decoder.canDecode(ResolvableType.forClreplaced(String.clreplaced), MimeTypeUtils.TEXT_PLAIN));
replacedertEquals(!textOnly, decoder.canDecode(ResolvableType.forClreplaced(String.clreplaced), MediaType.TEXT_EVENT_STREAM));
}
19
View Source File : CodecConfigurerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private void replacedertStringEncoder(Encoder<?> encoder, boolean textOnly) {
replacedertEquals(CharSequenceEncoder.clreplaced, encoder.getClreplaced());
replacedertTrue(encoder.canEncode(ResolvableType.forClreplaced(String.clreplaced), MimeTypeUtils.TEXT_PLAIN));
replacedertEquals(!textOnly, encoder.canEncode(ResolvableType.forClreplaced(String.clreplaced), MediaType.TEXT_EVENT_STREAM));
}
19
View Source File : ServerSentEventHttpMessageReaderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void readError() {
Flux<DataBuffer> body = Flux.just(stringBuffer("data:foo\ndata:bar\n\ndata:baz\n\n")).concatWith(Flux.error(new RuntimeException()));
MockServerHttpRequest request = MockServerHttpRequest.post("/").body(body);
Flux<String> data = messageReader.read(ResolvableType.forClreplaced(String.clreplaced), request, Collections.emptyMap()).cast(String.clreplaced);
StepVerifier.create(data).expectNextMatches(elem -> elem.equals("foo\nbar")).expectNextMatches(elem -> elem.equals("baz")).expectError().verify();
}
19
View Source File : ServerSentEventHttpMessageReaderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
// SPR-15331
@Test
public void decodeFullContentreplacedtring() {
String body = "data:foo\ndata:bar\n\ndata:baz\n\n";
MockServerHttpRequest request = MockServerHttpRequest.post("/").body(Mono.just(stringBuffer(body)));
String actual = messageReader.readMono(ResolvableType.forClreplaced(String.clreplaced), request, Collections.emptyMap()).cast(String.clreplaced).block(Duration.ZERO);
replacedertEquals(body, actual);
}
19
View Source File : ServerSentEventHttpMessageReaderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void readPojo() {
MockServerHttpRequest request = MockServerHttpRequest.post("/").body(Mono.just(stringBuffer("data:{\"foo\": \"foofoo\", \"bar\": \"barbar\"}\n\n" + "data:{\"foo\": \"foofoofoo\", \"bar\": \"barbarbar\"}\n\n")));
Flux<Pojo> data = messageReader.read(ResolvableType.forClreplaced(Pojo.clreplaced), request, Collections.emptyMap()).cast(Pojo.clreplaced);
StepVerifier.create(data).consumeNextWith(pojo -> {
replacedertEquals("foofoo", pojo.getFoo());
replacedertEquals("barbar", pojo.getBar());
}).consumeNextWith(pojo -> {
replacedertEquals("foofoofoo", pojo.getFoo());
replacedertEquals("barbarbar", pojo.getBar());
}).expectComplete().verify();
}
19
View Source File : ServerSentEventHttpMessageReaderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void canRead() {
replacedertTrue(messageReader.canRead(ResolvableType.forClreplaced(Object.clreplaced), new MediaType("text", "event-stream")));
replacedertTrue(messageReader.canRead(ResolvableType.forClreplaced(ServerSentEvent.clreplaced), new MediaType("foo", "bar")));
}
19
View Source File : ServerSentEventHttpMessageReaderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void cantRead() {
replacedertFalse(messageReader.canRead(ResolvableType.forClreplaced(Object.clreplaced), new MediaType("foo", "bar")));
replacedertFalse(messageReader.canRead(ResolvableType.forClreplaced(Object.clreplaced), null));
}
19
View Source File : ServerSentEventHttpMessageReaderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void readString() {
MockServerHttpRequest request = MockServerHttpRequest.post("/").body(Mono.just(stringBuffer("data:foo\ndata:bar\n\ndata:baz\n\n")));
Flux<String> data = messageReader.read(ResolvableType.forClreplaced(String.clreplaced), request, Collections.emptyMap()).cast(String.clreplaced);
StepVerifier.create(data).expectNextMatches(elem -> elem.equals("foo\nbar")).expectNextMatches(elem -> elem.equals("baz")).expectComplete().verify();
}
19
View Source File : MultipartHttpMessageWriterTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@SuppressWarnings("ConstantConditions")
private String decodeToString(Part part) {
return StringDecoder.textPlainOnly().decodeToMono(part.content(), ResolvableType.forClreplaced(String.clreplaced), MediaType.TEXT_PLAIN, Collections.emptyMap()).block(Duration.ZERO);
}
19
View Source File : Jackson2SmileEncoderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void canNotEncode() {
replacedertFalse(this.encoder.canEncode(ResolvableType.forClreplaced(String.clreplaced), null));
replacedertFalse(this.encoder.canEncode(ResolvableType.forClreplaced(Pojo.clreplaced), APPLICATION_XML));
ResolvableType sseType = ResolvableType.forClreplaced(ServerSentEvent.clreplaced);
replacedertFalse(this.encoder.canEncode(sseType, SMILE_MIME_TYPE));
}
19
View Source File : Jackson2SmileEncoderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void encodereplacedtream() throws Exception {
Pojo pojo1 = new Pojo("foo", "bar");
Pojo pojo2 = new Pojo("foofoo", "barbar");
Pojo pojo3 = new Pojo("foofoofoo", "barbarbar");
Flux<Pojo> input = Flux.just(pojo1, pojo2, pojo3);
ResolvableType type = ResolvableType.forClreplaced(Pojo.clreplaced);
testEncodeAll(input, type, step -> step.consumeNextWith(expect(pojo1, Pojo.clreplaced)).consumeNextWith(expect(pojo2, Pojo.clreplaced)).consumeNextWith(expect(pojo3, Pojo.clreplaced)).verifyComplete(), STREAM_SMILE_MIME_TYPE, null);
}
19
View Source File : Jackson2JsonEncoderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void fieldLevelJsonView() {
JacksonViewBean bean = new JacksonViewBean();
bean.setWithView1("with");
bean.setWithView2("with");
bean.setWithoutView("without");
Mono<JacksonViewBean> input = Mono.just(bean);
ResolvableType type = ResolvableType.forClreplaced(JacksonViewBean.clreplaced);
Map<String, Object> hints = singletonMap(JSON_VIEW_HINT, MyJacksonView1.clreplaced);
testEncode(input, type, step -> step.consumeNextWith(expectString("{\"withView1\":\"with\"}").andThen(DataBufferUtils::release)).verifyComplete(), null, hints);
}
See More Examples