Pārlūkot izejas kodu

Fix OutjarTest regarding Ajc output (usage messages etc.)

After Ajc usage text output is filtered into its own category
IMessage.USAGE now - see commit @31b2d60b - some tests in module
'org.aspectj.ajdt.core' were failing. I fixed and also improved them a
bit in @e4a2a5a5, but forgot to commit this one.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tags/java16-add-opens
Alexander Kriegisch pirms 3 gadiem
vecāks
revīzija
fa8dc8d9bf

+ 39
- 46
org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/OutjarTest.java Parādīt failu

/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004 IBM Corporation and others. * Copyright (c) 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
*
* Contributors: * Contributors:
* Matthew Webster - initial implementation * Matthew Webster - initial implementation
*******************************************************************************/ *******************************************************************************/
public class OutjarTest extends AjcTestCase { public class OutjarTest extends AjcTestCase {


public static final String PROJECT_DIR = "OutjarTest"; public static final String PROJECT_DIR = "OutjarTest";
public static final String injarName = "child.jar"; public static final String injarName = "child.jar";
public static final String aspectjarName = "aspects.jar"; public static final String aspectjarName = "aspects.jar";
public static final String outjarName = "outjar.jar"; public static final String outjarName = "outjar.jar";


private File baseDir; private File baseDir;
/** /**
* Make copies of JARs used for -injars/-inpath and -aspectpath because so * Make copies of JARs used for -injars/-inpath and -aspectpath because so
* they are not overwritten when a test fails. * they are not overwritten when a test fails.
super.setUp(); super.setUp();
baseDir = new File("../org.aspectj.ajdt.core/testdata",PROJECT_DIR); baseDir = new File("../org.aspectj.ajdt.core/testdata",PROJECT_DIR);
} }
/** /**
* Aim: Check that -outjar does not coincide with a member of -injars. This * Aim: Check that -outjar does not coincide with a member of -injars. This
* is because if a binary weave fails -outjar is deleted. * is because if a binary weave fails -outjar is deleted.
*
*
* Inputs to the compiler: * Inputs to the compiler:
* -injar * -injar
* -aspectpath * -aspectpath
* -outjar
*
* -outjar
*
* Expected result = Compile aborts with error message. * Expected result = Compile aborts with error message.
*/ */
public void testOutjarInInjars () { public void testOutjarInInjars () {
String[] args = new String[] {"-aspectpath", aspectjarName, "-injars", injarName, "-outjar", injarName};
String[] args = new String[] { "-aspectpath", aspectjarName, "-injars", injarName, "-outjar", injarName };
Message error = new Message(WeaverMessages.format(WeaverMessages.OUTJAR_IN_INPUT_PATH)); Message error = new Message(WeaverMessages.format(WeaverMessages.OUTJAR_IN_INPUT_PATH));
Message fail = new Message("Usage:");
MessageSpec spec = new MessageSpec(null,null,newMessageList(error),newMessageList(fail),null, null);
CompilationResult result = ajc(baseDir,args);
// System.out.println(result);
assertMessages(result,spec);
MessageSpec spec = new MessageSpec(null, null, newMessageList(error));
CompilationResult result = ajc(baseDir, args);
assertMessages(result, spec);
} }

/** /**
* Aim: Check that -outjar does not coincide with a member of -inpath. This * Aim: Check that -outjar does not coincide with a member of -inpath. This
* is because if a binary weave fails -outjar is deleted. * is because if a binary weave fails -outjar is deleted.
*
*
* Inputs to the compiler: * Inputs to the compiler:
* -injar * -injar
* -aspectpath * -aspectpath
* -outjar
*
* -outjar
*
* Expected result = Compile aborts with error message. * Expected result = Compile aborts with error message.
*/ */
public void testOutjarInInpath () { public void testOutjarInInpath () {
String[] args = new String[] {"-aspectpath", aspectjarName, "-inpath", injarName, "-outjar", injarName};
String[] args = new String[] { "-aspectpath", aspectjarName, "-inpath", injarName, "-outjar", injarName };
Message error = new Message(WeaverMessages.format(WeaverMessages.OUTJAR_IN_INPUT_PATH)); Message error = new Message(WeaverMessages.format(WeaverMessages.OUTJAR_IN_INPUT_PATH));
Message fail = new Message("Usage:");
MessageSpec spec = new MessageSpec(null,null,newMessageList(error),newMessageList(fail),null, null);
CompilationResult result = ajc(baseDir,args);
// System.out.println(result);
assertMessages(result,spec);
MessageSpec spec = new MessageSpec(null, null, newMessageList(error));
CompilationResult result = ajc(baseDir, args);
assertMessages(result, spec);
} }

/** /**
* Aim: Check that -outjar does not coincide with a member of -aspectpath. This * Aim: Check that -outjar does not coincide with a member of -aspectpath. This
* is because if a binary weave fails -outjar is deleted. * is because if a binary weave fails -outjar is deleted.
*
*
* Inputs to the compiler: * Inputs to the compiler:
* -injar * -injar
* -aspectpath * -aspectpath
* -outjar
*
* -outjar
*
* Expected result = Compile aborts with error message. * Expected result = Compile aborts with error message.
*/ */
public void testOutjarInAspectpath () { public void testOutjarInAspectpath () {
String[] args = new String[] {"-aspectpath", aspectjarName, "-inpath", injarName, "-outjar", aspectjarName};
String[] args = new String[] { "-aspectpath", aspectjarName, "-inpath", injarName, "-outjar", aspectjarName };
Message error = new Message(WeaverMessages.format(WeaverMessages.OUTJAR_IN_INPUT_PATH)); Message error = new Message(WeaverMessages.format(WeaverMessages.OUTJAR_IN_INPUT_PATH));
Message fail = new Message("Usage:");
MessageSpec spec = new MessageSpec(null,null,newMessageList(error),newMessageList(fail),null, null);
CompilationResult result = ajc(baseDir,args);
// System.out.println(result);
assertMessages(result,spec);
MessageSpec spec = new MessageSpec(null, null, newMessageList(error));
CompilationResult result = ajc(baseDir, args);
assertMessages(result, spec);
} }

/** /**
* Aim: Check that -outjar is not present when compile fails. * Aim: Check that -outjar is not present when compile fails.
*
*
* Inputs to the compiler: * Inputs to the compiler:
* -injar * -injar
* -aspectpath * -aspectpath
* -outjar
*
* -outjar
*
* Expected result = Compile fails with error message. * Expected result = Compile fails with error message.
*/ */
public void testOutjarDeletedOnError () { public void testOutjarDeletedOnError () {
String[] args = new String[] {"-aspectpath", aspectjarName, "-injars", injarName, "-outjar", outjarName,"-1.4"};
Message error = new Message(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_INTERFACES,"jar1.Parent"));
MessageSpec spec = new MessageSpec(null,newMessageList(error));
CompilationResult result = ajc(baseDir,args);
// System.out.println(result);
assertMessages(result,spec);
File outjar = new File(ajc.getSandboxDirectory(),outjarName);
assertFalse("-outjar " + outjar.getPath() + " should be deleted",outjar.exists());
String[] args = new String[] { "-aspectpath", aspectjarName, "-injars", injarName, "-outjar", outjarName, "-1.4" };
Message error = new Message(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_INTERFACES, "jar1.Parent"));
MessageSpec spec = new MessageSpec(null, newMessageList(error));
CompilationResult result = ajc(baseDir, args);
assertMessages(result, spec);
File outjar = new File(ajc.getSandboxDirectory(), outjarName);
assertFalse("-outjar " + outjar.getPath() + " should be deleted", outjar.exists());
} }


} }

Notiek ielāde…
Atcelt
Saglabāt