diff options
Diffstat (limited to 'ajde')
-rw-r--r-- | ajde/testsrc/org/aspectj/ajde/AjdeTests.java | 1 | ||||
-rw-r--r-- | ajde/testsrc/org/aspectj/ajde/OutxmlTest.java | 93 |
2 files changed, 94 insertions, 0 deletions
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java index dfe880ddb..461dfc52f 100644 --- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java +++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java @@ -59,6 +59,7 @@ public class AjdeTests extends TestCase { suite.addTestSuite(JarManifestTest.class); suite.addTestSuite(ExtensionTests.class); suite.addTestSuite(GenericsTest.class); + suite.addTestSuite(OutxmlTest.class); //$JUnit-END$ return suite; diff --git a/ajde/testsrc/org/aspectj/ajde/OutxmlTest.java b/ajde/testsrc/org/aspectj/ajde/OutxmlTest.java new file mode 100644 index 000000000..2ccb66b2d --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/OutxmlTest.java @@ -0,0 +1,93 @@ +/* ******************************************************************* + * Copyright (c) 2003 Contributors. + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Matthew Webster initial implementation + * ******************************************************************/ +package org.aspectj.ajde; + +import java.io.File; +import java.io.IOException; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +import org.aspectj.util.FileUtil; + +public class OutxmlTest extends AjdeTestCase { + + public static final String PROJECT_DIR = "OutxmlTest"; + public static final String BIN_DIR = "bin"; + public static final String OUTJAR_NAME = "/bin/test.jar"; + public static final String DEFAULT_AOPXML_NAME = "META-INF/aop.xml"; + public static final String CUSTOM_AOPXML_NAME = "custom/aop.xml"; + + /* + * Ensure the output directory is clean + */ + protected void setUp() throws Exception { + super.setUp(PROJECT_DIR); + FileUtil.deleteContents(openFile(BIN_DIR)); + } + + + /** + * Aim: Test "-outxml" option produces the correct xml file + * + */ + public void testOutxmlToFile () { +// System.out.println("OutxmlTest.testOutxmlToFile() outputpath='" + ideManager.getProjectProperties().getOutputPath() + "'"); + assertTrue("Build failed",doSynchronousBuild("outxml-to-file.lst")); + assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty()); + + File aopxml = openFile(BIN_DIR + "/" + DEFAULT_AOPXML_NAME); + assertTrue(DEFAULT_AOPXML_NAME + " missing",aopxml.exists()); + } + + /** + * Aim: Test "-outxmlfile filename" option produces the correct + * xml file + * + */ + public void testOutxmlfileToFile () { + assertTrue("Build failed",doSynchronousBuild("outxmlfile-to-file.lst")); + assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty()); + + File aopxml = openFile(BIN_DIR + "/" + CUSTOM_AOPXML_NAME); + assertTrue(CUSTOM_AOPXML_NAME + " missing",aopxml.exists()); + } + + /** + * Aim: Test "-outxmlfile filename" option produces the correct + * xml entry in outjar file + * + */ + public void testOutxmlfileToOutjar () { +// System.out.println("OutxmlTest.testOutxmlToOutjar() outputpath='" + ideManager.getProjectProperties().getOutputPath() + "'"); + File outjar = openFile(OUTJAR_NAME); + ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath()); + assertTrue("Build failed",doSynchronousBuild("outxmlfile-to-outjar.lst")); + assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty()); + + File aopxml = openFile(BIN_DIR + "/" + CUSTOM_AOPXML_NAME); + assertFalse(CUSTOM_AOPXML_NAME + " should not exisit",aopxml.exists()); + assertJarContainsEntry(outjar,CUSTOM_AOPXML_NAME); + } + + private void assertJarContainsEntry (File file, String entryName) { + + try { + JarFile jarFile = new JarFile(file); + JarEntry jarEntry = jarFile.getJarEntry(entryName); + assertNotNull(entryName + " missing",jarEntry); + } + catch (IOException ex) { + fail(ex.toString()); + } + } + +} |