diff options
Diffstat (limited to 'sched/tests')
12 files changed, 4 insertions, 969 deletions
diff --git a/sched/tests/com/android/sched/AllTests.java b/sched/tests/com/android/sched/AllTests.java index 7b29883..f3b621a 100644 --- a/sched/tests/com/android/sched/AllTests.java +++ b/sched/tests/com/android/sched/AllTests.java @@ -23,7 +23,6 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses(value = { com.android.sched.item.AllTests.class, com.android.sched.marker.AllTests.class, - com.android.sched.scheduler.AllTests.class, com.android.sched.use.AllTests.class, - com.android.sched.config.AllTests.class}) + com.android.sched.scheduler.AllTests.class, com.android.sched.config.AllTests.class}) public class AllTests { } diff --git a/sched/tests/com/android/sched/item/AllTests.java b/sched/tests/com/android/sched/item/AllTests.java index 9740968..50bf146 100644 --- a/sched/tests/com/android/sched/item/AllTests.java +++ b/sched/tests/com/android/sched/item/AllTests.java @@ -21,6 +21,6 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses(value = {ItemsTest.class, ItemSetTest.class}) +@SuiteClasses(value = {ItemsTest.class}) public class AllTests { } diff --git a/sched/tests/com/android/sched/item/ComposeOfTest.java b/sched/tests/com/android/sched/item/ComposeOfTest.java deleted file mode 100644 index ab69ed0..0000000 --- a/sched/tests/com/android/sched/item/ComposeOfTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed 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 com.android.sched.item; - -import static org.junit.Assert.fail; - -import com.android.sched.item.input.RunnerA; -import com.android.sched.item.input.RunnerB; -import com.android.sched.item.input.RunnerC; -import com.android.sched.item.input.RunnerD; -import com.android.sched.production.Production1; -import com.android.sched.scheduler.Component0; -import com.android.sched.scheduler.PlanBuilder; -import com.android.sched.scheduler.Request; -import com.android.sched.scheduler.Runner10; -import com.android.sched.scheduler.Runner8; -import com.android.sched.scheduler.Runner9; -import com.android.sched.scheduler.RunnerTest; -import com.android.sched.scheduler.SchedulableManager; -import com.android.sched.scheduler.SchedulableSet; -import com.android.sched.scheduler.ScheduleException; -import com.android.sched.scheduler.Scheduler; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class ComposeOfTest { - - SchedulableSet scs; - Scheduler scheduler; - - @Before - public void setUp() throws Exception { - Scheduler.class.getClassLoader().setDefaultAssertionStatus(true); - - scheduler = Scheduler.getScheduler(); - SchedulableManager sm = SchedulableManager.getSchedulableManager(); - - scs = sm.getAllSchedulable(); - scs.remove(Runner8.class); - scs.remove(Runner9.class); - scs.remove(Runner10.class); - } - - @After - public void tearDown() throws Exception { - RunnerTest.reset(); - } - - @Test - public void testComposedOf1() throws Exception { - Request sr = scheduler.createScheduleRequest(); - - sr.addSchedulables(scs); - sr.addProduction(Production1.class); - - try { - RunnerTest.init(scheduler, sr); - PlanBuilder<Component0> plan = sr.getPlanBuilder(Component0.class); - plan.append(RunnerA.class); - plan.append(RunnerB.class); - plan.append(RunnerC.class); - plan.append(RunnerD.class); - - - plan.getPlan().getScheduleInstance().process(new Component0()); - RunnerTest.done(sr); - } catch (ScheduleException e) { - fail(); - } - } -} diff --git a/sched/tests/com/android/sched/item/ItemSetTest.java b/sched/tests/com/android/sched/item/ItemSetTest.java deleted file mode 100644 index 1005bb3..0000000 --- a/sched/tests/com/android/sched/item/ItemSetTest.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed 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 com.android.sched.item; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import com.android.sched.scheduler.Scheduler; -import com.android.sched.scheduler.TagOrMarkerOrComponentSet; -import com.android.sched.tag.Tag1; -import com.android.sched.tag.Tag1and3and5; -import com.android.sched.tag.Tag2; -import com.android.sched.tag.Tag3; -import com.android.sched.tag.Tag4; -import com.android.sched.tag.Tag5; - -import junit.framework.Assert; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class ItemSetTest { - - TagOrMarkerOrComponentSet ts; - TagOrMarkerOrComponentSet tsAnB; - TagOrMarkerOrComponentSet tsA; - TagOrMarkerOrComponentSet tsB; - Class<? extends Tag>[] tAnB; - Class<? extends Tag>[] tA; - Class<? extends Tag>[] tB; - - Scheduler scheduler; - - @SuppressWarnings("unchecked") - @Before - public void setUp() throws Exception { - ItemSet.class.getClassLoader().setDefaultAssertionStatus(true); - scheduler = Scheduler.getScheduler(); - - ts = scheduler.createTagOrMarkerOrComponentSet(); - - tAnB = (Class<? extends Tag>[]) new Class<?>[] { - Tag1.class, Tag2.class, Tag3.class, Tag4.class, Tag5.class}; - tA = (Class<? extends Tag>[]) new Class<?>[] {Tag1.class, Tag3.class, Tag5.class}; - tB = (Class<? extends Tag>[]) new Class<?>[] {Tag2.class, Tag4.class}; - - tsAnB = scheduler.createTagOrMarkerOrComponentSet(); - for (Class<? extends Tag> tag : tAnB) { - tsAnB.add(tag); - } - - tsA = scheduler.createTagOrMarkerOrComponentSet(); - for (Class<? extends Tag> tag : tA) { - tsA.add(tag); - } - - tsB = scheduler.createTagOrMarkerOrComponentSet(); - for (Class<? extends Tag> tag : tB) { - tsB.add(tag); - } - } - - @After - public void tearDown() throws Exception { - ts = null; - tsAnB = null; - tsA = null; - tsB = null; - } - - @Test - public void testAddAndRemove() { - // Set of one element (TagOne) - ts.add(Tag1.class); - ts.remove(Tag2.class); - ts.add(Tag1.class); - ts.remove(Tag1.class); - Assert.assertTrue(ts.isEmpty()); - - // Set of set A - for (Class<? extends Tag> tag : tA) { - ts.add(tag); - } - - Assert.assertEquals(tA.length, ts.getSize()); - for (Class<? extends Tag> tag : tB) { - ts.remove(tag); - } - - Assert.assertEquals(tA.length, ts.getSize()); - for (Class<? extends Tag> tag : tA) { - ts.add(tag); - } - - Assert.assertEquals(tA.length, ts.getSize()); - for (Class<? extends Tag> tag : tA) { - int sz = ts.getSize(); - - ts.remove(tag); - Assert.assertEquals(sz - 1, ts.getSize()); - } - - // ComposedOf is ok - ts.add(Tag1and3and5.class); - Assert.assertEquals(tA.length, ts.getSize()); - for (Class<? extends Tag> tag : tA) { - int sz = ts.getSize(); - ts.add(tag); - Assert.assertEquals(sz, ts.getSize()); - - ts.remove(tag); - Assert.assertEquals(sz - 1, ts.getSize()); - } - } - - @Test - public void testConstructors() { - // Empty - Assert.assertEquals(0, ts.getSize()); - - // With tsAnB - - ts = new TagOrMarkerOrComponentSet(tsAnB); - - Assert.assertEquals(tAnB.length, ts.getSize()); - for (Class<? extends Tag> tag : tAnB) { - int sz = ts.getSize(); - - ts.remove(tag); - Assert.assertEquals(sz - 1, ts.getSize()); - } - - // With tsA - - ts = new TagOrMarkerOrComponentSet(tsA); - - Assert.assertEquals(tA.length, ts.getSize()); - for (Class<? extends Tag> tag : tA) { - int sz = ts.getSize(); - - ts.remove(tag); - Assert.assertEquals(sz - 1, ts.getSize()); - } - - // With tsB - - ts = new TagOrMarkerOrComponentSet(tsB); - - Assert.assertEquals(tB.length, ts.getSize()); - for (Class<? extends Tag> tag : tB) { - int sz = ts.getSize(); - - ts.remove(tag); - Assert.assertEquals(sz - 1, ts.getSize()); - } - } - - @Test - public void testAddAll() { - ts.addAll(tsA); - Assert.assertEquals(tsA.getSize(), ts.getSize()); - for (Class<? extends Tag> tag : tA) { - int sz = ts.getSize(); - ts.add(tag); - Assert.assertEquals(sz, ts.getSize()); - - ts.remove(tag); - Assert.assertEquals(sz - 1, ts.getSize()); - } - } - - @Test - public void testRemoveAll() { - ts.addAll(tsAnB); - - ts.removeAll(tsA); - Assert.assertEquals(tsB.getSize(), ts.getSize()); - - ts.removeAll(tsA); - Assert.assertEquals(tsB.getSize(), ts.getSize()); - - ts.removeAll(tsB); - Assert.assertEquals(0, ts.getSize()); - - ts.addAll(tsA); - ts.removeAll(tsAnB); - Assert.assertEquals(0, ts.getSize()); - } - - @Test - public void testContains() { - ts.addAll(tsA); - - for (Class<? extends Tag> tag : tA) { - assertTrue(ts.contains(tag)); - } - - for (Class<? extends Tag> tag : tB) { - assertFalse(ts.contains(tag)); - } - } - - @Test - public void testContainsAll() { - // tsAnB equal tsAnB - - ts.addAll(tsAnB); - assertTrue(ts.containsAll(tsAnB)); - assertTrue(tsAnB.containsAll(ts)); - - // tsA not equal tsB - - assertFalse(tsA.containsAll(tsB)); - assertFalse(tsB.containsAll(tsA)); - - // - - for (Class<? extends Tag> tag : tAnB) { - ts.remove(tag); - assertTrue(tsAnB.containsAll(ts)); - } - - ts.addAll(tsAnB); - for (Class<? extends Tag> tag : tAnB) { - ts.remove(tag); - assertFalse(ts.containsAll(tsAnB)); - } - } - - @Test - public void testContainsOne() { - ts.addAll(tsAnB); - assertTrue(ts.containsOne(tsAnB)); - assertTrue(tsAnB.containsOne(ts)); - - assertFalse(tsA.containsOne(tsB)); - assertFalse(tsB.containsOne(tsA)); - - assertTrue(tsAnB.containsOne(tsA)); - assertTrue(tsA.containsOne(tsAnB)); - assertTrue(tsAnB.containsOne(tsB)); - assertTrue(tsB.containsOne(tsAnB)); - } -} diff --git a/sched/tests/com/android/sched/marker/AllTests.java b/sched/tests/com/android/sched/marker/AllTests.java index 6ce6d5e..2c4b6df 100644 --- a/sched/tests/com/android/sched/marker/AllTests.java +++ b/sched/tests/com/android/sched/marker/AllTests.java @@ -21,6 +21,6 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses(value = {MarkerManagerTest.class, ManagedMarkerTest.class}) +@SuiteClasses(value = {ManagedMarkerTest.class}) public class AllTests { } diff --git a/sched/tests/com/android/sched/marker/MarkerManagerTest.java b/sched/tests/com/android/sched/marker/MarkerManagerTest.java deleted file mode 100644 index 561a53d..0000000 --- a/sched/tests/com/android/sched/marker/MarkerManagerTest.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed 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 com.android.sched.marker; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -public class MarkerManagerTest { - - StaticMarkerManager[] markeds; - Class<? extends Marker>[] markers; - boolean[][] compatible; - - @SuppressWarnings("unchecked") - @Before - public void setUp() throws Exception { - StaticMarkerManager.class.getClassLoader().setDefaultAssertionStatus(true); - - new StaticMarkerManager(); - - markeds = new StaticMarkerManager[] {new MarkedA(), new MarkedB(), new MarkedC(), new MarkedB1()}; - markers = (Class<? extends Marker>[]) new Class<?>[] { - Marker1.class, Marker2.class, Marker3.class}; - compatible = new boolean[markeds.length][markers.length]; - - compatible[0][0] = true; - compatible[1][1] = true; - compatible[3][1] = true; - compatible[0][2] = true; - compatible[1][2] = true; - compatible[3][2] = true; - } - - @After - public void tearDown() throws Exception {} - - @Test - public void testAddMarker() throws InstantiationException, IllegalAccessException { - - // - // Check addMarker and NotValidMarkerException - // - for (int i = 0; i < markeds.length; i++) { - for (int j = 0; j < markers.length; j++) { - try { - markeds[i].addMarker(markers[j].newInstance()); - assertTrue(compatible[i][j]); - } catch (AssertionError e) { - assertFalse(compatible[i][j]); - } - } - } - - // - // Check DuplicateMarkerException - // - for (int i = 0; i < markeds.length; i++) { - for (int j = 0; j < markers.length; j++) { - if (compatible[i][j]) { - try { - markeds[i].addMarker(markers[j].newInstance()); - fail("Must throw AssertionError"); - } catch (AssertionError e) { - // Normal Exception - } - } - } - } - } - - @Test - public void testAddAllMarker() throws InstantiationException, IllegalAccessException { - Marker[][] add = new Marker[markeds.length][markers.length]; - List<Marker> list = new ArrayList<Marker>(); - - // - // Populate markers - // - for (int i = 0; i < markeds.length; i++) { - list.clear(); - - for (int j = 0; j < markers.length; j++) { - if (compatible[i][j]) { - add[i][j] = markers[j].newInstance(); - list.add(add[i][j]); - } - } - - markeds[i].addAllMarker(list); - } - - // - // Check - // - for (int i = 0; i < markeds.length; i++) { - for (int j = 0; j < markers.length; j++) { - if (compatible[i][j]) { - assertSame(add[i][j], markeds[i].getMarker(markers[j])); - } else { - try { - markeds[i].getMarker(markers[j]); - fail(); - } catch (AssertionError e) { - // Normal Exception - } - } - } - } - } - - @SuppressWarnings("unchecked") - @Test - public void testGetAllMarkers() throws InstantiationException, IllegalAccessException { - List<Marker>[] lists = new ArrayList[markeds.length]; - - // - // Populate markers - // - for (int i = 0; i < markeds.length; i++) { - lists[i] = new ArrayList<Marker>(); - - for (int j = 0; j < markers.length; j++) { - if (compatible[i][j]) { - Marker marker = markers[j].newInstance(); - lists[i].add(marker); - markeds[i].addMarker(marker); - } - } - } - - // - // Check - // - for (int i = 0; i < markeds.length; i++) { - assertTrue(markeds[i].getAllMarkers().containsAll(lists[i])); - assertTrue(lists[i].containsAll(markeds[i].getAllMarkers())); - } - } - - @Test - public void testGetMarker() throws InstantiationException, IllegalAccessException { - Marker[][] add = new Marker[markeds.length][markers.length]; - - // - // Populate markers - // - for (int i = 0; i < markeds.length; i++) { - for (int j = 0; j < markers.length; j++) { - if (compatible[i][j]) { - add[i][j] = markers[j].newInstance(); - markeds[i].addMarker(add[i][j]); - } - } - } - - // - // Check - // - for (int i = 0; i < markeds.length; i++) { - for (int j = 0; j < markers.length; j++) { - if (compatible[i][j]) { - assertSame(add[i][j], markeds[i].getMarker(markers[j])); - } else { - try { - markeds[i].getMarker(markers[j]); - fail(); - } catch (AssertionError e) { - // Normal Exception - } - } - } - } - } - - @Test - public void testContainsMarker() throws InstantiationException, IllegalAccessException { - // - // Populate markers - // - for (int i = 0; i < markeds.length; i++) { - for (int j = 0; j < markers.length; j++) { - if (compatible[i][j]) { - markeds[i].addMarker(markers[j].newInstance()); - } - } - } - - // - // Check - // - for (int i = 0; i < markeds.length; i++) { - for (int j = 0; j < markers.length; j++) { - if (compatible[i][j]) { - assertEquals(Boolean.valueOf(compatible[i][j]), - Boolean.valueOf(markeds[i].containsMarker(markers[j]))); - } else { - try { - markeds[i].containsMarker(markers[j]); - fail(); - } catch (AssertionError e) { - // Normal Exception - } - } - } - } - } - - @Test - public void testRemoveMarker() throws InstantiationException, IllegalAccessException { - // - // Populate markers - // - for (int i = 0; i < markeds.length; i++) { - for (int j = 0; j < markers.length; j++) { - if (compatible[i][j]) { - markeds[i].addMarker(markers[j].newInstance()); - } - } - } - - // - // Check - // - for (int i = 0; i < markeds.length; i++) { - for (int j = 0; j < markers.length; j++) { - if (compatible[i][j]) { - markeds[i].removeMarker(markers[j]); - assertFalse(markeds[i].containsMarker(markers[j])); - } else { - try { - markeds[i].removeMarker(markers[j]); - fail(); - } catch (AssertionError e) { - // Normal Exception - } - } - } - } - } -} diff --git a/sched/tests/com/android/sched/scheduler/AllTests.java b/sched/tests/com/android/sched/scheduler/AllTests.java index ac5fc0b..0c12872 100644 --- a/sched/tests/com/android/sched/scheduler/AllTests.java +++ b/sched/tests/com/android/sched/scheduler/AllTests.java @@ -17,15 +17,12 @@ package com.android.sched.scheduler; -import com.android.sched.item.ComposeOfTest; - import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses(value = { - ManagedVisitorTest.class, ManagedRunnerTest.class, SchedulerTests.class, SubPlanTest.class, - ComposeOfTest.class}) + ManagedVisitorTest.class, SchedulerTests.class}) public class AllTests { } diff --git a/sched/tests/com/android/sched/scheduler/ManagedRunnerTest.java b/sched/tests/com/android/sched/scheduler/ManagedRunnerTest.java deleted file mode 100644 index 9a6b7f8..0000000 --- a/sched/tests/com/android/sched/scheduler/ManagedRunnerTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed 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 com.android.sched.scheduler; - -import static org.junit.Assert.fail; - -import com.android.sched.schedulable.RunnableSchedulable; - -import org.junit.Before; -import org.junit.Test; - -public class ManagedRunnerTest { - - @Before - public void setUp() { - ManagedRunnable.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testConstructor() { - testSchedulableError(RunnerError1.class); - testSchedulableError(RunnerError4.class); - testSchedulableError(RunnerError5.class); - testSchedulableError(RunnerError6.class); - testSchedulableError(RunnerError7.class); - testSchedulableError(RunnerError8.class); - testSchedulableError(RunnerError9.class); - testSchedulableError(RunnerError10.class); - } - - private void testSchedulableError(Class<? extends RunnableSchedulable<?>> sched) { - try { - new ManagedRunnable(sched); - fail(); - } catch (SchedulableNotConformException e) { - // Normal Exception - } - } -} diff --git a/sched/tests/com/android/sched/scheduler/SubPlanTest.java b/sched/tests/com/android/sched/scheduler/SubPlanTest.java deleted file mode 100644 index 0fd58a4..0000000 --- a/sched/tests/com/android/sched/scheduler/SubPlanTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed 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 com.android.sched.scheduler; - -import static org.junit.Assert.fail; - -import com.android.sched.marker.Marker1; -import com.android.sched.marker.Marker2; -import com.android.sched.marker.Marker3; -import com.android.sched.tag.Tag2; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class SubPlanTest { - - SchedulableSet scs; - Scheduler scheduler; - - @Before - public void setUp() throws Exception { - Scheduler.class.getClassLoader().setDefaultAssertionStatus(true); - scheduler = Scheduler.getScheduler(); - - scs = scheduler.getAllSchedulable(); - scs.remove(Runner8.class); - scs.remove(Runner9.class); - scs.remove(Runner10.class); - } - - @After - public void tearDown() throws Exception { - RunnerTest.reset(); - } - - @Test - public void testProcess1() throws Exception { - Request sr = scheduler.createScheduleRequest(scheduler.getAllSchedulable()); - - try { - RunnerTest.init(scheduler, sr); - PlanBuilder<Component0> spb = sr.getPlanBuilder(Component0.class); - sr.addTargetIncludeTagOrMarker(Marker1.class); - sr.addTargetIncludeTagOrMarker(Marker2.class); - sr.addTargetIncludeTagOrMarker(Marker3.class); - sr.addTargetIncludeTagOrMarker(Tag2.class); - spb.append(Runner1.class); - spb.append(Runner2.class); - spb.append(Runner6.class); - SubPlanBuilder<Component2> sspb = spb.appendSubPlan(Visitor1.class); - SubPlanBuilder<Component1> ssspb = sspb.appendSubPlan(Visitor2.class); - SubPlanBuilder<Component3> sssspb = ssspb.appendSubPlan(Visitor3.class); - sssspb.append(Runner3sub1.class); - Plan<Component0> sp = spb.getPlan(); - sp.getScheduleInstance().process(new Component0()); - RunnerTest.done(sr); - } catch (ScheduleException e) { - fail(); - } - } -} diff --git a/sched/tests/com/android/sched/scheduler/VerifierTest.java b/sched/tests/com/android/sched/scheduler/VerifierTest.java deleted file mode 100644 index 8c87411..0000000 --- a/sched/tests/com/android/sched/scheduler/VerifierTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed 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 com.android.sched.scheduler; - -import junit.framework.Assert; - -import org.junit.Before; -import org.junit.Test; - -public class VerifierTest { - Scheduler scheduler; - - @Before - public void setUp() throws Exception { - Scheduler.class.getClassLoader().setDefaultAssertionStatus(true); - - scheduler = Scheduler.getScheduler(); - } - - @Test - public void testVerifier() throws Exception { - Request sr = scheduler.createScheduleRequest(); - sr.addInitialTagOrMarker(Component1.class); - - PlanBuilder<Component0> plan = sr.getPlanBuilder(Component0.class); - plan.append(VerifierRunnable2.class); - plan.append(VerifierRunnable1.class); - try { - plan.getPlan().getScheduleInstance().process(new Component0()); - Assert.fail(); - } catch (PlanError e) { - // Ok - } - } -} diff --git a/sched/tests/com/android/sched/use/AllTests.java b/sched/tests/com/android/sched/use/AllTests.java deleted file mode 100644 index ee90f12..0000000 --- a/sched/tests/com/android/sched/use/AllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed 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 com.android.sched.use; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Suite.class) -@SuiteClasses(value = { - ManagedRunnerTest.class}) -public class AllTests { -} diff --git a/sched/tests/com/android/sched/use/ManagedRunnerTest.java b/sched/tests/com/android/sched/use/ManagedRunnerTest.java deleted file mode 100644 index 9a2f3a3..0000000 --- a/sched/tests/com/android/sched/use/ManagedRunnerTest.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed 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 com.android.sched.use; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import com.android.sched.feature.Feature1; -import com.android.sched.feature.Feature2; -import com.android.sched.marker.Marker1; -import com.android.sched.marker.Marker2; -import com.android.sched.marker.Marker3; -import com.android.sched.marker.Marker4; -import com.android.sched.marker.Marker5; -import com.android.sched.marker.Marker6; -import com.android.sched.marker.MarkerOk3; -import com.android.sched.marker.MarkerOk4; -import com.android.sched.production.Production1; -import com.android.sched.production.Production2; -import com.android.sched.scheduler.Component0; -import com.android.sched.scheduler.Component1; -import com.android.sched.scheduler.Component2; -import com.android.sched.scheduler.FeatureSet; -import com.android.sched.scheduler.ManagedRunnable; -import com.android.sched.scheduler.ProductionSet; -import com.android.sched.scheduler.Scheduler; -import com.android.sched.scheduler.TagOrMarkerOrComponentSet; -import com.android.sched.tag.Tag1; -import com.android.sched.tag.Tag2; -import com.android.sched.tag.Tag3; -import com.android.sched.tag.Tag4; -import com.android.sched.use.input.Runner1; - -import org.junit.Before; -import org.junit.Test; - -import java.util.Iterator; - -public class ManagedRunnerTest { - @Before - public void setUp() { - ManagedRunnable.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testRunner1() { - ManagedRunnable runner = new ManagedRunnable(Runner1.class); - Scheduler scheduler = Scheduler.getScheduler(); - - TagOrMarkerOrComponentSet tags = scheduler.createTagOrMarkerOrComponentSet(); - FeatureSet features = scheduler.createFeatureSet(); - ProductionSet productions = scheduler.createProductionSet(); - - tags.clear(); - tags.add(Marker3.class); - tags.add(Marker2.class); - assertEquals(tags, runner.getAddedTags()); - - tags.clear(); - tags.add(Tag2.class); - tags.add(Tag3.class); - assertEquals(tags, runner.getRemovedTags()); - - tags.clear(); - tags.add(Component0.class); - tags.add(Component2.class); - assertEquals(tags, runner.getModifiedTags()); - - productions.clear(); - productions.add(Production1.class); - productions.add(Production2.class); - assertEquals(productions, runner.getProductions()); - - features.clear(); - features.add(Feature2.class); - features.add(Feature1.class); - assertEquals(features, runner.getSupportedFeatures()); - - tags.clear(); - tags.add(Marker4.class); - tags.add(MarkerOk3.class); - tags.add(Tag3.class); - assertEquals(tags, runner.getDefaultNeededTags()); - - tags.clear(); - tags.add(Marker3.class); - tags.add(MarkerOk4.class); - assertEquals(tags, runner.getDefaultUnsupportedTags()); - - tags.clear(); - tags.add(Marker4.class); - tags.add(Marker1.class); - assertEquals(tags, runner.getProtectAddingTags()); - - tags.clear(); - tags.add(Tag1.class); - tags.add(Tag4.class); - assertEquals(tags, runner.getProtectRemovingTags()); - - tags.clear(); - tags.add(Component1.class); - tags.add(Component2.class); - assertEquals(tags, runner.getProtectModifyingTags()); - - tags.clear(); - tags.add(Marker6.class); - tags.add(Marker2.class); - assertEquals(tags, runner.getUnprotectByAddingTags()); - - tags.clear(); - tags.add(Marker1.class); - assertEquals(tags, runner.getUnprotectByRemovingTags()); - - Iterator<FeatureSet> iter = runner.getOptionalFeatures().iterator(); - assertTrue(iter.hasNext()); - - features.clear(); - features.add(Feature1.class); - assertEquals(features, iter.next()); - - tags.clear(); - tags.add(Marker5.class); - tags.add(Marker6.class); - assertEquals(tags, runner.getNeededTags(features)); - - tags.clear(); - assertEquals(tags, runner.getUnsupportedTags(features)); - - assertFalse(iter.hasNext()); - } -} |