#731 - ENH: Add support for using ebean.mf manifest file for finding/defining packages to search for entities

This commit is contained in:
Robin Bygrave
2016-06-02 17:35:06 +12:00
parent b3828572fd
commit 1304646cce
23 changed files with 241 additions and 17 deletions
@@ -3,7 +3,7 @@ package com.avaje.ebean.server.type;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.config.ServerConfig;
import com.avaje.ebean.config.dbplatform.H2Platform;
import com.avaje.ebeaninternal.server.core.BootupClasses;
import com.avaje.ebeaninternal.server.core.bootup.BootupClasses;
import com.avaje.ebeaninternal.server.type.CtCompoundType;
import com.avaje.ebeaninternal.server.type.DefaultTypeManager;
import com.avaje.ebeaninternal.server.type.RsetDataReader;
@@ -0,0 +1,50 @@
package com.avaje.ebeaninternal.server.core.bootup;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class DistillPackagesTest {
@Test
public void when_unique_expect_all() throws Exception {
List<String> distill = DistillPackages.distill(group("one", "two"), group("three"));
assertThat(distill).containsExactly("one", "three", "two");
}
@Test
public void when_sub_expect_distilled() throws Exception {
List<String> distill = DistillPackages.distill(group("one", "one.sub"), group("three"));
assertThat(distill).containsExactly("one", "three");
}
@Test
public void when_sub_expect_distilled2() throws Exception {
List<String> distill = DistillPackages.distill(group("one", "one.sub"), group("one.foo"));
assertThat(distill).containsExactly("one");
}
@Test
public void when_subDotSub_expect_distilled2() throws Exception {
List<String> distill = DistillPackages.distill(group("one", "one.sub.me"), group("two"));
assertThat(distill).containsExactly("one", "two");
}
@Test
public void when_unordered_expect_naturalOrder() throws Exception {
List<String> distill = DistillPackages.distill(group("z.x.y","two"), group("one", "one.sub.me"));
assertThat(distill).containsExactly("one", "two", "z.x.y");
}
List<String> group(String... packages) {
return Arrays.asList(packages);
}
}
@@ -0,0 +1,30 @@
package com.avaje.ebeaninternal.server.core.bootup;
import org.junit.Test;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
public class ManifestReaderTest {
@Test
public void readOne() throws Exception {
Set<String> packageSet = readMf("META-INF/test/test-one.mf");
assertThat(packageSet).contains("foo");
}
@Test
public void readSome() throws Exception {
Set<String> packageSet = readMf("META-INF/test/test-some.mf");
assertThat(packageSet).contains("com.foo.domain", "com.bar.domain");
}
private Set<String> readMf(String path) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
return ManifestReader.readManifests(classLoader, path);
}
}
@@ -2,7 +2,7 @@ package com.avaje.ebeaninternal.server.type;
import com.avaje.ebean.config.ServerConfig;
import com.avaje.ebean.config.dbplatform.PostgresPlatform;
import com.avaje.ebeaninternal.server.core.BootupClasses;
import com.avaje.ebeaninternal.server.core.bootup.BootupClasses;
import org.junit.Test;
import static org.junit.Assert.*;