/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 * 
 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 
 * 
 * The contents of this file are subject to the terms of the Common Development
 * and Distribution License("CDDL") (the "License").  You may not use this file
 * except in compliance with the License. 
 * 
 * You can obtain a copy of the License at:
 *     https://jersey.dev.java.net/license.txt
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * When distributing the Covered Code, include this CDDL Header Notice in each
 * file and include the License file at:
 *     https://jersey.dev.java.net/license.txt
 * If applicable, add the following below this CDDL Header, with the fields
 * enclosed by brackets [] replaced by your own identifying information:
 *     "Portions Copyrighted [year] [name of copyright owner]"
 */

package com.sun.ws.rest.deployer;

import java.io.File;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.UriTemplate;

/**
 * Some Proof of Concept Tests
 * @author Frank D. Martinez. fmartinez@asimovt.com
 */
public class Test {

    public static void main(String[] args) {
        if ("1".endsWith(args[0])) {
            testHelloWorld();
        }
        else if ("2".endsWith(args[0])) {
            testHelloWorldWeb();
        }
        else if ("3".endsWith(args[0])) {
            testBookstore();
        }
    }

    private static void testHelloWorld() {
        
        // Load the scanner
        ResourceClassScanner scanner = new ASMResourceClassScanner();
        
        // Annotations to be matched
        Class[] annotations = 
                new Class[] { UriTemplate.class, HttpMethod.class };
        
        // Classpath
        File[] repos = new File[] { new File("examples/HelloWorld") };
        
        // Show matching classes
        System.out.println("HelloWorld --------------------------------------");
        System.out.println(scanner.scan(repos, annotations));
        
    }
    
    private static void testHelloWorldWeb() {
        
        // Load the scanner
        ResourceClassScanner scanner = new ASMResourceClassScanner();
        
        // Annotations to be matched
        Class[] annotations = 
                new Class[] { UriTemplate.class, HttpMethod.class };
        
        // Classpath
        File[] repos = new File[] { 
            new File("examples/SimpleServlet_war/WEB-INF/classes"),
            new File("examples/SimpleServlet_war/WEB-INF/lib") 
        };
        
        // Show matching classes
        System.out.println("HelloWorldWeb -----------------------------------");
        System.out.println(scanner.scan(repos, annotations));
        
    }
    
    private static void testBookstore() {
        
        // Load the scanner
        ResourceClassScanner scanner = new ASMResourceClassScanner();
        
        // Annotations to be matched
        Class[] annotations = 
                new Class[] { UriTemplate.class, HttpMethod.class };
        
        // Classpath
        File[] repos = new File[] { 
            new File("examples/Bookstore_war/WEB-INF/classes"),
            new File("examples/Bookstore_war/WEB-INF/lib") 
        };
        
        // Show matching classes
        System.out.println("Bookstore ---------------------------------------");
        System.out.println(scanner.scan(repos, annotations));
        
    }

}
