repo stringclasses 1k
values | file_url stringlengths 96 373 | file_path stringlengths 11 294 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 6
values | commit_sha stringclasses 1k
values | retrieved_at stringdate 2026-01-04 14:45:56 2026-01-04 18:30:23 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/rpc/executor/Mock2IsolationExecutorSupportFactory.java | dubbo-common/src/test/java/org/apache/dubbo/rpc/executor/Mock2IsolationExecutorSupportFactory.java | /*
* 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.dubbo.rpc.executor;
import org.apache.dubbo.common.URL;
public class Mock2IsolationExecutorSupportFactory implements IsolationExecutorSupportFactory {
@Override
public ExecutorSupport createIsolationExecutorSupport(URL url) {
return new Mock2ExecutorSupport();
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/rpc/executor/IsolationExecutorSupportFactoryTest.java | dubbo-common/src/test/java/org/apache/dubbo/rpc/executor/IsolationExecutorSupportFactoryTest.java | /*
* 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.dubbo.rpc.executor;
import org.apache.dubbo.common.URL;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class IsolationExecutorSupportFactoryTest {
@Test
void test() {
Assertions.assertInstanceOf(
DefaultExecutorSupport.class,
IsolationExecutorSupportFactory.getIsolationExecutorSupport(URL.valueOf("dubbo://")));
Assertions.assertInstanceOf(
DefaultExecutorSupport.class,
IsolationExecutorSupportFactory.getIsolationExecutorSupport(URL.valueOf("empty://")));
Assertions.assertInstanceOf(
DefaultExecutorSupport.class,
IsolationExecutorSupportFactory.getIsolationExecutorSupport(URL.valueOf("exchange://")));
Assertions.assertInstanceOf(
Mock1ExecutorSupport.class,
IsolationExecutorSupportFactory.getIsolationExecutorSupport(URL.valueOf("mock1://")));
Assertions.assertInstanceOf(
Mock2ExecutorSupport.class,
IsolationExecutorSupportFactory.getIsolationExecutorSupport(URL.valueOf("mock2://")));
Assertions.assertInstanceOf(
DefaultExecutorSupport.class,
IsolationExecutorSupportFactory.getIsolationExecutorSupport(URL.valueOf("mock3://")));
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/rpc/executor/Mock1ExecutorSupport.java | dubbo-common/src/test/java/org/apache/dubbo/rpc/executor/Mock1ExecutorSupport.java | /*
* 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.dubbo.rpc.executor;
import java.util.concurrent.Executor;
public class Mock1ExecutorSupport implements ExecutorSupport {
@Override
public Executor getExecutor(Object data) {
return null;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/rpc/executor/Mock1IsolationExecutorSupportFactory.java | dubbo-common/src/test/java/org/apache/dubbo/rpc/executor/Mock1IsolationExecutorSupportFactory.java | /*
* 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.dubbo.rpc.executor;
import org.apache.dubbo.common.URL;
public class Mock1IsolationExecutorSupportFactory implements IsolationExecutorSupportFactory {
@Override
public ExecutorSupport createIsolationExecutorSupport(URL url) {
return new Mock1ExecutorSupport();
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/PojoUtilsForNonPublicStaticTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/PojoUtilsForNonPublicStaticTest.java | /*
* 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.dubbo.common;
import org.apache.dubbo.common.utils.PojoUtils;
import org.junit.jupiter.api.Test;
class PojoUtilsForNonPublicStaticTest {
@Test
void testNonPublicStaticClass() {
NonPublicStaticData nonPublicStaticData = new NonPublicStaticData("horizon");
PojoUtils.generalize(nonPublicStaticData);
}
/**
* the static class need is not same package with PojoUtils, so define it here.
*/
static class NonPublicStaticData {
private String name;
public NonPublicStaticData(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/ServiceKeyMatcherTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/ServiceKeyMatcherTest.java | /*
* 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.dubbo.common;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class ServiceKeyMatcherTest {
@Test
void testInterface() {
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, null, null), new ServiceKey(null, null, null)));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey("DemoService", null, null), new ServiceKey(null, null, null)));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey(null, null, null), new ServiceKey("DemoService", null, null)));
Assertions.assertFalse(
ServiceKey.Matcher.isMatch(new ServiceKey("*", null, null), new ServiceKey("DemoService", null, null)));
Assertions.assertFalse(
ServiceKey.Matcher.isMatch(new ServiceKey("*", null, null), new ServiceKey(null, null, null)));
}
@Test
void testVersion() {
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, "1.0.0", null), new ServiceKey(null, "1.0.0", null)));
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, null, null), new ServiceKey(null, null, null)));
Assertions.assertFalse(
ServiceKey.Matcher.isMatch(new ServiceKey(null, "1.0.0", null), new ServiceKey(null, null, null)));
Assertions.assertFalse(
ServiceKey.Matcher.isMatch(new ServiceKey(null, null, null), new ServiceKey(null, "1.0.0", null)));
Assertions.assertTrue(ServiceKey.Matcher.isMatch(
new ServiceKey(null, "1.0.0,1.0.1", null), new ServiceKey(null, "1.0.0", null)));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey(null, "1.0.0,1.0.1", null), new ServiceKey(null, "1.0.2", null)));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey(null, "1.0.0,1.0.1", null), new ServiceKey(null, null, null)));
Assertions.assertTrue(ServiceKey.Matcher.isMatch(
new ServiceKey(null, ",1.0.0,1.0.1", null), new ServiceKey(null, null, null)));
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, ",1.0.0,1.0.1", null), new ServiceKey(null, "", null)));
Assertions.assertTrue(ServiceKey.Matcher.isMatch(
new ServiceKey(null, "1.0.0,,1.0.1", null), new ServiceKey(null, null, null)));
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, "1.0.0,,1.0.1", null), new ServiceKey(null, "", null)));
Assertions.assertTrue(ServiceKey.Matcher.isMatch(
new ServiceKey(null, "1.0.0,1.0.1,", null), new ServiceKey(null, null, null)));
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, "1.0.0,1.0.1,", null), new ServiceKey(null, "", null)));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey(null, "1.0.0,1.0.1", null), new ServiceKey(null, null, null)));
Assertions.assertFalse(
ServiceKey.Matcher.isMatch(new ServiceKey(null, "1.0.0,1.0.1", null), new ServiceKey(null, "", null)));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey(null, ",1.0.0,1.0.1", null), new ServiceKey(null, "1.0.2", null)));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey(null, ",1.0.0,1.0.1", null), new ServiceKey(null, "1.0.2", null)));
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, "*", null), new ServiceKey(null, null, null)));
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, "*", null), new ServiceKey(null, "", null)));
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, "*", null), new ServiceKey(null, "1.0.0", null)));
}
@Test
void testGroup() {
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, null, "group1"), new ServiceKey(null, null, "group1")));
Assertions.assertFalse(
ServiceKey.Matcher.isMatch(new ServiceKey(null, null, "group1"), new ServiceKey(null, null, null)));
Assertions.assertFalse(
ServiceKey.Matcher.isMatch(new ServiceKey(null, null, null), new ServiceKey(null, null, "group1")));
Assertions.assertTrue(ServiceKey.Matcher.isMatch(
new ServiceKey(null, null, "group1, group2"), new ServiceKey(null, null, "group1")));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey(null, null, "group2, group3"), new ServiceKey(null, null, "group1")));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey(null, null, "group2, group3"), new ServiceKey(null, null, null)));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey(null, null, "group2, group3"), new ServiceKey(null, null, "")));
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, null, ",group2"), new ServiceKey(null, null, "")));
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, null, "group2,"), new ServiceKey(null, null, "")));
Assertions.assertTrue(ServiceKey.Matcher.isMatch(
new ServiceKey(null, null, "group2, ,group3"), new ServiceKey(null, null, "")));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey(null, null, ",group2"), new ServiceKey(null, null, "group1")));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey(null, null, "group2,"), new ServiceKey(null, null, "group1")));
Assertions.assertFalse(ServiceKey.Matcher.isMatch(
new ServiceKey(null, null, "group2, ,group3"), new ServiceKey(null, null, "group1")));
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, null, "*"), new ServiceKey(null, null, "")));
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, null, "*"), new ServiceKey(null, null, null)));
Assertions.assertTrue(
ServiceKey.Matcher.isMatch(new ServiceKey(null, null, "*"), new ServiceKey(null, null, "group1")));
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java | /*
* 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.dubbo.common;
import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.SystemPropertyConfigUtils;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Predicate;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.apache.dubbo.common.constants.CommonConstants.OS_WIN_PREFIX;
import static org.apache.dubbo.common.constants.CommonConstants.SystemProperty.SYSTEM_OS_NAME;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
class URLTest {
@Test
void test_ignore_pond() {
URL url = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path#index?version=1.0.0&id=org.apache.dubbo.config.RegistryConfig#0");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
assertEquals("org.apache.dubbo.config.RegistryConfig#0", url.getParameter("id"));
}
@Test
void testDefault() {
URL url1 = URL.valueOf("dubbo://127.0.0.1:12345?timeout=1234&default.timeout=5678");
assertEquals(1234, url1.getParameter("timeout", 0));
assertEquals(5678, url1.getParameter("default.timeout", 0));
URL url2 = URL.valueOf("dubbo://127.0.0.1:12345?default.timeout=5678");
assertEquals(5678, url2.getParameter("timeout", 0));
assertEquals(5678, url2.getParameter("default.timeout", 0));
}
@Test
void test_valueOf_noProtocolAndHost() throws Exception {
URL url = URL.valueOf("/context/path?version=1.0.0&application=morgan");
assertURLStrDecoder(url);
assertNull(url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertNull(url.getHost());
assertNull(url.getAddress());
assertEquals(0, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
assertEquals("morgan", url.getParameter("application"));
url = URL.valueOf("context/path?version=1.0.0&application=morgan");
// ^^^^^^^ Caution , parse as host
assertURLStrDecoder(url);
assertNull(url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertEquals("context", url.getHost());
assertEquals(0, url.getPort());
assertEquals("path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
assertEquals("morgan", url.getParameter("application"));
}
private void assertURLStrDecoder(URL url) {
String fullURLStr = url.toFullString();
URL newUrl = URLStrParser.parseEncodedStr(URL.encode(fullURLStr));
assertEquals(URL.valueOf(fullURLStr), newUrl);
URL newUrl2 = URLStrParser.parseDecodedStr(fullURLStr);
assertEquals(URL.valueOf(fullURLStr), newUrl2);
}
@Test
void test_valueOf_noProtocol() throws Exception {
URL url = URL.valueOf("10.20.130.230");
assertURLStrDecoder(url);
assertNull(url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230", url.getAddress());
assertEquals(0, url.getPort());
assertNull(url.getPath());
assertEquals(0, url.getParameters().size());
url = URL.valueOf("10.20.130.230:20880");
assertURLStrDecoder(url);
assertNull(url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertNull(url.getPath());
assertEquals(0, url.getParameters().size());
url = URL.valueOf("10.20.130.230/context/path");
assertURLStrDecoder(url);
assertNull(url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230", url.getAddress());
assertEquals(0, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(0, url.getParameters().size());
url = URL.valueOf("10.20.130.230:20880/context/path");
assertURLStrDecoder(url);
assertNull(url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(0, url.getParameters().size());
url = URL.valueOf("admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
assertURLStrDecoder(url);
assertNull(url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
assertEquals("morgan", url.getParameter("application"));
}
@Test
void test_valueOf_noHost() throws Exception {
URL url = URL.valueOf("file:///home/user1/router.js");
assertURLStrDecoder(url);
assertEquals("file", url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertNull(url.getHost());
assertNull(url.getAddress());
assertEquals(0, url.getPort());
assertEquals("home/user1/router.js", url.getPath());
assertEquals(0, url.getParameters().size());
// Caution!!
url = URL.valueOf("file://home/user1/router.js");
// ^^ only tow slash!
assertURLStrDecoder(url);
assertEquals("file", url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertEquals("home", url.getHost());
assertEquals(0, url.getPort());
assertEquals("user1/router.js", url.getPath());
assertEquals(0, url.getParameters().size());
url = URL.valueOf("file:/home/user1/router.js");
assertURLStrDecoder(url);
assertEquals("file", url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertNull(url.getHost());
assertNull(url.getAddress());
assertEquals(0, url.getPort());
assertEquals("home/user1/router.js", url.getPath());
assertEquals(0, url.getParameters().size());
url = URL.valueOf("file:///d:/home/user1/router.js");
assertURLStrDecoder(url);
assertEquals("file", url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertNull(url.getHost());
assertNull(url.getAddress());
assertEquals(0, url.getPort());
assertEquals("d:/home/user1/router.js", url.getPath());
assertEquals(0, url.getParameters().size());
url = URL.valueOf("file:///home/user1/router.js?p1=v1&p2=v2");
assertURLStrDecoder(url);
assertEquals("file", url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertNull(url.getHost());
assertNull(url.getAddress());
assertEquals(0, url.getPort());
assertEquals("home/user1/router.js", url.getPath());
assertEquals(2, url.getParameters().size());
Map<String, String> params = new HashMap<String, String>();
params.put("p1", "v1");
params.put("p2", "v2");
assertEquals(params, url.getParameters());
url = URL.valueOf("file:/home/user1/router.js?p1=v1&p2=v2");
assertURLStrDecoder(url);
assertEquals("file", url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertNull(url.getHost());
assertNull(url.getAddress());
assertEquals(0, url.getPort());
assertEquals("home/user1/router.js", url.getPath());
assertEquals(2, url.getParameters().size());
params = new HashMap<String, String>();
params.put("p1", "v1");
params.put("p2", "v2");
assertEquals(params, url.getParameters());
}
@Test
void test_valueOf_WithProtocolHost() throws Exception {
URL url = URL.valueOf("dubbo://10.20.130.230");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230", url.getAddress());
assertEquals(0, url.getPort());
assertNull(url.getPath());
assertEquals(0, url.getParameters().size());
url = URL.valueOf("dubbo://10.20.130.230:20880/context/path");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertNull(url.getUsername());
assertNull(url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(0, url.getParameters().size());
url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertNull(url.getPath());
assertEquals(0, url.getParameters().size());
url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880?version=1.0.0");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertNull(url.getPath());
assertEquals(1, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
assertEquals("morgan", url.getParameter("application"));
url = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&noValue=");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(3, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
assertEquals("morgan", url.getParameter("application"));
assertEquals("", url.getParameter("noValue"));
}
// TODO Do not want to use spaces? See: DUBBO-502, URL class handles special conventions for special characters.
@Test
void test_valueOf_spaceSafe() throws Exception {
URL url = URL.valueOf("http://1.2.3.4:8080/path?key=value1 value2");
assertURLStrDecoder(url);
assertEquals("http://1.2.3.4:8080/path?key=value1 value2", url.toString());
assertEquals("value1 value2", url.getParameter("key"));
}
@Test
void test_noValueKey() throws Exception {
URL url = URL.valueOf("http://1.2.3.4:8080/path?k0=&k1=v1");
assertURLStrDecoder(url);
assertFalse(url.hasParameter("k0"));
// If a Key has no corresponding Value, then empty string used as the Value.
assertEquals("", url.getParameter("k0"));
}
@Test
void test_valueOf_Exception_noProtocol() throws Exception {
try {
URL.valueOf("://1.2.3.4:8080/path");
fail();
} catch (IllegalStateException expected) {
assertEquals("url missing protocol: \"://1.2.3.4:8080/path\"", expected.getMessage());
}
try {
String encodedURLStr = URL.encode("://1.2.3.4:8080/path");
URLStrParser.parseEncodedStr(encodedURLStr);
fail();
} catch (IllegalStateException expected) {
assertEquals("url missing protocol: \"://1.2.3.4:8080/path\"", URL.decode(expected.getMessage()));
}
try {
URLStrParser.parseDecodedStr("://1.2.3.4:8080/path");
fail();
} catch (IllegalStateException expected) {
assertEquals("url missing protocol: \"://1.2.3.4:8080/path\"", expected.getMessage());
}
}
@Test
void test_getAddress() throws Exception {
URL url1 = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
assertURLStrDecoder(url1);
assertEquals("10.20.130.230:20880", url1.getAddress());
}
@Test
void test_getAbsolutePath() throws Exception {
URL url = new ServiceConfigURL("p1", "1.2.2.2", 33);
assertURLStrDecoder(url);
assertNull(url.getAbsolutePath());
url = new ServiceConfigURL("file", null, 90, "/home/user1/route.js");
assertURLStrDecoder(url);
assertEquals("/home/user1/route.js", url.getAbsolutePath());
}
@Test
void test_equals() throws Exception {
URL url1 = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
assertURLStrDecoder(url1);
Map<String, String> params = new HashMap<String, String>();
params.put("version", "1.0.0");
params.put("application", "morgan");
URL url2 = new ServiceConfigURL("dubbo", "admin", "hello1234", "10.20.130.230", 20880, "context/path", params);
assertURLStrDecoder(url2);
assertEquals(url1, url2);
}
@Test
void test_toString() throws Exception {
URL url1 = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
assertURLStrDecoder(url1);
assertThat(
url1.toString(),
anyOf(
equalTo("dubbo://10.20.130.230:20880/context/path?version=1.0.0&application=morgan"),
equalTo("dubbo://10.20.130.230:20880/context/path?application=morgan&version=1.0.0")));
}
@Test
void test_toFullString() throws Exception {
URL url1 = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
assertURLStrDecoder(url1);
assertThat(
url1.toFullString(),
anyOf(
equalTo(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan"),
equalTo(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan&version=1.0.0")));
}
@Test
void test_set_methods() throws Exception {
URL url = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
assertURLStrDecoder(url);
url = url.setHost("host");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("host", url.getHost());
assertEquals("host:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
assertEquals("morgan", url.getParameter("application"));
url = url.setPort(1);
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("host", url.getHost());
assertEquals("host:1", url.getAddress());
assertEquals(1, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
assertEquals("morgan", url.getParameter("application"));
url = url.setPath("path");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("host", url.getHost());
assertEquals("host:1", url.getAddress());
assertEquals(1, url.getPort());
assertEquals("path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
assertEquals("morgan", url.getParameter("application"));
url = url.setProtocol("protocol");
assertURLStrDecoder(url);
assertEquals("protocol", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("host", url.getHost());
assertEquals("host:1", url.getAddress());
assertEquals(1, url.getPort());
assertEquals("path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
assertEquals("morgan", url.getParameter("application"));
url = url.setUsername("username");
assertURLStrDecoder(url);
assertEquals("protocol", url.getProtocol());
assertEquals("username", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("host", url.getHost());
assertEquals("host:1", url.getAddress());
assertEquals(1, url.getPort());
assertEquals("path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
assertEquals("morgan", url.getParameter("application"));
url = url.setPassword("password");
assertURLStrDecoder(url);
assertEquals("protocol", url.getProtocol());
assertEquals("username", url.getUsername());
assertEquals("password", url.getPassword());
assertEquals("host", url.getHost());
assertEquals("host:1", url.getAddress());
assertEquals(1, url.getPort());
assertEquals("path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("1.0.0", url.getVersion());
assertEquals("morgan", url.getParameter("application"));
}
@Test
void test_removeParameters() throws Exception {
URL url = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&k1=v1&k2=v2");
assertURLStrDecoder(url);
url = url.removeParameter("version");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(3, url.getParameters().size());
assertEquals("morgan", url.getParameter("application"));
assertEquals("v1", url.getParameter("k1"));
assertEquals("v2", url.getParameter("k2"));
assertNull(url.getVersion());
url = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&k1=v1&k2=v2");
url = url.removeParameters("version", "application", "NotExistedKey");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("v1", url.getParameter("k1"));
assertEquals("v2", url.getParameter("k2"));
assertNull(url.getVersion());
assertNull(url.getParameter("application"));
url = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&k1=v1&k2=v2");
url = url.removeParameters(Arrays.asList("version", "application"));
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("v1", url.getParameter("k1"));
assertEquals("v2", url.getParameter("k2"));
assertNull(url.getVersion());
assertNull(url.getParameter("application"));
}
@Test
void test_addParameter() throws Exception {
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
url = url.addParameter("k1", "v1");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("morgan", url.getParameter("application"));
assertEquals("v1", url.getParameter("k1"));
}
@Test
void test_addParameter_sameKv() throws Exception {
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan&k1=v1");
URL newUrl = url.addParameter("k1", "v1");
assertURLStrDecoder(url);
assertSame(newUrl, url);
}
@Test
void test_addParameters() throws Exception {
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
url = url.addParameters(CollectionUtils.toStringMap("k1", "v1", "k2", "v2"));
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(3, url.getParameters().size());
assertEquals("morgan", url.getParameter("application"));
assertEquals("v1", url.getParameter("k1"));
assertEquals("v2", url.getParameter("k2"));
url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
url = url.addParameters("k1", "v1", "k2", "v2", "application", "xxx");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(3, url.getParameters().size());
assertEquals("xxx", url.getParameter("application"));
assertEquals("v1", url.getParameter("k1"));
assertEquals("v2", url.getParameter("k2"));
url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
url = url.addParametersIfAbsent(CollectionUtils.toStringMap("k1", "v1", "k2", "v2", "application", "xxx"));
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(3, url.getParameters().size());
assertEquals("morgan", url.getParameter("application"));
assertEquals("v1", url.getParameter("k1"));
assertEquals("v2", url.getParameter("k2"));
url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
url = url.addParameter("k1", "v1");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(2, url.getParameters().size());
assertEquals("morgan", url.getParameter("application"));
assertEquals("v1", url.getParameter("k1"));
url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
url = url.addParameter("application", "xxx");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(1, url.getParameters().size());
assertEquals("xxx", url.getParameter("application"));
}
@Test
void test_addParameters_SameKv() throws Exception {
{
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan&k1=v1");
URL newUrl = url.addParameters(CollectionUtils.toStringMap("k1", "v1"));
assertURLStrDecoder(url);
assertSame(url, newUrl);
}
{
URL url = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan&k1=v1&k2=v2");
URL newUrl = url.addParameters(CollectionUtils.toStringMap("k1", "v1", "k2", "v2"));
assertURLStrDecoder(url);
assertSame(newUrl, url);
}
}
@Test
void test_addParameterIfAbsent() throws Exception {
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
url = url.addParameterIfAbsent("application", "xxx");
assertURLStrDecoder(url);
assertEquals("dubbo", url.getProtocol());
assertEquals("admin", url.getUsername());
assertEquals("hello1234", url.getPassword());
assertEquals("10.20.130.230", url.getHost());
assertEquals("10.20.130.230:20880", url.getAddress());
assertEquals(20880, url.getPort());
assertEquals("context/path", url.getPath());
assertEquals(1, url.getParameters().size());
assertEquals("morgan", url.getParameter("application"));
}
@Test
void test_windowAbsolutePathBeginWithSlashIsValid() throws Exception {
final String osProperty = SystemPropertyConfigUtils.getSystemProperty(SYSTEM_OS_NAME);
if (!osProperty.toLowerCase().contains(OS_WIN_PREFIX)) return;
File f0 = new File("C:/Windows");
File f1 = new File("/C:/Windows");
File f2 = new File("C:\\Windows");
File f3 = new File("/C:\\Windows");
File f4 = new File("\\C:\\Windows");
assertEquals(f0, f1);
assertEquals(f0, f2);
assertEquals(f0, f3);
assertEquals(f0, f4);
}
@Test
void test_javaNetUrl() throws Exception {
java.net.URL url = new java.net.URL(
"http://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan#anchor1");
assertEquals("http", url.getProtocol());
assertEquals("admin:hello1234", url.getUserInfo());
assertEquals("10.20.130.230", url.getHost());
assertEquals(20880, url.getPort());
assertEquals("/context/path", url.getPath());
assertEquals("version=1.0.0&application=morgan", url.getQuery());
assertEquals("anchor1", url.getRef());
assertEquals("admin:hello1234@10.20.130.230:20880", url.getAuthority());
assertEquals("/context/path?version=1.0.0&application=morgan", url.getFile());
}
@Test
void test_Anyhost() throws Exception {
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | true |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/ServiceKeyTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/ServiceKeyTest.java | /*
* 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.dubbo.common;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class ServiceKeyTest {
@Test
void test() {
ServiceKey serviceKey = new ServiceKey("DemoService", "1.0.0", "group1");
Assertions.assertEquals("DemoService", serviceKey.getInterfaceName());
Assertions.assertEquals("1.0.0", serviceKey.getVersion());
Assertions.assertEquals("group1", serviceKey.getGroup());
Assertions.assertEquals("group1/DemoService:1.0.0", serviceKey.toString());
Assertions.assertEquals("DemoService", new ServiceKey("DemoService", null, null).toString());
Assertions.assertEquals("DemoService:1.0.0", new ServiceKey("DemoService", "1.0.0", null).toString());
Assertions.assertEquals("group1/DemoService", new ServiceKey("DemoService", null, "group1").toString());
Assertions.assertEquals(serviceKey, serviceKey);
ServiceKey serviceKey1 = new ServiceKey("DemoService", "1.0.0", "group1");
Assertions.assertEquals(serviceKey, serviceKey1);
Assertions.assertEquals(serviceKey.hashCode(), serviceKey1.hashCode());
ServiceKey serviceKey2 = new ServiceKey("DemoService", "1.0.0", "group2");
Assertions.assertNotEquals(serviceKey, serviceKey2);
ServiceKey serviceKey3 = new ServiceKey("DemoService", "1.0.1", "group1");
Assertions.assertNotEquals(serviceKey, serviceKey3);
ServiceKey serviceKey4 = new ServiceKey("DemoInterface", "1.0.0", "group1");
Assertions.assertNotEquals(serviceKey, serviceKey4);
ProtocolServiceKey protocolServiceKey = new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol1");
Assertions.assertNotEquals(serviceKey, protocolServiceKey);
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/URLBuilderTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/URLBuilderTest.java | /*
* 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.dubbo.common;
import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.NetUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
class URLBuilderTest {
@Test
void testNoArgConstructor() {
URL url = new URLBuilder().build();
assertThat(url.toString(), equalTo(""));
}
@Test
void shouldAddParameter() {
URL url1 = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
URL url2 = URLBuilder.from(url1)
.addParameter("newKey1", "newValue1") // string
.addParameter("newKey2", 2) // int
.addParameter("version", 1) // override
.build();
assertThat(url2.getParameter("newKey1"), equalTo("newValue1"));
assertThat(url2.getParameter("newKey2"), equalTo("2"));
assertThat(url2.getVersion(), equalTo("1"));
}
@Test
void testDefault() {
ServiceConfigURL url1 = URLBuilder.from(URL.valueOf(""))
.addParameter("timeout", "1234")
.addParameter("default.timeout", "5678")
.build();
assertThat(url1.getParameter("timeout"), equalTo("1234"));
assertThat(url1.getParameter("default.timeout"), equalTo("5678"));
ServiceConfigURL url2 = URLBuilder.from(URL.valueOf(""))
.addParameter("default.timeout", "5678")
.build();
assertThat(url2.getParameter("timeout"), equalTo("5678"));
assertThat(url2.getParameter("default.timeout"), equalTo("5678"));
}
@Test
void shouldSet() {
URL url1 = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
int port = NetUtils.getAvailablePort();
URL url2 = URLBuilder.from(url1)
.setProtocol("rest")
.setUsername("newUsername")
.setPassword("newPassword")
.setHost("newHost")
.setPath("newContext")
.setPort(port)
.build();
assertThat(url2.getProtocol(), equalTo("rest"));
assertThat(url2.getUsername(), equalTo("newUsername"));
assertThat(url2.getPassword(), equalTo("newPassword"));
assertThat(url2.getHost(), equalTo("newHost"));
assertThat(url2.getPort(), equalTo(port));
assertThat(url2.getPath(), equalTo("newContext"));
int port2 = NetUtils.getAvailablePort();
url2 = URLBuilder.from(url1).setAddress("newHost2:" + port2).build();
assertThat(url2.getHost(), equalTo("newHost2"));
assertThat(url2.getPort(), equalTo(port2));
}
@Test
void shouldClearParameters() {
URL url1 = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
URL url2 = URLBuilder.from(url1).clearParameters().build();
assertThat(url2.getParameters().size(), equalTo(0));
}
@Test
void shouldRemoveParameters() {
URL url1 = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&key2=v2");
URL url2 = URLBuilder.from(url1)
.removeParameters(Arrays.asList("key2", "application"))
.build();
assertThat(url2.getParameters().size(), equalTo(1));
assertThat(url2.getVersion(), equalTo("1.0.0"));
}
@Test
void shouldAddIfAbsent() {
URL url1 = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&key2=v2");
URL url2 = URLBuilder.from(url1)
.addParameterIfAbsent("absentKey", "absentValue")
.addParameterIfAbsent("version", "2.0.0") // should not override
.build();
assertThat(url2.getVersion(), equalTo("1.0.0"));
assertThat(url2.getParameter("absentKey"), equalTo("absentValue"));
}
@Test
void shouldAddParameters() {
URL url1 = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&key2=v2");
// string pairs test
URL url2 = URLBuilder.from(url1)
.addParameters("version", "1.0.0", "absentKey1", "absentValue1")
.build();
assertThat(url2.getParameter("version"), equalTo("1.0.0"));
assertThat(url2.getParameter("absentKey1"), equalTo("absentValue1"));
// map test
Map<String, String> parameters = new HashMap<String, String>() {
{
this.put("version", "2.0.0");
this.put("absentKey2", "absentValue2");
}
};
url2 = URLBuilder.from(url1).addParameters(parameters).build();
assertThat(url2.getParameter("version"), equalTo("2.0.0"));
assertThat(url2.getParameter("absentKey2"), equalTo("absentValue2"));
}
@Test
void shouldAddParametersIfAbsent() {
URL url1 = URL.valueOf(
"dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&key2=v2");
Map<String, String> parameters = new HashMap<String, String>() {
{
this.put("version", "2.0.0");
this.put("absentKey", "absentValue");
}
};
URL url2 = URLBuilder.from(url1).addParametersIfAbsent(parameters).build();
assertThat(url2.getParameter("version"), equalTo("1.0.0"));
assertThat(url2.getParameter("absentKey"), equalTo("absentValue"));
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/ProtocolServiceKeyTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/ProtocolServiceKeyTest.java | /*
* 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.dubbo.common;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class ProtocolServiceKeyTest {
@Test
void test() {
ProtocolServiceKey protocolServiceKey = new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol1");
Assertions.assertEquals("DemoService", protocolServiceKey.getInterfaceName());
Assertions.assertEquals("1.0.0", protocolServiceKey.getVersion());
Assertions.assertEquals("group1", protocolServiceKey.getGroup());
Assertions.assertEquals("protocol1", protocolServiceKey.getProtocol());
Assertions.assertEquals("group1/DemoService:1.0.0:protocol1", protocolServiceKey.toString());
Assertions.assertEquals("group1/DemoService:1.0.0", protocolServiceKey.getServiceKeyString());
Assertions.assertEquals(protocolServiceKey, protocolServiceKey);
ProtocolServiceKey protocolServiceKey1 = new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol1");
Assertions.assertEquals(protocolServiceKey, protocolServiceKey1);
Assertions.assertEquals(protocolServiceKey.hashCode(), protocolServiceKey1.hashCode());
ProtocolServiceKey protocolServiceKey2 = new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol2");
Assertions.assertNotEquals(protocolServiceKey, protocolServiceKey2);
ProtocolServiceKey protocolServiceKey3 = new ProtocolServiceKey("DemoService", "1.0.0", "group2", "protocol1");
Assertions.assertNotEquals(protocolServiceKey, protocolServiceKey3);
ProtocolServiceKey protocolServiceKey4 = new ProtocolServiceKey("DemoService", "1.0.1", "group1", "protocol1");
Assertions.assertNotEquals(protocolServiceKey, protocolServiceKey4);
ProtocolServiceKey protocolServiceKey5 =
new ProtocolServiceKey("DemoInterface", "1.0.0", "group1", "protocol1");
Assertions.assertNotEquals(protocolServiceKey, protocolServiceKey5);
ServiceKey serviceKey = new ServiceKey("DemoService", "1.0.0", "group1");
Assertions.assertNotEquals(protocolServiceKey, serviceKey);
Assertions.assertTrue(protocolServiceKey.isSameWith(protocolServiceKey));
Assertions.assertTrue(
protocolServiceKey.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", "")));
Assertions.assertTrue(
protocolServiceKey.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", null)));
Assertions.assertFalse(
protocolServiceKey.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group2", "protocol1")));
Assertions.assertFalse(
protocolServiceKey.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group2", "")));
Assertions.assertFalse(
protocolServiceKey.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group2", null)));
ProtocolServiceKey protocolServiceKey6 = new ProtocolServiceKey("DemoService", "1.0.0", "group1", null);
Assertions.assertTrue(protocolServiceKey6.isSameWith(protocolServiceKey6));
Assertions.assertTrue(
protocolServiceKey6.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", "")));
Assertions.assertTrue(
protocolServiceKey6.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol1")));
Assertions.assertTrue(
protocolServiceKey6.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol2")));
ProtocolServiceKey protocolServiceKey7 = new ProtocolServiceKey("DemoService", "1.0.0", "group1", "*");
Assertions.assertFalse(
protocolServiceKey7.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", null)));
Assertions.assertFalse(
protocolServiceKey7.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", "")));
Assertions.assertFalse(
protocolServiceKey7.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol1")));
Assertions.assertFalse(
protocolServiceKey7.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol2")));
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/ProtocolServiceKeyMatcherTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/ProtocolServiceKeyMatcherTest.java | /*
* 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.dubbo.common;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class ProtocolServiceKeyMatcherTest {
@Test
void testProtocol() {
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "dubbo"), new ProtocolServiceKey(null, null, null, "dubbo")));
Assertions.assertFalse(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "dubbo"), new ProtocolServiceKey(null, null, null, null)));
Assertions.assertFalse(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "dubbo"),
new ProtocolServiceKey("DemoService", null, null, "dubbo")));
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, null), new ProtocolServiceKey(null, null, null, "dubbo")));
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, ""), new ProtocolServiceKey(null, null, null, "dubbo")));
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "*"), new ProtocolServiceKey(null, null, null, "dubbo")));
Assertions.assertFalse(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "dubbo1,dubbo2"),
new ProtocolServiceKey(null, null, null, "dubbo")));
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "dubbo1,dubbo2"),
new ProtocolServiceKey(null, null, null, "dubbo1")));
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "dubbo1,dubbo2"),
new ProtocolServiceKey(null, null, null, "dubbo2")));
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "dubbo1,,dubbo2"),
new ProtocolServiceKey(null, null, null, null)));
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "dubbo1,,dubbo2"),
new ProtocolServiceKey(null, null, null, "")));
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, ",dubbo1,dubbo2"),
new ProtocolServiceKey(null, null, null, null)));
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, ",dubbo1,dubbo2"),
new ProtocolServiceKey(null, null, null, "")));
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "dubbo1,dubbo2,"),
new ProtocolServiceKey(null, null, null, null)));
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "dubbo1,dubbo2,"),
new ProtocolServiceKey(null, null, null, "")));
Assertions.assertFalse(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "dubbo1,,dubbo2"),
new ProtocolServiceKey(null, null, null, "dubbo")));
Assertions.assertFalse(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, ",dubbo1,dubbo2"),
new ProtocolServiceKey(null, null, null, "dubbo")));
Assertions.assertFalse(ProtocolServiceKey.Matcher.isMatch(
new ProtocolServiceKey(null, null, null, "dubbo1,dubbo2,"),
new ProtocolServiceKey(null, null, null, "dubbo")));
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/CommonScopeModelInitializerTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/CommonScopeModelInitializerTest.java | /*
* 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.dubbo.common;
import org.apache.dubbo.common.beans.factory.ScopeBeanFactory;
import org.apache.dubbo.common.config.ConfigurationCache;
import org.apache.dubbo.common.lang.ShutdownHookCallbacks;
import org.apache.dubbo.common.status.reporter.FrameworkStatusReportService;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;
import org.apache.dubbo.rpc.model.ModuleModel;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* {@link CommonScopeModelInitializer}
*/
class CommonScopeModelInitializerTest {
private FrameworkModel frameworkModel;
private ApplicationModel applicationModel;
private ModuleModel moduleModel;
@BeforeEach
public void setUp() {
frameworkModel = new FrameworkModel();
applicationModel = frameworkModel.newApplication();
moduleModel = applicationModel.newModule();
}
@AfterEach
public void reset() {
frameworkModel.destroy();
}
@Test
void test() {
ScopeBeanFactory applicationModelBeanFactory = applicationModel.getBeanFactory();
Assertions.assertNotNull(applicationModelBeanFactory.getBean(ShutdownHookCallbacks.class));
Assertions.assertNotNull(applicationModelBeanFactory.getBean(FrameworkStatusReportService.class));
Assertions.assertNotNull(applicationModelBeanFactory.getBean(ConfigurationCache.class));
ScopeBeanFactory moduleModelBeanFactory = moduleModel.getBeanFactory();
Assertions.assertNotNull(moduleModelBeanFactory.getBean(ConfigurationCache.class));
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/URLStrParserTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/URLStrParserTest.java | /*
* 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.dubbo.common;
import java.util.HashSet;
import java.util.Set;
import net.bytebuddy.utility.RandomString;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Created by LinShunkang on 2020/03/12
*/
class URLStrParserTest {
private static Set<String> testCases = new HashSet<>(16);
private static Set<String> errorDecodedCases = new HashSet<>(8);
private static Set<String> errorEncodedCases = new HashSet<>(8);
static {
testCases.add("dubbo://192.168.1.1");
testCases.add("dubbo://192.168.1.1?");
testCases.add("dubbo://127.0.0.1?test=中文测试");
testCases.add("dubbo://admin:admin123@192.168.1.41:28113/org.test.api"
+ ".DemoService$Iface?anyhost=true&application=demo-service&dubbo=2.6.1&generic=false&interface=org"
+ ".test.api.DemoService$Iface&methods=orbCompare,checkText,checkPicture&pid=65557&revision=1.4"
+ ".17&service.filter=bootMetrics&side=provider&status=server&threads=200×tamp=1583136298859"
+ "&version=1.0.0");
// super long text test
testCases.add("dubbo://192.168.1.1/" + RandomString.make(10240));
testCases.add("file:/path/to/file.txt");
testCases.add("dubbo://fe80:0:0:0:894:aeec:f37d:23e1%en0/path?abc=abc");
testCases.add("dubbo://[fe80:0:0:0:894:aeec:f37d:23e1]:20880/path?abc=abc");
testCases.add("nacos://192.168.1.1:8848?username=&password=");
testCases.add("dubbo://127.0.0.1?timeout=1234&default.timeout=5678");
testCases.add("dubbo://127.0.0.1?default.timeout=5678");
errorDecodedCases.add("dubbo:192.168.1.1");
errorDecodedCases.add("://192.168.1.1");
errorDecodedCases.add(":/192.168.1.1");
errorEncodedCases.add("dubbo%3a%2f%2f192.168.1.41%3fabc%3");
errorEncodedCases.add("dubbo%3a192.168.1.1%3fabc%3dabc");
errorEncodedCases.add("%3a%2f%2f192.168.1.1%3fabc%3dabc");
errorEncodedCases.add("%3a%2f192.168.1.1%3fabc%3dabc");
errorEncodedCases.add("dubbo%3a%2f%2f127.0.0.1%3ftest%3d%e2%96%b2%e2%96%bc%e2%97%80%e2%96%b6%e2%86%90%e2%86"
+ "%91%e2%86%92%e2%86%93%e2%86%94%e2%86%95%e2%88%9e%c2%b1%e9%be%98%e9%9d%90%e9%bd%89%9%d%b");
}
@Test
void testEncoded() {
testCases.forEach(testCase -> {
assertThat(URLStrParser.parseEncodedStr(URL.encode(testCase)), equalTo(URL.valueOf(testCase)));
});
errorEncodedCases.forEach(errorCase -> {
Assertions.assertThrows(RuntimeException.class, () -> URLStrParser.parseEncodedStr(errorCase));
});
}
@Test
void testDecoded() {
testCases.forEach(testCase -> {
assertThat(URLStrParser.parseDecodedStr(testCase), equalTo(URL.valueOf(testCase)));
});
errorDecodedCases.forEach(errorCase -> {
Assertions.assertThrows(RuntimeException.class, () -> URLStrParser.parseDecodedStr(errorCase));
});
}
@Test
void testDefault() {
URL url1 = URLStrParser.parseEncodedStr(URL.encode("dubbo://127.0.0.1?timeout=1234&default.timeout=5678"));
assertThat(url1.getParameter("timeout"), equalTo("1234"));
assertThat(url1.getParameter("default.timeout"), equalTo("5678"));
URL url2 = URLStrParser.parseEncodedStr(URL.encode("dubbo://127.0.0.1?default.timeout=5678"));
assertThat(url2.getParameter("timeout"), equalTo("5678"));
assertThat(url2.getParameter("default.timeout"), equalTo("5678"));
}
@Test
void testPond() {
String str = "https://a#@b";
URL url1 = URL.valueOf(str);
URL url2 = URLStrParser.parseDecodedStr(str);
Assertions.assertEquals("https", url1.getProtocol());
Assertions.assertEquals("https", url2.getProtocol());
Assertions.assertEquals("a", url1.getHost());
Assertions.assertEquals("a", url2.getHost());
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/BaseServiceMetadataTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/BaseServiceMetadataTest.java | /*
* 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.dubbo.common;
import org.junit.jupiter.api.Test;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_VERSION;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
class BaseServiceMetadataTest {
@Test
void test() {
BaseServiceMetadata baseServiceMetadata = new BaseServiceMetadata();
baseServiceMetadata.setGroup("group1");
baseServiceMetadata.setServiceInterfaceName("org.apache.dubbo.common.TestInterface");
baseServiceMetadata.setVersion("1.0.0");
baseServiceMetadata.setServiceKey(
BaseServiceMetadata.buildServiceKey("org.apache.dubbo.common.TestInterface", "group1", "1.0.0"));
assertEquals(baseServiceMetadata.getGroup(), "group1");
assertEquals(baseServiceMetadata.getServiceInterfaceName(), "org.apache.dubbo.common.TestInterface");
assertEquals(baseServiceMetadata.getVersion(), "1.0.0");
assertEquals(baseServiceMetadata.getServiceKey(), "group1/org.apache.dubbo.common.TestInterface:1.0.0");
assertEquals(baseServiceMetadata.getDisplayServiceKey(), "org.apache.dubbo.common.TestInterface:1.0.0");
baseServiceMetadata.setServiceKey(
BaseServiceMetadata.buildServiceKey("org.apache.dubbo.common.TestInterface", null, null));
assertEquals(baseServiceMetadata.getServiceKey(), "org.apache.dubbo.common.TestInterface");
baseServiceMetadata.setServiceKey(
BaseServiceMetadata.buildServiceKey("org.apache.dubbo.common.TestInterface", "", ""));
assertEquals(baseServiceMetadata.getServiceKey(), "org.apache.dubbo.common.TestInterface");
baseServiceMetadata.setVersion("2.0.0");
baseServiceMetadata.generateServiceKey();
assertEquals(baseServiceMetadata.getServiceKey(), "group1/org.apache.dubbo.common.TestInterface:2.0.0");
assertEquals(
BaseServiceMetadata.versionFromServiceKey("group1/org.apache.dubbo.common.TestInterface:1.0.0"),
"1.0.0");
assertEquals(
BaseServiceMetadata.groupFromServiceKey("group1/org.apache.dubbo.common.TestInterface:1.0.0"),
"group1");
assertEquals(
BaseServiceMetadata.interfaceFromServiceKey("group1/org.apache.dubbo.common.TestInterface:1.0.0"),
"org.apache.dubbo.common.TestInterface");
assertEquals(DEFAULT_VERSION, BaseServiceMetadata.versionFromServiceKey(""));
assertNull(BaseServiceMetadata.groupFromServiceKey(""));
assertEquals(BaseServiceMetadata.interfaceFromServiceKey(""), "");
assertEquals(
BaseServiceMetadata.revertDisplayServiceKey("org.apache.dubbo.common.TestInterface:1.0.0")
.getDisplayServiceKey(),
"org.apache.dubbo.common.TestInterface:1.0.0");
assertEquals(
BaseServiceMetadata.revertDisplayServiceKey("org.apache.dubbo.common.TestInterface")
.getDisplayServiceKey(),
"org.apache.dubbo.common.TestInterface:null");
assertEquals(BaseServiceMetadata.revertDisplayServiceKey(null).getDisplayServiceKey(), "null:null");
assertEquals(
BaseServiceMetadata.revertDisplayServiceKey("org.apache.dubbo.common.TestInterface:1.0.0:1")
.getDisplayServiceKey(),
"null:null");
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/InterfaceAddressURLTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/InterfaceAddressURLTest.java | /*
* 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.dubbo.common;
import org.apache.dubbo.common.url.component.DubboServiceAddressURL;
import org.apache.dubbo.common.url.component.ServiceAddressURL;
import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.junit.jupiter.api.Test;
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
class InterfaceAddressURLTest {
private static final String rawURL =
"dubbo://10.20.130.230:20880/context/path?version=1.0.0&group=g1&application=provider&timeout=1000&category=provider&side=provider&sayHello.weight=222";
private static final URL overrideURL = URL.valueOf(
"override://10.20.130.230:20880/context/path?version=1.0.0&application=morgan&timeout=2000&category=configurators&sayHello.overrideKey=override");
private static final URL consumerURL = URL.valueOf(
"consumer://10.20.130.230/context/path?version=2.0.0,1.0.0&group=g2&application=morgan&timeout=3000&side=consumer&sayHello.timeout=5000");
@Test
void testMergeOverriden() {
URL url = URL.valueOf(rawURL);
ServiceAddressURL interfaceAddressURL =
new DubboServiceAddressURL(url.getUrlAddress(), url.getUrlParam(), null, null);
assertEquals("1000", interfaceAddressURL.getParameter(TIMEOUT_KEY));
ServiceAddressURL withConsumer = DubboServiceAddressURL.valueOf(rawURL, consumerURL);
assertEquals("3000", withConsumer.getParameter(TIMEOUT_KEY));
ServiceAddressURL withOverriden =
DubboServiceAddressURL.valueOf(rawURL, consumerURL, (ServiceConfigURL) overrideURL);
assertEquals("2000", withOverriden.getParameter(TIMEOUT_KEY));
}
@Test
void testGetParameter() {
URL url = URL.valueOf(rawURL);
ServiceAddressURL interfaceAddressURL =
new DubboServiceAddressURL(url.getUrlAddress(), url.getUrlParam(), consumerURL, null);
assertEquals("3000", interfaceAddressURL.getParameter(TIMEOUT_KEY));
assertEquals("morgan", interfaceAddressURL.getApplication());
assertEquals("provider", interfaceAddressURL.getRemoteApplication());
assertEquals("dubbo", interfaceAddressURL.getProtocol());
assertEquals("context/path", interfaceAddressURL.getPath());
assertEquals("consumer", interfaceAddressURL.getSide());
assertEquals("1.0.0", interfaceAddressURL.getVersion());
assertEquals("g1", interfaceAddressURL.getGroup());
}
@Test
void testGetMethodParameter() {
URL url = URL.valueOf(rawURL);
ServiceAddressURL interfaceAddressURL = new DubboServiceAddressURL(
url.getUrlAddress(), url.getUrlParam(), consumerURL, (ServiceConfigURL) overrideURL);
assertEquals("5000", interfaceAddressURL.getMethodParameter("sayHello", TIMEOUT_KEY));
assertEquals("2000", interfaceAddressURL.getMethodParameter("non-exist-methods", TIMEOUT_KEY));
assertEquals("222", interfaceAddressURL.getMethodParameter("sayHello", "weight"));
assertEquals("222", interfaceAddressURL.getMethodParameter("sayHello", "weight"));
assertEquals("override", interfaceAddressURL.getMethodParameter("sayHello", "overrideKey"));
}
@Test
void testURLEquals() {
URL url1 = URL.valueOf(rawURL);
URL url2 = URL.valueOf(rawURL);
assertNotSame(url1, url2);
assertEquals(url1, url2);
// with consumer
ServiceAddressURL withConsumer =
new DubboServiceAddressURL(url1.getUrlAddress(), url1.getUrlParam(), consumerURL, null);
ServiceAddressURL withConsumer2 =
new DubboServiceAddressURL(url1.getUrlAddress(), url1.getUrlParam(), consumerURL, null);
assertEquals(withConsumer, withConsumer2);
ServiceAddressURL withOverride = new DubboServiceAddressURL(
url1.getUrlAddress(), url1.getUrlParam(), consumerURL, (ServiceConfigURL) overrideURL);
url2 = url2.addParameter("timeout", "4444");
ServiceAddressURL withOverride2 = new DubboServiceAddressURL(
url2.getUrlAddress(), url2.getUrlParam(), consumerURL, (ServiceConfigURL) overrideURL);
assertNotEquals(url1, url2);
assertEquals(withOverride, withOverride2);
}
@Test
void testToString() {
URL url1 = URL.valueOf(rawURL);
assertNotNull(url1.toString());
ServiceAddressURL withConsumer =
new DubboServiceAddressURL(url1.getUrlAddress(), url1.getUrlParam(), consumerURL, null);
assertNotNull(withConsumer.toString());
ServiceAddressURL withOverride2 = new DubboServiceAddressURL(
url1.getUrlAddress(), url1.getUrlParam(), consumerURL, (ServiceConfigURL) overrideURL);
assertNotNull(withOverride2.toString());
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/profiler/ProfilerTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/profiler/ProfilerTest.java | /*
* 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.dubbo.common.profiler;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class ProfilerTest {
@Test
void testProfiler() {
ProfilerEntry one = Profiler.start("1");
ProfilerEntry two = Profiler.enter(one, "1-2");
ProfilerEntry three = Profiler.enter(two, "1-2-3");
ProfilerEntry four = Profiler.enter(three, "1-2-3-4");
Assertions.assertEquals(three, Profiler.release(four));
ProfilerEntry five = Profiler.enter(three, "1-2-3-5");
Assertions.assertEquals(three, Profiler.release(five));
Assertions.assertEquals(two, Profiler.release(three));
ProfilerEntry six = Profiler.enter(two, "1-2-6");
Assertions.assertEquals(two, Profiler.release(six));
ProfilerEntry seven = Profiler.enter(six, "1-2-6-7");
Assertions.assertEquals(six, Profiler.release(seven));
ProfilerEntry eight = Profiler.enter(six, "1-2-6-8");
Assertions.assertEquals(six, Profiler.release(eight));
Assertions.assertEquals(2, two.getSub().size());
Assertions.assertEquals(three, two.getSub().get(0));
Assertions.assertEquals(six, two.getSub().get(1));
Profiler.release(two);
ProfilerEntry nine = Profiler.enter(one, "1-9");
Profiler.release(nine);
Profiler.release(one);
/*
* Start time: 287395734500659
* +-[ Offset: 0.000000ms; Usage: 4.721583ms, 100% ] 1
* +-[ Offset: 0.013136ms; Usage: 4.706288ms, 99% ] 1-2
* | +-[ Offset: 0.027903ms; Usage: 4.662918ms, 98% ] 1-2-3
* | | +-[ Offset: 0.029742ms; Usage: 0.003785ms, 0% ] 1-2-3-4
* | | +-[ Offset: 4.688477ms; Usage: 0.001398ms, 0% ] 1-2-3-5
* | +-[ Offset: 4.693346ms; Usage: 0.000316ms, 0% ] 1-2-6
* | +-[ Offset: 4.695191ms; Usage: 0.000212ms, 0% ] 1-2-6-7
* | +-[ Offset: 4.696655ms; Usage: 0.000195ms, 0% ] 1-2-6-8
* +-[ Offset: 4.721044ms; Usage: 0.000270ms, 0% ] 1-9
*/
Assertions.assertNotEquals(Profiler.buildDetail(one), Profiler.buildDetail(two));
Assertions.assertNotEquals(Profiler.buildDetail(one), Profiler.buildDetail(three));
Assertions.assertNotEquals(Profiler.buildDetail(one), Profiler.buildDetail(four));
Assertions.assertNotEquals(Profiler.buildDetail(one), Profiler.buildDetail(five));
Assertions.assertNotEquals(Profiler.buildDetail(one), Profiler.buildDetail(six));
Assertions.assertNotEquals(Profiler.buildDetail(one), Profiler.buildDetail(seven));
Assertions.assertNotEquals(Profiler.buildDetail(one), Profiler.buildDetail(eight));
Assertions.assertNotEquals(Profiler.buildDetail(one), Profiler.buildDetail(nine));
}
@Test
void testBizProfiler() {
Assertions.assertNull(Profiler.getBizProfiler());
ProfilerEntry one = Profiler.start("1");
Profiler.setToBizProfiler(one);
Profiler.release(Profiler.enter(Profiler.getBizProfiler(), "1-2"));
Assertions.assertEquals(one, Profiler.getBizProfiler());
Assertions.assertEquals(1, one.getSub().size());
Profiler.removeBizProfiler();
Assertions.assertNull(Profiler.getBizProfiler());
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/beans/InstantiationStrategyTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/beans/InstantiationStrategyTest.java | /*
* 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.dubbo.common.beans;
import org.apache.dubbo.common.beans.model.FooBeanWithApplicationModel;
import org.apache.dubbo.common.beans.model.FooBeanWithFrameworkModel;
import org.apache.dubbo.common.beans.model.FooBeanWithModuleModel;
import org.apache.dubbo.common.beans.model.FooBeanWithScopeModel;
import org.apache.dubbo.common.beans.model.FooBeanWithoutUniqueConstructors;
import org.apache.dubbo.common.beans.support.InstantiationStrategy;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.ScopeModel;
import org.apache.dubbo.rpc.model.ScopeModelAccessor;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class InstantiationStrategyTest {
private ScopeModelAccessor scopeModelAccessor = new ScopeModelAccessor() {
@Override
public ScopeModel getScopeModel() {
return ApplicationModel.defaultModel().getDefaultModule();
}
};
@Test
void testCreateBeanWithScopeModelArgument() throws ReflectiveOperationException {
InstantiationStrategy instantiationStrategy = new InstantiationStrategy(scopeModelAccessor);
FooBeanWithFrameworkModel beanWithFrameworkModel =
instantiationStrategy.instantiate(FooBeanWithFrameworkModel.class);
Assertions.assertSame(scopeModelAccessor.getFrameworkModel(), beanWithFrameworkModel.getFrameworkModel());
FooBeanWithApplicationModel beanWithApplicationModel =
instantiationStrategy.instantiate(FooBeanWithApplicationModel.class);
Assertions.assertSame(scopeModelAccessor.getApplicationModel(), beanWithApplicationModel.getApplicationModel());
FooBeanWithModuleModel beanWithModuleModel = instantiationStrategy.instantiate(FooBeanWithModuleModel.class);
Assertions.assertSame(scopeModelAccessor.getModuleModel(), beanWithModuleModel.getModuleModel());
FooBeanWithScopeModel beanWithScopeModel = instantiationStrategy.instantiate(FooBeanWithScopeModel.class);
Assertions.assertSame(scopeModelAccessor.getScopeModel(), beanWithScopeModel.getScopeModel());
// test not unique matched constructors
try {
instantiationStrategy.instantiate(FooBeanWithoutUniqueConstructors.class);
Assertions.fail("Expect throwing exception");
} catch (Exception e) {
Assertions.assertTrue(
e.getMessage().contains("Expect only one but found 2 matched constructors"),
StringUtils.toString(e));
}
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/beans/ScopeBeanFactoryTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/beans/ScopeBeanFactoryTest.java | /*
* 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.dubbo.common.beans;
import org.apache.dubbo.common.beans.factory.ScopeBeanFactory;
import org.apache.dubbo.common.beans.model.FooBeanWithApplicationModel;
import org.apache.dubbo.common.beans.model.FooBeanWithFrameworkModel;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class ScopeBeanFactoryTest {
@Test
void testInjection() {
ApplicationModel applicationModel = ApplicationModel.defaultModel();
ScopeBeanFactory beanFactory = applicationModel.getBeanFactory();
FooBeanWithApplicationModel beanWithApplicationModel =
beanFactory.registerBean(FooBeanWithApplicationModel.class);
Assertions.assertSame(applicationModel, beanWithApplicationModel.getApplicationModel());
FrameworkModel frameworkModel = applicationModel.getFrameworkModel();
FooBeanWithFrameworkModel beanWithFrameworkModel =
frameworkModel.getBeanFactory().registerBean(FooBeanWithFrameworkModel.class);
Assertions.assertSame(frameworkModel, beanWithFrameworkModel.getFrameworkModel());
// child bean factory can obtain bean from parent bean factory
FooBeanWithFrameworkModel beanWithFrameworkModelFromApp =
applicationModel.getBeanFactory().getBean(FooBeanWithFrameworkModel.class);
Assertions.assertSame(beanWithFrameworkModel, beanWithFrameworkModelFromApp);
Object objectBean = applicationModel.getBeanFactory().getBean(Object.class);
Assertions.assertNull(objectBean);
// child bean factory can obtain bean from parent bean factory by classType
frameworkModel.getBeanFactory().registerBean(new TestBean());
applicationModel.getBeanFactory().registerBean(new TestBean());
List<TestBean> testBeans = applicationModel.getBeanFactory().getBeansOfType(TestBean.class);
Assertions.assertEquals(testBeans.size(), 2);
// father can't get son's
List<TestBean> testBeans_1 = frameworkModel.getBeanFactory().getBeansOfType(TestBean.class);
Assertions.assertEquals(testBeans_1.size(), 1);
Assertions.assertFalse(beanWithApplicationModel.isDestroyed());
Assertions.assertFalse(beanWithFrameworkModel.isDestroyed());
// destroy
frameworkModel.destroy();
Assertions.assertTrue(beanWithApplicationModel.isDestroyed());
Assertions.assertTrue(beanWithFrameworkModel.isDestroyed());
}
static class TestBean {}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/beans/model/FooBeanWithApplicationModel.java | dubbo-common/src/test/java/org/apache/dubbo/common/beans/model/FooBeanWithApplicationModel.java | /*
* 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.dubbo.common.beans.model;
import org.apache.dubbo.common.resource.Disposable;
import org.apache.dubbo.rpc.model.ApplicationModel;
public class FooBeanWithApplicationModel implements Disposable {
private ApplicationModel applicationModel;
private boolean destroyed;
public FooBeanWithApplicationModel(ApplicationModel applicationModel) {
this.applicationModel = applicationModel;
}
public ApplicationModel getApplicationModel() {
return applicationModel;
}
@Override
public void destroy() {
this.destroyed = true;
}
public boolean isDestroyed() {
return destroyed;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/beans/model/FooBeanWithScopeModel.java | dubbo-common/src/test/java/org/apache/dubbo/common/beans/model/FooBeanWithScopeModel.java | /*
* 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.dubbo.common.beans.model;
import org.apache.dubbo.rpc.model.ScopeModel;
public class FooBeanWithScopeModel {
private ScopeModel scopeModel;
public FooBeanWithScopeModel(ScopeModel scopeModel) {
this.scopeModel = scopeModel;
}
public ScopeModel getScopeModel() {
return scopeModel;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/beans/model/FooBeanWithoutUniqueConstructors.java | dubbo-common/src/test/java/org/apache/dubbo/common/beans/model/FooBeanWithoutUniqueConstructors.java | /*
* 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.dubbo.common.beans.model;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.ModuleModel;
public class FooBeanWithoutUniqueConstructors {
private ModuleModel moduleModel;
private ApplicationModel applicationModel;
public FooBeanWithoutUniqueConstructors(ModuleModel moduleModel) {
this.moduleModel = moduleModel;
}
public FooBeanWithoutUniqueConstructors(ApplicationModel applicationModel) {
this.applicationModel = applicationModel;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/beans/model/FooBeanWithModuleModel.java | dubbo-common/src/test/java/org/apache/dubbo/common/beans/model/FooBeanWithModuleModel.java | /*
* 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.dubbo.common.beans.model;
import org.apache.dubbo.rpc.model.ModuleModel;
public class FooBeanWithModuleModel {
private ModuleModel moduleModel;
public FooBeanWithModuleModel(ModuleModel moduleModel) {
this.moduleModel = moduleModel;
}
public ModuleModel getModuleModel() {
return moduleModel;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/beans/model/FooBeanWithFrameworkModel.java | dubbo-common/src/test/java/org/apache/dubbo/common/beans/model/FooBeanWithFrameworkModel.java | /*
* 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.dubbo.common.beans.model;
import org.apache.dubbo.common.resource.Disposable;
import org.apache.dubbo.rpc.model.FrameworkModel;
public class FooBeanWithFrameworkModel implements Disposable {
private FrameworkModel frameworkModel;
private boolean destroyed;
public FooBeanWithFrameworkModel(FrameworkModel frameworkModel) {
this.frameworkModel = frameworkModel;
}
public FrameworkModel getFrameworkModel() {
return frameworkModel;
}
@Override
public void destroy() {
this.destroyed = true;
}
public boolean isDestroyed() {
return destroyed;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/threadlocal/NamedInternalThreadFactoryTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/threadlocal/NamedInternalThreadFactoryTest.java | /*
* 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.dubbo.common.threadlocal;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class NamedInternalThreadFactoryTest {
@Test
void newThread() throws Exception {
NamedInternalThreadFactory namedInternalThreadFactory = new NamedInternalThreadFactory();
Thread t = namedInternalThreadFactory.newThread(() -> {});
Assertions.assertEquals(t.getClass(), InternalThread.class, "thread is not InternalThread");
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/threadlocal/InternalThreadLocalTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/threadlocal/InternalThreadLocalTest.java | /*
* 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.dubbo.common.threadlocal;
import java.lang.reflect.Field;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.LockSupport;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
class InternalThreadLocalTest {
private static final Logger logger = LoggerFactory.getLogger(InternalThreadLocalTest.class);
private static final int THREADS = 10;
private static final int PERFORMANCE_THREAD_COUNT = 1000;
private static final int GET_COUNT = 1000000;
@AfterEach
public void setup() {
InternalThreadLocalMap.remove();
}
@Test
void testInternalThreadLocal() {
final AtomicInteger index = new AtomicInteger(0);
final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>() {
@Override
protected Integer initialValue() {
Integer v = index.getAndIncrement();
return v;
}
};
for (int i = 0; i < THREADS; i++) {
Thread t = new Thread(internalThreadLocal::get);
t.start();
}
await().until(index::get, is(THREADS));
}
@Test
void testRemoveAll() {
final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>();
internalThreadLocal.set(1);
Assertions.assertEquals(1, (int) internalThreadLocal.get(), "set failed");
final InternalThreadLocal<String> internalThreadLocalString = new InternalThreadLocal<String>();
internalThreadLocalString.set("value");
Assertions.assertEquals("value", internalThreadLocalString.get(), "set failed");
InternalThreadLocal.removeAll();
Assertions.assertNull(internalThreadLocal.get(), "removeAll failed!");
Assertions.assertNull(internalThreadLocalString.get(), "removeAll failed!");
}
@Test
void testSize() {
final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>();
internalThreadLocal.set(1);
Assertions.assertEquals(1, InternalThreadLocal.size(), "size method is wrong!");
final InternalThreadLocal<String> internalThreadLocalString = new InternalThreadLocal<String>();
internalThreadLocalString.set("value");
Assertions.assertEquals(2, InternalThreadLocal.size(), "size method is wrong!");
InternalThreadLocal.removeAll();
}
@Test
void testSetAndGet() {
final Integer testVal = 10;
final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>();
internalThreadLocal.set(testVal);
Assertions.assertEquals(testVal, internalThreadLocal.get(), "set is not equals get");
}
@Test
void testRemove() {
final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>();
internalThreadLocal.set(1);
Assertions.assertEquals(1, (int) internalThreadLocal.get(), "get method false!");
internalThreadLocal.remove();
Assertions.assertNull(internalThreadLocal.get(), "remove failed!");
}
@Test
void testOnRemove() {
final Integer[] valueToRemove = {null};
final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>() {
@Override
protected void onRemoval(Integer value) {
// value calculate
valueToRemove[0] = value + 1;
}
};
internalThreadLocal.set(1);
Assertions.assertEquals(1, (int) internalThreadLocal.get(), "get method false!");
internalThreadLocal.remove();
Assertions.assertEquals(2, (int) valueToRemove[0], "onRemove method failed!");
}
@Test
void testMultiThreadSetAndGet() throws InterruptedException {
final Integer testVal1 = 10;
final Integer testVal2 = 20;
final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>();
final CountDownLatch countDownLatch = new CountDownLatch(2);
Thread t1 = new Thread(new Runnable() {
@Override
public void run() {
internalThreadLocal.set(testVal1);
Assertions.assertEquals(testVal1, internalThreadLocal.get(), "set is not equals get");
countDownLatch.countDown();
}
});
t1.start();
Thread t2 = new Thread(new Runnable() {
@Override
public void run() {
internalThreadLocal.set(testVal2);
Assertions.assertEquals(testVal2, internalThreadLocal.get(), "set is not equals get");
countDownLatch.countDown();
}
});
t2.start();
countDownLatch.await();
}
/**
* print
* take[2689]ms
* <p></p>
* This test is based on a Machine with 4 core and 16g memory.
*/
@Test
void testPerformanceTradition() {
final ThreadLocal<String>[] caches1 = new ThreadLocal[PERFORMANCE_THREAD_COUNT];
final Thread mainThread = Thread.currentThread();
for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) {
caches1[i] = new ThreadLocal<String>();
}
Thread t1 = new Thread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) {
caches1[i].set("float.lu");
}
long start = System.nanoTime();
for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) {
for (int j = 0; j < GET_COUNT; j++) {
caches1[i].get();
}
}
long end = System.nanoTime();
logger.info("take[{}]ms", TimeUnit.NANOSECONDS.toMillis(end - start));
LockSupport.unpark(mainThread);
}
});
t1.start();
LockSupport.park(mainThread);
}
/**
* print
* take[14]ms
* <p></p>
* This test is based on a Machine with 4 core and 16g memory.
*/
@Test
void testPerformance() {
final InternalThreadLocal<String>[] caches = new InternalThreadLocal[PERFORMANCE_THREAD_COUNT];
final Thread mainThread = Thread.currentThread();
for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) {
caches[i] = new InternalThreadLocal<String>();
}
Thread t = new InternalThread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) {
caches[i].set("float.lu");
}
long start = System.nanoTime();
for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) {
for (int j = 0; j < GET_COUNT; j++) {
caches[i].get();
}
}
long end = System.nanoTime();
logger.info("take[{}]ms", TimeUnit.NANOSECONDS.toMillis(end - start));
LockSupport.unpark(mainThread);
}
});
t.start();
LockSupport.park(mainThread);
}
@Test
void testConstructionWithIndex() throws Exception {
// reset ARRAY_LIST_CAPACITY_MAX_SIZE to speed up
int NEW_ARRAY_LIST_CAPACITY_MAX_SIZE = 8;
Field nextIndexField = InternalThreadLocalMap.class.getDeclaredField("NEXT_INDEX");
nextIndexField.setAccessible(true);
AtomicInteger nextIndex = (AtomicInteger) nextIndexField.get(AtomicInteger.class);
int arrayListCapacityMaxSize = InternalThreadLocalMap.ARRAY_LIST_CAPACITY_MAX_SIZE;
int nextIndex_before = nextIndex.incrementAndGet();
nextIndex.set(0);
final AtomicReference<Throwable> throwable = new AtomicReference<Throwable>();
try {
InternalThreadLocalMap.ARRAY_LIST_CAPACITY_MAX_SIZE = NEW_ARRAY_LIST_CAPACITY_MAX_SIZE;
while (nextIndex.get() < NEW_ARRAY_LIST_CAPACITY_MAX_SIZE) {
new InternalThreadLocal<Boolean>();
}
assertEquals(NEW_ARRAY_LIST_CAPACITY_MAX_SIZE - 1, InternalThreadLocalMap.lastVariableIndex());
try {
new InternalThreadLocal<Boolean>();
} catch (Throwable t) {
throwable.set(t);
}
// Assert the max index cannot greater than (ARRAY_LIST_CAPACITY_MAX_SIZE - 1)
assertThat(throwable.get(), is(instanceOf(IllegalStateException.class)));
// Assert the index was reset to ARRAY_LIST_CAPACITY_MAX_SIZE after it reaches ARRAY_LIST_CAPACITY_MAX_SIZE
assertEquals(NEW_ARRAY_LIST_CAPACITY_MAX_SIZE - 1, InternalThreadLocalMap.lastVariableIndex());
} finally {
// Restore the index
nextIndex.set(nextIndex_before);
InternalThreadLocalMap.ARRAY_LIST_CAPACITY_MAX_SIZE = arrayListCapacityMaxSize;
}
}
@Test
void testInternalThreadLocalMapExpand() throws Exception {
final AtomicReference<Throwable> throwable = new AtomicReference<Throwable>();
Runnable runnable = new Runnable() {
@Override
public void run() {
int expand_threshold = 1 << 30;
try {
InternalThreadLocalMap.get().setIndexedVariable(expand_threshold, null);
} catch (Throwable t) {
throwable.set(t);
}
}
};
InternalThread internalThread = new InternalThread(runnable);
internalThread.start();
internalThread.join();
// Assert the expanded size is not overflowed to negative value
assertThat(throwable.get(), is(not(instanceOf(NegativeArraySizeException.class))));
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionDirectorTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionDirectorTest.java | /*
* 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.dubbo.common.extension;
import org.apache.dubbo.common.extension.director.FooAppService;
import org.apache.dubbo.common.extension.director.FooFrameworkService;
import org.apache.dubbo.common.extension.director.FooModuleService;
import org.apache.dubbo.common.extension.director.impl.TestAppService;
import org.apache.dubbo.common.extension.director.impl.TestFrameworkService;
import org.apache.dubbo.common.extension.director.impl.TestModuleService;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;
import org.apache.dubbo.rpc.model.ModuleModel;
import java.util.Collection;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class ExtensionDirectorTest {
String testFwSrvName = "testFwSrv";
String testAppSrvName = "testAppSrv";
String testMdSrvName = "testMdSrv";
@Test
void testInheritanceAndScope() {
// Expecting:
// 1. SPI extension only be created in ExtensionDirector which matched scope
// 2. Child ExtensionDirector can get extension instance from parent
// 3. Parent ExtensionDirector can't get extension instance from child
ExtensionDirector fwExtensionDirector = FrameworkModel.defaultModel().getExtensionDirector();
ExtensionDirector appExtensionDirector =
new ExtensionDirector(fwExtensionDirector, ExtensionScope.APPLICATION, ApplicationModel.defaultModel());
ExtensionDirector moduleExtensionDirector = new ExtensionDirector(
appExtensionDirector,
ExtensionScope.MODULE,
ApplicationModel.defaultModel().getDefaultModule());
// test module extension loader
FooFrameworkService testFwSrvFromModule =
moduleExtensionDirector.getExtension(FooFrameworkService.class, testFwSrvName);
FooAppService testAppSrvFromModule = moduleExtensionDirector.getExtension(FooAppService.class, testAppSrvName);
FooModuleService testMdSrvFromModule =
moduleExtensionDirector.getExtension(FooModuleService.class, testMdSrvName);
Assertions.assertNotNull(testFwSrvFromModule);
Assertions.assertNotNull(testAppSrvFromModule);
Assertions.assertNotNull(testMdSrvFromModule);
// test app extension loader
FooFrameworkService testFwSrvFromApp =
appExtensionDirector.getExtension(FooFrameworkService.class, testFwSrvName);
FooAppService testAppSrvFromApp = appExtensionDirector.getExtension(FooAppService.class, testAppSrvName);
FooModuleService testMdSrvFromApp = appExtensionDirector.getExtension(FooModuleService.class, testMdSrvName);
Assertions.assertSame(testFwSrvFromApp, testFwSrvFromModule);
Assertions.assertSame(testAppSrvFromApp, testAppSrvFromModule);
Assertions.assertNull(testMdSrvFromApp);
// test framework extension loader
FooFrameworkService testFwSrvFromFw =
fwExtensionDirector.getExtension(FooFrameworkService.class, testFwSrvName);
FooAppService testAppSrvFromFw = fwExtensionDirector.getExtension(FooAppService.class, testAppSrvName);
FooModuleService testMdSrvFromFw = fwExtensionDirector.getExtension(FooModuleService.class, testMdSrvName);
Assertions.assertSame(testFwSrvFromFw, testFwSrvFromApp);
Assertions.assertNull(testAppSrvFromFw);
Assertions.assertNull(testMdSrvFromFw);
}
@Test
void testPostProcessor() {}
@Test
void testModelAware() {
// Expecting:
// 1. Module scope SPI can be injected ModuleModel, ApplicationModel, FrameworkModel
// 2. Application scope SPI can be injected ApplicationModel, FrameworkModel, but not ModuleModel
// 3. Framework scope SPI can be injected FrameworkModel, but not ModuleModel, ApplicationModel
FrameworkModel frameworkModel = new FrameworkModel();
ApplicationModel applicationModel = frameworkModel.newApplication();
ModuleModel moduleModel = applicationModel.newModule();
ExtensionDirector moduleExtensionDirector = moduleModel.getExtensionDirector();
ExtensionDirector appExtensionDirector = applicationModel.getExtensionDirector();
ExtensionDirector fwExtensionDirector = frameworkModel.getExtensionDirector();
// check extension director inheritance
Assertions.assertSame(appExtensionDirector, moduleExtensionDirector.getParent());
Assertions.assertSame(fwExtensionDirector, appExtensionDirector.getParent());
Assertions.assertSame(null, fwExtensionDirector.getParent());
// check module extension aware
TestFrameworkService testFwSrvFromModule =
(TestFrameworkService) moduleExtensionDirector.getExtension(FooFrameworkService.class, testFwSrvName);
TestAppService testAppSrvFromModule =
(TestAppService) moduleExtensionDirector.getExtension(FooAppService.class, testAppSrvName);
TestModuleService testMdSrvFromModule =
(TestModuleService) moduleExtensionDirector.getExtension(FooModuleService.class, testMdSrvName);
Assertions.assertSame(frameworkModel, testFwSrvFromModule.getFrameworkModel());
Assertions.assertSame(null, testFwSrvFromModule.getApplicationModel());
Assertions.assertSame(null, testFwSrvFromModule.getModuleModel());
Assertions.assertSame(frameworkModel, testAppSrvFromModule.getFrameworkModel());
Assertions.assertSame(applicationModel, testAppSrvFromModule.getApplicationModel());
Assertions.assertSame(null, testAppSrvFromModule.getModuleModel());
Assertions.assertSame(frameworkModel, testMdSrvFromModule.getFrameworkModel());
Assertions.assertSame(applicationModel, testMdSrvFromModule.getApplicationModel());
Assertions.assertSame(moduleModel, testMdSrvFromModule.getModuleModel());
// check app extension aware
TestFrameworkService testFwSrvFromApp =
(TestFrameworkService) appExtensionDirector.getExtension(FooFrameworkService.class, testFwSrvName);
TestAppService testAppSrvFromApp =
(TestAppService) appExtensionDirector.getExtension(FooAppService.class, testAppSrvName);
TestModuleService testMdSrvFromApp =
(TestModuleService) appExtensionDirector.getExtension(FooModuleService.class, testMdSrvName);
Assertions.assertSame(testFwSrvFromApp, testFwSrvFromModule);
Assertions.assertSame(testAppSrvFromApp, testAppSrvFromModule);
Assertions.assertNull(testMdSrvFromApp);
// check framework extension aware
FooFrameworkService testFwSrvFromFw =
fwExtensionDirector.getExtension(FooFrameworkService.class, testFwSrvName);
FooAppService testAppSrvFromFw = fwExtensionDirector.getExtension(FooAppService.class, testAppSrvName);
FooModuleService testMdSrvFromFw = fwExtensionDirector.getExtension(FooModuleService.class, testMdSrvName);
Assertions.assertSame(testFwSrvFromFw, testFwSrvFromApp);
Assertions.assertNull(testAppSrvFromFw);
Assertions.assertNull(testMdSrvFromFw);
}
@Test
void testModelDataIsolation() {
// Model Tree
// ├─frameworkModel1
// │ ├─applicationModel11
// │ │ ├─moduleModel111
// │ │ └─moduleModel112
// │ └─applicationModel12
// │ └─moduleModel121
// └─frameworkModel2
// └─applicationModel21
// └─moduleModel211
FrameworkModel frameworkModel1 = new FrameworkModel();
ApplicationModel applicationModel11 = frameworkModel1.newApplication();
ModuleModel moduleModel111 = applicationModel11.newModule();
ModuleModel moduleModel112 = applicationModel11.newModule();
ApplicationModel applicationModel12 = frameworkModel1.newApplication();
ModuleModel moduleModel121 = applicationModel12.newModule();
FrameworkModel frameworkModel2 = new FrameworkModel();
ApplicationModel applicationModel21 = frameworkModel2.newApplication();
ModuleModel moduleModel211 = applicationModel21.newModule();
// test model references
Collection<ApplicationModel> applicationsOfFw1 = frameworkModel1.getApplicationModels();
Assertions.assertEquals(2, applicationsOfFw1.size());
Assertions.assertTrue(applicationsOfFw1.contains(applicationModel11));
Assertions.assertTrue(applicationsOfFw1.contains(applicationModel12));
Assertions.assertFalse(applicationsOfFw1.contains(applicationModel21));
Collection<ModuleModel> modulesOfApp11 = applicationModel11.getModuleModels();
Assertions.assertTrue(modulesOfApp11.contains(moduleModel111));
Assertions.assertTrue(modulesOfApp11.contains(moduleModel112));
// test isolation of FrameworkModel
FooFrameworkService frameworkService1 =
frameworkModel1.getExtensionDirector().getExtension(FooFrameworkService.class, testFwSrvName);
FooFrameworkService frameworkService2 =
frameworkModel2.getExtensionDirector().getExtension(FooFrameworkService.class, testFwSrvName);
Assertions.assertNotSame(frameworkService1, frameworkService2);
// test isolation of ApplicationModel
// applicationModel11 and applicationModel12 are shared frameworkModel1
FooFrameworkService frameworkService11 =
applicationModel11.getExtensionDirector().getExtension(FooFrameworkService.class, testFwSrvName);
FooFrameworkService frameworkService12 =
applicationModel12.getExtensionDirector().getExtension(FooFrameworkService.class, testFwSrvName);
Assertions.assertSame(frameworkService1, frameworkService11);
Assertions.assertSame(frameworkService1, frameworkService12);
// applicationModel11 and applicationModel12 are isolated in application scope
FooAppService applicationService11 =
applicationModel11.getExtensionDirector().getExtension(FooAppService.class, testAppSrvName);
FooAppService applicationService12 =
applicationModel12.getExtensionDirector().getExtension(FooAppService.class, testAppSrvName);
Assertions.assertNotSame(applicationService11, applicationService12);
// applicationModel11 and applicationModel21 are isolated in both framework and application scope
FooFrameworkService frameworkService21 =
applicationModel21.getExtensionDirector().getExtension(FooFrameworkService.class, testFwSrvName);
FooAppService applicationService21 =
applicationModel21.getExtensionDirector().getExtension(FooAppService.class, testAppSrvName);
Assertions.assertNotSame(frameworkService11, frameworkService21);
Assertions.assertNotSame(applicationService11, applicationService21);
// test isolation of ModuleModel
FooModuleService moduleService111 =
moduleModel111.getExtensionDirector().getExtension(FooModuleService.class, testMdSrvName);
FooModuleService moduleService112 =
moduleModel112.getExtensionDirector().getExtension(FooModuleService.class, testMdSrvName);
// moduleModel111 and moduleModel112 are isolated in module scope
Assertions.assertNotSame(moduleService111, moduleService112);
// moduleModel111 and moduleModel112 are shared applicationModel11
FooAppService applicationService111 =
moduleModel111.getExtensionDirector().getExtension(FooAppService.class, testAppSrvName);
FooAppService applicationService112 =
moduleModel112.getExtensionDirector().getExtension(FooAppService.class, testAppSrvName);
Assertions.assertSame(applicationService111, applicationService112);
// moduleModel111 and moduleModel121 are isolated in application scope, but shared frameworkModel1
FooAppService applicationService121 =
moduleModel121.getExtensionDirector().getExtension(FooAppService.class, testAppSrvName);
Assertions.assertNotSame(applicationService111, applicationService121);
FooFrameworkService frameworkService111 =
moduleModel111.getExtensionDirector().getExtension(FooFrameworkService.class, testFwSrvName);
FooFrameworkService frameworkService121 =
moduleModel121.getExtensionDirector().getExtension(FooFrameworkService.class, testFwSrvName);
Assertions.assertSame(frameworkService111, frameworkService121);
// moduleModel111 and moduleModel211 are isolated in both framework and application scope
FooModuleService moduleService211 =
moduleModel211.getExtensionDirector().getExtension(FooModuleService.class, testMdSrvName);
FooAppService applicationService211 =
moduleModel211.getExtensionDirector().getExtension(FooAppService.class, testAppSrvName);
FooFrameworkService frameworkService211 =
moduleModel211.getExtensionDirector().getExtension(FooFrameworkService.class, testFwSrvName);
Assertions.assertNotSame(moduleService111, moduleService211);
Assertions.assertNotSame(applicationService111, applicationService211);
Assertions.assertNotSame(frameworkService111, frameworkService211);
}
@Test
void testInjection() {
// Expect:
// 1. Framework scope extension can be injected to extensions of Framework/Application/Module scope
// 2. Application scope extension can be injected to extensions of Application/Module scope, but not Framework
// scope
// 3. Module scope extension can be injected to extensions of Module scope, but not Framework/Application scope
FrameworkModel frameworkModel = new FrameworkModel();
ApplicationModel applicationModel = frameworkModel.newApplication();
ModuleModel moduleModel = applicationModel.newModule();
// check module service
TestModuleService moduleService = (TestModuleService)
moduleModel.getExtensionDirector().getExtension(FooModuleService.class, testMdSrvName);
Assertions.assertNotNull(moduleService.getFrameworkService());
Assertions.assertNotNull(moduleService.getFrameworkProvider());
Assertions.assertNotNull(moduleService.getAppService());
Assertions.assertNotNull(moduleService.getAppProvider());
Assertions.assertNotNull(moduleService.getModuleProvider());
// check app service
TestAppService appService = (TestAppService)
applicationModel.getExtensionDirector().getExtension(FooAppService.class, testAppSrvName);
Assertions.assertNotNull(appService.getFrameworkService());
Assertions.assertNotNull(appService.getFrameworkProvider());
Assertions.assertNotNull(appService.getAppProvider());
Assertions.assertNull(appService.getModuleProvider());
// check framework service
TestFrameworkService frameworkService = (TestFrameworkService)
frameworkModel.getExtensionDirector().getExtension(FooFrameworkService.class, testFwSrvName);
Assertions.assertNotNull(frameworkService.getFrameworkProvider());
Assertions.assertNull(frameworkService.getAppProvider());
Assertions.assertNull(frameworkService.getModuleProvider());
Assertions.assertFalse(moduleService.isDestroyed());
Assertions.assertFalse(appService.isDestroyed());
Assertions.assertFalse(frameworkService.isDestroyed());
// destroy
frameworkModel.destroy();
Assertions.assertTrue(moduleService.isDestroyed());
Assertions.assertTrue(appService.isDestroyed());
Assertions.assertTrue(frameworkService.isDestroyed());
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGeneratorTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGeneratorTest.java | /*
* 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.dubbo.common.extension;
import org.apache.dubbo.common.extension.adaptive.HasAdaptiveExt;
import org.apache.dubbo.common.utils.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* {@link AdaptiveClassCodeGenerator} Test
*
* @since 2.7.5
*/
class AdaptiveClassCodeGeneratorTest {
@Test
void testGenerate() throws IOException {
AdaptiveClassCodeGenerator generator = new AdaptiveClassCodeGenerator(HasAdaptiveExt.class, "adaptive");
String value = generator.generate();
URL url = getClass().getResource("/org/apache/dubbo/common/extension/adaptive/HasAdaptiveExt$Adaptive");
try (InputStream inputStream = url.openStream()) {
String content = IOUtils.read(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
// in Windows platform content get from resource contains \r delimiter
content = content.replaceAll("\r", "");
assertTrue(content.contains(value));
}
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/DubboExternalLoadingStrategy.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/DubboExternalLoadingStrategy.java | /*
* 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.dubbo.common.extension;
/**
* Dubbo external {@link LoadingStrategy} for testing
*
* @since 2.7.7
*/
public class DubboExternalLoadingStrategy implements LoadingStrategy {
@Override
public String directory() {
return "META-INF/dubbo/external/";
}
@Override
public boolean overridden() {
return true;
}
@Override
public int getPriority() {
return MAX_PRIORITY + 1;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI4.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI4.java | /*
* 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.dubbo.common.extension;
@SPI
public interface SPI4 {
String sayHello();
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI2.java | /*
* 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.dubbo.common.extension;
@SPI
public interface SPI2 {
String sayHello();
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Adaptive_UseJdkCompiler_Test.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Adaptive_UseJdkCompiler_Test.java | /*
* 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.dubbo.common.extension;
import org.apache.dubbo.common.compiler.support.AdaptiveCompiler;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
class ExtensionLoader_Adaptive_UseJdkCompiler_Test extends ExtensionLoader_Adaptive_Test {
@BeforeAll
public static void setUp() throws Exception {
AdaptiveCompiler.setDefaultCompiler("jdk");
}
@AfterAll
public static void tearDown() throws Exception {
AdaptiveCompiler.setDefaultCompiler("javassist");
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Adaptive_Test.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Adaptive_Test.java | /*
* 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.dubbo.common.extension;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.adaptive.HasAdaptiveExt;
import org.apache.dubbo.common.extension.adaptive.impl.HasAdaptiveExt_ManualAdaptive;
import org.apache.dubbo.common.extension.ext1.SimpleExt;
import org.apache.dubbo.common.extension.ext2.Ext2;
import org.apache.dubbo.common.extension.ext2.UrlHolder;
import org.apache.dubbo.common.extension.ext3.UseProtocolKeyExt;
import org.apache.dubbo.common.extension.ext4.NoUrlParamExt;
import org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt;
import org.apache.dubbo.common.extension.ext6_inject.Ext6;
import org.apache.dubbo.common.extension.ext6_inject.impl.Ext6Impl2;
import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.LogUtil;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
class ExtensionLoader_Adaptive_Test {
@Test
void test_useAdaptiveClass() throws Exception {
ExtensionLoader<HasAdaptiveExt> loader = ExtensionLoader.getExtensionLoader(HasAdaptiveExt.class);
HasAdaptiveExt ext = loader.getAdaptiveExtension();
assertTrue(ext instanceof HasAdaptiveExt_ManualAdaptive);
}
@Test
void test_getAdaptiveExtension_defaultAdaptiveKey() throws Exception {
{
SimpleExt ext = ExtensionLoader.getExtensionLoader(SimpleExt.class).getAdaptiveExtension();
Map<String, String> map = new HashMap<String, String>();
URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1", map);
String echo = ext.echo(url, "haha");
assertEquals("Ext1Impl1-echo", echo);
}
{
SimpleExt ext = ExtensionLoader.getExtensionLoader(SimpleExt.class).getAdaptiveExtension();
Map<String, String> map = new HashMap<String, String>();
map.put("simple.ext", "impl2");
URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1", map);
String echo = ext.echo(url, "haha");
assertEquals("Ext1Impl2-echo", echo);
}
}
@Test
void test_getAdaptiveExtension_customizeAdaptiveKey() throws Exception {
SimpleExt ext = ExtensionLoader.getExtensionLoader(SimpleExt.class).getAdaptiveExtension();
Map<String, String> map = new HashMap<String, String>();
map.put("key2", "impl2");
URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1", map);
String echo = ext.yell(url, "haha");
assertEquals("Ext1Impl2-yell", echo);
url = url.addParameter("key1", "impl3"); // note: URL is value's type
echo = ext.yell(url, "haha");
assertEquals("Ext1Impl3-yell", echo);
}
@Test
void test_getAdaptiveExtension_protocolKey() throws Exception {
UseProtocolKeyExt ext =
ExtensionLoader.getExtensionLoader(UseProtocolKeyExt.class).getAdaptiveExtension();
{
String echo = ext.echo(URL.valueOf("1.2.3.4:20880"), "s");
assertEquals("Ext3Impl1-echo", echo); // default value
Map<String, String> map = new HashMap<String, String>();
URL url = new ServiceConfigURL("impl3", "1.2.3.4", 1010, "path1", map);
echo = ext.echo(url, "s");
assertEquals("Ext3Impl3-echo", echo); // use 2nd key, protocol
url = url.addParameter("key1", "impl2");
echo = ext.echo(url, "s");
assertEquals("Ext3Impl2-echo", echo); // use 1st key, key1
}
{
Map<String, String> map = new HashMap<String, String>();
URL url = new ServiceConfigURL(null, "1.2.3.4", 1010, "path1", map);
String yell = ext.yell(url, "s");
assertEquals("Ext3Impl1-yell", yell); // default value
url = url.addParameter("key2", "impl2"); // use 2nd key, key2
yell = ext.yell(url, "s");
assertEquals("Ext3Impl2-yell", yell);
url = url.setProtocol("impl3"); // use 1st key, protocol
yell = ext.yell(url, "d");
assertEquals("Ext3Impl3-yell", yell);
}
}
@Test
void test_getAdaptiveExtension_UrlNpe() throws Exception {
SimpleExt ext = ExtensionLoader.getExtensionLoader(SimpleExt.class).getAdaptiveExtension();
try {
ext.echo(null, "haha");
fail();
} catch (IllegalArgumentException e) {
assertEquals("url == null", e.getMessage());
}
}
@Test
void test_getAdaptiveExtension_ExceptionWhenNoAdaptiveMethodOnInterface() throws Exception {
try {
ExtensionLoader.getExtensionLoader(NoAdaptiveMethodExt.class).getAdaptiveExtension();
fail();
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
allOf(
containsString(
"Can't create adaptive extension interface org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt"),
containsString(
"No adaptive method exist on extension org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt, refuse to create the adaptive class")));
}
// report same error when get is invoked for multiple times
try {
ExtensionLoader.getExtensionLoader(NoAdaptiveMethodExt.class).getAdaptiveExtension();
fail();
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
allOf(
containsString(
"Can't create adaptive extension interface org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt"),
containsString(
"No adaptive method exist on extension org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt, refuse to create the adaptive class")));
}
}
@Test
void test_getAdaptiveExtension_ExceptionWhenNotAdaptiveMethod() throws Exception {
SimpleExt ext = ExtensionLoader.getExtensionLoader(SimpleExt.class).getAdaptiveExtension();
Map<String, String> map = new HashMap<String, String>();
URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1", map);
try {
ext.bang(url, 33);
fail();
} catch (UnsupportedOperationException expected) {
assertThat(expected.getMessage(), containsString("method "));
assertThat(
expected.getMessage(),
containsString(
"of interface org.apache.dubbo.common.extension.ext1.SimpleExt is not adaptive method!"));
}
}
@Test
void test_getAdaptiveExtension_ExceptionWhenNoUrlAttribute() throws Exception {
try {
ExtensionLoader.getExtensionLoader(NoUrlParamExt.class).getAdaptiveExtension();
fail();
} catch (Exception expected) {
assertThat(expected.getMessage(), containsString("Failed to create adaptive class for interface "));
assertThat(
expected.getMessage(),
containsString(": not found url parameter or url attribute in parameters of method "));
}
}
@Test
void test_urlHolder_getAdaptiveExtension() throws Exception {
Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
Map<String, String> map = new HashMap<String, String>();
map.put("ext2", "impl1");
URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1", map);
UrlHolder holder = new UrlHolder();
holder.setUrl(url);
String echo = ext.echo(holder, "haha");
assertEquals("Ext2Impl1-echo", echo);
}
@Test
void test_urlHolder_getAdaptiveExtension_noExtension() throws Exception {
Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1");
UrlHolder holder = new UrlHolder();
holder.setUrl(url);
try {
ext.echo(holder, "haha");
fail();
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString("Failed to get extension"));
}
url = url.addParameter("ext2", "XXX");
holder.setUrl(url);
try {
ext.echo(holder, "haha");
fail();
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString("No such extension"));
}
}
@Test
void test_urlHolder_getAdaptiveExtension_UrlNpe() throws Exception {
Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
try {
ext.echo(null, "haha");
fail();
} catch (IllegalArgumentException e) {
assertEquals("org.apache.dubbo.common.extension.ext2.UrlHolder argument == null", e.getMessage());
}
try {
ext.echo(new UrlHolder(), "haha");
fail();
} catch (IllegalArgumentException e) {
assertEquals("org.apache.dubbo.common.extension.ext2.UrlHolder argument getUrl() == null", e.getMessage());
}
}
@Test
void test_urlHolder_getAdaptiveExtension_ExceptionWhenNotAdativeMethod() throws Exception {
Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
Map<String, String> map = new HashMap<String, String>();
URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1", map);
try {
ext.bang(url, 33);
fail();
} catch (UnsupportedOperationException expected) {
assertThat(expected.getMessage(), containsString("method "));
assertThat(
expected.getMessage(),
containsString("of interface org.apache.dubbo.common.extension.ext2.Ext2 is not adaptive method!"));
}
}
@Test
void test_urlHolder_getAdaptiveExtension_ExceptionWhenNameNotProvided() throws Exception {
Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1");
UrlHolder holder = new UrlHolder();
holder.setUrl(url);
try {
ext.echo(holder, "impl1");
fail();
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString("Failed to get extension"));
}
url = url.addParameter("key1", "impl1");
holder.setUrl(url);
try {
ext.echo(holder, "haha");
fail();
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString(
"Failed to get extension (org.apache.dubbo.common.extension.ext2.Ext2) name from url"));
}
}
@Test
void test_getAdaptiveExtension_inject() throws Exception {
LogUtil.start();
Ext6 ext = ExtensionLoader.getExtensionLoader(Ext6.class).getAdaptiveExtension();
URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1");
url = url.addParameters("ext6", "impl1");
assertEquals("Ext6Impl1-echo-Ext1Impl1-echo", ext.echo(url, "ha"));
Assertions.assertTrue(LogUtil.checkNoError(), "can not find error.");
LogUtil.stop();
url = url.addParameters("simple.ext", "impl2");
assertEquals("Ext6Impl1-echo-Ext1Impl2-echo", ext.echo(url, "ha"));
}
@Test
void test_getAdaptiveExtension_InjectNotExtFail() throws Exception {
Ext6 ext = ExtensionLoader.getExtensionLoader(Ext6.class).getExtension("impl2");
Ext6Impl2 impl = (Ext6Impl2) ext;
assertNull(impl.getList());
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI4Impl.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI4Impl.java | /*
* 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.dubbo.common.extension;
@Activate
public class SPI4Impl implements SPI4 {
@Override
public String sayHello() {
return null;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI3.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI3.java | /*
* 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.dubbo.common.extension;
@SPI
public interface SPI3 {
String sayHello();
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI1Impl.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI1Impl.java | /*
* 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.dubbo.common.extension;
@Activate
public class SPI1Impl implements SPI1 {
@Override
public String sayHello() {
return null;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI1.java | /*
* 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.dubbo.common.extension;
@SPI
public interface SPI1 {
String sayHello();
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/NoSpiExt.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/NoSpiExt.java | /*
* 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.dubbo.common.extension;
import org.apache.dubbo.common.URL;
/**
* Has no SPI annotation
*/
public interface NoSpiExt {
@Adaptive
String echo(URL url, String s);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI2Impl.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI2Impl.java | /*
* 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.dubbo.common.extension;
@Activate
public class SPI2Impl implements SPI2 {
@Override
public String sayHello() {
return null;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java | /*
* 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.dubbo.common.extension;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.convert.Converter;
import org.apache.dubbo.common.convert.StringToBooleanConverter;
import org.apache.dubbo.common.convert.StringToDoubleConverter;
import org.apache.dubbo.common.convert.StringToIntegerConverter;
import org.apache.dubbo.common.extension.activate.ActivateExt1;
import org.apache.dubbo.common.extension.activate.impl.ActivateExt1Impl1;
import org.apache.dubbo.common.extension.activate.impl.GroupActivateExtImpl;
import org.apache.dubbo.common.extension.activate.impl.OrderActivateExtImpl1;
import org.apache.dubbo.common.extension.activate.impl.OrderActivateExtImpl2;
import org.apache.dubbo.common.extension.activate.impl.ValueActivateExtImpl;
import org.apache.dubbo.common.extension.convert.String2BooleanConverter;
import org.apache.dubbo.common.extension.convert.String2DoubleConverter;
import org.apache.dubbo.common.extension.convert.String2IntegerConverter;
import org.apache.dubbo.common.extension.duplicated.DuplicatedOverriddenExt;
import org.apache.dubbo.common.extension.duplicated.DuplicatedWithoutOverriddenExt;
import org.apache.dubbo.common.extension.ext1.SimpleExt;
import org.apache.dubbo.common.extension.ext1.impl.SimpleExtImpl1;
import org.apache.dubbo.common.extension.ext1.impl.SimpleExtImpl2;
import org.apache.dubbo.common.extension.ext10_multi_names.Ext10MultiNames;
import org.apache.dubbo.common.extension.ext11_no_adaptive.NoAdaptiveExt;
import org.apache.dubbo.common.extension.ext11_no_adaptive.NoAdaptiveExtImpl;
import org.apache.dubbo.common.extension.ext2.Ext2;
import org.apache.dubbo.common.extension.ext6_wrap.WrappedExt;
import org.apache.dubbo.common.extension.ext6_wrap.WrappedExtWrapper;
import org.apache.dubbo.common.extension.ext6_wrap.impl.Ext6Impl1;
import org.apache.dubbo.common.extension.ext6_wrap.impl.Ext6Impl3;
import org.apache.dubbo.common.extension.ext6_wrap.impl.Ext6Wrapper1;
import org.apache.dubbo.common.extension.ext6_wrap.impl.Ext6Wrapper2;
import org.apache.dubbo.common.extension.ext6_wrap.impl.Ext6Wrapper3;
import org.apache.dubbo.common.extension.ext6_wrap.impl.Ext6Wrapper4;
import org.apache.dubbo.common.extension.ext7.InitErrorExt;
import org.apache.dubbo.common.extension.ext8_add.AddExt1;
import org.apache.dubbo.common.extension.ext8_add.AddExt2;
import org.apache.dubbo.common.extension.ext8_add.AddExt3;
import org.apache.dubbo.common.extension.ext8_add.AddExt4;
import org.apache.dubbo.common.extension.ext8_add.impl.AddExt1Impl1;
import org.apache.dubbo.common.extension.ext8_add.impl.AddExt1_ManualAdaptive;
import org.apache.dubbo.common.extension.ext8_add.impl.AddExt1_ManualAdd1;
import org.apache.dubbo.common.extension.ext8_add.impl.AddExt1_ManualAdd2;
import org.apache.dubbo.common.extension.ext8_add.impl.AddExt2_ManualAdaptive;
import org.apache.dubbo.common.extension.ext8_add.impl.AddExt3_ManualAdaptive;
import org.apache.dubbo.common.extension.ext8_add.impl.AddExt4_ManualAdaptive;
import org.apache.dubbo.common.extension.ext9_empty.Ext9Empty;
import org.apache.dubbo.common.extension.ext9_empty.impl.Ext9EmptyImpl;
import org.apache.dubbo.common.extension.injection.InjectExt;
import org.apache.dubbo.common.extension.injection.impl.InjectExtImpl;
import org.apache.dubbo.common.extension.wrapper.Demo;
import org.apache.dubbo.common.extension.wrapper.impl.DemoImpl;
import org.apache.dubbo.common.extension.wrapper.impl.DemoWrapper;
import org.apache.dubbo.common.extension.wrapper.impl.DemoWrapper2;
import org.apache.dubbo.common.lang.Prioritized;
import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.rpc.model.ApplicationModel;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
import static org.apache.dubbo.common.extension.ExtensionLoader.getLoadingStrategies;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
class ExtensionLoaderTest {
private <T> ExtensionLoader<T> getExtensionLoader(Class<T> type) {
return ApplicationModel.defaultModel().getExtensionDirector().getExtensionLoader(type);
}
@Test
void test_getExtensionLoader_Null() {
try {
getExtensionLoader(null);
fail();
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage(), containsString("Extension type == null"));
}
}
@Test
void test_getExtensionLoader_NotInterface() {
try {
getExtensionLoader(ExtensionLoaderTest.class);
fail();
} catch (IllegalArgumentException expected) {
assertThat(
expected.getMessage(),
containsString(
"Extension type (class org.apache.dubbo.common.extension.ExtensionLoaderTest) is not an interface"));
}
}
@Test
void test_getExtensionLoader_NotSpiAnnotation() {
try {
getExtensionLoader(NoSpiExt.class);
fail();
} catch (IllegalArgumentException expected) {
assertThat(
expected.getMessage(),
allOf(
containsString("org.apache.dubbo.common.extension.NoSpiExt"),
containsString("is not an extension"),
containsString("NOT annotated with @SPI")));
}
}
@Test
void test_getDefaultExtension() {
SimpleExt ext = getExtensionLoader(SimpleExt.class).getDefaultExtension();
assertThat(ext, instanceOf(SimpleExtImpl1.class));
String name = getExtensionLoader(SimpleExt.class).getDefaultExtensionName();
assertEquals("impl1", name);
}
@Test
void test_getDefaultExtension_NULL() {
Ext2 ext = getExtensionLoader(Ext2.class).getDefaultExtension();
assertNull(ext);
String name = getExtensionLoader(Ext2.class).getDefaultExtensionName();
assertNull(name);
}
@Test
void test_getExtension() {
assertTrue(getExtensionLoader(SimpleExt.class).getExtension("impl1") instanceof SimpleExtImpl1);
assertTrue(getExtensionLoader(SimpleExt.class).getExtension("impl2") instanceof SimpleExtImpl2);
}
@Test
void test_getExtension_WithWrapper() {
WrappedExt impl1 = getExtensionLoader(WrappedExt.class).getExtension("impl1");
assertThat(impl1, anyOf(instanceOf(Ext6Wrapper1.class), instanceOf(Ext6Wrapper2.class)));
assertThat(impl1, instanceOf(WrappedExtWrapper.class));
// get origin instance from wrapper
WrappedExt originImpl1 = impl1;
while (originImpl1 instanceof WrappedExtWrapper) {
originImpl1 = ((WrappedExtWrapper) originImpl1).getOrigin();
}
// test unwrapped instance
WrappedExt unwrappedImpl1 = getExtensionLoader(WrappedExt.class).getExtension("impl1", false);
assertThat(unwrappedImpl1, instanceOf(Ext6Impl1.class));
assertNotSame(unwrappedImpl1, impl1);
assertSame(unwrappedImpl1, originImpl1);
WrappedExt impl2 = getExtensionLoader(WrappedExt.class).getExtension("impl2");
assertThat(impl2, anyOf(instanceOf(Ext6Wrapper1.class), instanceOf(Ext6Wrapper2.class)));
URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1");
int echoCount1 = Ext6Wrapper1.echoCount.get();
int echoCount2 = Ext6Wrapper2.echoCount.get();
assertEquals("Ext6Impl1-echo", impl1.echo(url, "ha"));
assertEquals(echoCount1 + 1, Ext6Wrapper1.echoCount.get());
assertEquals(echoCount2 + 1, Ext6Wrapper2.echoCount.get());
}
@Test
void test_getExtension_withWrapperAnnotation() {
WrappedExt impl3 = getExtensionLoader(WrappedExt.class).getExtension("impl3");
assertThat(impl3, instanceOf(Ext6Wrapper3.class));
WrappedExt originImpl3 = impl3;
while (originImpl3 instanceof WrappedExtWrapper) {
originImpl3 = ((WrappedExtWrapper) originImpl3).getOrigin();
}
// test unwrapped instance
WrappedExt unwrappedImpl3 = getExtensionLoader(WrappedExt.class).getExtension("impl3", false);
assertThat(unwrappedImpl3, instanceOf(Ext6Impl3.class));
assertNotSame(unwrappedImpl3, impl3);
assertSame(unwrappedImpl3, originImpl3);
WrappedExt impl4 = getExtensionLoader(WrappedExt.class).getExtension("impl4");
assertThat(impl4, instanceOf(Ext6Wrapper4.class));
URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1");
int echoCount3 = Ext6Wrapper3.echoCount.get();
int echoCount4 = Ext6Wrapper4.echoCount.get();
assertEquals("Ext6Impl4-echo", impl4.echo(url, "haha"));
assertEquals(echoCount3, Ext6Wrapper3.echoCount.get());
assertEquals(echoCount4 + 1, Ext6Wrapper4.echoCount.get());
}
@Test
void test_getActivateExtension_WithWrapper1() {
URL url = URL.valueOf("test://localhost/test");
List<ActivateExt1> list =
getExtensionLoader(ActivateExt1.class).getActivateExtension(url, new String[] {}, "order");
assertEquals(2, list.size());
}
@Test
void test_getExtension_ExceptionNoExtension() {
try {
getExtensionLoader(SimpleExt.class).getExtension("XXX");
fail();
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString("No such extension org.apache.dubbo.common.extension.ext1.SimpleExt by name XXX"));
}
}
@Test
void test_getExtension_ExceptionNoExtension_WrapperNotAffactName() {
try {
getExtensionLoader(WrappedExt.class).getExtension("XXX");
fail();
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString(
"No such extension org.apache.dubbo.common.extension.ext6_wrap.WrappedExt by name XXX"));
}
}
@Test
void test_getExtension_ExceptionNullArg() {
try {
getExtensionLoader(SimpleExt.class).getExtension(null);
fail();
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage(), containsString("Extension name == null"));
}
}
@Test
void test_hasExtension() {
assertTrue(getExtensionLoader(SimpleExt.class).hasExtension("impl1"));
assertFalse(getExtensionLoader(SimpleExt.class).hasExtension("impl1,impl2"));
assertFalse(getExtensionLoader(SimpleExt.class).hasExtension("xxx"));
try {
getExtensionLoader(SimpleExt.class).hasExtension(null);
fail();
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage(), containsString("Extension name == null"));
}
}
@Test
void test_hasExtension_wrapperIsNotExt() {
assertTrue(getExtensionLoader(WrappedExt.class).hasExtension("impl1"));
assertFalse(getExtensionLoader(WrappedExt.class).hasExtension("impl1,impl2"));
assertFalse(getExtensionLoader(WrappedExt.class).hasExtension("xxx"));
assertFalse(getExtensionLoader(WrappedExt.class).hasExtension("wrapper1"));
try {
getExtensionLoader(WrappedExt.class).hasExtension(null);
fail();
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage(), containsString("Extension name == null"));
}
}
@Test
void test_getSupportedExtensions() {
Set<String> exts = getExtensionLoader(SimpleExt.class).getSupportedExtensions();
Set<String> expected = new HashSet<>();
expected.add("impl1");
expected.add("impl2");
expected.add("impl3");
assertEquals(expected, exts);
}
@Test
void test_getSupportedExtensions_wrapperIsNotExt() {
Set<String> exts = getExtensionLoader(WrappedExt.class).getSupportedExtensions();
Set<String> expected = new HashSet<>();
expected.add("impl1");
expected.add("impl2");
expected.add("impl3");
expected.add("impl4");
assertEquals(expected, exts);
}
@Test
void test_AddExtension() {
try {
getExtensionLoader(AddExt1.class).getExtension("Manual1");
fail();
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString(
"No such extension org.apache.dubbo.common.extension.ext8_add.AddExt1 by name Manual"));
}
getExtensionLoader(AddExt1.class).addExtension("Manual1", AddExt1_ManualAdd1.class);
AddExt1 ext = getExtensionLoader(AddExt1.class).getExtension("Manual1");
assertThat(ext, instanceOf(AddExt1_ManualAdd1.class));
assertEquals("Manual1", getExtensionLoader(AddExt1.class).getExtensionName(AddExt1_ManualAdd1.class));
}
@Test
void test_AddExtension_NoExtend() {
getExtensionLoader(Ext9Empty.class).addExtension("ext9", Ext9EmptyImpl.class);
Ext9Empty ext = getExtensionLoader(Ext9Empty.class).getExtension("ext9");
assertThat(ext, instanceOf(Ext9Empty.class));
assertEquals("ext9", getExtensionLoader(Ext9Empty.class).getExtensionName(Ext9EmptyImpl.class));
}
@Test
void test_AddExtension_ExceptionWhenExistedExtension() {
SimpleExt ext = getExtensionLoader(SimpleExt.class).getExtension("impl1");
try {
getExtensionLoader(AddExt1.class).addExtension("impl1", AddExt1_ManualAdd1.class);
fail();
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString(
"Extension name impl1 already exists (Extension interface org.apache.dubbo.common.extension.ext8_add.AddExt1)!"));
}
}
@Test
void test_AddExtension_Adaptive() {
ExtensionLoader<AddExt2> loader = getExtensionLoader(AddExt2.class);
loader.addExtension(null, AddExt2_ManualAdaptive.class);
AddExt2 adaptive = loader.getAdaptiveExtension();
assertTrue(adaptive instanceof AddExt2_ManualAdaptive);
}
@Test
void test_AddExtension_Adaptive_ExceptionWhenExistedAdaptive() {
ExtensionLoader<AddExt1> loader = getExtensionLoader(AddExt1.class);
loader.getAdaptiveExtension();
try {
loader.addExtension(null, AddExt1_ManualAdaptive.class);
fail();
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString(
"Adaptive Extension already exists (Extension interface org.apache.dubbo.common.extension.ext8_add.AddExt1)!"));
}
}
@Test
void test_addExtension_with_error_class() {
try {
getExtensionLoader(SimpleExt.class).addExtension("impl1", ExtensionLoaderTest.class);
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString(
"Input type class org.apache.dubbo.common.extension.ExtensionLoaderTest "
+ "doesn't implement the Extension interface org.apache.dubbo.common.extension.ext1.SimpleExt"));
}
}
@Test
void test_addExtension_with_interface() {
try {
getExtensionLoader(SimpleExt.class).addExtension("impl1", SimpleExt.class);
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString("Input type interface org.apache.dubbo.common.extension.ext1.SimpleExt "
+ "can't be interface!"));
}
}
@Test
void test_addExtension_without_adaptive_annotation() {
try {
getExtensionLoader(NoAdaptiveExt.class).addExtension(null, NoAdaptiveExtImpl.class);
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString(
"Extension name is blank "
+ "(Extension interface org.apache.dubbo.common.extension.ext11_no_adaptive.NoAdaptiveExt)!"));
}
}
@Test
void test_getLoadedExtension_name_with_null() {
try {
getExtensionLoader(SimpleExt.class).getLoadedExtension(null);
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage(), containsString("Extension name == null"));
}
}
@Test
void test_getLoadedExtension_null() {
SimpleExt impl1 = getExtensionLoader(SimpleExt.class).getLoadedExtension("XXX");
assertNull(impl1);
}
@Test
void test_getLoadedExtension() {
SimpleExt simpleExt = getExtensionLoader(SimpleExt.class).getExtension("impl1");
assertThat(simpleExt, instanceOf(SimpleExtImpl1.class));
SimpleExt simpleExt1 = getExtensionLoader(SimpleExt.class).getLoadedExtension("impl1");
assertThat(simpleExt1, instanceOf(SimpleExtImpl1.class));
}
@Test
void test_getLoadedExtensions() {
SimpleExt simpleExt1 = getExtensionLoader(SimpleExt.class).getExtension("impl1");
assertThat(simpleExt1, instanceOf(SimpleExtImpl1.class));
SimpleExt simpleExt2 = getExtensionLoader(SimpleExt.class).getExtension("impl2");
assertThat(simpleExt2, instanceOf(SimpleExtImpl2.class));
Set<String> loadedExtensions = getExtensionLoader(SimpleExt.class).getLoadedExtensions();
Assertions.assertNotNull(loadedExtensions);
}
@Test
void test_getLoadedExtensionInstances() {
SimpleExt simpleExt1 = getExtensionLoader(SimpleExt.class).getExtension("impl1");
assertThat(simpleExt1, instanceOf(SimpleExtImpl1.class));
SimpleExt simpleExt2 = getExtensionLoader(SimpleExt.class).getExtension("impl2");
assertThat(simpleExt2, instanceOf(SimpleExtImpl2.class));
List<SimpleExt> loadedExtensionInstances =
getExtensionLoader(SimpleExt.class).getLoadedExtensionInstances();
Assertions.assertNotNull(loadedExtensionInstances);
}
@Test
void test_replaceExtension_with_error_class() {
try {
getExtensionLoader(SimpleExt.class).replaceExtension("impl1", ExtensionLoaderTest.class);
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString(
"Input type class org.apache.dubbo.common.extension.ExtensionLoaderTest "
+ "doesn't implement Extension interface org.apache.dubbo.common.extension.ext1.SimpleExt"));
}
}
@Test
void test_replaceExtension_with_interface() {
try {
getExtensionLoader(SimpleExt.class).replaceExtension("impl1", SimpleExt.class);
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString("Input type interface org.apache.dubbo.common.extension.ext1.SimpleExt "
+ "can't be interface!"));
}
}
@Test
void test_replaceExtension() {
try {
getExtensionLoader(AddExt1.class).getExtension("Manual2");
fail();
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString(
"No such extension org.apache.dubbo.common.extension.ext8_add.AddExt1 by name Manual"));
}
{
AddExt1 ext = getExtensionLoader(AddExt1.class).getExtension("impl1");
assertThat(ext, instanceOf(AddExt1Impl1.class));
assertEquals("impl1", getExtensionLoader(AddExt1.class).getExtensionName(AddExt1Impl1.class));
}
{
getExtensionLoader(AddExt1.class).replaceExtension("impl1", AddExt1_ManualAdd2.class);
AddExt1 ext = getExtensionLoader(AddExt1.class).getExtension("impl1");
assertThat(ext, instanceOf(AddExt1_ManualAdd2.class));
assertEquals("impl1", getExtensionLoader(AddExt1.class).getExtensionName(AddExt1_ManualAdd2.class));
}
}
@Test
void test_replaceExtension_Adaptive() {
ExtensionLoader<AddExt3> loader = getExtensionLoader(AddExt3.class);
AddExt3 adaptive = loader.getAdaptiveExtension();
assertFalse(adaptive instanceof AddExt3_ManualAdaptive);
loader.replaceExtension(null, AddExt3_ManualAdaptive.class);
adaptive = loader.getAdaptiveExtension();
assertTrue(adaptive instanceof AddExt3_ManualAdaptive);
}
@Test
void test_replaceExtension_ExceptionWhenNotExistedExtension() {
AddExt1 ext = getExtensionLoader(AddExt1.class).getExtension("impl1");
try {
getExtensionLoader(AddExt1.class).replaceExtension("NotExistedExtension", AddExt1_ManualAdd1.class);
fail();
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString(
"Extension name NotExistedExtension doesn't exist (Extension interface org.apache.dubbo.common.extension.ext8_add.AddExt1)"));
}
}
@Test
void test_replaceExtension_Adaptive_ExceptionWhenNotExistedExtension() {
ExtensionLoader<AddExt4> loader = getExtensionLoader(AddExt4.class);
try {
loader.replaceExtension(null, AddExt4_ManualAdaptive.class);
fail();
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString(
"Adaptive Extension doesn't exist (Extension interface org.apache.dubbo.common.extension.ext8_add.AddExt4)"));
}
}
@Test
void test_InitError() {
ExtensionLoader<InitErrorExt> loader = getExtensionLoader(InitErrorExt.class);
loader.getExtension("ok");
try {
loader.getExtension("error");
fail();
} catch (IllegalStateException expected) {
assertThat(
expected.getMessage(),
containsString(
"Failed to load extension class (interface: interface org.apache.dubbo.common.extension.ext7.InitErrorExt"));
assertThat(expected.getMessage(), containsString("java.lang.ExceptionInInitializerError"));
}
}
@Test
void testLoadActivateExtension() {
// test default
URL url = URL.valueOf("test://localhost/test");
List<ActivateExt1> list =
getExtensionLoader(ActivateExt1.class).getActivateExtension(url, new String[] {}, "default_group");
Assertions.assertEquals(1, list.size());
assertSame(list.get(0).getClass(), ActivateExt1Impl1.class);
// test group
url = url.addParameter(GROUP_KEY, "group1");
list = getExtensionLoader(ActivateExt1.class).getActivateExtension(url, new String[] {}, "group1");
Assertions.assertEquals(1, list.size());
assertSame(list.get(0).getClass(), GroupActivateExtImpl.class);
// test value
url = url.removeParameter(GROUP_KEY);
url = url.addParameter(GROUP_KEY, "value");
url = url.addParameter("value", "value");
list = getExtensionLoader(ActivateExt1.class).getActivateExtension(url, new String[] {}, "value");
Assertions.assertEquals(1, list.size());
assertSame(list.get(0).getClass(), ValueActivateExtImpl.class);
// test order
url = URL.valueOf("test://localhost/test");
url = url.addParameter(GROUP_KEY, "order");
list = getExtensionLoader(ActivateExt1.class).getActivateExtension(url, new String[] {}, "order");
Assertions.assertEquals(2, list.size());
assertSame(list.get(0).getClass(), OrderActivateExtImpl1.class);
assertSame(list.get(1).getClass(), OrderActivateExtImpl2.class);
}
@Test
void testLoadDefaultActivateExtension1() {
// test default
URL url = URL.valueOf("test://localhost/test?ext=order1,default");
List<ActivateExt1> list =
getExtensionLoader(ActivateExt1.class).getActivateExtension(url, "ext", "default_group");
Assertions.assertEquals(2, list.size());
assertSame(list.get(0).getClass(), OrderActivateExtImpl1.class);
assertSame(list.get(1).getClass(), ActivateExt1Impl1.class);
url = URL.valueOf("test://localhost/test?ext=default,order1");
list = getExtensionLoader(ActivateExt1.class).getActivateExtension(url, "ext", "default_group");
Assertions.assertEquals(2, list.size());
assertSame(list.get(0).getClass(), ActivateExt1Impl1.class);
assertSame(list.get(1).getClass(), OrderActivateExtImpl1.class);
url = URL.valueOf("test://localhost/test?ext=order1");
list = getExtensionLoader(ActivateExt1.class).getActivateExtension(url, "ext", "default_group");
Assertions.assertEquals(2, list.size());
assertSame(list.get(0).getClass(), ActivateExt1Impl1.class);
assertSame(list.get(1).getClass(), OrderActivateExtImpl1.class);
}
@Test
void testLoadDefaultActivateExtension2() {
// test default
URL url = URL.valueOf("test://localhost/test?ext=order1 , default");
List<ActivateExt1> list =
getExtensionLoader(ActivateExt1.class).getActivateExtension(url, "ext", "default_group");
Assertions.assertEquals(2, list.size());
assertSame(list.get(0).getClass(), OrderActivateExtImpl1.class);
assertSame(list.get(1).getClass(), ActivateExt1Impl1.class);
url = URL.valueOf("test://localhost/test?ext=default, order1");
list = getExtensionLoader(ActivateExt1.class).getActivateExtension(url, "ext", "default_group");
Assertions.assertEquals(2, list.size());
assertSame(list.get(0).getClass(), ActivateExt1Impl1.class);
assertSame(list.get(1).getClass(), OrderActivateExtImpl1.class);
url = URL.valueOf("test://localhost/test?ext=order1");
list = getExtensionLoader(ActivateExt1.class).getActivateExtension(url, "ext", "default_group");
Assertions.assertEquals(2, list.size());
assertSame(list.get(0).getClass(), ActivateExt1Impl1.class);
assertSame(list.get(1).getClass(), OrderActivateExtImpl1.class);
}
@Test
void testInjectExtension() {
// register bean for test ScopeBeanExtensionInjector
DemoImpl demoBean = new DemoImpl();
ApplicationModel.defaultModel().getBeanFactory().registerBean(demoBean);
// test default
InjectExt injectExt = getExtensionLoader(InjectExt.class).getExtension("injection");
InjectExtImpl injectExtImpl = (InjectExtImpl) injectExt;
Assertions.assertNotNull(injectExtImpl.getSimpleExt());
Assertions.assertNull(injectExtImpl.getSimpleExt1());
Assertions.assertNull(injectExtImpl.getGenericType());
Assertions.assertSame(demoBean, injectExtImpl.getDemo());
}
@Test
void testMultiNames() {
Ext10MultiNames ext10MultiNames =
getExtensionLoader(Ext10MultiNames.class).getExtension("impl");
Assertions.assertNotNull(ext10MultiNames);
ext10MultiNames = getExtensionLoader(Ext10MultiNames.class).getExtension("implMultiName");
Assertions.assertNotNull(ext10MultiNames);
Assertions.assertThrows(IllegalStateException.class, () -> getExtensionLoader(Ext10MultiNames.class)
.getExtension("impl,implMultiName"));
}
@Test
void testGetOrDefaultExtension() {
ExtensionLoader<InjectExt> loader = getExtensionLoader(InjectExt.class);
InjectExt injectExt = loader.getOrDefaultExtension("non-exists");
assertEquals(InjectExtImpl.class, injectExt.getClass());
assertEquals(
InjectExtImpl.class, loader.getOrDefaultExtension("injection").getClass());
}
@Test
void testGetSupported() {
ExtensionLoader<InjectExt> loader = getExtensionLoader(InjectExt.class);
assertEquals(1, loader.getSupportedExtensions().size());
assertEquals(Collections.singleton("injection"), loader.getSupportedExtensions());
}
/**
* @since 2.7.7
*/
@Test
void testOverridden() {
ExtensionLoader<Converter> loader = getExtensionLoader(Converter.class);
Converter converter = loader.getExtension("string-to-boolean");
assertEquals(String2BooleanConverter.class, converter.getClass());
converter = loader.getExtension("string-to-double");
assertEquals(String2DoubleConverter.class, converter.getClass());
converter = loader.getExtension("string-to-integer");
assertEquals(String2IntegerConverter.class, converter.getClass());
assertEquals("string-to-boolean", loader.getExtensionName(String2BooleanConverter.class));
assertEquals("string-to-boolean", loader.getExtensionName(StringToBooleanConverter.class));
assertEquals("string-to-double", loader.getExtensionName(String2DoubleConverter.class));
assertEquals("string-to-double", loader.getExtensionName(StringToDoubleConverter.class));
assertEquals("string-to-integer", loader.getExtensionName(String2IntegerConverter.class));
assertEquals("string-to-integer", loader.getExtensionName(StringToIntegerConverter.class));
}
/**
* @since 2.7.7
*/
@Test
void testGetLoadingStrategies() {
List<LoadingStrategy> strategies = getLoadingStrategies();
assertEquals(4, strategies.size());
int i = 0;
LoadingStrategy loadingStrategy = strategies.get(i++);
assertEquals(DubboInternalLoadingStrategy.class, loadingStrategy.getClass());
assertEquals(Prioritized.MAX_PRIORITY, loadingStrategy.getPriority());
loadingStrategy = strategies.get(i++);
assertEquals(DubboExternalLoadingStrategy.class, loadingStrategy.getClass());
assertEquals(Prioritized.MAX_PRIORITY + 1, loadingStrategy.getPriority());
loadingStrategy = strategies.get(i++);
assertEquals(DubboLoadingStrategy.class, loadingStrategy.getClass());
assertEquals(Prioritized.NORMAL_PRIORITY, loadingStrategy.getPriority());
loadingStrategy = strategies.get(i++);
assertEquals(ServicesLoadingStrategy.class, loadingStrategy.getClass());
assertEquals(Prioritized.MIN_PRIORITY, loadingStrategy.getPriority());
}
@Test
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | true |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI3Impl.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/SPI3Impl.java | /*
* 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.dubbo.common.extension;
@Activate
public class SPI3Impl implements SPI3 {
@Override
public String sayHello() {
return null;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Activate_Test.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Activate_Test.java | /*
* 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.dubbo.common.extension;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.activate.ActivateExt1;
import java.util.List;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ExtensionLoader_Activate_Test {
@Test
void test_onClass() throws Exception {
URL url = URL.valueOf("test://localhost/test");
ExtensionLoader<ActivateExt1> loader = ExtensionLoader.getExtensionLoader(ActivateExt1.class);
List<ActivateExt1> list = loader.getActivateExtension(url, new String[] {}, "onClass");
assertTrue(list == null || list.size() == 0);
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Compatible_Test.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Compatible_Test.java | /*
* 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.dubbo.common.extension;
import org.apache.dubbo.common.extension.compatible.CompatibleExt;
import org.apache.dubbo.common.extension.compatible.impl.CompatibleExtImpl1;
import org.apache.dubbo.common.extension.compatible.impl.CompatibleExtImpl2;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.ModuleModel;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
class ExtensionLoader_Compatible_Test {
@Test
void test_getExtension() {
ModuleModel moduleModel = ApplicationModel.defaultModel().getDefaultModule();
assertTrue(
moduleModel.getExtensionLoader(CompatibleExt.class).getExtension("impl1")
instanceof CompatibleExtImpl1);
assertTrue(
moduleModel.getExtensionLoader(CompatibleExt.class).getExtension("impl2")
instanceof CompatibleExtImpl2);
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/injection/InjectExt.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/injection/InjectExt.java | /*
* 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.dubbo.common.extension.injection;
import org.apache.dubbo.common.extension.SPI;
@SPI("injection")
public interface InjectExt {
String echo(String msg);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/injection/impl/InjectExtImpl.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/injection/impl/InjectExtImpl.java | /*
* 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.dubbo.common.extension.injection.impl;
import org.apache.dubbo.common.extension.DisableInject;
import org.apache.dubbo.common.extension.ext1.SimpleExt;
import org.apache.dubbo.common.extension.injection.InjectExt;
import org.apache.dubbo.common.extension.wrapper.Demo;
public class InjectExtImpl implements InjectExt {
private SimpleExt simpleExt;
private SimpleExt simpleExt1;
private Object genericType;
private Demo demo;
public void setSimpleExt(SimpleExt simpleExt) {
this.simpleExt = simpleExt;
}
@DisableInject
public void setSimpleExt1(SimpleExt simpleExt1) {
this.simpleExt1 = simpleExt1;
}
public void setGenericType(Object genericType) {
this.genericType = genericType;
}
@Override
public String echo(String msg) {
return null;
}
public SimpleExt getSimpleExt() {
return simpleExt;
}
public SimpleExt getSimpleExt1() {
return simpleExt1;
}
public Object getGenericType() {
return genericType;
}
public Demo getDemo() {
return demo;
}
public void setDemo(Demo demo) {
this.demo = demo;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/inject/AdaptiveExtensionInjectorTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/inject/AdaptiveExtensionInjectorTest.java | /*
* 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.dubbo.common.extension.inject;
import org.apache.dubbo.common.beans.ScopeBeanExtensionInjector;
import org.apache.dubbo.common.beans.factory.ScopeBeanFactory;
import org.apache.dubbo.common.extension.ExtensionInjector;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.extension.director.FooFrameworkProvider;
import org.apache.dubbo.rpc.model.FrameworkModel;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* {@link AdaptiveExtensionInjector}
* {@link ScopeBeanExtensionInjector}
* {@link SpiExtensionInjector}
*/
class AdaptiveExtensionInjectorTest {
@Test
void test() {
FrameworkModel frameworkModel = new FrameworkModel();
ExtensionLoader<ExtensionInjector> extensionLoader = frameworkModel.getExtensionLoader(ExtensionInjector.class);
ExtensionInjector adaptiveExtensionInjector = extensionLoader.getAdaptiveExtension();
ExtensionInjector scopeExtensionInjector = extensionLoader.getExtension("scopeBean");
ExtensionInjector spiExtensionInjector = extensionLoader.getExtension("spi");
FooFrameworkProvider testFrameworkProvider =
adaptiveExtensionInjector.getInstance(FooFrameworkProvider.class, "testFrameworkProvider");
Assertions.assertNotNull(testFrameworkProvider);
Assertions.assertTrue(testFrameworkProvider.getClass().getName().endsWith("$Adaptive"));
Assertions.assertEquals(
spiExtensionInjector.getInstance(FooFrameworkProvider.class, "testFrameworkProvider"),
testFrameworkProvider);
ScopeBeanFactory beanFactory = frameworkModel.getBeanFactory();
AdaptiveExtensionInjectorTest obj = new AdaptiveExtensionInjectorTest();
beanFactory.registerBean("bean", obj);
AdaptiveExtensionInjectorTest bean =
adaptiveExtensionInjector.getInstance(AdaptiveExtensionInjectorTest.class, "bean");
Assertions.assertEquals(bean, obj);
Assertions.assertEquals(scopeExtensionInjector.getInstance(AdaptiveExtensionInjectorTest.class, "bean"), bean);
frameworkModel.destroy();
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext3/UseProtocolKeyExt.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext3/UseProtocolKeyExt.java | /*
* 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.dubbo.common.extension.ext3;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
@SPI("impl1")
public interface UseProtocolKeyExt {
// protocol key is the second
@Adaptive({"key1", "protocol"})
String echo(URL url, String s);
// protocol key is the first
@Adaptive({"protocol", "key2"})
String yell(URL url, String s);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext3/impl/UseProtocolKeyExtImpl2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext3/impl/UseProtocolKeyExtImpl2.java | /*
* 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.dubbo.common.extension.ext3.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext3.UseProtocolKeyExt;
public class UseProtocolKeyExtImpl2 implements UseProtocolKeyExt {
public String echo(URL url, String s) {
return "Ext3Impl2-echo";
}
public String yell(URL url, String s) {
return "Ext3Impl2-yell";
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext3/impl/UseProtocolKeyExtImpl1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext3/impl/UseProtocolKeyExtImpl1.java | /*
* 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.dubbo.common.extension.ext3.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext3.UseProtocolKeyExt;
public class UseProtocolKeyExtImpl1 implements UseProtocolKeyExt {
public String echo(URL url, String s) {
return "Ext3Impl1-echo";
}
public String yell(URL url, String s) {
return "Ext3Impl1-yell";
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext3/impl/UseProtocolKeyExtImpl3.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext3/impl/UseProtocolKeyExtImpl3.java | /*
* 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.dubbo.common.extension.ext3.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext3.UseProtocolKeyExt;
public class UseProtocolKeyExtImpl3 implements UseProtocolKeyExt {
public String echo(URL url, String s) {
return "Ext3Impl3-echo";
}
public String yell(URL url, String s) {
return "Ext3Impl3-yell";
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Filter1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Filter1.java | /*
* 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.dubbo.common.extension.support;
import org.apache.dubbo.common.extension.Activate;
@Activate
public class Filter1 implements Filter0 {}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Filter2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Filter2.java | /*
* 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.dubbo.common.extension.support;
import org.apache.dubbo.common.extension.Activate;
@Activate(before = "_1")
public class Filter2 implements Filter0 {}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Order0Filter2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Order0Filter2.java | /*
* 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.dubbo.common.extension.support;
import org.apache.dubbo.common.extension.Activate;
@Activate
public class Order0Filter2 implements Order0Filter0 {}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/ActivateComparatorTest.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/ActivateComparatorTest.java | /*
* 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.dubbo.common.extension.support;
import org.apache.dubbo.rpc.model.ApplicationModel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class ActivateComparatorTest {
private ActivateComparator activateComparator;
@BeforeEach
public void setup() {
activateComparator =
new ActivateComparator(ApplicationModel.defaultModel().getExtensionDirector());
}
@Test
void testActivateComparator() {
Filter1 f1 = new Filter1();
Filter2 f2 = new Filter2();
Filter3 f3 = new Filter3();
Filter4 f4 = new Filter4();
List<Class<?>> filters = new ArrayList<>();
filters.add(f1.getClass());
filters.add(f2.getClass());
filters.add(f3.getClass());
filters.add(f4.getClass());
Collections.sort(filters, activateComparator);
Assertions.assertEquals(f4.getClass(), filters.get(0));
Assertions.assertEquals(f3.getClass(), filters.get(1));
Assertions.assertEquals(f2.getClass(), filters.get(2));
Assertions.assertEquals(f1.getClass(), filters.get(3));
}
@Test
void testFilterOrder() {
Order0Filter1 order0Filter1 = new Order0Filter1();
Order0Filter2 order0Filter2 = new Order0Filter2();
List<Class<?>> filters = null;
{
filters = new ArrayList<>();
filters.add(order0Filter1.getClass());
filters.add(order0Filter2.getClass());
filters.sort(activateComparator);
Assertions.assertEquals(order0Filter1.getClass(), filters.get(0));
Assertions.assertEquals(order0Filter2.getClass(), filters.get(1));
}
{
filters = new ArrayList<>();
filters.add(order0Filter2.getClass());
filters.add(order0Filter1.getClass());
filters.sort(activateComparator);
Assertions.assertEquals(order0Filter1.getClass(), filters.get(0));
Assertions.assertEquals(order0Filter2.getClass(), filters.get(1));
}
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Filter0.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Filter0.java | /*
* 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.dubbo.common.extension.support;
import org.apache.dubbo.common.extension.SPI;
@SPI
public interface Filter0 {}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Filter3.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Filter3.java | /*
* 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.dubbo.common.extension.support;
import org.apache.dubbo.common.extension.Activate;
@Activate(after = "_4")
public class Filter3 implements Filter0 {}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Filter4.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Filter4.java | /*
* 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.dubbo.common.extension.support;
import org.apache.dubbo.common.extension.Activate;
@Activate(before = "_2")
public class Filter4 implements Filter0 {}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Order0Filter1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Order0Filter1.java | /*
* 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.dubbo.common.extension.support;
import org.apache.dubbo.common.extension.Activate;
@Activate
public class Order0Filter1 implements Order0Filter0 {}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Order0Filter0.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/support/Order0Filter0.java | /*
* 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.dubbo.common.extension.support;
import org.apache.dubbo.common.extension.SPI;
@SPI
public interface Order0Filter0 {}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/AddExt2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/AddExt2.java | /*
* 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.dubbo.common.extension.ext8_add;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
/**
* show add extension pragmatically. use for test addAdaptive successful
*/
@SPI("impl1")
public interface AddExt2 {
@Adaptive
String echo(URL url, String s);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/AddExt4.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/AddExt4.java | /*
* 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.dubbo.common.extension.ext8_add;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
/**
* show add extension pragmatically. use for test replaceAdaptive fail
*/
@SPI("impl1")
public interface AddExt4 {
@Adaptive
String echo(URL url, String s);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/AddExt1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/AddExt1.java | /*
* 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.dubbo.common.extension.ext8_add;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
/**
* show add extension pragmatically
*/
@SPI("impl1")
public interface AddExt1 {
@Adaptive
String echo(URL url, String s);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/AddExt3.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/AddExt3.java | /*
* 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.dubbo.common.extension.ext8_add;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
/**
* show add extension pragmatically. use for test replaceAdaptive success
*/
@SPI("impl1")
public interface AddExt3 {
@Adaptive
String echo(URL url, String s);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt1_ManualAdd1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt1_ManualAdd1.java | /*
* 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.dubbo.common.extension.ext8_add.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext8_add.AddExt1;
public class AddExt1_ManualAdd1 implements AddExt1 {
public String echo(URL url, String s) {
return this.getClass().getSimpleName();
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt1Impl1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt1Impl1.java | /*
* 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.dubbo.common.extension.ext8_add.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext8_add.AddExt1;
public class AddExt1Impl1 implements AddExt1 {
public String echo(URL url, String s) {
return this.getClass().getSimpleName();
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt2_ManualAdaptive.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt2_ManualAdaptive.java | /*
* 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.dubbo.common.extension.ext8_add.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.extension.ext8_add.AddExt2;
@Adaptive
public class AddExt2_ManualAdaptive implements AddExt2 {
public String echo(URL url, String s) {
AddExt2 addExt1 = ExtensionLoader.getExtensionLoader(AddExt2.class).getExtension(url.getParameter("add.ext2"));
return addExt1.echo(url, s);
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt3_ManualAdaptive.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt3_ManualAdaptive.java | /*
* 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.dubbo.common.extension.ext8_add.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.extension.ext8_add.AddExt3;
@Adaptive
public class AddExt3_ManualAdaptive implements AddExt3 {
public String echo(URL url, String s) {
AddExt3 addExt1 = ExtensionLoader.getExtensionLoader(AddExt3.class).getExtension(url.getParameter("add.ext3"));
return addExt1.echo(url, s);
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt1_ManualAdd2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt1_ManualAdd2.java | /*
* 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.dubbo.common.extension.ext8_add.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext8_add.AddExt1;
public class AddExt1_ManualAdd2 implements AddExt1 {
public String echo(URL url, String s) {
return this.getClass().getSimpleName();
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt1_ManualAdaptive.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt1_ManualAdaptive.java | /*
* 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.dubbo.common.extension.ext8_add.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.extension.ext8_add.AddExt1;
@Adaptive
public class AddExt1_ManualAdaptive implements AddExt1 {
public String echo(URL url, String s) {
AddExt1 addExt1 = ExtensionLoader.getExtensionLoader(AddExt1.class).getExtension(url.getParameter("add.ext1"));
return addExt1.echo(url, s);
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt4_ManualAdaptive.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt4_ManualAdaptive.java | /*
* 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.dubbo.common.extension.ext8_add.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.extension.ext8_add.AddExt4;
@Adaptive
public class AddExt4_ManualAdaptive implements AddExt4 {
public String echo(URL url, String s) {
AddExt4 addExt1 = ExtensionLoader.getExtensionLoader(AddExt4.class).getExtension(url.getParameter("add.ext4"));
return addExt1.echo(url, s);
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt2Impl1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext8_add/impl/AddExt2Impl1.java | /*
* 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.dubbo.common.extension.ext8_add.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext8_add.AddExt2;
public class AddExt2Impl1 implements AddExt2 {
public String echo(URL url, String s) {
return this.getClass().getSimpleName();
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext4/NoUrlParamExt.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext4/NoUrlParamExt.java | /*
* 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.dubbo.common.extension.ext4;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
import java.util.List;
@SPI("impl1")
public interface NoUrlParamExt {
// method has no URL parameter
@Adaptive
String bark(String name, List<Object> list);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext4/impl/Ext4Impl2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext4/impl/Ext4Impl2.java | /*
* 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.dubbo.common.extension.ext4.impl;
import org.apache.dubbo.common.extension.ext4.NoUrlParamExt;
import java.util.List;
public class Ext4Impl2 implements NoUrlParamExt {
public String bark(String name, List<Object> list) {
return null;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext4/impl/Ext4Impl1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext4/impl/Ext4Impl1.java | /*
* 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.dubbo.common.extension.ext4.impl;
import org.apache.dubbo.common.extension.ext4.NoUrlParamExt;
import java.util.List;
public class Ext4Impl1 implements NoUrlParamExt {
public String bark(String name, List<Object> list) {
return null;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext5/NoAdaptiveMethodExt.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext5/NoAdaptiveMethodExt.java | /*
* 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.dubbo.common.extension.ext5;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.SPI;
/**
* No Adaptive Method!!
*/
@SPI("impl1")
public interface NoAdaptiveMethodExt {
String echo(URL url, String s);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext5/impl/Ext5Impl1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext5/impl/Ext5Impl1.java | /*
* 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.dubbo.common.extension.ext5.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt;
public class Ext5Impl1 implements NoAdaptiveMethodExt {
public String echo(URL url, String s) {
return "Ext5Impl1-echo";
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext5/impl/Ext5Impl2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext5/impl/Ext5Impl2.java | /*
* 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.dubbo.common.extension.ext5.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt;
public class Ext5Impl2 implements NoAdaptiveMethodExt {
public String echo(URL url, String s) {
return "Ext5Impl2-echo";
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext6_inject/Dao.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext6_inject/Dao.java | /*
* 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.dubbo.common.extension.ext6_inject;
public interface Dao {
void update();
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext6_inject/Ext6.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext6_inject/Ext6.java | /*
* 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.dubbo.common.extension.ext6_inject;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
/**
* No default
*/
@SPI
public interface Ext6 {
@Adaptive
String echo(URL url, String s);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext6_inject/impl/DaoImpl.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext6_inject/impl/DaoImpl.java | /*
* 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.dubbo.common.extension.ext6_inject.impl;
import org.apache.dubbo.common.extension.ext6_inject.Dao;
public class DaoImpl implements Dao {
public void update() {}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext6_inject/impl/Ext6Impl2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext6_inject/impl/Ext6Impl2.java | /*
* 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.dubbo.common.extension.ext6_inject.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext6_inject.Ext6;
import java.util.List;
public class Ext6Impl2 implements Ext6 {
List<String> list;
public List<String> getList() {
return list;
}
public void setList(List<String> list) {
this.list = list;
}
public String echo(URL url, String s) {
throw new UnsupportedOperationException();
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext6_inject/impl/Ext6Impl1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext6_inject/impl/Ext6Impl1.java | /*
* 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.dubbo.common.extension.ext6_inject.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext1.SimpleExt;
import org.apache.dubbo.common.extension.ext6_inject.Dao;
import org.apache.dubbo.common.extension.ext6_inject.Ext6;
import org.junit.jupiter.api.Assertions;
public class Ext6Impl1 implements Ext6 {
public Dao obj;
SimpleExt ext1;
public void setDao(Dao obj) {
Assertions.assertNotNull(obj, "inject extension instance can not be null");
Assertions.fail();
}
public void setExt1(SimpleExt ext1) {
this.ext1 = ext1;
}
public String echo(URL url, String s) {
return "Ext6Impl1-echo-" + ext1.echo(url, s);
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/ActivateWrapperExt1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/ActivateWrapperExt1.java | /*
* 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.dubbo.common.extension.activate;
import org.apache.dubbo.common.extension.SPI;
@SPI("extImp1")
public interface ActivateWrapperExt1 {
String echo(String msg);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/ActivateExt1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/ActivateExt1.java | /*
* 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.dubbo.common.extension.activate;
import org.apache.dubbo.common.extension.SPI;
@SPI("impl1")
public interface ActivateExt1 {
String echo(String msg);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/ValueActivateExtImpl.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/ValueActivateExtImpl.java | /*
* 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.dubbo.common.extension.activate.impl;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.extension.activate.ActivateExt1;
@Activate(
value = {"value"},
group = {"value"})
public class ValueActivateExtImpl implements ActivateExt1 {
public String echo(String msg) {
return msg;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/ActivateOnClassExt1Impl.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/ActivateOnClassExt1Impl.java | /*
* 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.dubbo.common.extension.activate.impl;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.extension.activate.ActivateExt1;
@Activate(
group = {"onClass"},
onClass = "org.springframework.security.core.context.SecurityContextHolder")
public class ActivateOnClassExt1Impl implements ActivateExt1 {
@Override
public String echo(String msg) {
return null;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/ActivateWrapperExt1Wrapper.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/ActivateWrapperExt1Wrapper.java | /*
* 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.dubbo.common.extension.activate.impl;
import org.apache.dubbo.common.extension.activate.ActivateWrapperExt1;
public class ActivateWrapperExt1Wrapper implements ActivateWrapperExt1 {
private ActivateWrapperExt1 activateWrapperExt1;
public ActivateWrapperExt1Wrapper(ActivateWrapperExt1 activateWrapperExt1) {
this.activateWrapperExt1 = activateWrapperExt1;
}
@Override
public String echo(String msg) {
return activateWrapperExt1.echo(msg);
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/GroupActivateExtImpl.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/GroupActivateExtImpl.java | /*
* 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.dubbo.common.extension.activate.impl;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.extension.activate.ActivateExt1;
@Activate(group = {"group1", "group2"})
public class GroupActivateExtImpl implements ActivateExt1 {
public String echo(String msg) {
return msg;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/OrderActivateExtImpl2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/OrderActivateExtImpl2.java | /*
* 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.dubbo.common.extension.activate.impl;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.extension.activate.ActivateExt1;
@Activate(
order = 100,
group = {"order"})
public class OrderActivateExtImpl2 implements ActivateExt1 {
public String echo(String msg) {
return msg;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/ActivateExt1Impl1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/ActivateExt1Impl1.java | /*
* 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.dubbo.common.extension.activate.impl;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.extension.activate.ActivateExt1;
@Activate(
order = 1,
group = {"default_group"})
public class ActivateExt1Impl1 implements ActivateExt1 {
public String echo(String msg) {
return msg;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/ActivateWrapperExt1Impl2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/ActivateWrapperExt1Impl2.java | /*
* 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.dubbo.common.extension.activate.impl;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.extension.activate.ActivateWrapperExt1;
@Activate(
order = 2,
group = {"order"})
public class ActivateWrapperExt1Impl2 implements ActivateWrapperExt1 {
public String echo(String msg) {
return msg;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/OrderActivateExtImpl1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/OrderActivateExtImpl1.java | /*
* 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.dubbo.common.extension.activate.impl;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.extension.activate.ActivateExt1;
@Activate(
order = 2,
group = {"order"})
public class OrderActivateExtImpl1 implements ActivateExt1 {
public String echo(String msg) {
return msg;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/ActivateWrapperExt1Impl1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/activate/impl/ActivateWrapperExt1Impl1.java | /*
* 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.dubbo.common.extension.activate.impl;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.extension.activate.ActivateWrapperExt1;
@Activate(
order = 1,
group = {"order"})
public class ActivateWrapperExt1Impl1 implements ActivateWrapperExt1 {
public String echo(String msg) {
return msg;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext2/UrlHolder.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext2/UrlHolder.java | /*
* 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.dubbo.common.extension.ext2;
import org.apache.dubbo.common.URL;
public class UrlHolder {
private Double Num;
private URL url;
private String name;
private int age;
public Double getNum() {
return Num;
}
public void setNum(Double num) {
Num = num;
}
public URL getUrl() {
return url;
}
public void setUrl(URL url) {
this.url = url;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext2/Ext2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext2/Ext2.java | /*
* 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.dubbo.common.extension.ext2;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
/**
* Has no default
*/
@SPI
public interface Ext2 {
// one of the properties of an argument is an instance of URL.
@Adaptive
String echo(UrlHolder holder, String s);
String bang(URL url, int i);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext2/impl/Ext2Impl3.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext2/impl/Ext2Impl3.java | /*
* 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.dubbo.common.extension.ext2.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext2.Ext2;
import org.apache.dubbo.common.extension.ext2.UrlHolder;
public class Ext2Impl3 implements Ext2 {
public String echo(UrlHolder holder, String s) {
return "Ext2Impl3-echo";
}
public String bang(URL url, int i) {
return "bang3";
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext2/impl/Ext2Impl1.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext2/impl/Ext2Impl1.java | /*
* 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.dubbo.common.extension.ext2.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext2.Ext2;
import org.apache.dubbo.common.extension.ext2.UrlHolder;
public class Ext2Impl1 implements Ext2 {
public String echo(UrlHolder holder, String s) {
return "Ext2Impl1-echo";
}
public String bang(URL url, int i) {
return "bang1";
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext2/impl/Ext2Impl2.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext2/impl/Ext2Impl2.java | /*
* 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.dubbo.common.extension.ext2.impl;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ext2.Ext2;
import org.apache.dubbo.common.extension.ext2.UrlHolder;
public class Ext2Impl2 implements Ext2 {
public String echo(UrlHolder holder, String s) {
return "Ext2Impl2-echo";
}
public String bang(URL url, int i) {
return "bang2";
}
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext10_multi_names/Ext10MultiNames.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext10_multi_names/Ext10MultiNames.java | /*
* 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.dubbo.common.extension.ext10_multi_names;
import org.apache.dubbo.common.extension.SPI;
@SPI
public interface Ext10MultiNames {}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext10_multi_names/impl/Ext10MultiNamesImpl.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext10_multi_names/impl/Ext10MultiNamesImpl.java | /*
* 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.dubbo.common.extension.ext10_multi_names.impl;
import org.apache.dubbo.common.extension.ext10_multi_names.Ext10MultiNames;
public class Ext10MultiNamesImpl implements Ext10MultiNames {}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
apache/dubbo | https://github.com/apache/dubbo/blob/ac1621f9a0470054c0308c47f84c7668f6bc2868/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext7/InitErrorExt.java | dubbo-common/src/test/java/org/apache/dubbo/common/extension/ext7/InitErrorExt.java | /*
* 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.dubbo.common.extension.ext7;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
/**
* Test scenario for DUBBO-144: extension load failure when third-party dependency doesn't exist. If extension is not
* referenced/used, do not report error in load time (instead, report issue when it gets used)
*/
@SPI
public interface InitErrorExt {
@Adaptive
String echo(URL url, String s);
}
| java | Apache-2.0 | ac1621f9a0470054c0308c47f84c7668f6bc2868 | 2026-01-04T14:45:57.057261Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.