package org.bench4q.agent.test.plugin;

import java.util.Map;

import org.bench4q.agent.helper.ClassHelper;
import org.bench4q.agent.helper.ClassLoadRestriction;
import org.bench4q.agent.plugin.Plugin;
import org.junit.Test;

import static org.junit.Assert.*;

public class Test_ClassHelper {

	@Test
	public void test_loadClasses() {
		Map<String, Class<?>> plugins = new ClassHelper().loadClasses(
				"org.bench4q.agent.plugin", new ClassLoadRestriction() {
					public boolean accept(Class<?> classUnderTest) {
						return classUnderTest.isAnnotationPresent(Plugin.class);
					}

					public String getAcceptKey(Class<?> classUnderTest) {
						return classUnderTest.getAnnotation(Plugin.class)
								.value();
					}
				});
		assertEquals(9, plugins.size());
		assertEquals(true, plugins.containsKey("Http"));
	}
}
