blob: ac6955b558d42c13c17a657bffe91df398588edd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.derived;
import com.yahoo.schema.ApplicationBuilder;
import com.yahoo.schema.parser.ParseException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.File;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests struct inheritance
*
* @author arnej
*/
public class StructInheritanceTestCase extends AbstractExportingTestCase {
@TempDir
public File tmpDir;
@Test
void requireThatStructCanInherit() throws IOException, ParseException {
String dir = "src/test/derived/structinheritance/";
ApplicationBuilder builder = new ApplicationBuilder();
builder.addSchemaFile(dir + "simple.sd");
builder.build(false);
derive("structinheritance", builder, builder.getSchema("simple"));
assertCorrectConfigFiles("structinheritance");
}
@Test
void requireThatRedeclareIsNotAllowed() throws IOException, ParseException {
Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
String dir = "src/test/derived/structinheritance/";
ApplicationBuilder builder = new ApplicationBuilder();
builder.addSchemaFile(dir + "bad.sd");
builder.build(true);
derive("structinheritance", builder, builder.getSchema("bad"));
});
assertTrue(exception.getMessage().contains("cannot inherit from base and redeclare field name"));
}
}
|