OSDN Git Service

d9bda0f2eff85e389c259718519ce48fd4ad97e9
[xerial/xerial-core.git] / src / test / java / org / xerial / relation / query / StreamAmoebaJoinTest.java
1 /*--------------------------------------------------------------------------\r
2  *  Copyright 2009 Taro L. Saito\r
3  *\r
4  *  Licensed under the Apache License, Version 2.0 (the "License");\r
5  *  you may not use this file except in compliance with the License.\r
6  *  You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  *  Unless required by applicable law or agreed to in writing, software\r
11  *  distributed under the License is distributed on an "AS IS" BASIS,\r
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  *  See the License for the specific language governing permissions and\r
14  *  limitations under the License.\r
15  *--------------------------------------------------------------------------*/\r
16 //--------------------------------------\r
17 // XerialJ\r
18 //\r
19 // StreamAmoebaJoinTest.java\r
20 // Since: 2009/05/14 17:52:37\r
21 //\r
22 // $URL$\r
23 // $Author$\r
24 //--------------------------------------\r
25 package org.xerial.relation.query;\r
26 \r
27 import org.junit.After;\r
28 import org.junit.Before;\r
29 import org.junit.Test;\r
30 import org.xerial.relation.DataType;\r
31 import org.xerial.relation.FD;\r
32 import org.xerial.relation.Node;\r
33 import org.xerial.relation.schema.Schema;\r
34 import org.xerial.relation.schema.SchemaBuilder;\r
35 import org.xerial.silk.SilkWalker;\r
36 import org.xerial.util.FileResource;\r
37 import org.xerial.util.log.Logger;\r
38 \r
39 public class StreamAmoebaJoinTest\r
40 {\r
41     private static Logger _logger = Logger.getLogger(StreamAmoebaJoinTest.class);\r
42 \r
43     @Before\r
44     public void setUp() throws Exception\r
45     {}\r
46 \r
47     @After\r
48     public void tearDown() throws Exception\r
49     {}\r
50 \r
51     @Test\r
52     public void query() throws Exception\r
53     {\r
54         QuerySet qs = new QuerySet();\r
55         qs.addQueryTarget(new SchemaBuilder().add("coordinate").add("group").add("species").add("revision").add("name")\r
56                 .build());\r
57         qs.addQueryTarget(new SchemaBuilder().add("coordinate").add("gene", DataType.STRUCT, FD.ONE_OR_MORE).build());\r
58         qs.addQueryTarget(new SchemaBuilder().add("gene").add("id").add("name").add("start").add("end").build());\r
59 \r
60         StreamAmoebaJoin aj = new StreamAmoebaJoin(qs, new RelationEventHandler() {\r
61 \r
62             public void newRelationFragment(Schema schema, Node n1, Node n2)\r
63             {\r
64                 _logger.info(String.format("relation (%s, %s)", n1, n2));\r
65             }\r
66 \r
67             public void leaveNode(Schema schema, Node node)\r
68             {\r
69                 _logger.info(String.format("leave %s in %s", node, schema));\r
70             }\r
71 \r
72             public void text(String nodeName, String text)\r
73             {\r
74             // TODO Auto-generated method stub\r
75 \r
76             }\r
77         });\r
78 \r
79         aj.sweep(new SilkWalker(FileResource.find(StreamAmoebaJoinTest.class, "sample.silk")));\r
80     }\r
81 }\r