Author: pete.muir(a)jboss.org
Date: 2009-03-10 10:11:50 -0400 (Tue, 10 Mar 2009)
New Revision: 1906
Added:
test-harness/trunk/tests/
test-harness/trunk/tests/pom.xml
test-harness/trunk/tests/src/
test-harness/trunk/tests/src/main/
test-harness/trunk/tests/src/main/java/
test-harness/trunk/tests/src/main/resources/
test-harness/trunk/tests/src/test/
test-harness/trunk/tests/src/test/java/
test-harness/trunk/tests/src/test/java/org/
test-harness/trunk/tests/src/test/java/org/jboss/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/impl/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/impl/packaging/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/impl/packaging/ear/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/impl/packaging/ear/ejb-jar.xml
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/mock/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/mock/MockConfiguration.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/AbstractArtifactTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/Cow.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/DeclarativeEarTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/DummyTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/Fox.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Cow.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DeclarativeStandaloneTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyClassesSpecifiedTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyCustomBeansXmlTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyEjbTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyIntegrationTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyResourcesSpecifiedTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyWarUnitTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Fox.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/subpackage/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/subpackage/Rat.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/Cow.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/DeclarativeWarTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/DummyTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/Fox.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarativeArtifact/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/Cow.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/DummyTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/EarArtifactTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/ArtifactTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/Cow.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/Fox.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/Cow.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/SubpackagesArtifactTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/subpackge/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/subpackge/Fox.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/Cow.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/DummyTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/TCKArtifactTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/Cow.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/DummyTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/WarArtifactTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/ArtifactScannerTest.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/DummyArtifact.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/subpackage/
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/subpackage/AnotherDummyArtifact.java
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/subpackage/NotAnArtifact.java
test-harness/trunk/tests/src/test/resources/
test-harness/trunk/tests/src/test/resources/org/
test-harness/trunk/tests/src/test/resources/org/jboss/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/impl/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/impl/packaging/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/impl/packaging/ear/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/impl/packaging/ear/ejb-jar.xml
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/foo/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/foo/foo.xml
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/my-web-beans.xml
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/war/
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/war/my-web.xml
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarativeArtifact/
Removed:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/impl/packaging/ear/
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/mock/
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/AbstractArtifactTest.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Cow.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DeclarativeStandaloneTest.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyClassesSpecifiedTest.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyCustomBeansXmlTest.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyEjbTest.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyIntegrationTest.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyResourcesSpecifiedTest.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyTest.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyWarUnitTest.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Fox.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/subpackage/
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarativeArtifact/
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/Cow.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/SubpackagesArtifactTest.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/subpackge/
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/ArtifactScannerTest.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/DummyArtifact.java
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/subpackage/
test-harness/trunk/impl/src/test/resources/org/jboss/testharness/impl/packaging/ear/
test-harness/trunk/impl/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/
test-harness/trunk/impl/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/foo/
test-harness/trunk/impl/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/my-web-beans.xml
test-harness/trunk/impl/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/war/
test-harness/trunk/impl/src/test/resources/org/jboss/testharness/test/impl/packaging/declarativeArtifact/
Modified:
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/jsr299/TCKArtifactDescriptor.java
test-harness/trunk/pom.xml
Log:
split out tests and don't rebuild harness jar
Modified:
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/jsr299/TCKArtifactDescriptor.java
===================================================================
---
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/jsr299/TCKArtifactDescriptor.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/jsr299/TCKArtifactDescriptor.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -8,34 +8,12 @@
import java.io.Writer;
import org.apache.log4j.Logger;
-import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.ArtifactDescriptor;
import org.jboss.testharness.impl.packaging.ResourceDescriptor;
import org.jboss.testharness.impl.util.DeploymentProperties;
public class TCKArtifactDescriptor extends ArtifactDescriptor
{
-
- private static ResourceDescriptor getTckSupportJar()
- {
- ArtifactDescriptor descriptor = new
ArtifactDescriptor(TCKArtifactDescriptor.class);
- descriptor.addPackage(AbstractTest.class.getPackage());
- descriptor.addPackage("org.jboss.testharness.impl", true);
- descriptor.addPackage("org.jboss.testharness.runner", true);
- if (descriptor.getClasses().size() == 0)
- {
- throw new AssertionError("Error building tck-support.jar");
- }
- try
- {
- return new ResourceDescriptor("tck-support.jar",
descriptor.getJar());
- }
- catch (IOException e)
- {
- throw new RuntimeException("Error building TCK support Jar", e);
- }
- }
-
private static final Logger log = Logger.getLogger(TCKArtifactDescriptor.class);
private boolean unit;
@@ -49,7 +27,7 @@
{
getLibraries().add(new ResourceDescriptor("testng.jar",
"/lib/testng-jdk15.jar"));
getLibraries().add(new
ResourceDescriptor("jboss-test-harness-api.jar",
"/lib/jboss-test-harness-api.jar"));
- getLibraries().add(getTckSupportJar());
+ getLibraries().add(new ResourceDescriptor("jboss-test-harness.jar",
"/lib/jboss-test-harness.jar"));
InputStream deploymentProperties = null;
try
{
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/AbstractArtifactTest.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/AbstractArtifactTest.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/AbstractArtifactTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,134 +0,0 @@
-package org.jboss.testharness.test.impl.packaging;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.util.Arrays;
-
-public abstract class AbstractArtifactTest
-{
-
- protected static final FilenameFilter WEB_INF_FILTER = new FilenameFilter()
- {
- public boolean accept(File dir, String name)
- {
- return name.equals("WEB-INF");
- }
- };
-
- protected static final FilenameFilter CLASSES_FILTER = new FilenameFilter()
- {
- public boolean accept(File dir, String name)
- {
- return name.equals("classes");
- }
- };
-
- protected static final FilenameFilter META_INF_FILTER = new FilenameFilter()
- {
- public boolean accept(File dir, String name)
- {
- return name.equals("META-INF");
- }
- };
-
- protected static final FilenameFilter BEANS_XML_FILTER = new FilenameFilter()
- {
-
- public boolean accept(File dir, String name)
- {
- return name.equals("beans.xml");
- }
-
- };
-
-
-
- protected static final FilenameFilter WEB_XML_FILTER = new FilenameFilter()
- {
-
- public boolean accept(File dir, String name)
- {
- return name.equals("web.xml");
- }
-
- };
-
- protected File getCurrentPackageAsFile(File root)
- {
- return getPackageAsFile(getClass().getPackage(), root);
- }
-
- protected File getPackageAsFile(Package pkg, File root)
- {
- String[] packageHierarchy = pkg.getName().split("\\.");
- for (final String packageName : packageHierarchy)
- {
- File[] files = root.listFiles(new FilenameFilter()
- {
-
- public boolean accept(File dir, String name)
- {
- return name.equals(packageName);
- }
-
- });
- if (files.length == 1)
- {
- root = files[0];
- }
- else
- {
- throw new IllegalStateException("Unable to traverse package hierarchy
" + Arrays.asList(packageHierarchy) + ", unable to open directory " +
packageName);
- }
- }
- return root;
- }
-
- protected String readFile(File file) throws IOException
- {
- if (file.isFile())
- {
- Reader reader = new InputStreamReader(new BufferedInputStream(new
FileInputStream(file)));
- StringBuffer buffer = new StringBuffer(1024);
- char[] bytes = new char[1024];
- while (reader.read(bytes) > -1)
- {
- buffer.append(String.valueOf(bytes));
- }
- reader.close();
- return buffer.toString();
- }
- else
- {
- return null;
- }
- }
-
- protected static void copy(InputStream inputStream, File file) throws IOException
- {
- OutputStream os = new FileOutputStream(file);
- try
- {
- byte[] buf = new byte[1024];
- int i = 0;
- while ((i = inputStream.read(buf)) != -1)
- {
- os.write(buf, 0, i);
- }
- }
- finally
- {
- os.close();
- }
-
- }
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Cow.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Cow.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Cow.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,6 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.declarative.standalone;
-
-class Cow
-{
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DeclarativeStandaloneTest.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DeclarativeStandaloneTest.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DeclarativeStandaloneTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,163 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.declarative.standalone;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-import org.jboss.testharness.api.Configuration;
-import org.jboss.testharness.impl.packaging.ArtifactGenerator;
-import org.jboss.testharness.impl.packaging.ear.EarArtifactDescriptor;
-import org.jboss.testharness.impl.packaging.jsr299.JSR299ArtifactDescriptor;
-import org.jboss.testharness.impl.packaging.jsr299.TCKArtifactDescriptor;
-import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
-import org.jboss.testharness.test.impl.mock.MockConfiguration;
-import org.jboss.testharness.test.impl.packaging.AbstractArtifactTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-public class DeclarativeStandaloneTest extends AbstractArtifactTest
-{
-
- private Configuration standaloneConfiguration;
- private Configuration nonStandaloneConfiguration;
-
- @BeforeClass
- public void beforeClass()
- {
- standaloneConfiguration = new MockConfiguration();
- standaloneConfiguration.setStandalone(true);
- nonStandaloneConfiguration = new MockConfiguration();
- nonStandaloneConfiguration.setStandalone(false);
- }
-
- @Test
- public void testDefaultDeclartiveArtifact() throws Exception
- {
- TCKArtifactDescriptor artifact = new
ArtifactGenerator(standaloneConfiguration).createArtifact(DummyTest.class);
- assert artifact.getClass().equals(JSR299ArtifactDescriptor.class);
- assert artifact.isUnit();
- File root = artifact.getExplodedJar();
- File currentPackage = getCurrentPackageAsFile(root);
- File[] cowClasses = currentPackage.listFiles(new FilenameFilter()
- {
-
- public boolean accept(File dir, String name)
- {
- return name.equals("Cow.class");
- }
-
- });
- assert cowClasses.length == 1;
- assert cowClasses[0].getName().equals("Cow.class");
- assert cowClasses[0].isFile();
- File[] foxClasses = currentPackage.listFiles(new FilenameFilter()
- {
-
- public boolean accept(File dir, String name)
- {
- return name.equals("Fox.class");
- }
-
- });
- assert foxClasses.length == 1;
- assert foxClasses[0].getName().equals("Fox.class");
- assert foxClasses[0].isFile();
-
- File[] testClasses = currentPackage.listFiles(new FilenameFilter()
- {
-
- public boolean accept(File dir, String name)
- {
- return name.startsWith("DummyTest");
- }
-
- });
- assert testClasses.length == 1;
-
- assert root.listFiles(META_INF_FILTER).length == 1;
- File metaInf = root.listFiles(META_INF_FILTER)[0];
- assert metaInf.listFiles().length == 1;
- assert metaInf.listFiles(BEANS_XML_FILTER).length == 1;
- assert metaInf.listFiles(BEANS_XML_FILTER)[0].length() == 0;
- }
-
- @Test
- public void testClassesSpecifiedArtifact() throws Exception
- {
- TCKArtifactDescriptor artifact = new
ArtifactGenerator(standaloneConfiguration).createArtifact(DummyClassesSpecifiedTest.class);
- File root = artifact.getExplodedJar();
- File currentPackage = getCurrentPackageAsFile(root);
- assert currentPackage.listFiles().length == 1;
- File[] subPackages = currentPackage.listFiles(new FilenameFilter()
- {
-
- public boolean accept(File dir, String name)
- {
- return name.startsWith("subpackage");
- }
-
- });
- assert subPackages.length == 1;
- File subPackage = subPackages[0];
- assert subPackage.listFiles().length == 1;
- assert subPackage.listFiles()[0].getName().equals("Rat.class");
- }
-
- @Test
- public void testResourcesSpecifiedArtifact() throws Exception
- {
- TCKArtifactDescriptor artifact = new
ArtifactGenerator(standaloneConfiguration).createArtifact(DummyResourcesSpecifiedTest.class);
- File root = artifact.getExplodedJar();
- assert root.listFiles(META_INF_FILTER).length == 1;
- File metaInf = root.listFiles(META_INF_FILTER)[0];
- assert metaInf.listFiles(new FilenameFilter()
- {
-
- public boolean accept(File dir, String name)
- {
- return name.equals("bar.xml");
- }
-
- }).length == 1;
- }
-
- @Test
- public void testIntegrationTestDeclartiveArtifact() throws Exception
- {
- TCKArtifactDescriptor artifact = new
ArtifactGenerator(standaloneConfiguration).createArtifact(DummyIntegrationTest.class);
- assert !artifact.isUnit();
- }
-
- @Test
- public void testCustomBeansXml() throws Exception
- {
- TCKArtifactDescriptor artifact = new
ArtifactGenerator(standaloneConfiguration).createArtifact(DummyCustomBeansXmlTest.class);
- File root = artifact.getExplodedJar();
- File metaInf = root.listFiles(META_INF_FILTER)[0];
- assert metaInf.listFiles(BEANS_XML_FILTER).length == 1;
- assert metaInf.listFiles(BEANS_XML_FILTER)[0].length() != 0;
- String beans = readFile(metaInf.listFiles(BEANS_XML_FILTER)[0]);
- assert beans.startsWith("<my></my>");
- }
-
- @Test
- public void testEjbTestDeclartiveArtifact() throws Exception
- {
- TCKArtifactDescriptor artifact = new
ArtifactGenerator(nonStandaloneConfiguration).createArtifact(DummyEjbTest.class);
- assert artifact.getClass().equals(EarArtifactDescriptor.class);
- }
-
- @Test
- public void testStandaloneEjbTestDeclartiveArtifact() throws Exception
- {
- TCKArtifactDescriptor artifact = new
ArtifactGenerator(standaloneConfiguration).createArtifact(DummyEjbTest.class);
- assert artifact.getClass().equals(JSR299ArtifactDescriptor.class);
- }
-
- @Test
- public void testWarDeclarativePackaging()
- {
- TCKArtifactDescriptor artifact = new
ArtifactGenerator(nonStandaloneConfiguration).createArtifact(DummyWarUnitTest.class);
- assert artifact.getClass().equals(WarArtifactDescriptor.class);
- }
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyClassesSpecifiedTest.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyClassesSpecifiedTest.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyClassesSpecifiedTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,18 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.declarative.standalone;
-
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.test.impl.packaging.declarative.standalone.subpackage.Rat;
-
-
-@Artifact(addCurrentPackage=false)
-(a)Classes(Rat.class)
-class DummyClassesSpecifiedTest
-{
-
- public void test()
- {
- assert true;
- }
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyCustomBeansXmlTest.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyCustomBeansXmlTest.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyCustomBeansXmlTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,16 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.declarative.standalone;
-
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
-
-
-@Artifact @BeansXml(value="my-web-beans.xml")
-class DummyCustomBeansXmlTest
-{
-
- public void test()
- {
- assert true;
- }
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyEjbTest.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyEjbTest.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyEjbTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,17 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.declarative.standalone;
-
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Packaging;
-import org.jboss.testharness.impl.packaging.PackagingType;
-
-
-@Artifact @Packaging(PackagingType.EAR)
-class DummyEjbTest
-{
-
- public void test()
- {
- assert true;
- }
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyIntegrationTest.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyIntegrationTest.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyIntegrationTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,17 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.declarative.standalone;
-
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.IntegrationTest;
-
-
-@Artifact
-@IntegrationTest
-class DummyIntegrationTest
-{
-
- public void test()
- {
- assert true;
- }
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyResourcesSpecifiedTest.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyResourcesSpecifiedTest.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyResourcesSpecifiedTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,18 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.declarative.standalone;
-
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.Resources;
-
-
-@Artifact(addCurrentPackage=false)
-@Resources(value=@Resource(destination = "/META-INF/bar.xml",
source="foo/foo.xml"))
-class DummyResourcesSpecifiedTest
-{
-
- public void test()
- {
- assert true;
- }
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyTest.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyTest.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,15 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.declarative.standalone;
-
-import org.jboss.testharness.impl.packaging.Artifact;
-
-
-@Artifact
-class DummyTest
-{
-
- public void test()
- {
- assert true;
- }
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyWarUnitTest.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyWarUnitTest.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyWarUnitTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,18 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.declarative.standalone;
-
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Packaging;
-import org.jboss.testharness.impl.packaging.PackagingType;
-
-
-@Artifact
-(a)Packaging(PackagingType.WAR)
-class DummyWarUnitTest
-{
-
- public void test()
- {
- assert true;
- }
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Fox.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Fox.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Fox.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,6 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.declarative.standalone;
-
-class Fox
-{
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/Cow.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/Cow.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/Cow.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,6 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.descriptors.subpackages;
-
-class Cow
-{
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/SubpackagesArtifactTest.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/SubpackagesArtifactTest.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/SubpackagesArtifactTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,46 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.descriptors.subpackages;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-import org.jboss.testharness.impl.packaging.ArtifactDescriptor;
-import org.jboss.testharness.test.impl.packaging.AbstractArtifactTest;
-import org.testng.annotations.Test;
-
-public class SubpackagesArtifactTest extends AbstractArtifactTest
-{
-
- @Test
- public void testAllClassesInPackageAndNotSubPackages() throws Exception
- {
- ArtifactDescriptor artifactDescriptor = new ArtifactDescriptor(null);
- artifactDescriptor.addPackage(SubpackagesArtifactTest.class.getPackage());
- File root = artifactDescriptor.getExplodedJar();
- File currentPackage = getCurrentPackageAsFile(root);
- assert currentPackage.listFiles().length == 4;
- File[] cowClasses = currentPackage.listFiles(new FilenameFilter()
- {
-
- public boolean accept(File dir, String name)
- {
- return name.equals("Cow.class");
- }
-
- });
- assert cowClasses.length == 1;
- assert cowClasses[0].getName().equals("Cow.class");
- assert cowClasses[0].isFile();
-
- File[] testClasses = currentPackage.listFiles(new FilenameFilter()
- {
-
- public boolean accept(File dir, String name)
- {
- return name.startsWith("SubpackagesArtifactTest");
- }
-
- });
- assert testClasses.length == 3;
- }
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/ArtifactScannerTest.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/ArtifactScannerTest.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/ArtifactScannerTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,54 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.scanner;
-
-import java.util.List;
-import java.util.Set;
-
-import org.jboss.testharness.api.Configuration;
-import org.jboss.testharness.impl.packaging.ArtifactDescriptor;
-import org.jboss.testharness.impl.packaging.ArtifactGenerator;
-import org.jboss.testharness.impl.packaging.ArtifactScanner;
-import org.jboss.testharness.test.impl.mock.MockConfiguration;
-import
org.jboss.testharness.test.impl.packaging.scanner.subpackage.AnotherDummyArtifact;
-import org.jboss.testharness.test.impl.packaging.scanner.subpackage.NotAnArtifact;
-import org.testng.annotations.Test;
-
-public class ArtifactScannerTest
-{
-
- @Test
- public void testScanner()
- {
- ArtifactScanner scanner = new
ArtifactScanner(ArtifactScannerTest.class.getPackage().getName(), null);
- Set<Class<?>> classes = scanner.getClasses();
- assert classes.contains(DummyArtifact.class);
- assert classes.contains(AnotherDummyArtifact.class);
- assert !classes.contains(NotAnArtifact.class);
- }
-
- @Test
- public void testMockArtifactGenerator() throws Exception
- {
- Configuration configuration = new MockConfiguration();
- ArtifactGenerator generator = new ArtifactGenerator(configuration);
- List<ArtifactDescriptor> artifacts =
generator.createArtifacts(DummyArtifact.class.getPackage().getName());
- assert artifacts.size() == 2;
- for (ArtifactDescriptor artifact : artifacts)
- {
- if (artifact.getDeclaringClass().equals(DummyArtifact.class))
- {
- assert artifact.getClasses().contains(ArtifactScannerTest.class);
- assert artifact.getClasses().contains(DummyArtifact.class);
- assert !artifact.getClasses().contains(AnotherDummyArtifact.class);
- assert !artifact.getClasses().contains(NotAnArtifact.class);
- }
- if (artifact.getDeclaringClass().equals(AnotherDummyArtifact.class))
- {
- assert !artifact.getClasses().contains(ArtifactScannerTest.class);
- assert !artifact.getClasses().contains(DummyArtifact.class);
- assert artifact.getClasses().contains(AnotherDummyArtifact.class);
- assert artifact.getClasses().contains(NotAnArtifact.class);
- }
- }
- }
-
-}
Deleted:
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/DummyArtifact.java
===================================================================
---
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/DummyArtifact.java 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/DummyArtifact.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1,9 +0,0 @@
-package org.jboss.testharness.test.impl.packaging.scanner;
-
-import org.jboss.testharness.impl.packaging.Artifact;
-
-@Artifact
-public class DummyArtifact
-{
-
-}
Deleted:
test-harness/trunk/impl/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/my-web-beans.xml
===================================================================
---
test-harness/trunk/impl/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/my-web-beans.xml 2009-03-10
13:53:33 UTC (rev 1905)
+++
test-harness/trunk/impl/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/my-web-beans.xml 2009-03-10
14:11:50 UTC (rev 1906)
@@ -1 +0,0 @@
-<my></my>
\ No newline at end of file
Modified: test-harness/trunk/pom.xml
===================================================================
--- test-harness/trunk/pom.xml 2009-03-10 13:53:33 UTC (rev 1905)
+++ test-harness/trunk/pom.xml 2009-03-10 14:11:50 UTC (rev 1906)
@@ -42,6 +42,7 @@
<modules>
<module>api</module>
<module>impl</module>
+ <module>tests</module>
</modules>
<dependencyManagement>
@@ -59,6 +60,12 @@
<artifactId>jboss-test-harness-api</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>log4j</groupId>
Added: test-harness/trunk/tests/pom.xml
===================================================================
--- test-harness/trunk/tests/pom.xml (rev 0)
+++ test-harness/trunk/tests/pom.xml 2009-03-10 14:11:50 UTC (rev 1906)
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>jboss-test-harness-parent</artifactId>
+ <groupId>org.jboss.test-harness</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness-tests</artifactId>
+ <name>JBoss Test Harness Integration Tests</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-in-container-dependencies</id>
+ <phase>generate-test-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+
<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
+ <stripVersion>true</stripVersion>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness</artifactId>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <defaultGoal>install</defaultGoal>
+ </build>
+
+</project>
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/impl/packaging/ear/ejb-jar.xml
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/impl/packaging/ear/ejb-jar.xml
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/impl/packaging/ear/ejb-jar.xml 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+
+</ejb-jar>
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/mock/MockConfiguration.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/mock/MockConfiguration.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/mock/MockConfiguration.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,8 @@
+package org.jboss.testharness.test.impl.mock;
+
+import org.jboss.testharness.impl.ConfigurationImpl;
+
+public class MockConfiguration extends ConfigurationImpl
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/AbstractArtifactTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/AbstractArtifactTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/AbstractArtifactTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,134 @@
+package org.jboss.testharness.test.impl.packaging;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.util.Arrays;
+
+public abstract class AbstractArtifactTest
+{
+
+ protected static final FilenameFilter WEB_INF_FILTER = new FilenameFilter()
+ {
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("WEB-INF");
+ }
+ };
+
+ protected static final FilenameFilter CLASSES_FILTER = new FilenameFilter()
+ {
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("classes");
+ }
+ };
+
+ protected static final FilenameFilter META_INF_FILTER = new FilenameFilter()
+ {
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("META-INF");
+ }
+ };
+
+ protected static final FilenameFilter BEANS_XML_FILTER = new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("beans.xml");
+ }
+
+ };
+
+
+
+ protected static final FilenameFilter WEB_XML_FILTER = new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("web.xml");
+ }
+
+ };
+
+ protected File getCurrentPackageAsFile(File root)
+ {
+ return getPackageAsFile(getClass().getPackage(), root);
+ }
+
+ protected File getPackageAsFile(Package pkg, File root)
+ {
+ String[] packageHierarchy = pkg.getName().split("\\.");
+ for (final String packageName : packageHierarchy)
+ {
+ File[] files = root.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals(packageName);
+ }
+
+ });
+ if (files.length == 1)
+ {
+ root = files[0];
+ }
+ else
+ {
+ throw new IllegalStateException("Unable to traverse package hierarchy
" + Arrays.asList(packageHierarchy) + ", unable to open directory " +
packageName);
+ }
+ }
+ return root;
+ }
+
+ protected String readFile(File file) throws IOException
+ {
+ if (file.isFile())
+ {
+ Reader reader = new InputStreamReader(new BufferedInputStream(new
FileInputStream(file)));
+ StringBuffer buffer = new StringBuffer(1024);
+ char[] bytes = new char[1024];
+ while (reader.read(bytes) > -1)
+ {
+ buffer.append(String.valueOf(bytes));
+ }
+ reader.close();
+ return buffer.toString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected static void copy(InputStream inputStream, File file) throws IOException
+ {
+ OutputStream os = new FileOutputStream(file);
+ try
+ {
+ byte[] buf = new byte[1024];
+ int i = 0;
+ while ((i = inputStream.read(buf)) != -1)
+ {
+ os.write(buf, 0, i);
+ }
+ }
+ finally
+ {
+ os.close();
+ }
+
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/Cow.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/Cow.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/Cow.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.declarative.ear;
+
+class Cow
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/DeclarativeEarTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/DeclarativeEarTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/DeclarativeEarTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,39 @@
+package org.jboss.testharness.test.impl.packaging.declarative.ear;
+
+import java.io.File;
+
+import org.jboss.testharness.api.Configuration;
+import org.jboss.testharness.impl.packaging.ArtifactGenerator;
+import org.jboss.testharness.impl.packaging.ear.EarArtifactDescriptor;
+import org.jboss.testharness.impl.packaging.jsr299.TCKArtifactDescriptor;
+import org.jboss.testharness.test.impl.mock.MockConfiguration;
+import org.jboss.testharness.test.impl.packaging.AbstractArtifactTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class DeclarativeEarTest extends AbstractArtifactTest
+{
+
+ private Configuration configuration;
+
+ @BeforeClass
+ public void beforeClass()
+ {
+ configuration = new MockConfiguration();
+ configuration.setStandalone(false);
+ }
+
+ @Test
+ public void testDeclarativeEar() throws Exception
+ {
+ TCKArtifactDescriptor artifact = new
ArtifactGenerator(configuration).createArtifact(DummyTest.class);
+ assert artifact instanceof EarArtifactDescriptor;
+ EarArtifactDescriptor earArtifact = (EarArtifactDescriptor) artifact;
+ assert artifact.getExplodedJar().list().length == 4;
+ File currentPackage =
getCurrentPackageAsFile(earArtifact.getEjbJar().getExplodedJar());
+ assert new File(currentPackage, "Cow.class").isFile();
+ assert new File(currentPackage, "DummyTest.class").isFile();
+ assert new File(currentPackage, "Fox.class").isFile();
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/DummyTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/DummyTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/DummyTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,20 @@
+package org.jboss.testharness.test.impl.packaging.declarative.ear;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+
+
+@Artifact
+@IntegrationTest
+(a)Packaging(PackagingType.EAR)
+class DummyTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/Fox.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/Fox.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/ear/Fox.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.declarative.ear;
+
+class Fox
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Cow.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Cow.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Cow.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.declarative.standalone;
+
+class Cow
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DeclarativeStandaloneTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DeclarativeStandaloneTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DeclarativeStandaloneTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,163 @@
+package org.jboss.testharness.test.impl.packaging.declarative.standalone;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.jboss.testharness.api.Configuration;
+import org.jboss.testharness.impl.packaging.ArtifactGenerator;
+import org.jboss.testharness.impl.packaging.ear.EarArtifactDescriptor;
+import org.jboss.testharness.impl.packaging.jsr299.JSR299ArtifactDescriptor;
+import org.jboss.testharness.impl.packaging.jsr299.TCKArtifactDescriptor;
+import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
+import org.jboss.testharness.test.impl.mock.MockConfiguration;
+import org.jboss.testharness.test.impl.packaging.AbstractArtifactTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class DeclarativeStandaloneTest extends AbstractArtifactTest
+{
+
+ private Configuration standaloneConfiguration;
+ private Configuration nonStandaloneConfiguration;
+
+ @BeforeClass
+ public void beforeClass()
+ {
+ standaloneConfiguration = new MockConfiguration();
+ standaloneConfiguration.setStandalone(true);
+ nonStandaloneConfiguration = new MockConfiguration();
+ nonStandaloneConfiguration.setStandalone(false);
+ }
+
+ @Test
+ public void testDefaultDeclartiveArtifact() throws Exception
+ {
+ TCKArtifactDescriptor artifact = new
ArtifactGenerator(standaloneConfiguration).createArtifact(DummyTest.class);
+ assert artifact.getClass().equals(JSR299ArtifactDescriptor.class);
+ assert artifact.isUnit();
+ File root = artifact.getExplodedJar();
+ File currentPackage = getCurrentPackageAsFile(root);
+ File[] cowClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("Cow.class");
+ }
+
+ });
+ assert cowClasses.length == 1;
+ assert cowClasses[0].getName().equals("Cow.class");
+ assert cowClasses[0].isFile();
+ File[] foxClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("Fox.class");
+ }
+
+ });
+ assert foxClasses.length == 1;
+ assert foxClasses[0].getName().equals("Fox.class");
+ assert foxClasses[0].isFile();
+
+ File[] testClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.startsWith("DummyTest");
+ }
+
+ });
+ assert testClasses.length == 1;
+
+ assert root.listFiles(META_INF_FILTER).length == 1;
+ File metaInf = root.listFiles(META_INF_FILTER)[0];
+ assert metaInf.listFiles().length == 1;
+ assert metaInf.listFiles(BEANS_XML_FILTER).length == 1;
+ assert metaInf.listFiles(BEANS_XML_FILTER)[0].length() == 0;
+ }
+
+ @Test
+ public void testClassesSpecifiedArtifact() throws Exception
+ {
+ TCKArtifactDescriptor artifact = new
ArtifactGenerator(standaloneConfiguration).createArtifact(DummyClassesSpecifiedTest.class);
+ File root = artifact.getExplodedJar();
+ File currentPackage = getCurrentPackageAsFile(root);
+ assert currentPackage.listFiles().length == 1;
+ File[] subPackages = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.startsWith("subpackage");
+ }
+
+ });
+ assert subPackages.length == 1;
+ File subPackage = subPackages[0];
+ assert subPackage.listFiles().length == 1;
+ assert subPackage.listFiles()[0].getName().equals("Rat.class");
+ }
+
+ @Test
+ public void testResourcesSpecifiedArtifact() throws Exception
+ {
+ TCKArtifactDescriptor artifact = new
ArtifactGenerator(standaloneConfiguration).createArtifact(DummyResourcesSpecifiedTest.class);
+ File root = artifact.getExplodedJar();
+ assert root.listFiles(META_INF_FILTER).length == 1;
+ File metaInf = root.listFiles(META_INF_FILTER)[0];
+ assert metaInf.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("bar.xml");
+ }
+
+ }).length == 1;
+ }
+
+ @Test
+ public void testIntegrationTestDeclartiveArtifact() throws Exception
+ {
+ TCKArtifactDescriptor artifact = new
ArtifactGenerator(standaloneConfiguration).createArtifact(DummyIntegrationTest.class);
+ assert !artifact.isUnit();
+ }
+
+ @Test
+ public void testCustomBeansXml() throws Exception
+ {
+ TCKArtifactDescriptor artifact = new
ArtifactGenerator(standaloneConfiguration).createArtifact(DummyCustomBeansXmlTest.class);
+ File root = artifact.getExplodedJar();
+ File metaInf = root.listFiles(META_INF_FILTER)[0];
+ assert metaInf.listFiles(BEANS_XML_FILTER).length == 1;
+ assert metaInf.listFiles(BEANS_XML_FILTER)[0].length() != 0;
+ String beans = readFile(metaInf.listFiles(BEANS_XML_FILTER)[0]);
+ assert beans.startsWith("<my></my>");
+ }
+
+ @Test
+ public void testEjbTestDeclartiveArtifact() throws Exception
+ {
+ TCKArtifactDescriptor artifact = new
ArtifactGenerator(nonStandaloneConfiguration).createArtifact(DummyEjbTest.class);
+ assert artifact.getClass().equals(EarArtifactDescriptor.class);
+ }
+
+ @Test
+ public void testStandaloneEjbTestDeclartiveArtifact() throws Exception
+ {
+ TCKArtifactDescriptor artifact = new
ArtifactGenerator(standaloneConfiguration).createArtifact(DummyEjbTest.class);
+ assert artifact.getClass().equals(JSR299ArtifactDescriptor.class);
+ }
+
+ @Test
+ public void testWarDeclarativePackaging()
+ {
+ TCKArtifactDescriptor artifact = new
ArtifactGenerator(nonStandaloneConfiguration).createArtifact(DummyWarUnitTest.class);
+ assert artifact.getClass().equals(WarArtifactDescriptor.class);
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyClassesSpecifiedTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyClassesSpecifiedTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyClassesSpecifiedTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,18 @@
+package org.jboss.testharness.test.impl.packaging.declarative.standalone;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.test.impl.packaging.declarative.standalone.subpackage.Rat;
+
+
+@Artifact(addCurrentPackage=false)
+(a)Classes(Rat.class)
+class DummyClassesSpecifiedTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyCustomBeansXmlTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyCustomBeansXmlTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyCustomBeansXmlTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,16 @@
+package org.jboss.testharness.test.impl.packaging.declarative.standalone;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+
+
+@Artifact @BeansXml(value="my-web-beans.xml")
+class DummyCustomBeansXmlTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyEjbTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyEjbTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyEjbTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,17 @@
+package org.jboss.testharness.test.impl.packaging.declarative.standalone;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+
+
+@Artifact @Packaging(PackagingType.EAR)
+class DummyEjbTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyIntegrationTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyIntegrationTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyIntegrationTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,17 @@
+package org.jboss.testharness.test.impl.packaging.declarative.standalone;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+
+
+@Artifact
+@IntegrationTest
+class DummyIntegrationTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyResourcesSpecifiedTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyResourcesSpecifiedTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyResourcesSpecifiedTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,18 @@
+package org.jboss.testharness.test.impl.packaging.declarative.standalone;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+
+
+@Artifact(addCurrentPackage=false)
+@Resources(value=@Resource(destination = "/META-INF/bar.xml",
source="foo/foo.xml"))
+class DummyResourcesSpecifiedTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,15 @@
+package org.jboss.testharness.test.impl.packaging.declarative.standalone;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+
+
+@Artifact
+class DummyTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyWarUnitTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyWarUnitTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/DummyWarUnitTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,18 @@
+package org.jboss.testharness.test.impl.packaging.declarative.standalone;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+
+
+@Artifact
+(a)Packaging(PackagingType.WAR)
+class DummyWarUnitTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Fox.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Fox.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/Fox.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.declarative.standalone;
+
+class Fox
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/subpackage/Rat.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/subpackage/Rat.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/standalone/subpackage/Rat.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.declarative.standalone.subpackage;
+
+public class Rat
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/Cow.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/Cow.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/Cow.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.declarative.war;
+
+class Cow
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/DeclarativeWarTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/DeclarativeWarTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/DeclarativeWarTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,41 @@
+package org.jboss.testharness.test.impl.packaging.declarative.war;
+
+import java.io.File;
+
+import org.jboss.testharness.api.Configuration;
+import org.jboss.testharness.impl.packaging.ArtifactGenerator;
+import org.jboss.testharness.impl.packaging.jsr299.TCKArtifactDescriptor;
+import org.jboss.testharness.test.impl.mock.MockConfiguration;
+import org.jboss.testharness.test.impl.packaging.AbstractArtifactTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class DeclarativeWarTest extends AbstractArtifactTest
+{
+
+ private Configuration configuration;
+
+ @BeforeClass
+ public void beforeClass()
+ {
+ configuration = new MockConfiguration();
+ configuration.setStandalone(false);
+ }
+
+ @Test
+ public void testDefaultWebXml() throws Exception
+ {
+ TCKArtifactDescriptor artifact = new
ArtifactGenerator(configuration).createArtifact(DummyTest.class);
+ File root = artifact.getExplodedJar();
+ assert root.listFiles(WEB_INF_FILTER).length == 1;
+ File webInf = root.listFiles(WEB_INF_FILTER)[0];
+ assert webInf.getName().equals("WEB-INF");
+ assert webInf.isDirectory();
+ assert webInf.listFiles(WEB_XML_FILTER).length == 1;
+ File webXml = webInf.listFiles(WEB_XML_FILTER)[0];
+ assert webXml.isFile();
+ assert webXml.getName().equals("web.xml");
+ assert webXml.length() != 0;
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/DummyTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/DummyTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/DummyTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,20 @@
+package org.jboss.testharness.test.impl.packaging.declarative.war;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+
+
+@Artifact
+@IntegrationTest
+(a)Packaging(PackagingType.WAR)
+class DummyTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/Fox.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/Fox.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/declarative/war/Fox.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.declarative.war;
+
+class Fox
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/Cow.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/Cow.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/Cow.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.ear;
+
+class Cow
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/DummyTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/DummyTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/DummyTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.ear;
+
+public class DummyTest
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/EarArtifactTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/EarArtifactTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/EarArtifactTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,154 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.ear;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.ear.EarArtifactDescriptor;
+import org.jboss.testharness.test.impl.packaging.AbstractArtifactTest;
+import org.testng.annotations.Test;
+
+public class EarArtifactTest extends AbstractArtifactTest
+{
+ @Test
+ public void testDefaultEar() throws Exception
+ {
+ EarArtifactDescriptor ear = new EarArtifactDescriptor(DummyTest.class, null);
+ ear.getClasses().add(Cow.class);
+ File root = ear.getExplodedJar();
+ assert root.isDirectory();
+ assert root.listFiles().length == 4;
+
+ File warRoot = ear.getWar().getExplodedJar();
+ assert warRoot.listFiles().length == 1;
+ assert warRoot.isDirectory();
+ assert warRoot.listFiles(WEB_INF_FILTER).length == 1;
+ File webInf = warRoot.listFiles(WEB_INF_FILTER)[0];
+ assert webInf.getName().equals("WEB-INF");
+ assert webInf.isDirectory();
+ assert webInf.listFiles().length == 1;
+ assert webInf.listFiles(WEB_XML_FILTER).length == 1;
+ File webXml = webInf.listFiles(WEB_XML_FILTER)[0];
+ assert webXml.isFile();
+ assert webXml.getName().equals("web.xml");
+ assert webXml.length() != 0;
+ assert !new File(webInf, "beans.xml").exists();
+
+ File webInfLib = new File(webInf, "lib");
+ assert !webInfLib.exists();
+
+ File webInfClasses = new File(webInf, "classes");
+ assert !webInfClasses.exists();
+
+ File ejbJar = new File(root, DummyTest.class.getName() + ".jar");
+ assert ejbJar.exists();
+ assert ejbJar.length() > 0;
+
+ File war = new File(root, DummyTest.class.getName() + ".war");
+ assert war.exists();
+ assert war.length() > 0;
+
+ File lib = new File(root, "lib");
+ assert lib.isDirectory();
+ assert lib.list().length == 3;
+ List<String> libs = Arrays.asList(lib.list());
+ assert libs.contains("jboss-test-harness-api.jar");
+ assert libs.contains("testng.jar");
+ assert libs.contains("jboss-test-harness.jar");
+
+ File metaInf = new File(root, "META-INF");
+ assert metaInf.isDirectory();
+ assert metaInf.list().length == 2;
+ List<String> metaInfs = Arrays.asList(metaInf.list());
+ assert metaInfs.contains("application.xml");
+
+ File applicationXml = new File(metaInf, "application.xml");
+ assert applicationXml.length() > 0;
+
+ File webBeansTckProperties = new File(metaInf,
"web-beans-tck.properties");
+ assert webBeansTckProperties.isFile();
+ assert webBeansTckProperties.length() > 0;
+
+ File ejbJarRoot = ear.getEjbJar().getExplodedJar();
+
+ File ejbJarXml = new File(ejbJarRoot, "META-INF/ejb-jar.xml");
+ assert ejbJarXml.isFile();
+ assert ejbJarXml.length() > 0;
+
+ File webbeansXml = new File(ejbJarRoot, "META-INF/beans.xml");
+ assert webbeansXml.isFile();
+ assert webbeansXml.length() == 0;
+
+
+
+ File currentPackage = getCurrentPackageAsFile(ejbJarRoot);
+ File[] cowClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("Cow.class");
+ }
+
+ });
+ assert cowClasses.length == 1;
+ assert cowClasses[0].getName().equals("Cow.class");
+ assert cowClasses[0].isFile();
+ File tckPackage = getPackageAsFile(AbstractTest.class.getPackage(), ejbJarRoot);
+ File[] abstractTestClasses = tckPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("AbstractTest.class");
+ }
+
+ });
+
+
+ }
+
+ @Test
+ public void testJarProduction() throws Exception
+ {
+ EarArtifactDescriptor ear = new EarArtifactDescriptor(DummyTest.class, null);
+ ear.getClasses().add(Cow.class);
+ JarInputStream is = new JarInputStream(ear.getJarAsStream());
+ JarEntry entry;
+ List<String> fileNames = new ArrayList<String>();
+ while ((entry = is.getNextJarEntry()) != null)
+ {
+ fileNames.add(entry.getName().replace(File.separator, "/"));
+ }
+ is.close();
+ assert fileNames.contains("META-INF/application.xml");
+ assert fileNames.contains("META-INF/web-beans-tck.properties");
+ assert fileNames.contains("lib/jboss-test-harness.jar");
+ assert fileNames.contains(DummyTest.class.getName() + ".jar");
+ assert fileNames.contains(DummyTest.class.getName() + ".war");
+
+
+ File ejbJar = new File(ear.getExplodedJar(), DummyTest.class.getName() +
".jar");
+ assert ejbJar.exists();
+ assert ejbJar.isFile();
+ assert ejbJar.length() > 0;
+ is = new JarInputStream(new FileInputStream(ejbJar));
+ fileNames = new ArrayList<String>();
+ while ((entry = is.getNextJarEntry()) != null)
+ {
+ fileNames.add(entry.getName().replace(File.separator, "/"));
+ }
+ is.close();
+ assert fileNames.contains("META-INF/ejb-jar.xml");
+ assert fileNames.contains("META-INF/beans.xml");
+ assert
fileNames.contains("org/jboss/testharness/test/impl/packaging/descriptors/ear/Cow.class");
+ }
+
+}
+
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/ArtifactTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/ArtifactTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/ArtifactTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,59 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.packages;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.jboss.testharness.impl.packaging.ArtifactDescriptor;
+import org.jboss.testharness.test.impl.packaging.AbstractArtifactTest;
+import org.testng.annotations.Test;
+
+public class ArtifactTest extends AbstractArtifactTest
+{
+
+ @Test
+ public void testAllClassesInPackage() throws Exception
+ {
+ ArtifactDescriptor artifactDescriptor = new ArtifactDescriptor(null);
+ artifactDescriptor.addPackage(ArtifactTest.class.getPackage());
+ File root = artifactDescriptor.getExplodedJar();
+ File currentPackage = getCurrentPackageAsFile(root);
+ assert currentPackage.listFiles().length == 6;
+ File[] cowClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("Cow.class");
+ }
+
+ });
+ assert cowClasses.length == 1;
+ assert cowClasses[0].getName().equals("Cow.class");
+ assert cowClasses[0].isFile();
+ File[] foxClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("Fox.class");
+ }
+
+ });
+ assert foxClasses.length == 1;
+ assert foxClasses[0].getName().equals("Fox.class");
+ assert foxClasses[0].isFile();
+
+ File[] testClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.startsWith("ArtifactTest");
+ }
+
+ });
+ assert testClasses.length == 4;
+
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/Cow.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/Cow.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/Cow.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.packages;
+
+class Cow
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/Fox.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/Fox.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/packages/Fox.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.packages;
+
+class Fox
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/Cow.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/Cow.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/Cow.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.subpackages;
+
+class Cow
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/SubpackagesArtifactTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/SubpackagesArtifactTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/SubpackagesArtifactTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,46 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.subpackages;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.jboss.testharness.impl.packaging.ArtifactDescriptor;
+import org.jboss.testharness.test.impl.packaging.AbstractArtifactTest;
+import org.testng.annotations.Test;
+
+public class SubpackagesArtifactTest extends AbstractArtifactTest
+{
+
+ @Test
+ public void testAllClassesInPackageAndNotSubPackages() throws Exception
+ {
+ ArtifactDescriptor artifactDescriptor = new ArtifactDescriptor(null);
+ artifactDescriptor.addPackage(SubpackagesArtifactTest.class.getPackage());
+ File root = artifactDescriptor.getExplodedJar();
+ File currentPackage = getCurrentPackageAsFile(root);
+ assert currentPackage.listFiles().length == 4;
+ File[] cowClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("Cow.class");
+ }
+
+ });
+ assert cowClasses.length == 1;
+ assert cowClasses[0].getName().equals("Cow.class");
+ assert cowClasses[0].isFile();
+
+ File[] testClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.startsWith("SubpackagesArtifactTest");
+ }
+
+ });
+ assert testClasses.length == 3;
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/subpackge/Fox.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/subpackge/Fox.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/subpackages/subpackge/Fox.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.subpackages.subpackge;
+
+class Fox
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/Cow.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/Cow.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/Cow.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.tck;
+
+class Cow
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/DummyTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/DummyTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/DummyTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.tck;
+
+public class DummyTest
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/TCKArtifactTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/TCKArtifactTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/tck/TCKArtifactTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,44 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.tck;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+import org.jboss.testharness.impl.packaging.ArtifactDescriptor;
+import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
+import org.jboss.testharness.test.impl.packaging.AbstractArtifactTest;
+import org.testng.annotations.Test;
+
+public class TCKArtifactTest extends AbstractArtifactTest
+{
+
+ @Test
+ public void testTCKSupportJar() throws Exception
+ {
+ ArtifactDescriptor artifactDescriptor = new WarArtifactDescriptor(DummyTest.class,
null);
+ File root = artifactDescriptor.getExplodedJar();
+ File tckSupportJar = new File(root,
"WEB-INF/lib/jboss-test-harness.jar");
+ assert tckSupportJar.exists();
+ assert tckSupportJar.isFile();
+ assert tckSupportJar.length() > 0;
+ JarInputStream is = new JarInputStream(new FileInputStream(tckSupportJar));
+ JarEntry entry;
+ List<String> fileNames = new ArrayList<String>();
+ while ((entry = is.getNextJarEntry()) != null)
+ {
+ fileNames.add(entry.getName().replace(File.separator, "/"));
+ }
+ assert
fileNames.contains("org/jboss/testharness/impl/util/Reflections.class");
+ assert fileNames.contains("org/jboss/testharness/AbstractTest.class");
+ assert fileNames.contains("org/jboss/testharness/impl/TCKImpl.class");
+ assert
fileNames.contains("org/jboss/testharness/impl/packaging/ArtifactDescriptor.class");
+ assert
fileNames.contains("org/jboss/testharness/impl/packaging/jsr299/TCKArtifactDescriptor.class");
+ assert
fileNames.contains("org/jboss/testharness/impl/packaging/war/WarArtifactDescriptor.class");
+ assert
fileNames.contains("org/jboss/testharness/impl/runner/TestRunner.class");
+ assert
fileNames.contains("org/jboss/testharness/impl/runner/servlet/ServletTestRunner.class");
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/Cow.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/Cow.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/Cow.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.war;
+
+class Cow
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/DummyTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/DummyTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/DummyTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.war;
+
+public class DummyTest
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/WarArtifactTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/WarArtifactTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/war/WarArtifactTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,101 @@
+package org.jboss.testharness.test.impl.packaging.descriptors.war;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
+import org.jboss.testharness.test.impl.packaging.AbstractArtifactTest;
+import org.testng.annotations.Test;
+
+public class WarArtifactTest extends AbstractArtifactTest
+{
+ @Test
+ public void testDefaultWar() throws Exception
+ {
+ WarArtifactDescriptor war = new WarArtifactDescriptor(DummyTest.class, null);
+ war.getClasses().add(Cow.class);
+ File root = war.getExplodedJar();
+ assert root.listFiles().length == 1;
+ assert root.isDirectory();
+ assert root.listFiles(WEB_INF_FILTER).length == 1;
+ File webInf = root.listFiles(WEB_INF_FILTER)[0];
+ assert webInf.getName().equals("WEB-INF");
+ assert webInf.isDirectory();
+ assert webInf.listFiles().length == 4;
+ assert webInf.listFiles(WEB_XML_FILTER).length == 1;
+ File webXml = webInf.listFiles(WEB_XML_FILTER)[0];
+ assert webXml.isFile();
+ assert webXml.getName().equals("web.xml");
+ assert webXml.length() != 0;
+ File beansXml = webInf.listFiles(BEANS_XML_FILTER)[0];
+ assert beansXml.isFile();
+ assert beansXml.getName().equals("beans.xml");
+ assert beansXml.length() == 0;
+ File currentPackage = getCurrentPackageAsFile(root);
+ File[] cowClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("Cow.class");
+ }
+
+ });
+ assert cowClasses.length == 1;
+ assert cowClasses[0].getName().equals("Cow.class");
+ assert cowClasses[0].isFile();
+ File tckPackage = getPackageAsFile(AbstractTest.class.getPackage(), root);
+ File[] abstractTestClasses = tckPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("AbstractTest.class");
+ }
+
+ });
+ File webInfLib = new File(webInf, "lib");
+ assert webInfLib.isDirectory();
+ assert webInfLib.list().length == 3;
+ List<String> libs = Arrays.asList(webInfLib.list());
+ assert libs.contains("jboss-test-harness-api.jar");
+ assert libs.contains("testng.jar");
+ assert libs.contains("jboss-test-harness.jar");
+ }
+
+
+ @Test
+ public void testJarProduction() throws Exception
+ {
+ WarArtifactDescriptor war = new WarArtifactDescriptor(DummyTest.class, null);
+ war.getClasses().add(Cow.class);
+ JarInputStream is = new JarInputStream(war.getJarAsStream());
+ JarEntry entry;
+ List<String> fileNames = new ArrayList<String>();
+ while ((entry = is.getNextJarEntry()) != null)
+ {
+ fileNames.add(entry.getName().replace(File.separator, "/"));
+ }
+ is.close();
+ assert fileNames.contains("WEB-INF/beans.xml");
+ assert fileNames.contains("WEB-INF/web.xml");
+ assert
fileNames.contains("WEB-INF/classes/org/jboss/testharness/test/impl/packaging/descriptors/war/Cow.class");
+ assert fileNames.contains("WEB-INF/lib/jboss-test-harness.jar");
+ }
+
+ @Override
+ protected File getPackageAsFile(Package pkg, File root)
+ {
+ root = root.listFiles(WEB_INF_FILTER)[0];
+ root = root.listFiles(CLASSES_FILTER)[0];
+ return super.getPackageAsFile(pkg, root);
+ }
+
+}
+
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/ArtifactScannerTest.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/ArtifactScannerTest.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/ArtifactScannerTest.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,54 @@
+package org.jboss.testharness.test.impl.packaging.scanner;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.testharness.api.Configuration;
+import org.jboss.testharness.impl.packaging.ArtifactDescriptor;
+import org.jboss.testharness.impl.packaging.ArtifactGenerator;
+import org.jboss.testharness.impl.packaging.ArtifactScanner;
+import org.jboss.testharness.test.impl.mock.MockConfiguration;
+import
org.jboss.testharness.test.impl.packaging.scanner.subpackage.AnotherDummyArtifact;
+import org.jboss.testharness.test.impl.packaging.scanner.subpackage.NotAnArtifact;
+import org.testng.annotations.Test;
+
+public class ArtifactScannerTest
+{
+
+ @Test
+ public void testScanner()
+ {
+ ArtifactScanner scanner = new
ArtifactScanner(ArtifactScannerTest.class.getPackage().getName(), null);
+ Set<Class<?>> classes = scanner.getClasses();
+ assert classes.contains(DummyArtifact.class);
+ assert classes.contains(AnotherDummyArtifact.class);
+ assert !classes.contains(NotAnArtifact.class);
+ }
+
+ @Test
+ public void testMockArtifactGenerator() throws Exception
+ {
+ Configuration configuration = new MockConfiguration();
+ ArtifactGenerator generator = new ArtifactGenerator(configuration);
+ List<ArtifactDescriptor> artifacts =
generator.createArtifacts(DummyArtifact.class.getPackage().getName());
+ assert artifacts.size() == 2;
+ for (ArtifactDescriptor artifact : artifacts)
+ {
+ if (artifact.getDeclaringClass().equals(DummyArtifact.class))
+ {
+ assert artifact.getClasses().contains(ArtifactScannerTest.class);
+ assert artifact.getClasses().contains(DummyArtifact.class);
+ assert !artifact.getClasses().contains(AnotherDummyArtifact.class);
+ assert !artifact.getClasses().contains(NotAnArtifact.class);
+ }
+ if (artifact.getDeclaringClass().equals(AnotherDummyArtifact.class))
+ {
+ assert !artifact.getClasses().contains(ArtifactScannerTest.class);
+ assert !artifact.getClasses().contains(DummyArtifact.class);
+ assert artifact.getClasses().contains(AnotherDummyArtifact.class);
+ assert artifact.getClasses().contains(NotAnArtifact.class);
+ }
+ }
+ }
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/DummyArtifact.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/DummyArtifact.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/DummyArtifact.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,9 @@
+package org.jboss.testharness.test.impl.packaging.scanner;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+
+@Artifact
+public class DummyArtifact
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/subpackage/AnotherDummyArtifact.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/subpackage/AnotherDummyArtifact.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/subpackage/AnotherDummyArtifact.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,9 @@
+package org.jboss.testharness.test.impl.packaging.scanner.subpackage;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+
+@Artifact
+public class AnotherDummyArtifact
+{
+
+}
Added:
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/subpackage/NotAnArtifact.java
===================================================================
---
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/subpackage/NotAnArtifact.java
(rev 0)
+++
test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/scanner/subpackage/NotAnArtifact.java 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,6 @@
+package org.jboss.testharness.test.impl.packaging.scanner.subpackage;
+
+public class NotAnArtifact
+{
+
+}
Added:
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/impl/packaging/ear/ejb-jar.xml
===================================================================
---
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/impl/packaging/ear/ejb-jar.xml
(rev 0)
+++
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/impl/packaging/ear/ejb-jar.xml 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+
+</ejb-jar>
Added:
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
===================================================================
Added:
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/foo/foo.xml
===================================================================
Added:
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/my-web-beans.xml
===================================================================
---
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/my-web-beans.xml
(rev 0)
+++
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/standalone/my-web-beans.xml 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1 @@
+<my></my>
\ No newline at end of file
Added:
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/war/my-web.xml
===================================================================
---
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/war/my-web.xml
(rev 0)
+++
test-harness/trunk/tests/src/test/resources/org/jboss/testharness/test/impl/packaging/declarative/war/my-web.xml 2009-03-10
14:11:50 UTC (rev 1906)
@@ -0,0 +1 @@
+<web></web>
\ No newline at end of file