KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > repository > RepositoryTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.repository;
24
25 import java.util.*;
26 import javax.naming.*;
27 // IASRI 4660742 START
28
import java.util.logging.*;
29 import com.sun.logging.*;
30 // IASRI 4660742 END
31

32 import com.sun.enterprise.repository.Repository;
33
34 public class RepositoryTest {
35 // IASRI 4660742 START
36
private static Logger _logger=null;
37     static{
38        _logger=LogDomains.getLogger(LogDomains.ROOT_LOGGER);
39         }
40 // IASRI 4660742 END
41
/*
42     public static void main(String[] args) {
43         boolean runReadOnlyTest = true;
44         boolean runReadWriteTest = true;
45         switch (args.length) {
46             case 1:
47                 if (args[0] == "r") {
48                     runReadOnlyTest = true;
49                     runReadWriteTest = false;
50                 } else if (args[0] == "rw") {
51                     runReadOnlyTest = false;
52                     runReadWriteTest = true;
53                 } else if (args[0] == "b") {
54                     runReadOnlyTest = true;
55                     runReadWriteTest = true;
56                 }
57             default:
58                 runReadOnlyTest = true;
59                 runReadWriteTest = true;
60                 break;
61         }
62         Repository.createInstance("repository.txt", true);
63         if (runReadOnlyTest) {
64             boolean passed = readOnlyTest(Repository.getInstance());
65         }
66         if (runReadWriteTest) {
67             boolean passed = readWriteTest(Repository.getInstance());
68         }
69         Repository.destroyInstance();
70     }
71     
72     static boolean readOnlyTest(Repository rep) {
73         boolean passed = rep.find("app1") == null ? false : true;
74 // IASRI 4660742 System.out.println("Read only test " + (passed ? "passed." : "failed!"));
75 // START OF IASRI 4660742
76     if(_logger.isLoggable(Level.FINE))
77         _logger.log(Level.FINE,"Read only test " + (passed ? "passed." : "failed!"));
78 // END OF IASRI 4660742
79         return passed;
80     }
81     
82     static boolean readWriteTest(Repository rep) {
83         boolean passed = true;
84         passed = passed && rep.add("app1", "file:///ejbd/jars/app1.jar");
85         passed = passed && rep.add("app2", "file:///ejbd/jars/app2.jar");
86 // IASRI 4660742 System.out.println("Read write test " + (passed ? "passed":"failed"));
87 // START OF IASRI 4660742
88     if(_logger.isLoggable(Level.FINE))
89         _logger.log(Level.FINE,"Read write test " + (passed ? "passed":"failed"));
90 // END OF IASRI 4660742
91         return passed;
92     }
93 */

94 }
95
Popular Tags