summaryrefslogtreecommitdiff
path: root/java/test/Glacier2/attack/AttackClient.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/test/Glacier2/attack/AttackClient.java')
-rw-r--r--java/test/Glacier2/attack/AttackClient.java138
1 files changed, 0 insertions, 138 deletions
diff --git a/java/test/Glacier2/attack/AttackClient.java b/java/test/Glacier2/attack/AttackClient.java
deleted file mode 100644
index 1a93f058ae4..00000000000
--- a/java/test/Glacier2/attack/AttackClient.java
+++ /dev/null
@@ -1,138 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-import Test.*;
-
-class AttackClient extends Ice.Application
-{
- public int
- run(String[] args)
- {
- System.out.print("getting router... ");
- System.out.flush();
- Ice.ObjectPrx routerBase = communicator().stringToProxy("Glacier2/router:default -p 12347 -t 10000");
- Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.checkedCast(routerBase);
- test(router != null);
- System.out.println("ok");
-
- System.out.print("creating session... ");
- System.out.flush();
- try
- {
- Glacier2.SessionPrx session = router.createSession("userid", "abc123");
- }
- catch(Glacier2.PermissionDeniedException ex)
- {
- assert(false);
- }
- catch(Glacier2.CannotCreateSessionException ex)
- {
- assert(false);
- }
- communicator().setDefaultRouter(router);
- System.out.println("ok");
-
- System.out.print("making thousands of invocations on proxies... ");
- System.out.flush();
- Ice.ObjectPrx backendBase = communicator().stringToProxy("dummy:tcp -p 12010 -t 10000");
- BackendPrx backend = BackendPrxHelper.uncheckedCast(backendBase);
- backend.ice_ping();
-
- java.util.Map<BackendPrx, BackendPrx> backends = new java.util.HashMap<BackendPrx, BackendPrx>();
- java.util.Random rand = new java.util.Random();
-
- String msg = "";
- for(int i = 1; i <= 10000; ++i)
- {
- if(i % 100 == 0)
- {
- for(int j = 0; j < msg.length(); ++j)
- {
- System.out.print('\b');
- }
-
- msg = "" + i;
- System.out.print(i);
- System.out.flush();
- }
-
- Ice.Identity ident = new Ice.Identity();
-
- StringBuffer name = new StringBuffer();
- name.append((char)('A' + rand.nextInt(26)));
- ident.name = name.toString();
-
- StringBuffer category = new StringBuffer();
- int len = rand.nextInt(2);
- for(int j = 0; j < len; ++j)
- {
- category.append((char)('a' + rand.nextInt(26)));
- }
- ident.category = category.toString();
-
- BackendPrx newBackend = BackendPrxHelper.uncheckedCast(backendBase.ice_identity(ident));
-
- if(!backends.containsKey(newBackend))
- {
- backends.put(newBackend, newBackend);
- backend = newBackend;
- }
- else
- {
- backend = backends.get(newBackend);
- }
-
- backend.ice_ping();
- }
-
- for(int j = 0; j < msg.length(); ++j)
- {
- System.out.print('\b');
- }
- for(int j = 0; j < msg.length(); ++j)
- {
- System.out.print(' ');
- }
- for(int j = 0; j < msg.length(); ++j)
- {
- System.out.print('\b');
- }
- System.out.println("ok");
-
- System.out.print("testing server and router shutdown... ");
- System.out.flush();
- backend.shutdown();
- communicator().setDefaultRouter(null);
- Ice.ObjectPrx processBase =
- communicator().stringToProxy("Glacier2/admin -f Process:tcp -h 127.0.0.1 -p 12348 -t 10000");
- Ice.ProcessPrx process = Ice.ProcessPrxHelper.checkedCast(processBase);
- test(process != null);
- process.shutdown();
- try
- {
- process.ice_ping();
- test(false);
- }
- catch(Ice.LocalException ex)
- {
- System.out.println("ok");
- }
-
- return 0;
- }
-
- private static void
- test(boolean b)
- {
- if(!b)
- {
- throw new RuntimeException();
- }
- }
-}