1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.mkstubs.sourcer;
18 
19 
20 import org.junit.After;
21 import org.junit.Assert;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.objectweb.asm.Opcodes;
25 
26 import java.io.StringWriter;
27 
28 public class AccessSourcerTest {
29 
30     private StringWriter mWriter;
31     private AccessSourcer mSourcer;
32 
33 
34     @Before
setUp()35     public void setUp() throws Exception {
36         mWriter = new StringWriter();
37         mSourcer = new AccessSourcer(new Output(mWriter));
38     }
39 
40     @After
tearDown()41     public void tearDown() throws Exception {
42         mWriter = null;
43         mSourcer = null;
44     }
45 
46     @Test
testAbstractPublic()47     public void testAbstractPublic() throws Exception {
48         mSourcer.write(Opcodes.ACC_ABSTRACT | Opcodes.ACC_PUBLIC, AccessSourcer.IS_CLASS);
49 
50         String s = mWriter.toString();
51         Assert.assertEquals("public abstract", s);
52     }
53 
54     @Test
testPrivateFinalStatic()55     public void testPrivateFinalStatic() throws Exception {
56         mSourcer.write(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL | Opcodes.ACC_STATIC,
57                 AccessSourcer.IS_METHOD);
58 
59         String s = mWriter.toString();
60         Assert.assertEquals("private static final", s);
61     }
62 
63 }
64