Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loaders #446

Merged
merged 3 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.k.loader.groovy.dsl
package org.apache.camel.k.loader.groovy

import org.apache.camel.Predicate
import org.apache.camel.Processor
import org.apache.camel.RuntimeCamelException
import org.apache.camel.component.jackson.JacksonDataFormat
import org.apache.camel.component.log.LogComponent
import org.apache.camel.component.seda.SedaComponent
import org.apache.camel.k.Sources
import org.apache.camel.k.listener.RoutesConfigurer
import org.apache.camel.k.loader.groovy.support.TestRuntime
import org.apache.camel.language.bean.BeanLanguage
import org.apache.camel.model.FromDefinition
import org.apache.camel.model.ModelCamelContext
import org.apache.camel.model.ToDefinition
import org.apache.camel.model.rest.GetVerbDefinition
import org.apache.camel.model.rest.PostVerbDefinition
import org.apache.camel.processor.FatalFallbackErrorHandler
Expand All @@ -36,10 +41,50 @@ import spock.lang.Specification

import javax.sql.DataSource

class IntegrationTest extends Specification {
class GroovySourceLoaderTest extends Specification {
@AutoCleanup
def runtime = new TestRuntime()

def "load routes"() {
given:
def source = Sources.fromURI("classpath:routes.groovy")

when:
def loader = RoutesConfigurer.load(runtime, source)

then:
loader instanceof GroovySourceLoader

with(runtime.getCamelContext(ModelCamelContext.class).routeDefinitions) {
it.size() == 1

it[0].outputs[0] instanceof ToDefinition
it[0].input.endpointUri == 'timer:tick'
}
}

def "load routes with endpoint dsl"() {
given:
def source = Sources.fromURI("classpath:routes-with-endpoint-dsl.groovy")

when:
def loader = RoutesConfigurer.load(runtime, source)

then:
loader instanceof GroovySourceLoader

with(runtime.getCamelContext(ModelCamelContext.class).routeDefinitions) {
it.size() == 1

with(it[0].input, FromDefinition) {
it.endpointUri == 'timer://tick?period=1s'
}
with(it[0].outputs[0], ToDefinition) {
it.endpointUri == 'log://info'
}
}
}

def "load integration with rest"() {
when:
runtime.loadRoutes('classpath:routes-with-rest.groovy')
Expand Down Expand Up @@ -183,4 +228,3 @@ class IntegrationTest extends Specification {
1 == 1
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.k.loader.groovy.dsl.extension
package org.apache.camel.k.loader.groovy.extension


import org.apache.camel.impl.DefaultCamelContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.k.loader.groovy.dsl.extension
package org.apache.camel.k.loader.groovy.extension

import org.apache.camel.component.log.LogComponent
import org.apache.camel.impl.DefaultCamelContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.camel.k.loader.yaml

import org.apache.camel.impl.DefaultCamelContext
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.ChoiceDefinition
import org.apache.camel.model.FilterDefinition
import org.apache.camel.model.SplitDefinition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package org.apache.camel.k.loader.yaml

import org.apache.camel.component.mock.MockEndpoint
import org.apache.camel.k.loader.yaml.support.MyFailingProcessor
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.processor.aggregate.UseLatestAggregationStrategy
import org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.camel.k.loader.yaml

import org.apache.camel.component.direct.DirectEndpoint
import org.apache.camel.k.loader.yaml.support.TestSupport

class RoutesWithPlaceholdersTest extends TestSupport {
def 'route'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.AggregateDefinition
import org.apache.camel.model.language.SimpleExpression

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.apache.camel.k.loader.yaml.parser


import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.BeanDefinition

class BeanTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.k.loader.yaml.spi.StepParserException
import org.apache.camel.model.ChoiceDefinition

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.CircuitBreakerDefinition
import org.apache.camel.model.ToDefinition

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.ClaimCheckDefinition

class ClaimCheckTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.ConvertBodyDefinition

class ConvertBodyTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.DelayDefinition

class DelayTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.TryDefinition

class DoTryTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.DynamicRouterDefinition

class DynamicRouterTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.EnrichDefinition

class EnrichTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.apache.camel.builder.DeadLetterChannelBuilder
import org.apache.camel.builder.DefaultErrorHandlerBuilder
import org.apache.camel.builder.ErrorHandlerBuilderRef
import org.apache.camel.builder.NoErrorHandlerBuilder
import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.RouteDefinition

class ErrorHandlerTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.FilterDefinition

class FilterTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.k.loader.yaml.spi.StepParserException
import org.apache.camel.model.FromDefinition
import org.apache.camel.model.RouteDefinition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.IdempotentConsumerDefinition
import org.apache.camel.model.SplitDefinition

class IdempotentConsumerTest extends TestSupport {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.LoadBalanceDefinition
import org.apache.camel.model.loadbalancer.CustomLoadBalancerDefinition
import org.apache.camel.model.loadbalancer.FailoverLoadBalancerDefinition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.apache.camel.k.loader.yaml.parser


import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.LogDefinition

class LogTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.LoopDefinition

class LoopTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.MarshalDefinition

class MarshalTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.MulticastDefinition

class MulticastTest extends TestSupport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.OnExceptionDefinition
import org.apache.camel.model.ToDefinition
import org.apache.camel.model.language.ConstantExpression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.apache.camel.k.loader.yaml.parser


import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.k.loader.yaml.spi.StepParserException
import org.apache.camel.model.PipelineDefinition

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.camel.k.loader.yaml.parser

import org.apache.camel.k.loader.yaml.TestSupport
import org.apache.camel.k.loader.yaml.support.TestSupport
import org.apache.camel.model.PollEnrichDefinition

class PollEnrichTest extends TestSupport {
Expand Down
Loading