You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/06/01 09:21:47 UTC

[GitHub] [camel] orpiske commented on a change in pull request #5611: Parallel

orpiske commented on a change in pull request #5611:
URL: https://github.com/apache/camel/pull/5611#discussion_r642921858



##########
File path: components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/resources/impl/TestServiceManager.java
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.test.junit5.resources.impl;
+
+import java.lang.reflect.Field;
+
+import org.apache.camel.test.junit5.resources.BaseResourceManager;
+import org.apache.camel.test.junit5.resources.TestService;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+public class TestServiceManager extends BaseResourceManager<TestService> {
+
+    public TestServiceManager() {
+        super(TestService.class);
+    }
+
+    @Override
+    protected Holder createHolder(ExtensionContext context, Field field) {
+        return new Holder() {
+            org.apache.camel.test.infra.common.services.TestService service;
+
+            @Override
+            public synchronized Object get() throws Exception {
+                if (service == null) {
+                    Class<?> serviceClass = field.getType();
+                    Class<?> factoryClass = serviceClass.getClassLoader().loadClass(serviceClass.getName() + "Factory");

Review comment:
       We have a few more complex service cases where we use the builder pattern to construct the service. I am wondering here if we could modify the test-infra in some way to make this part of the TestServiceManager job easier. 

##########
File path: components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/properties/TestPropertiesSource.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.test.junit5.properties;
+
+import java.lang.reflect.Field;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.RuntimeCamelException;
+
+import static org.junit.platform.commons.util.ReflectionUtils.makeAccessible;
+
+public class TestPropertiesSource implements org.apache.camel.spi.PropertiesSource {

Review comment:
       This would break CKC test framework, but I think I can reimplement the logic on `getProperty` with the same pattern there. So, IMHO, it would not be a problem. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org