aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/test/java/org/aspectj/systemtest/ajc171/NewFeatures.java
blob: b3facba82477863ab6c4897543266217596ea52c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*******************************************************************************
 * Copyright (c) 2012 Lucierna
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
 *
 * Contributors:
 *    Abraham Nevado (lucierna) - initial implementation
 *******************************************************************************/
package org.aspectj.systemtest.ajc171;

import java.io.File;

import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.testing.XMLBasedAjcTestCase;

import junit.framework.Test;

// NOTE THIS IS ACTUALLY IN 1.7.2 - IT IS JUST THAT THE PATCH WAS CREATED AGAINST 1.7.1
public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase {

	public void testSharedCache() {
		this.runTest("Test Shared Cache");
		File cacheFolder =  new File(ajc.getSandboxDirectory().getAbsolutePath() + File.separator + "panenka.cache");
		assertTrue("Cache folder should be written when using share cache", cacheFolder.exists());
		//Delete the cache from the ajc sandbox
		deleteFolder(cacheFolder);
	}

	public void testPerClassLoaderCache() {
		this.runTest("Test Per ClassLoader Cache");
		File cacheFolder =  new File(ajc.getSandboxDirectory().getAbsolutePath() + File.separator + "panenka.cache");
		assertFalse("Shared Cache Folder should not be present", cacheFolder.exists());
	}

	public void testDefaultCachePerClassloader() {
		this.runTest("Test Default Cache Per ClassLoader");
		File cacheFolder =  new File(ajc.getSandboxDirectory().getAbsolutePath() + File.separator + "panenka.cache");
		assertFalse("By Default Per ClassLoader Cache should be used and not the shared one", cacheFolder.exists());
	}

	// ///////////////////////////////////////

	private static void deleteFolder(File folder) {
	    File[] files = folder.listFiles();
	    if(files!=null) { //some JVMs return null for empty dirs
	        for(File f: files) {
	            if(f.isDirectory()) {
	                deleteFolder(f);
	            } else {
	                f.delete();
	            }
	        }
	    }
	    folder.delete();
	}

	public static Test suite() {
		return XMLBasedAjcTestCase.loadSuite(NewFeatures.class);
	}

	@SuppressWarnings("unused")
	private JavaClass getMyClass(String className) throws ClassNotFoundException {
		return getClassFrom(ajc.getSandboxDirectory(), className);
	}

	@Override
	protected java.net.URL getSpecFile() {
		return getClassResource("newfeatures-tests.xml");
//		return new File("../tests/src/org/aspectj/systemtest/ajc171/newfeatures-tests.xml");
	}

}