1+ // Licensed to the Apache Software Foundation (ASF) under one
2+ // or more contributor license agreements. See the NOTICE file
3+ // distributed with this work for additional information
4+ // regarding copyright ownership. The ASF licenses this file
5+ // to you under the Apache License, Version 2.0 (the
6+ // "License"); you may not use this file except in compliance
7+ // the License. You may obtain a copy of the License at
8+ //
9+ // http://www.apache.org/licenses/LICENSE-2.0
10+ //
11+ // Unless required by applicable law or agreed to in writing,
12+ // software distributed under the License is distributed on an
13+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+ // KIND, either express or implied. See the License for the
15+ // specific language governing permissions and limitations
16+ // under the License.
117package com .cloud .utils .db ;
218
319import javax .inject .Inject ;
723import org .springframework .test .context .ContextConfiguration ;
824import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
925
26+ import com .cloud .utils .component .ComponentContext ;
27+
1028@ RunWith (SpringJUnit4ClassRunner .class )
1129@ ContextConfiguration (locations ="classpath:/com/cloud/utils/db/transactioncontextBuilderTest.xml" )
1230public class TransactionContextBuilderTest {
13-
1431 @ Inject
1532 DbAnnotatedBaseDerived _derived ;
1633
@@ -19,7 +36,11 @@ public class TransactionContextBuilderTest {
1936
2037 @ Test
2138 public void test () {
22- _derived .DbAnnotatedMethod ();
23- _base .MethodWithClassDbAnnotated ();
39+ // _derived.DbAnnotatedMethod();
40+ // _base.MethodWithClassDbAnnotated();
41+
42+ // test @DB injection on dynamically constructed objects
43+ DbAnnotatedBase base = ComponentContext .inject (new DbAnnotatedBase ());
44+ base .MethodWithClassDbAnnotated ();
2445 }
2546}
0 commit comments