123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- /* *******************************************************************
- * 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());
- }
- }
-
- }
|