-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DSL to bind object to camel registry
- Loading branch information
1 parent
3258b92
commit a32bab5
Showing
28 changed files
with
725 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
runtime/groovy/src/test/java/org/apache/camel/k/groovy/ComponentConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.camel.k.groovy; | ||
|
||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.Component; | ||
import org.apache.camel.k.jvm.Runtime; | ||
import org.apache.camel.main.MainListenerSupport; | ||
import org.apache.camel.main.MainSupport; | ||
import org.junit.Test; | ||
|
||
import static org.assertj.core.api.Java6Assertions.assertThat; | ||
|
||
public class ComponentConfigurationTest { | ||
@Test | ||
public void testLoadRouteWithComponentConfiguration() throws Exception { | ||
Runtime runtime = new Runtime(); | ||
runtime.setDuration(5); | ||
runtime.load("classpath:routes-with-component-configuration.groovy", null); | ||
runtime.addMainListener(new MainListenerSupport() { | ||
@Override | ||
public void afterStart(MainSupport main) { | ||
try { | ||
CamelContext context = main.getCamelContexts().get(0); | ||
Component component = context.getComponent("seda"); | ||
|
||
assertThat(component).isNotNull(); | ||
assertThat(component).hasFieldOrPropertyWithValue("queueSize", 1234); | ||
|
||
main.stop(); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
}); | ||
|
||
runtime.run(); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
runtime/groovy/src/test/java/org/apache/camel/k/groovy/RestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.camel.k.groovy; | ||
|
||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.k.jvm.Runtime; | ||
import org.apache.camel.main.MainListenerSupport; | ||
import org.apache.camel.main.MainSupport; | ||
import org.junit.Test; | ||
|
||
import static org.assertj.core.api.Java6Assertions.assertThat; | ||
|
||
public class RestTest { | ||
@Test | ||
public void testLoadRouteWithRest() throws Exception { | ||
Runtime runtime = new Runtime(); | ||
runtime.setDuration(5); | ||
runtime.load("classpath:routes-with-rest.groovy", null); | ||
runtime.addMainListener(new MainListenerSupport() { | ||
@Override | ||
public void afterStart(MainSupport main) { | ||
try { | ||
CamelContext context = main.getCamelContexts().get(0); | ||
|
||
assertThat(context.getRestConfiguration()).hasFieldOrPropertyWithValue("host", "my-host"); | ||
assertThat(context.getRestConfiguration()).hasFieldOrPropertyWithValue("port", 9192); | ||
assertThat(context.getRestConfiguration("undertow", false)).hasFieldOrPropertyWithValue("host", "my-undertow-host"); | ||
assertThat(context.getRestConfiguration("undertow", false)).hasFieldOrPropertyWithValue("port", 9193); | ||
|
||
main.stop(); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
}); | ||
|
||
runtime.run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
runtime/groovy/src/test/java/org/apache/camel/k/groovy/RuntimeRegistryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.camel.k.groovy; | ||
|
||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.k.jvm.Runtime; | ||
import org.apache.camel.main.MainListenerSupport; | ||
import org.apache.camel.main.MainSupport; | ||
import org.apache.camel.spi.Registry; | ||
import org.junit.Test; | ||
|
||
import static org.assertj.core.api.Java6Assertions.assertThat; | ||
|
||
public class RuntimeRegistryTest { | ||
@Test | ||
public void testLoadRouteWithBindings() throws Exception { | ||
Runtime runtime = new Runtime(); | ||
runtime.setDuration(5); | ||
runtime.load("classpath:routes-with-bindings.groovy", null); | ||
runtime.addMainListener(new MainListenerSupport() { | ||
@Override | ||
public void afterStart(MainSupport main) { | ||
try { | ||
CamelContext context = main.getCamelContexts().get(0); | ||
Registry registry = context.getRegistry(); | ||
|
||
assertThat(registry.lookup("myEntry1")).isEqualTo("myRegistryEntry1"); | ||
assertThat(registry.lookup("myEntry2")).isEqualTo("myRegistryEntry2"); | ||
|
||
main.stop(); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
}); | ||
|
||
runtime.run(); | ||
} | ||
} |
Oops, something went wrong.