-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
24 changed files
with
173 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...org/springcn/rsf/example/dto/Product.java → .../springstack/rsf/example/dto/Product.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.springcn.rsf.example.dto; | ||
package org.springstack.rsf.example.dto; | ||
|
||
/** | ||
* Prodct Info. | ||
|
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
6 changes: 3 additions & 3 deletions
6
...f/example/service/ProductServiceImpl.java → ...f/example/service/ProductServiceImpl.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
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
34 changes: 0 additions & 34 deletions
34
samples/HelloSpringRSF/src/test/java/org/springcn/rsf/example/rpc/ProductServiceTest.java
This file was deleted.
Oops, something went wrong.
94 changes: 94 additions & 0 deletions
94
samples/HelloSpringRSF/src/test/java/org/springstack/rsf/example/rpc/ProductServiceTest.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,94 @@ | ||
package org.springstack.rsf.example.rpc; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.IOException; | ||
import java.net.HttpURLConnection; | ||
import java.net.InetAddress; | ||
import java.net.InetSocketAddress; | ||
import java.net.Socket; | ||
import java.net.URL; | ||
import java.net.UnknownHostException; | ||
import java.nio.channels.SocketChannel; | ||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springstack.rsf.example.dto.Product; | ||
import org.springstack.rsf.example.rpc.ProductService; | ||
|
||
@ContextConfiguration(locations = "classpath:applicationContext-rpc-test.xml") | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
public class ProductServiceTest { | ||
|
||
@Autowired | ||
private ProductService productService; | ||
|
||
@Test | ||
public void testInvokeRpcMethod() { | ||
Product product = productService.get(1L); | ||
assertNotNull(product); | ||
assertEquals(product.getId(), new Long(1L)); | ||
|
||
assertTrue(productService.delete(1L)); | ||
|
||
List<Product> products = productService.findByCategory("all"); | ||
assertTrue(products.size() > 0); | ||
} | ||
|
||
@Test | ||
public void testHttpPing() throws UnknownHostException, IOException { | ||
for(int i = 0; i < 200; i++){ | ||
// long s1 = System.currentTimeMillis(); | ||
// boolean s2 = pingByURL("http://191.2.3.2:81"); | ||
// long s3 = System.currentTimeMillis(); | ||
// | ||
long f1 = System.currentTimeMillis(); | ||
boolean f2 = InetAddress.getByName("127.0.0.1").isReachable(10); | ||
long f3 = System.currentTimeMillis(); | ||
|
||
|
||
System.out.println(" Socket:" + (f3-f1) + " " + f2); | ||
} | ||
} | ||
|
||
public static boolean pingByURL(String URLName){ | ||
try { | ||
HttpURLConnection.setFollowRedirects(false); | ||
// note : you may also need | ||
// HttpURLConnection.setInstanceFollowRedirects(false) | ||
HttpURLConnection con = | ||
(HttpURLConnection) new URL(URLName).openConnection(); | ||
con.setRequestMethod("HEAD"); | ||
return (con.getResponseCode() == HttpURLConnection.HTTP_OK); | ||
} | ||
catch (Exception e) { | ||
//e.printStackTrace(); | ||
return false; | ||
} | ||
} | ||
|
||
public static boolean pingBySocket(String hostnameOrIP, int port) { | ||
Socket socket = null; | ||
boolean reachable = false; | ||
try { | ||
socket = new Socket(hostnameOrIP, port); | ||
reachable = true; | ||
}catch(Exception e){ | ||
e.printStackTrace(); | ||
} | ||
finally { | ||
if (socket != null) try { socket.close(); } catch(IOException e) {} | ||
} | ||
return reachable; | ||
} | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...springcn/rsf/LocalRSFServersProvider.java → ...ingstack/rsf/LocalRSFServersProvider.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.springcn.rsf; | ||
package org.springstack.rsf; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
2 changes: 1 addition & 1 deletion
2
...main/java/org/springcn/rsf/RSFServer.java → ...n/java/org/springstack/rsf/RSFServer.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.springcn.rsf; | ||
package org.springstack.rsf; | ||
|
||
import java.net.URI; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
.../org/springcn/rsf/RSFServersProvider.java → ...g/springstack/rsf/RSFServersProvider.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.springcn.rsf; | ||
package org.springstack.rsf; | ||
|
||
import java.util.List; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
.../springcn/rsf/http/HttpClientBuilder.java → ...ringstack/rsf/http/HttpClientBuilder.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
6 changes: 3 additions & 3 deletions
6
...oadbalancer/AbstractLoadBalancerRule.java → ...oadbalancer/AbstractLoadBalancerRule.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
4 changes: 2 additions & 2 deletions
4
...g/springcn/rsf/loadbalancer/HttpPing.java → ...pringstack/rsf/loadbalancer/HttpPing.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
2 changes: 1 addition & 1 deletion
2
...rsf/loadbalancer/LoadBalancerFactory.java → ...rsf/loadbalancer/LoadBalancerFactory.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.springcn.rsf.loadbalancer; | ||
package org.springstack.rsf.loadbalancer; | ||
|
||
|
||
/** | ||
|
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
Oops, something went wrong.