You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@composer.apache.org by ha...@apache.org on 2008/02/04 04:18:00 UTC
svn commit: r618168 [2/2] - in /incubator/composer/trunk/composer-core: ./
src/main/java/org/apache/composer/core/monitors/
src/main/java/org/apache/composer/core/monitors/prefuse/
src/test/java/org/apache/composer/core/monitors/ src/test/java/org/apac...
Added: incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/monitors/prefuse/DependencySetTestCase.java
URL: http://svn.apache.org/viewvc/incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/monitors/prefuse/DependencySetTestCase.java?rev=618168&view=auto
==============================================================================
--- incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/monitors/prefuse/DependencySetTestCase.java (added)
+++ incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/monitors/prefuse/DependencySetTestCase.java Sun Feb 3 20:17:59 2008
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.composer.monitors.prefuse;
+
+import org.apache.composer.core.monitors.ComponentDependencyMonitor;
+import org.apache.composer.core.monitors.prefuse.ComponentDependencyListener;
+import org.apache.composer.core.monitors.prefuse.DependencySet;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class DependencySetTestCase {
+ int callCount = 0;
+
+ @Test public void testShouldNotAddDuplicates() throws Exception {
+ ComponentDependencyListener mockListener = new ComponentDependencyListener(){
+ public void addDependency(ComponentDependencyMonitor.Dependency dependency) {
+ callCount++;
+ }
+ };
+ DependencySet set = new DependencySet(mockListener);
+ ComponentDependencyMonitor.Dependency dependency = new ComponentDependencyMonitor.Dependency(Object.class, String.class);
+ set.addDependency(dependency);
+ set.addDependency(dependency);
+ assertEquals(1, set.getDependencies().length);
+ assertEquals(dependency, set.getDependencies()[0]);
+ assertEquals("Call count should be called once",1,callCount );
+ }
+}
Added: incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/monitors/prefuse/PrefuseDependencyGraphTestCase.java
URL: http://svn.apache.org/viewvc/incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/monitors/prefuse/PrefuseDependencyGraphTestCase.java?rev=618168&view=auto
==============================================================================
--- incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/monitors/prefuse/PrefuseDependencyGraphTestCase.java (added)
+++ incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/monitors/prefuse/PrefuseDependencyGraphTestCase.java Sun Feb 3 20:17:59 2008
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.composer.core.monitors.prefuse;
+
+import org.apache.composer.core.monitors.ComponentDependencyMonitor.Dependency;
+import org.apache.composer.core.monitors.prefuse.PrefuseDependencyGraph;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+import java.util.Collection;
+
+public final class PrefuseDependencyGraphTestCase {
+ final PrefuseDependencyGraph prefuseGraph = new PrefuseDependencyGraph();
+
+ @Test public void testAComponentWithoutAnyDependenciesShouldOnlyCreateOneNode2() throws Exception {
+ prefuseGraph.addDependency(new Dependency(Object.class, null));
+ assertEquals(1, prefuseGraph.getNodes().length);
+ assertEquals(Object.class, prefuseGraph.getNodes()[0].get("type"));
+ }
+
+ @Test public void testDependencyShouldAddTwoNodes() throws Exception {
+ prefuseGraph.addDependency(new Dependency(Object.class, Boolean.class));
+ assertEquals(2, prefuseGraph.getNodes().length);
+ Collection types = prefuseGraph.getTypes();
+ assertTrue(types.contains(Object.class));
+ assertTrue(types.contains(Boolean.class));
+ }
+
+ @Test public void testDependencyShouldAddOneNewNode() throws Exception {
+ prefuseGraph.addDependency(new Dependency(Object.class, Boolean.class));
+ prefuseGraph.addDependency(new Dependency(Object.class, String.class));
+ assertEquals(3, prefuseGraph.getNodes().length);
+
+ Collection types = prefuseGraph.getTypes();
+
+ assertTrue(types.contains(Object.class));
+ assertTrue(types.contains(Boolean.class));
+ assertTrue(types.contains(String.class));
+ }
+
+ @Test public void testDependencyShouldAddThreeNodes() throws Exception {
+ prefuseGraph.addDependency(new Dependency(Object.class, Boolean.class));
+ assertEquals(2, prefuseGraph.getNodes().length);
+ prefuseGraph.addDependency(new Dependency(String.class, Boolean.class));
+ assertEquals(3, prefuseGraph.getNodes().length);
+
+ Collection types = prefuseGraph.getTypes();
+
+ assertTrue(types.contains(Object.class));
+ assertTrue(types.contains(Boolean.class));
+ assertTrue(types.contains(String.class));
+ }
+
+ @Test public void testDependencyShouldAddOneEdge() throws Exception {
+ prefuseGraph.addDependency(new Dependency(Object.class, Boolean.class));
+ assertEquals(1, prefuseGraph.getEdges().getTupleCount());
+ }
+
+ @Test public void testDependencyShouldAddTwoEdges() throws Exception {
+ prefuseGraph.addDependency(new Dependency(Object.class, Boolean.class));
+ prefuseGraph.addDependency(new Dependency(String.class, Boolean.class));
+ assertEquals(2, prefuseGraph.getEdges().getTupleCount());
+ }
+
+ @Test public void testDependencyShouldAddOneEdgeWithSame() throws Exception {
+ prefuseGraph.addDependency(new Dependency(Object.class, Boolean.class));
+ prefuseGraph.addDependency(new Dependency(Object.class, Boolean.class));
+ assertEquals(2, prefuseGraph.getEdges().getTupleCount());
+ }
+
+ @Test public void testGraphShouldNotContainAnyEdges() throws Exception {
+ prefuseGraph.addDependency(new Dependency(Object.class, null));
+ assertEquals(0, prefuseGraph.getEdges().getTupleCount());
+ }
+}
Added: incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/CompatibleTouchable.java
URL: http://svn.apache.org/viewvc/incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/CompatibleTouchable.java?rev=618168&view=auto
==============================================================================
--- incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/CompatibleTouchable.java (added)
+++ incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/CompatibleTouchable.java Sun Feb 3 20:17:59 2008
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * Copyright (C) NanoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Original code by Joerg Schaibe *
+ *****************************************************************************/
+
+package org.apache.composer.core.testmodel;
+
+import java.io.Serializable;
+
+
+/**
+ * Method compatible Touchable.
+ *
+ * @author Jörg Schaible
+ */
+public class CompatibleTouchable implements Serializable {
+ private boolean wasTouched;
+
+ public void touch() {
+ wasTouched = true;
+ }
+
+ public boolean wasTouched() {
+ return wasTouched;
+ }
+}
\ No newline at end of file
Added: incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/DependsOnArray.java
URL: http://svn.apache.org/viewvc/incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/DependsOnArray.java?rev=618168&view=auto
==============================================================================
--- incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/DependsOnArray.java (added)
+++ incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/DependsOnArray.java Sun Feb 3 20:17:59 2008
@@ -0,0 +1,23 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ *****************************************************************************/
+
+package org.apache.composer.core.testmodel;
+
+/**
+ * @author Nick Sieger
+ */
+public final class DependsOnArray {
+ private final Object[] array;
+ public DependsOnArray(Object[] a) {
+ this.array = a;
+ }
+
+ public Object[] getDependencies() {
+ return array;
+ }
+}
Added: incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/DependsOnDependsOnListAndVector.java
URL: http://svn.apache.org/viewvc/incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/DependsOnDependsOnListAndVector.java?rev=618168&view=auto
==============================================================================
--- incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/DependsOnDependsOnListAndVector.java (added)
+++ incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/DependsOnDependsOnListAndVector.java Sun Feb 3 20:17:59 2008
@@ -0,0 +1,18 @@
+/*****************************************************************************
+ * Copyright (c) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ *****************************************************************************/
+
+package org.apache.composer.core.testmodel;
+
+import java.util.Vector;
+
+public class DependsOnDependsOnListAndVector {
+ public DependsOnDependsOnListAndVector(Vector vec, DependsOnList dol) {
+ }
+}
+
Added: incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/DependsOnList.java
URL: http://svn.apache.org/viewvc/incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/DependsOnList.java?rev=618168&view=auto
==============================================================================
--- incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/DependsOnList.java (added)
+++ incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/testmodel/DependsOnList.java Sun Feb 3 20:17:59 2008
@@ -0,0 +1,26 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ *****************************************************************************/
+
+package org.apache.composer.core.testmodel;
+
+import java.util.List;
+
+/**
+ * @author Nick Sieger
+ */
+public final class DependsOnList {
+ private final List list;
+
+ public DependsOnList(List l) {
+ this.list = l;
+ }
+
+ public List getDependencies() {
+ return list;
+ }
+}