org.springframework.core.io.Resource Java Examples

The following examples show how to use org.springframework.core.io.Resource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PropertiesConfiguration.java    From gravitee-management-rest-api with Apache License 2.0 7 votes vote down vote up
@Bean(name = "graviteeProperties")
public static Properties graviteeProperties() throws IOException {
    LOGGER.info("Loading Gravitee Management configuration.");

    YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();

    String yamlConfiguration = System.getProperty(GRAVITEE_CONFIGURATION);
    Resource yamlResource = new FileSystemResource(yamlConfiguration);

    LOGGER.info("\tGravitee Management configuration loaded from {}", yamlResource.getURL().getPath());

    yaml.setResources(yamlResource);
    Properties properties = yaml.getObject();
    LOGGER.info("Loading Gravitee Management configuration. DONE");

    return properties;
}
 
Example #2
Source File: ResourceServerTokenServicesConfiguration.java    From spring-security-oauth2-boot with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean(JwtAccessTokenConverter.class)
public JwtAccessTokenConverter accessTokenConverter() {
	Assert.notNull(this.resource.getJwt().getKeyStore(), "keyStore cannot be null");
	Assert.notNull(this.resource.getJwt().getKeyStorePassword(), "keyStorePassword cannot be null");
	Assert.notNull(this.resource.getJwt().getKeyAlias(), "keyAlias cannot be null");

	JwtAccessTokenConverter converter = new JwtAccessTokenConverter();

	Resource keyStore = this.context.getResource(this.resource.getJwt().getKeyStore());
	char[] keyStorePassword = this.resource.getJwt().getKeyStorePassword().toCharArray();
	KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(keyStore, keyStorePassword);

	String keyAlias = this.resource.getJwt().getKeyAlias();
	char[] keyPassword = Optional.ofNullable(this.resource.getJwt().getKeyPassword()).map(String::toCharArray)
			.orElse(keyStorePassword);
	converter.setKeyPair(keyStoreKeyFactory.getKeyPair(keyAlias, keyPassword));

	return converter;
}
 
Example #3
Source File: SqlSessionFactory2Config.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Bean(name = "sqlSessionFactory2")
@Primary
public SqlSessionFactoryBean createSqlSessionFactory2Bean() throws IOException {
	SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
	/** 设置datasource */
	sqlSessionFactoryBean.setDataSource(dataSource2);
	VFS.addImplClass(SpringBootVFS.class);
	/** 设置mybatis configuration 扫描路径 */
	sqlSessionFactoryBean.setConfigLocation(new ClassPathResource("Configuration.xml"));
	/** 设置typeAlias 包扫描路径 */
	sqlSessionFactoryBean.setTypeAliasesPackage("indi.mybatis.flying");
	/** 添加mapper 扫描路径 */
	PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
	Resource[] ra1 = resolver.getResources("classpath*:indi/mybatis/flying/mapper*/*.xml");
	sqlSessionFactoryBean.setMapperLocations(ra1); // 扫描映射文件
	return sqlSessionFactoryBean;
}
 
Example #4
Source File: JsonCacheDataImporterExporterIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 6 votes vote down vote up
@Bean
JsonCacheDataImporterExporter exampleRegionDataImporter() {

	return new JsonCacheDataImporterExporter() {

		@Override @SuppressWarnings("rawtypes")
		protected Optional<Resource> getResource(@NonNull Region region, String resourcePrefix) {
			return Optional.ofNullable(resourceSupplier.get());
		}

		@NonNull @Override
		Writer newWriter(@NonNull Resource resource) {
			return writerSupplier.get();
		}
	};
}
 
Example #5
Source File: SingleResourceAutoDeploymentStrategy.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected void deployResourcesInternal(String deploymentNameHint, Resource[] resources, ProcessEngine engine) {
    // Create a separate deployment for each resource using the resource name
    RepositoryService repositoryService = engine.getRepositoryService();

    for (final Resource resource : resources) {

        final String resourceName = determineResourceName(resource);
        final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(resourceName);
        addResource(resource, resourceName, deploymentBuilder);
        try {
            deploymentBuilder.deploy();
        } catch (RuntimeException e) {
            if (isThrowExceptionOnDeploymentFailure()) {
                throw e;
            } else {
                LOGGER.warn(
                    "Exception while autodeploying process definitions for resource {}. This exception can be ignored if the root cause indicates a unique constraint violation, which is typically caused by two (or more) servers booting up at the exact same time and deploying the same definitions. ",
                    resource, e);
            }
        }
    }
}
 
Example #6
Source File: SingleResourceAutoDeploymentStrategyTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeployResources() {
  final Resource[] resources = new Resource[] { resourceMock1, resourceMock2, resourceMock3, resourceMock4, resourceMock5 };
  classUnderTest.deployResources(deploymentNameHint, resources, repositoryServiceMock);

  verify(repositoryServiceMock, times(5)).createDeployment();
  verify(deploymentBuilderMock, times(5)).enableDuplicateFiltering();
  verify(deploymentBuilderMock, times(1)).name(resourceName1);
  verify(deploymentBuilderMock, times(1)).name(resourceName2);
  verify(deploymentBuilderMock, times(1)).name(resourceName3);
  verify(deploymentBuilderMock, times(1)).name(resourceName4);
  verify(deploymentBuilderMock, times(1)).name(resourceName5);
  verify(deploymentBuilderMock, times(1)).addInputStream(eq(resourceName1), isA(InputStream.class));
  verify(deploymentBuilderMock, times(1)).addInputStream(eq(resourceName2), isA(InputStream.class));
  verify(deploymentBuilderMock, times(3)).addZipInputStream(isA(ZipInputStream.class));
  verify(deploymentBuilderMock, times(5)).deploy();
}
 
Example #7
Source File: JourneySimulator.java    From istio-fleetman with MIT License 6 votes vote down vote up
/**
 * Read the data from the resources directory - should work for an executable Jar as
 * well as through direct execution
 */
@PostConstruct
private void setUpData() 
{
	PathMatchingResourcePatternResolver path = new PathMatchingResourcePatternResolver();
	try
	{
		for (Resource nextFile : path.getResources("tracks/*"))
		{
			URL resource = nextFile.getURL();
			File f = new File(resource.getFile()); 
			String vehicleName = VehicleNameUtils.prettifyName(f.getName());				
			vehicleNames.add(vehicleName);
			populateReportQueueForVehicle(vehicleName);
		}
	}
	catch (IOException e)
	{
		throw new RuntimeException(e);
	}
	positionTracker.clearHistories();
}
 
Example #8
Source File: WebJarResourceResolver.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void scanResources(ApplicationContext applicationContext) throws IOException {
    // retrieve all resources from all JARs
    Resource[] resources = applicationContext.getResources("classpath*:META-INF/resources/webjars/**");

    for (Resource resource : resources) {
        URL url = resource.getURL();
        String urlString = url.toString();
        int classPathStartIndex = urlString.indexOf(CLASSPATH_WEBJAR_PREFIX);
        if (classPathStartIndex > 0) {
            String resourcePath = urlString.substring(classPathStartIndex + CLASSPATH_WEBJAR_PREFIX.length());
            if (!Strings.isNullOrEmpty(resourcePath)
                    && !resourcePath.endsWith("/")) {
                mapping.put(resourcePath, new UrlHolder(url));
            }
        } else {
            log.debug("Ignored WebJAR resource {} since it does not contain class path prefix {}",
                    urlString, CLASSPATH_WEBJAR_PREFIX);
        }
    }

    this.fullPathIndex = getFullPathIndex(mapping.keySet());
}
 
Example #9
Source File: CamundaBpmRunProcessEngineConfiguration.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
protected String getFileResourceName(Resource resource) {
  // only path relative to the root deployment directory as identifier to
  // prevent re-deployments when the path changes (e.g. distro is moved)
  try {
    String deploymentDir = env.getProperty(CamundaBpmRunDeploymentConfiguration.CAMUNDA_DEPLOYMENT_DIR_PROPERTY);
    if(File.separator.equals("\\")) {
      deploymentDir = deploymentDir.replace("\\", "/");
    }
    String resourceAbsolutePath = resource.getURI().toString();
    int startIndex = resourceAbsolutePath.indexOf(deploymentDir) + deploymentDir.length();
    return resourceAbsolutePath.substring(startIndex);
  } catch (IOException e) {
    throw new ProcessEngineException("Failed to locate resource " + resource.getFilename(), e);
  }
}
 
Example #10
Source File: CROSSRecSimilarityCalculatorTest.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void init(){
	artifactRepository.deleteAll();
	githubUserRepository.deleteAll();
	crossRecGraphRepository.deleteAll();
	try {
		ObjectMapper mapper = new ObjectMapper();
		Resource resource = new ClassPathResource("artifacts.json");
		InputStream resourceInputStream = resource.getInputStream();
		artifacts = mapper.readValue(resourceInputStream, new TypeReference<List<Artifact>>(){});
		artifactRepository.save(artifacts);
		for (Artifact artifact : artifacts) {
			ossmeterImporter.storeGithubUser(artifact.getStarred(), artifact.getFullName());
			ossmeterImporter.storeGithubUserCommitter(artifact.getCommitteers(), artifact.getFullName());
		}
		resourceInputStream.close();
	} catch (IOException e) {
		logger.error(e.getMessage());
	}
}
 
Example #11
Source File: SQLErrorCodesFactoryTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Check that user defined error codes take precedence.
 */
@Test
public void testFindUserDefinedCodes() {
	class TestSQLErrorCodesFactory extends SQLErrorCodesFactory {
		@Override
		protected Resource loadResource(String path) {
			if (SQLErrorCodesFactory.SQL_ERROR_CODE_OVERRIDE_PATH.equals(path)) {
				return new ClassPathResource("test-error-codes.xml", SQLErrorCodesFactoryTests.class);
			}
			return null;
		}
	}

	// Should have loaded without error
	TestSQLErrorCodesFactory sf = new TestSQLErrorCodesFactory();
	assertTrue(sf.getErrorCodes("XX").getBadSqlGrammarCodes().length == 0);
	assertEquals(2, sf.getErrorCodes("Oracle").getBadSqlGrammarCodes().length);
	assertEquals("1", sf.getErrorCodes("Oracle").getBadSqlGrammarCodes()[0]);
	assertEquals("2", sf.getErrorCodes("Oracle").getBadSqlGrammarCodes()[1]);
}
 
Example #12
Source File: MockServletContext.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
@Nullable
public InputStream getResourceAsStream(String path) {
	Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
	if (!resource.exists()) {
		return null;
	}
	try {
		return resource.getInputStream();
	}
	catch (IOException ex) {
		if (logger.isWarnEnabled()) {
			logger.warn("Could not open InputStream for " + resource, ex);
		}
		return null;
	}
}
 
Example #13
Source File: MockZisTest.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldRegisterAgents() throws IOException {
    Resource xmlFile = new ClassPathResource("TestRegisterMessage.xml");

    StringWriter writer = new StringWriter();
    IOUtils.copy(xmlFile.getInputStream(), writer, "UTF-8");
    String sifString = writer.toString();

    mockZis.parseSIFMessage(sifString);

    //check that the correct URL has been added to the
    Set<String> agentUrls = mockZis.getAgentUrls();

    Assert.assertEquals("Should register one agent", 1, agentUrls.size());
    Assert.assertEquals("Registered agent URL incorrect",
            "http://10.81.1.35:25101/zone/TestZone/", agentUrls.iterator().next());
}
 
Example #14
Source File: SamlHelperTest.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
@Test
public void testInlineDecryption() {
    Resource inlineAssertionResource = new ClassPathResource("saml/inlineEncryptedAssertion.xml");
    EncryptedAssertion encAssertion = createAssertion(inlineAssertionResource);

    Assertion assertion = samlHelper.decryptAssertion(encAssertion, encryptPKEntry);
    verifyAssertion(assertion);
}
 
Example #15
Source File: CloudS3Application.java    From building-microservices with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void resourceAccess() throws IOException {
	String location = "s3://" + this.bucket + "/file.txt";
	WritableResource writeableResource = (WritableResource) this.resourceLoader
			.getResource(location);
	FileCopyUtils.copy("Hello World!",
			new OutputStreamWriter(writeableResource.getOutputStream()));

	Resource resource = this.resourceLoader.getResource(location);
	System.out.println(FileCopyUtils
			.copyToString(new InputStreamReader(resource.getInputStream())));
}
 
Example #16
Source File: EdfiRecordUnmarshallerTest.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void testSourceLocation() throws Throwable {

    Resource schema = new ClassPathResource("edfiXsd-SLI/SLI-Interchange-StudentParent.xsd");
    Resource xml = new ClassPathResource("parser/InterchangeStudentParent/ThirteenStudents.xml");

    RecordVisitor mockVisitor = Mockito.mock(RecordVisitor.class);
    EdfiRecordUnmarshaller.parse(xml.getInputStream(), schema, tp, mockVisitor,
            new DummyMessageReport(), new SimpleReportStats(), new JobSource(xml.getFilename()));

    ArgumentCaptor<RecordMeta> recordMetaCaptor = ArgumentCaptor.forClass(RecordMeta.class);
    verify(mockVisitor, times(13)).visit(recordMetaCaptor.capture(), any(Map.class));

    int recordCount = 0;
    for (RecordMeta recordMeta : recordMetaCaptor.getAllValues()) {
        recordCount++;

        if (recordCount == 11) {
            assertEquals(1574, recordMeta.getSourceStartLocation().getLineNumber());
            assertEquals(1730, recordMeta.getSourceEndLocation().getLineNumber());
        } else if (recordCount == 13) {
            assertEquals(1888, recordMeta.getSourceStartLocation().getLineNumber());
            assertEquals(2044, recordMeta.getSourceEndLocation().getLineNumber());
        }
    }
}
 
Example #17
Source File: PathResourceResolverTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void resolveFromClasspath() throws IOException {
	Resource location = new ClassPathResource("test/", PathResourceResolver.class);
	String path = "bar.css";
	List<Resource> locations = singletonList(location);
	Resource actual = this.resolver.resolveResource(null, path, locations, null).block(TIMEOUT);

	assertEquals(location.createRelative(path), actual);
}
 
Example #18
Source File: ConfigurablePropertiesModule.java    From attic-rave with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a Resource that contains property key-value pairs.
 * If no system property is set for the resource location, the default location is used
 *
 * @return the {@link Resource} with the
 */
private Resource getPropertyResource() {
    final String overrideProperty = System.getProperty(SHINDIG_OVERRIDE_PROPERTIES);
    if (StringUtils.isBlank(overrideProperty)) {
        return new ClassPathResource(DEFAULT_PROPERTIES);
    } else if (overrideProperty.startsWith(CLASSPATH)) {
        return new ClassPathResource(overrideProperty.trim().substring(CLASSPATH.length()));
    } else {
        return new FileSystemResource(overrideProperty.trim());
    }
}
 
Example #19
Source File: Sys.java    From zfile with MIT License 5 votes vote down vote up
public Sys() {
    this.osName = System.getProperty("os.name");
    this.osArch = System.getProperty("os.arch");
    this.osVersion = System.getProperty("os.version");
    Resource resource = new ClassPathResource("");
    try {
        this.projectDir = resource.getFile().getAbsolutePath();
    } catch (IOException e) {
        e.printStackTrace();
    }

    long uptime = ManagementFactory.getRuntimeMXBean().getUptime();
    this.upTime = DateUtil.formatBetween(uptime, BetweenFormater.Level.SECOND);
}
 
Example #20
Source File: ResourceDecoderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void testDecodeError(Publisher<DataBuffer> input, ResolvableType outputType,
		@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {

	input = Flux.concat(
			Flux.from(input).take(1),
			Flux.error(new InputException()));

	Flux<Resource> result = this.decoder.decode(input, outputType, mimeType, hints);

	StepVerifier.create(result)
			.expectError(InputException.class)
			.verify();
}
 
Example #21
Source File: VersionResourceResolverTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void resolveResourceNoVersionInPath() {
	String file = "bar.css";
	given(this.chain.resolveResource(null, file, this.locations)).willReturn(Mono.empty());
	given(this.versionStrategy.extractVersion(file)).willReturn("");

	this.resolver.setStrategyMap(Collections.singletonMap("/**", this.versionStrategy));
	Resource actual = this.resolver
			.resolveResourceInternal(null, file, this.locations, this.chain)
			.block(Duration.ofMillis(5000));

	assertNull(actual);
	verify(this.chain, times(1)).resolveResource(null, file, this.locations);
	verify(this.versionStrategy, times(1)).extractVersion(file);
}
 
Example #22
Source File: EncodedResource.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private EncodedResource(Resource resource, String encoding, Charset charset) {
	super();
	Assert.notNull(resource, "Resource must not be null");
	this.resource = resource;
	this.encoding = encoding;
	this.charset = charset;
}
 
Example #23
Source File: DefaultTaskExecutionInfoService.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
public List<AppDeploymentRequest> createTaskDeploymentRequests(String taskName, String dslText) {
	List<AppDeploymentRequest> appDeploymentRequests = new ArrayList<>();
	TaskParser taskParser = new TaskParser(taskName, dslText, true, true);
	TaskNode taskNode = taskParser.parse();
	if (taskNode.isComposed()) {
		for (TaskApp subTask : taskNode.getTaskApps()) {
			// composed tasks have taskDefinitions in the graph
			TaskDefinition subTaskDefinition = taskDefinitionRepository.findByTaskName(subTask.getName());
			String subTaskDsl = subTaskDefinition.getDslText();
			TaskParser subTaskParser = new TaskParser(subTaskDefinition.getTaskName(), subTaskDsl, true, true);
			TaskNode subTaskNode = subTaskParser.parse();
			String subTaskName = subTaskNode.getTaskApp().getName();
			AppRegistration appRegistration = appRegistryService.find(subTaskName,
					ApplicationType.task);
			Assert.notNull(appRegistration, "Unknown task app: " + subTask.getName());
			Resource appResource = appRegistryService.getAppResource(appRegistration);

			// TODO whitelist args
			// TODO incorporate the label somehow, ea. 1:timestamp --format=YYYY
			AppDefinition appDefinition = new AppDefinition(subTask.getName(), subTaskNode.getTaskApp().getArgumentsAsMap());

			AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(appDefinition,
					appResource, null, null);
			appDeploymentRequests.add(appDeploymentRequest);
		}
	}
	return appDeploymentRequests;
}
 
Example #24
Source File: ResourceTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void doTestResource(Resource resource) throws IOException {
	assertEquals("Resource.class", resource.getFilename());
	assertTrue(resource.getURL().getFile().endsWith("Resource.class"));

	Resource relative1 = resource.createRelative("ClassPathResource.class");
	assertEquals("ClassPathResource.class", relative1.getFilename());
	assertTrue(relative1.getURL().getFile().endsWith("ClassPathResource.class"));
	assertTrue(relative1.exists());

	Resource relative2 = resource.createRelative("support/ResourcePatternResolver.class");
	assertEquals("ResourcePatternResolver.class", relative2.getFilename());
	assertTrue(relative2.getURL().getFile().endsWith("ResourcePatternResolver.class"));
	assertTrue(relative2.exists());
}
 
Example #25
Source File: ResourcePropertySource.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Return the description for the given Resource; if the description is
 * empty, return the class name of the resource plus its identity hash code.
 * @see org.springframework.core.io.Resource#getDescription()
 */
private static String getNameForResource(Resource resource) {
	String name = resource.getDescription();
	if (!StringUtils.hasText(name)) {
		name = resource.getClass().getSimpleName() + "@" + System.identityHashCode(resource);
	}
	return name;
}
 
Example #26
Source File: AppResourceCommonTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testJarMetadataUriDockerApp() throws Exception {
	String appUri = "docker:springcloudstream/log-sink-rabbit:1.2.0.RELEASE";
	String metadataUri = "https://repo.spring.io/libs-release/org/springframework/cloud/stream/app/file-sink-rabbit/1.2.0.RELEASE/file-sink-rabbit-1.2.0.RELEASE.jar";
	Resource metadataResource = appResourceCommon.getMetadataResource(new URI(appUri), new URI(metadataUri));
	verify(resourceLoader).getResource(eq(metadataUri));
}
 
Example #27
Source File: SimilarityLiveCalculatorTest.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void init(){
	try {
		ObjectMapper mapper = new ObjectMapper();
		Resource resource = new ClassPathResource("artifacts.json");
		InputStream resourceInputStream = resource.getInputStream();
		artifacts = mapper.readValue(resourceInputStream, new TypeReference<List<Artifact>>(){});
		resourceInputStream.close();
	} catch (IOException e) {
		logger.error(e.getMessage());
	}
}
 
Example #28
Source File: ResourceTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testServletContextResourceWithRelativePath() throws IOException {
	MockServletContext sc = new MockServletContext();
	Resource resource = new ServletContextResource(sc, "dir/");
	Resource relative = resource.createRelative("subdir");
	assertEquals(new ServletContextResource(sc, "dir/subdir"), relative);
}
 
Example #29
Source File: ManifestUtilsTest.java    From spring-cloud-skipper with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateManifest() throws IOException {
	Resource resource = new ClassPathResource("/repositories/sources/test/ticktock/ticktock-1.0.1");
	PackageReader packageReader = new DefaultPackageReader();

	Package pkg = packageReader.read(resource.getFile());
	assertThat(pkg).isNotNull();

	Date date = new Date(666);
	Map<String, Object> log = new HashMap<>();
	log.put("version", "666");
	log.put("adate", new Date(666));
	log.put("bool", true);
	log.put("array", "[a, b, c]");

	Map<String, String> time = new HashMap<>();
	time.put("version", "666");

	Map<String, Object> map = new HashMap<>();
	map.put("log", log);
	map.put("time", time);

	String manifest = ManifestUtils.createManifest(pkg, map);

	String dateAsStringWithQuotes = "\"" + date.toString() + "\"";

	assertThat(manifest).contains("\"version\": \"666\"").describedAs("Handle Integer");
	assertThat(manifest).contains("\"bool\": \"true\"").describedAs("Handle Boolean");
	assertThat(manifest).contains("\"adate\": " + dateAsStringWithQuotes).describedAs("Handle Date");
	assertThat(manifest).contains("\"array\":\n  - \"a\"\n  - \"b\"\n  - \"c\"").describedAs("Handle Array");
	assertThat(manifest).contains("\"deploymentProperties\": !!null \"null\"").describedAs("Handle Null");
}
 
Example #30
Source File: DataBufferUtilsTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void readByteArrayResourcePositionAndTakeUntil() throws Exception {
	Resource resource = new ByteArrayResource("foobarbazqux" .getBytes());
	Flux<DataBuffer> flux = DataBufferUtils.read(resource, 3, this.bufferFactory, 3);

	flux = DataBufferUtils.takeUntilByteCount(flux, 5);


	StepVerifier.create(flux)
			.consumeNextWith(stringConsumer("bar"))
			.consumeNextWith(stringConsumer("ba"))
			.expectComplete()
			.verify(Duration.ofSeconds(5));
}