forked from hibernate/hibernate-orm
/
InstrumentTest.java
executable file
·124 lines (109 loc) · 3.98 KB
/
InstrumentTest.java
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2006-2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.instrument.buildtime;
import org.junit.Test;
import org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper;
import org.hibernate.test.instrument.cases.Executable;
import org.hibernate.test.instrument.cases.TestCustomColumnReadAndWrite;
import org.hibernate.test.instrument.cases.TestDirtyCheckExecutable;
import org.hibernate.test.instrument.cases.TestFetchAllExecutable;
import org.hibernate.test.instrument.cases.TestInjectFieldInterceptorExecutable;
import org.hibernate.test.instrument.cases.TestIsPropertyInitializedExecutable;
import org.hibernate.test.instrument.cases.TestLazyBasicPropertyUpdateExecutable;
import org.hibernate.test.instrument.cases.TestLazyExecutable;
import org.hibernate.test.instrument.cases.TestLazyManyToOneExecutable;
import org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable;
import org.hibernate.test.instrument.cases.TestManyToOneProxyExecutable;
import org.hibernate.test.instrument.cases.TestSharedPKOneToOneExecutable;
import org.hibernate.test.instrument.domain.Document;
import org.hibernate.testing.Skip;
import org.hibernate.testing.junit4.BaseUnitTestCase;
/**
* @author Gavin King
*/
@Skip(
message = "domain classes not instrumented for build-time instrumentation testing",
condition = InstrumentTest.SkipCheck.class
)
public class InstrumentTest extends BaseUnitTestCase {
@Test
public void testDirtyCheck() throws Exception {
execute( new TestDirtyCheckExecutable() );
}
@Test
public void testFetchAll() throws Exception {
execute( new TestFetchAllExecutable() );
}
@Test
public void testLazy() throws Exception {
execute( new TestLazyExecutable() );
}
@Test
public void testLazyManyToOne() throws Exception {
execute( new TestLazyManyToOneExecutable() );
}
@Test
public void testSetFieldInterceptor() throws Exception {
execute( new TestInjectFieldInterceptorExecutable() );
}
@Test
public void testPropertyInitialized() throws Exception {
execute( new TestIsPropertyInitializedExecutable() );
}
@Test
public void testManyToOneProxy() throws Exception {
execute( new TestManyToOneProxyExecutable() );
}
@Test
public void testLazyPropertyCustomTypeExecutable() throws Exception {
execute( new TestLazyPropertyCustomTypeExecutable() );
}
@Test
public void testLazyBasicPropertyUpdate() throws Exception {
execute( new TestLazyBasicPropertyUpdateExecutable() );
}
@Test
public void testSharedPKOneToOne() throws Exception {
execute( new TestSharedPKOneToOneExecutable() );
}
@Test
public void testCustomColumnReadAndWrite() throws Exception {
execute( new TestCustomColumnReadAndWrite() );
}
private void execute(Executable executable) throws Exception {
executable.prepare();
try {
executable.execute();
}
finally {
executable.complete();
}
}
public static class SkipCheck implements Skip.Matcher {
@Override
public boolean isMatch() {
return ! FieldInterceptionHelper.isInstrumented( new Document() );
}
}
}