1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */1819package org.apache.giraph.examples.block_app;
2021importstatic org.junit.Assert.assertEquals;
22importstatic org.junit.Assert.assertTrue;
2324import org.apache.giraph.BspCase;
25import org.apache.giraph.block_app.framework.BlockUtils;
26import org.apache.giraph.conf.GiraphConfiguration;
27import org.apache.giraph.examples.SimplePageRankComputation.SimplePageRankVertexInputFormat;
28import org.apache.giraph.job.GiraphJob;
29import org.junit.Test;
3031/**32 * Unit test for many simple BSP applications.33 */34publicclass35TestMigrationBspBasicextendsBspCase {
3637publicTestMigrationBspBasic() {
38super(TestMigrationBspBasic.class.getName());
39 }
4041/**42 * Run a sample BSP job locally and test using migration43 * library for Blocks Framework, as an drop-in replacement.44 */45 @Test
46publicvoid testBspMigrationToBlocksFramework() throws Exception {
47 GiraphConfiguration conf = new GiraphConfiguration();
48 conf.setVertexInputFormatClass(SimplePageRankVertexInputFormat.class);
49 BlockUtils.setAndInitBlockFactoryClass(
50 conf, SimpleMigrationMasterBlockFactory.class);
51 GiraphJob job = prepareJob(getCallingMethodName(), conf);
52 assertTrue(job.run(true));
53if (!runningInDistributedMode()) {
54double finalSum =
55 SimpleMigrationMasterBlockFactory.SimpleMigrationMasterWorkerContext.getFinalSum();
56 System.out.println("testBspMasterCompute: finalSum=" + finalSum);
57 assertEquals(32.5, finalSum, 0d);
58 }
59 }
60 }