Added a sample that illustrates using multiple DataSources
This PR adds a sample that illustrates the use of multiple DataSources in a single Spring Cloud Task application. Resolves #413 Updated based on code review
This commit is contained in:
committed by
Glenn Renfro
parent
486ef0dec3
commit
09ff552b8d
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or 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 io.spring;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Michael Minella
|
||||
*/
|
||||
public class MultiDataSourcesApplicationTests {
|
||||
|
||||
@Rule
|
||||
public OutputCapture outputCapture = new OutputCapture();
|
||||
|
||||
@Test
|
||||
public void testTimeStampApp() throws Exception {
|
||||
|
||||
SpringApplication.run(MultipleDataSourcesApplication.class, new String[0]);
|
||||
|
||||
String output = this.outputCapture.toString();
|
||||
|
||||
assertTrue("Unable to find CommandLineRunner output: " + output,
|
||||
output.contains("There are 2 DataSources within this application"));
|
||||
assertTrue("Unable to find start task message: " + output,
|
||||
output.contains("Creating: TaskExecution{"));
|
||||
assertTrue("Unable to find update task message: " + output,
|
||||
output.contains("Updating: TaskExecution"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Copyright 2016 the original author or 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.
|
||||
#
|
||||
|
||||
spring.application.name=Demo Multiple DataSources Task
|
||||
logging.level.org.springframework.cloud.task=DEBUG
|
||||
Reference in New Issue
Block a user