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 */18package org.apache.giraph.io.gora;
1920importstatic org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_DATASTORE_CLASS;
21importstatic org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_END_KEY;
22importstatic org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_KEYS_FACTORY_CLASS;
23importstatic org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_KEY_CLASS;
24importstatic org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_PERSISTENT_CLASS;
25importstatic org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_START_KEY;
26importstatic org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_OUTPUT_DATASTORE_CLASS;
27importstatic org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_OUTPUT_KEY_CLASS;
28importstatic org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_OUTPUT_PERSISTENT_CLASS;
2930import org.apache.giraph.conf.GiraphConfiguration;
31import org.apache.giraph.io.gora.TestGoraVertexInputFormat.EmptyComputation;
32import org.apache.giraph.utils.InternalVertexRunner;
33import org.junit.Assert;
34import org.junit.Test;
3536/**37 * Test class for Gora vertex output formats.38 */39publicclassTestGoraVertexOutputFormat {
4041 @Test
42publicvoid getWritingDb() throws Exception {
43 Iterable<String> results;
44 GiraphConfiguration conf = new GiraphConfiguration();
45 GIRAPH_GORA_DATASTORE_CLASS.
46 set(conf, "org.apache.gora.memory.store.MemStore");
47 GIRAPH_GORA_KEYS_FACTORY_CLASS.
48 set(conf,"org.apache.giraph.io.gora.utils.DefaultKeyFactory");
49 GIRAPH_GORA_KEY_CLASS.set(conf,"java.lang.String");
50 GIRAPH_GORA_PERSISTENT_CLASS.
51 set(conf,"org.apache.giraph.io.gora.generated.GVertex");
52 GIRAPH_GORA_START_KEY.set(conf,"1");
53 GIRAPH_GORA_END_KEY.set(conf,"10");
54 GIRAPH_GORA_OUTPUT_DATASTORE_CLASS.
55 set(conf, "org.apache.gora.memory.store.MemStore");
56 GIRAPH_GORA_OUTPUT_KEY_CLASS.set(conf, "java.lang.String");
57 GIRAPH_GORA_OUTPUT_PERSISTENT_CLASS.
58 set(conf, "org.apache.giraph.io.gora.generated.GVertex");
59 conf.set("io.serializations",
60"org.apache.hadoop.io.serializer.WritableSerialization," +
61"org.apache.hadoop.io.serializer.JavaSerialization");
62 conf.setComputationClass(EmptyComputation.class);
63 conf.setVertexInputFormatClass(GoraTestVertexInputFormat.class);
64// Parameters for output65 GIRAPH_GORA_OUTPUT_DATASTORE_CLASS.
66 set(conf, "org.apache.gora.memory.store.MemStore");
67 GIRAPH_GORA_OUTPUT_KEY_CLASS.set(conf, "java.lang.String");
68 GIRAPH_GORA_OUTPUT_PERSISTENT_CLASS.
69 set(conf,"org.apache.giraph.io.gora.generated.GVertex");
70 conf.setVertexOutputFormatClass(GoraTestVertexOutputFormat.class);
71 results = InternalVertexRunner.run(conf, new String[0], new String[0]);
72 Assert.assertNotNull(results);
73 }
74 }