]> source.dussan.org Git - aspectj.git/commitdiff
242797: testcode
authoraclement <aclement>
Fri, 19 Sep 2008 00:00:43 +0000 (00:00 +0000)
committeraclement <aclement>
Fri, 19 Sep 2008 00:00:43 +0000 (00:00 +0000)
24 files changed:
tests/multiIncremental/PR242797_3/base/src/test1/SelectAction.java [new file with mode: 0644]
tests/multiIncremental/PR242797_3/base/src/test1/SelectActionAspect.aj [new file with mode: 0644]
tests/multiIncremental/PR242797_4/base/src/test2/ProfileAction.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/A.class [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/A.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/DuplicateStrategy.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/EntityManager.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/EqualityUtils.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/FailingManager.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/H2Lookup.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/Localized.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/LocalizedManager.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/Manager.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/ManagerAspect.aj [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/NaturallyComparable.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/NaturallyComparablePruner.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/Partitioned.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/PartitionedManager.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/PartitionedManagerAspect.aj [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/PartitionedPruner.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/Query.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/QueryUtils.java [new file with mode: 0644]
tests/multiIncremental/pr242797_1/base/src/bug/X.class [new file with mode: 0644]
tests/multiIncremental/pr242797_2/base/src/bug2/FailingManager.java [new file with mode: 0644]

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 (file)
index 0000000..caa78d8
--- /dev/null
@@ -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 (file)
index 0000000..b94fcf8
--- /dev/null
@@ -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 (file)
index 0000000..5b067b4
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..073691b
Binary files /dev/null and b/tests/multiIncremental/pr242797_1/base/src/bug/A.class differ
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 (file)
index 0000000..4b9427a
--- /dev/null
@@ -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 (file)
index 0000000..0cbedc9
--- /dev/null
@@ -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 (file)
index 0000000..7622d8d
--- /dev/null
@@ -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 (file)
index 0000000..c6e4ecc
--- /dev/null
@@ -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 (file)
index 0000000..e055c72
--- /dev/null
@@ -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 (file)
index 0000000..a09886c
--- /dev/null
@@ -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 (file)
index 0000000..5cdd674
--- /dev/null
@@ -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 (file)
index 0000000..bf89e05
--- /dev/null
@@ -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 (file)
index 0000000..91a5589
--- /dev/null
@@ -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 (file)
index 0000000..77c6d95
--- /dev/null
@@ -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 (file)
index 0000000..06872fb
--- /dev/null
@@ -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 (file)
index 0000000..cbae269
--- /dev/null
@@ -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 (file)
index 0000000..1aa069a
--- /dev/null
@@ -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 (file)
index 0000000..cfd9c39
--- /dev/null
@@ -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 (file)
index 0000000..8e899ed
--- /dev/null
@@ -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 (file)
index 0000000..457e1a7
--- /dev/null
@@ -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 (file)
index 0000000..38c7e01
--- /dev/null
@@ -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 (file)
index 0000000..3b19e83
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..ba81362
Binary files /dev/null and b/tests/multiIncremental/pr242797_1/base/src/bug/X.class differ
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 (file)
index 0000000..bd0af46
--- /dev/null
@@ -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;
+    }
+       
+}