/*
 * JBoss, Home of Professional Open Source.
 * Copyright (c) 2011, Red Hat, Inc., and individual contributors
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.as.embedded.ejb3;

import org.junit.Assert;
import org.junit.Test;

import javax.ejb.embeddable.EJBContainer;
import java.io.File;
import java.util.Collections;

/**
 * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
 */
public class ClassPathEjbJarScannerTest {
    @Test
    public void testEmpty() {
        // use surefire.test.class.path, because we don't (want to) know our test environment
        final String oldProperty = System.setProperty("surefire.test.class.path", "non-existent");
        // setup an empty entry in the middle
        System.setProperty("surefire.test.class.path", "/dummy1" + File.pathSeparator + File.pathSeparator + "/dummy2");
        try {
            ClassPathEjbJarScanner.getEjbJars(Collections.<Object, Object>emptyMap());
        }
        finally {
            if (oldProperty != null)
                System.setProperty("surefire.test.class.path", oldProperty);
        }
    }

    @Test
    public void testNonExistent() {
        // use surefire.test.class.path, because we don't (want to) know our test environment
        final String oldProperty = System.setProperty("surefire.test.class.path", "non-existent");
        try {
            ClassPathEjbJarScanner.getEjbJars(Collections.<Object, Object>emptyMap());
        }
        finally {
            if (oldProperty != null)
                System.setProperty("surefire.test.class.path", oldProperty);
        }
    }


    @Test
    public void testSpecifyingFile() {
        final String myFile = "/my/file.jar";
        final String[] results = ClassPathEjbJarScanner.getEjbJars(Collections.singletonMap(EJBContainer.MODULES, new File(myFile)));
        Assert.assertEquals(1, results.length);
        Assert.assertEquals(myFile, results[0]);
    }

        @Test
    public void testSpecifyingFileArray() {
        final String myFile = "/my/file.jar";
        final String[] results = ClassPathEjbJarScanner.getEjbJars(Collections.singletonMap(EJBContainer.MODULES, new File[]{new File(myFile)}));
        Assert.assertEquals(1, results.length);
        Assert.assertEquals(myFile, results[0]);
    }

}

@@ -1078,81 +1078,14 @@
 nit.
-Assert;%0Aimport org.junit.Test;%0A%0Aimport javax.ejb.embeddable.EJBContainer;
+Test;%0A
 %0Aimp
@@ -2411,694 +2411,6 @@
  %7D%0A%0A
-%0A    @Test%0A    public void testSpecifyingFile() %7B%0A        final String myFile = %22/my/file.jar%22;%0A        final String%5B%5D results = ClassPathEjbJarScanner.getEjbJars(Collections.singletonMap(EJBContainer.MODULES, new File(myFile)));%0A        Assert.assertEquals(1, results.length);%0A        Assert.assertEquals(myFile, results%5B0%5D);%0A    %7D%0A%0A        @Test%0A    public void testSpecifyingFileArray() %7B%0A        final String myFile = %22/my/file.jar%22;%0A        final String%5B%5D results = ClassPathEjbJarScanner.getEjbJars(Collections.singletonMap(EJBContainer.MODULES, new File%5B%5D%7Bnew File(myFile)%7D));%0A        Assert.assertEquals(1, results.length);%0A        Assert.assertEquals(myFile, results%5B0%5D);%0A    %7D%0A%0A
 %7D%0A

Delete bogus tests