User: starksm 
  Date: 01/04/18 12:48:28

  Modified:    src/main/org/jboss/test/lock/test Main.java
  Log:
  Try to clean up out of date JUnit tests.
  Add additional naming tests
  
  Revision  Changes    Path
  1.3       +53 -49    jbosstest/src/main/org/jboss/test/lock/test/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/lock/test/Main.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Main.java 2000/10/19 01:28:08     1.2
  +++ Main.java 2001/04/18 19:48:28     1.3
  @@ -14,7 +14,8 @@
   import org.jboss.test.lock.interfaces.EnterpriseEntity;
   
   
  -public class Main {
  +public class Main extends junit.framework.TestCase
  +{
        
        boolean deployed = false;
        int nbThreads;
  @@ -25,66 +26,69 @@
        HashMap param = new HashMap();
        EnterpriseEntity entity;
        
  -     public static void main(String arg[]) {
  +     public static void main(String arg[]) throws Exception {
                Main main = new Main(arg);
                
  -             main.go();
  +             main.testLock();
        }
  -     
  +
        public Main(String arg[]) {
  -             
  +             super("main");
                // scanning parameters
                int i = 0;
                while (i < arg.length) {
                        StringTokenizer st = new StringTokenizer (arg[i++], "=");
                        param.put (st.nextToken (),     st.hasMoreTokens () ? 
st.nextToken () : "");
                }
  -     }
  -     
  -     public void go() {
  -             try {
  -                     if (param.containsKey("help") || param.containsKey("-help")) {
  -                             System.out.println("Valid Parameters:");
  -                             System.out.println("  threads=<t>     run <t> threads 
concurrently (default 2)");
  -                             System.out.println("  iterations=<n>  each thread will 
perform <n> calls (default 10)");
  -                             System.out.println("  b2b             use bean to bean 
calls (default: single bean call)");
  -                             System.out.println();
  -                             System.exit(0);
  -                     }
  -                             
  -                     
  -                     init();       // get params
  -                     if (! nodeploy) deploy();     // deploy the bean
  -                     
  -                     Context ctx = new InitialContext();
  -                     EnterpriseEntityHome home = 
(EnterpriseEntityHome)ctx.lookup("EnterpriseEntity");
  -                     
  -                     try {
  -                             entity = home.findByPrimaryKey("seb");
  -                     } catch (FinderException e) {
  -                             entity = home.create("seb");
  -                     }
  -                     
  -                     if (b2b) entity.setNextEntity("daniel");
  -                     
  -                     Worker[] threads = new Worker[nbThreads];
  -                     
  -                     System.out.println("Spawning " + nbThreads + " threads for " + 
  -                             iterations + " iterations" + 
  -                             (b2b ? " with bean to bean call" : " with single bean 
call")); 
  -                     
  -                     for (int i=0; i<nbThreads; i++) {
  -                             threads[i] = new Worker("thread no " + (i+1));
  -                             threads[i].start();
  -                     }
  -                     
  -                     for (int i=0; i<nbThreads; i++) threads[i].join();
  -             
  -             } catch (Exception e) {
  -                     e.printStackTrace();
  +             if (param.containsKey("help") || param.containsKey("-help")) {
  +                     System.out.println("Valid Parameters:");
  +                     System.out.println("  threads=<t>     run <t> threads 
concurrently (default 2)");
  +                     System.out.println("  iterations=<n>  each thread will perform 
<n> calls (default 10)");
  +                     System.out.println("  b2b             use bean to bean calls 
(default: single bean call)");
  +                     System.out.println();
  +                     System.exit(0);
                }
        }
  -     
  +
  +    public Main(String name)
  +    {
  +        super(name);
  +    }
  +
  +    protected void setUp() throws Exception
  +    {
  +        init();       // get params
  +        if( nodeploy == false )
  +            deploy();     // deploy the bean
  +    }
  +
  +    public void testLock() throws Exception
  +    {                
  +        Context ctx = new InitialContext();
  +        EnterpriseEntityHome home = 
(EnterpriseEntityHome)ctx.lookup("EnterpriseEntity");
  +                     
  +        try {
  +            entity = home.findByPrimaryKey("seb");
  +        } catch (FinderException e) {
  +            entity = home.create("seb");
  +        }
  +                     
  +        if (b2b) entity.setNextEntity("daniel");
  +                     
  +        Worker[] threads = new Worker[nbThreads];
  +                     
  +        System.out.println("Spawning " + nbThreads + " threads for " + 
  +                iterations + " iterations" + 
  +                (b2b ? " with bean to bean call" : " with single bean call")); 
  +                     
  +        for (int i=0; i<nbThreads; i++) {
  +            threads[i] = new Worker("thread no " + (i+1));
  +            threads[i].start();
  +        }
  +                     
  +        for (int i=0; i<nbThreads; i++) threads[i].join();   
  +    }
  +
        
        private void init() {
                nbThreads = 2;
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to