diff options
author | aclement <aclement> | 2008-09-19 00:00:43 +0000 |
---|---|---|
committer | aclement <aclement> | 2008-09-19 00:00:43 +0000 |
commit | 3d7308774c6229548756abb27c6f3afe135fccc6 (patch) | |
tree | 73505ae672c2eccc0ff0955c59af2a83bf02745a /tests | |
parent | 6d6adfc1327fea030f0547737543df96b5447387 (diff) | |
download | aspectj-3d7308774c6229548756abb27c6f3afe135fccc6.tar.gz aspectj-3d7308774c6229548756abb27c6f3afe135fccc6.zip |
242797: testcode
Diffstat (limited to 'tests')
24 files changed, 503 insertions, 0 deletions
diff --git a/tests/multiIncremental/PR242797_3/base/src/test1/SelectAction.java b/tests/multiIncremental/PR242797_3/base/src/test1/SelectAction.java new file mode 100644 index 000000000..caa78d8ab --- /dev/null +++ b/tests/multiIncremental/PR242797_3/base/src/test1/SelectAction.java @@ -0,0 +1,16 @@ +/* + * Created on Mar 7, 2008 + */ +package test1; + +public interface SelectAction<T>{ + + public void select(T object); + + public T getSelected(); + + public void setSelected(T object); + + public void deselect(); + +}
\ No newline at end of file diff --git a/tests/multiIncremental/PR242797_3/base/src/test1/SelectActionAspect.aj b/tests/multiIncremental/PR242797_3/base/src/test1/SelectActionAspect.aj new file mode 100644 index 000000000..b94fcf8a9 --- /dev/null +++ b/tests/multiIncremental/PR242797_3/base/src/test1/SelectActionAspect.aj @@ -0,0 +1,26 @@ +/* + * Created on Sep 4, 2008 + */ +package test1; + +public aspect SelectActionAspect { + + private T SelectAction<T>.selected; + + public void SelectAction<T>.select(T object){ + this.selected = object; + } + + public T SelectAction<T>.getSelected(){ + return selected; + } + + public void SelectAction<T>.setSelected(T object){ + this.selected = object; + } + + public void SelectAction<T>.deselect(){ + this.selected = null; + } + +} diff --git a/tests/multiIncremental/PR242797_4/base/src/test2/ProfileAction.java b/tests/multiIncremental/PR242797_4/base/src/test2/ProfileAction.java new file mode 100644 index 000000000..5b067b4f3 --- /dev/null +++ b/tests/multiIncremental/PR242797_4/base/src/test2/ProfileAction.java @@ -0,0 +1,11 @@ +package test2; +import test1.SelectAction; + + +/* + * Created on Sep 11, 2008 + */ + +public class ProfileAction implements SelectAction<Object>{ + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/A.class b/tests/multiIncremental/pr242797_1/base/src/bug/A.class Binary files differnew file mode 100644 index 000000000..073691b68 --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/A.class diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/A.java b/tests/multiIncremental/pr242797_1/base/src/bug/A.java new file mode 100644 index 000000000..4b9427ade --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/A.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface A { + + List<?> getfoos() ; +} + +aspect X { + List<?> A.getFoos() { return null; } +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/DuplicateStrategy.java b/tests/multiIncremental/pr242797_1/base/src/bug/DuplicateStrategy.java new file mode 100644 index 000000000..0cbedc9ca --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/DuplicateStrategy.java @@ -0,0 +1,12 @@ +/* + * Created on Aug 22, 2008 + */ +package bug; + + +public enum DuplicateStrategy { + + COMBINE, + BEST_MATCH + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/EntityManager.java b/tests/multiIncremental/pr242797_1/base/src/bug/EntityManager.java new file mode 100644 index 000000000..7622d8d1c --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/EntityManager.java @@ -0,0 +1,23 @@ +/* + * Created on Sep 18, 2008 + */ +package bug; + + +public class EntityManager { + + public Query createQuery(String query){ + return new Query(); + } + + public Object find(Class<?> type, Object id){ + return new Object(); + } + + public void merge(Object object){} + + public void persist(Object object){} + + public void remove(Object object){} + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/EqualityUtils.java b/tests/multiIncremental/pr242797_1/base/src/bug/EqualityUtils.java new file mode 100644 index 000000000..c6e4ecc5d --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/EqualityUtils.java @@ -0,0 +1,20 @@ +/* + * Created on Aug 8, 2008 + */ +package bug; + +public class EqualityUtils { + + public static boolean equal(Object obj1, Object obj2){ + if(obj1 == null){ + if(obj2 == null) + return true; + return false; + } else if(obj2 == null){ + return false; + } else{ + return obj1.equals(obj2); + } + } + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/FailingManager.java b/tests/multiIncremental/pr242797_1/base/src/bug/FailingManager.java new file mode 100644 index 000000000..e055c7205 --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/FailingManager.java @@ -0,0 +1,23 @@ +/* + * Created on Sep 18, 2008 + */ +package bug; + +import java.util.List; + + +public class FailingManager implements PartitionedManager { + + public Class<Object> getManagedType(){ + return Object.class; + } + + public List<String> getDefaultPartitionOrder() { + return null; + } + + public DuplicateStrategy getPartitionedDuplicateStrategy() { + return null; + } + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/H2Lookup.java b/tests/multiIncremental/pr242797_1/base/src/bug/H2Lookup.java new file mode 100644 index 000000000..a09886cec --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/H2Lookup.java @@ -0,0 +1,13 @@ +/* + * Created on Sep 18, 2008 + */ +package bug; + + +public class H2Lookup { + + public static EntityManager em(){ + return new EntityManager(); + } + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/Localized.java b/tests/multiIncremental/pr242797_1/base/src/bug/Localized.java new file mode 100644 index 000000000..5cdd67468 --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/Localized.java @@ -0,0 +1,10 @@ +/* + * Created on Jul 23, 2008 + */ +package bug; + +public interface Localized extends NaturallyComparable{ + + public String getLanguage(); + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/LocalizedManager.java b/tests/multiIncremental/pr242797_1/base/src/bug/LocalizedManager.java new file mode 100644 index 000000000..bf89e05a7 --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/LocalizedManager.java @@ -0,0 +1,31 @@ +/* + * Created on Jul 25, 2008 + */ +package bug; + +import java.util.List; + + +public interface LocalizedManager extends Manager{ + + public Class<? extends Localized> getLocalizedType(); + + public List<? extends Localized> getAllInLocale(String language); + + public List<? extends Localized> getAllInLocales(List<String> languages); + + public List<? extends Localized> getAllInDefaultLocales(); + + public List<? extends Localized> getBestInLocales(List<String> languages); + + public List<? extends Localized> getBestInDefaultLocales(); + + public List<? extends Localized> removeWeakLanguageMatches(List<? extends Localized> localized); + + public List<? extends Localized> removeWeakLanguageMatches(List<? extends Localized> localized, List<String> languageOrder); + + public DuplicateStrategy getLocalizedDuplicateStrategy(); + + public List<String> getDefaultLanguageOrder(); + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/Manager.java b/tests/multiIncremental/pr242797_1/base/src/bug/Manager.java new file mode 100644 index 000000000..91a558931 --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/Manager.java @@ -0,0 +1,28 @@ +/* + * Created on Jul 25, 2008 + */ +package bug; + +import java.util.List; + +public interface Manager { + + public Class<?> getManagedType(); + + public <T> T find(Object id); + + public <T> T update(T object); + + public <T> T save(T object); + + public <T> T remove(T object); + + public List<?> getAny(); + + public List<?> getAll(); + + public Query createQuery(String queryString); + + public EntityManager getEntityManager(); + +}
\ No newline at end of file diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/ManagerAspect.aj b/tests/multiIncremental/pr242797_1/base/src/bug/ManagerAspect.aj new file mode 100644 index 000000000..77c6d9579 --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/ManagerAspect.aj @@ -0,0 +1,57 @@ +package bug; + +import java.util.List; + +public aspect ManagerAspect { + + public List<?> Manager.getAny(){ + return getEntityManager().createQuery("SELECT obj FROM " + + getManagedType().getName() + " obj ").getResultList(); + } + + public List<?> Manager.getAll(){ + List<?> values = null; + if(this instanceof LocalizedManager){ + LocalizedManager manager = (LocalizedManager)this; + values = manager.getAllInDefaultLocales(); + } + else if(this instanceof PartitionedManager){ + PartitionedManager manager = (PartitionedManager)this; + values = manager.getBestInDefaultPartitions(); + } + else{ + values = getAny(); + } + return values; + } + + public <T> T Manager.find(Object id){ + return (T) getEntityManager().find(getManagedType(), id); + } + + public <T> T Manager.save(T object){ + getEntityManager().persist(object); + return object; + } + + public <T> T Manager.update(T object){ + getEntityManager().merge(object); + return object; + } + + public <T> T Manager.remove(T object){ + getEntityManager().remove(object); + return object; + } + + public Query Manager.createQuery(String queryString){ + EntityManager em = getEntityManager(); + Query query = em.createQuery(queryString); + return query; + } + + public EntityManager Manager.getEntityManager() { + return H2Lookup.em(); + } + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/NaturallyComparable.java b/tests/multiIncremental/pr242797_1/base/src/bug/NaturallyComparable.java new file mode 100644 index 000000000..06872fb01 --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/NaturallyComparable.java @@ -0,0 +1,13 @@ +/* + * Created on Aug 22, 2008 + */ +package bug; + + +public interface NaturallyComparable { + + public Object getNaturalId(); + + public boolean naturallyEqual(NaturallyComparable to); + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/NaturallyComparablePruner.java b/tests/multiIncremental/pr242797_1/base/src/bug/NaturallyComparablePruner.java new file mode 100644 index 000000000..cbae2697b --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/NaturallyComparablePruner.java @@ -0,0 +1,49 @@ +/* + * Created on Aug 22, 2008 + */ +package bug; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public abstract class NaturallyComparablePruner<T extends NaturallyComparable, O> { + + public List<? extends T> prune(List<? extends T> list, List<O> order){ + Map<Object, List<T>> sep = new HashMap<Object, List<T>>(); + for(T obj : list){ + Object id = obj.getNaturalId(); + List<T> matches = sep.get(id); + if(matches == null){ + matches = new ArrayList<T>(); + sep.put(id, matches); + } + if(matches.size() == 0) + matches.add(obj); + else{ + T match = matches.get(0); + O yours = getOrdering(match); + O mine = getOrdering(obj); + if(EqualityUtils.equal(mine, yours)) + matches.add(obj); + else{ + int yourIndex = order.indexOf(yours); + int myIndex = order.indexOf(mine); + if(myIndex < yourIndex){ + matches.clear(); + matches.add(obj); + } + } + } + } + List<T> result = new ArrayList<T>(); + for(List<T> values : sep.values()) + result.addAll(values); + return result; + } + + public abstract O getOrdering(T object); + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/Partitioned.java b/tests/multiIncremental/pr242797_1/base/src/bug/Partitioned.java new file mode 100644 index 000000000..1aa069aa6 --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/Partitioned.java @@ -0,0 +1,12 @@ +/* + * Created on Jul 23, 2008 + */ +package bug; + +public interface Partitioned extends NaturallyComparable{ + + public String getOwnerId(); + + public String getPartitionId(); + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/PartitionedManager.java b/tests/multiIncremental/pr242797_1/base/src/bug/PartitionedManager.java new file mode 100644 index 000000000..cfd9c3930 --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/PartitionedManager.java @@ -0,0 +1,28 @@ +/* + * Created on Jul 25, 2008 + */ +package bug; + +import java.util.List; + +public interface PartitionedManager extends Manager{ + + public Class<? extends Partitioned> getPartitionedType(); + + public List<? extends Partitioned> getAllInPartitions(List<String> partitionOrder); + + public List<? extends Partitioned> getAllInPartition(String partitionId); + + public List<? extends Partitioned> getBestInPartitions(List<String> partitionOrder); + + public List<? extends Partitioned> getBestInDefaultPartitions(); + + public List<? extends Partitioned> removeWeakPartitionMatches(List<? extends Partitioned> partitioned); + + public List<? extends Partitioned> removeWeakPartitionMatches(List<? extends Partitioned> partitioned, List<String> partitionOrder); + + public DuplicateStrategy getPartitionedDuplicateStrategy(); + + public List<String> getDefaultPartitionOrder(); + +}
\ No newline at end of file diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/PartitionedManagerAspect.aj b/tests/multiIncremental/pr242797_1/base/src/bug/PartitionedManagerAspect.aj new file mode 100644 index 000000000..8e899ed02 --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/PartitionedManagerAspect.aj @@ -0,0 +1,46 @@ +package bug; + +import java.util.List; + +public aspect PartitionedManagerAspect { + + public Class<? extends Partitioned> PartitionedManager.getPartitionedType(){ + return (Class<? extends Partitioned>) getManagedType(); + } + + public List<? extends Partitioned> PartitionedManager.removeWeakPartitionMatches(List<? extends Partitioned> partitioned){ + return removeWeakPartitionMatches(partitioned, getDefaultPartitionOrder()); + } + + public List<? extends Partitioned> PartitionedManager.removeWeakPartitionMatches( + List<? extends Partitioned> partitioned, List<String> partitionOrder){ + return new PartitionedPruner().prune(partitioned, partitionOrder); + } + + public List<? extends Partitioned> PartitionedManager.getBestInDefaultPartitions(){ + return getBestInPartitions(getDefaultPartitionOrder()); + } + + public List<? extends Partitioned> PartitionedManager.getBestInPartitions(List<String> partitionOrder){ + List<? extends Partitioned> results = getAllInPartitions(partitionOrder); + results = removeWeakPartitionMatches(results, partitionOrder); + return results; + } + + public List<? extends Partitioned> PartitionedManager.getAllInPartition(String partitionId){ + String queryString = QueryUtils.select(getPartitionedType(), "partitioned") + + " WHERE partitioned.partitionId = :partitionId"; + Query query = createQuery(queryString); + query.setParameter("partitionId", partitionId); + return query.getResultList(); + } + + public List<? extends Partitioned> PartitionedManager.getAllInPartitions(List<String> partitionOrder){ + String queryString = QueryUtils.select(getPartitionedType(), "partitioned") + + " WHERE partitioned.partitionId IN (:partitionOrder)"; + Query query = createQuery(queryString); + query.setParameter("partitionORder", partitionOrder); + return query.getResultList(); + } + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/PartitionedPruner.java b/tests/multiIncremental/pr242797_1/base/src/bug/PartitionedPruner.java new file mode 100644 index 000000000..457e1a727 --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/PartitionedPruner.java @@ -0,0 +1,13 @@ +/* + * Created on Aug 22, 2008 + */ +package bug; + +public class PartitionedPruner extends NaturallyComparablePruner<Partitioned, String>{ + + @Override + public String getOrdering(Partitioned object) { + return object.getPartitionId(); + } + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/Query.java b/tests/multiIncremental/pr242797_1/base/src/bug/Query.java new file mode 100644 index 000000000..38c7e01ac --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/Query.java @@ -0,0 +1,20 @@ +/* + * Created on Sep 18, 2008 + */ +package bug; + +import java.util.ArrayList; +import java.util.List; + + +public class Query { + + public List getResultList(){ + return new ArrayList<Object>(); + } + + public Query setParameter(String name, Object value){ + return this; + } + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/QueryUtils.java b/tests/multiIncremental/pr242797_1/base/src/bug/QueryUtils.java new file mode 100644 index 000000000..3b19e83ca --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/QueryUtils.java @@ -0,0 +1,16 @@ +/* + * Created on Aug 18, 2008 + */ +package bug; + +public class QueryUtils { + + public static String select(Class<?> from, String alias){ + return select(from, alias, alias); + } + + public static String select(Class<?> from, String alias, String target){ + return "SELECT " + target + " FROM " + from.getName() + " " + alias + " "; + } + +} diff --git a/tests/multiIncremental/pr242797_1/base/src/bug/X.class b/tests/multiIncremental/pr242797_1/base/src/bug/X.class Binary files differnew file mode 100644 index 000000000..ba8136255 --- /dev/null +++ b/tests/multiIncremental/pr242797_1/base/src/bug/X.class diff --git a/tests/multiIncremental/pr242797_2/base/src/bug2/FailingManager.java b/tests/multiIncremental/pr242797_2/base/src/bug2/FailingManager.java new file mode 100644 index 000000000..bd0af4676 --- /dev/null +++ b/tests/multiIncremental/pr242797_2/base/src/bug2/FailingManager.java @@ -0,0 +1,26 @@ +/* + * Created on Sep 18, 2008 + */ +package bug2; + +import java.util.List; + +import bug.DuplicateStrategy; +import bug.PartitionedManager; + + +public class FailingManager implements PartitionedManager { + + public Class<Object> getManagedType(){ + return Object.class; + } + + public List<String> getDefaultPartitionOrder() { + return null; + } + + public DuplicateStrategy getPartitionedDuplicateStrategy() { + return null; + } + +} |