forked from apache/dubbo
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe71a91
commit 5078dc3
Showing
3 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
...config-spring/src/test/java/org/apache/dubbo/config/spring/schema/GenericServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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.config.spring.schema; | ||
|
||
import org.apache.dubbo.config.spring.ReferenceBean; | ||
import org.apache.dubbo.config.spring.ServiceBean; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.context.annotation.ImportResource; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
@RunWith(SpringRunner.class) | ||
@ContextConfiguration(classes = GenericServiceTest.class) | ||
@ImportResource(locations = "classpath:/META-INF/spring/dubbo-generic-consumer.xml") | ||
public class GenericServiceTest { | ||
|
||
@Autowired | ||
@Qualifier("demoServiceRef") | ||
private ReferenceBean referenceBean; | ||
|
||
@Autowired | ||
@Qualifier("demoService") | ||
private ServiceBean serviceBean; | ||
|
||
@Test | ||
public void testBeanDefinitionParser() { | ||
assertNotNull(referenceBean); | ||
assertNotNull(serviceBean); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...o-config-spring/src/test/java/org/apache/dubbo/config/spring/schema/MyGenericService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.config.spring.schema; | ||
|
||
import org.apache.dubbo.rpc.service.GenericException; | ||
import org.apache.dubbo.rpc.service.GenericService; | ||
|
||
public class MyGenericService implements GenericService { | ||
|
||
public Object $invoke(String methodName, String[] parameterTypes, Object[] args) throws GenericException { | ||
if ("sayHello".equals(methodName)) { | ||
return "Welcome " + args[0]; | ||
} | ||
return null; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...-config/dubbo-config-spring/src/test/resources/META-INF/spring/dubbo-generic-consumer.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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. | ||
--> | ||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo" | ||
xmlns="http://www.springframework.org/schema/beans" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd | ||
http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd"> | ||
|
||
<!-- 当前应用信息配置 --> | ||
<dubbo:application name="dubbo-generic-consumer"/> | ||
|
||
<!-- 连接注册中心配置 --> | ||
<dubbo:registry address="N/A"/> | ||
|
||
<dubbo:reference id="demoServiceRef" interface="org.apache.dubbo.config.spring.api.DemoService" generic="true"/> | ||
|
||
<bean id="genericService" class="org.apache.dubbo.config.spring.schema.MyGenericService"/> | ||
|
||
<dubbo:service id="demoService" interface="org.apache.dubbo.demo.service.DemoService" generic="true" | ||
ref="genericService"/> | ||
</beans> |