Home | History | Annotate | Download | only in adt
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
      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 package com.android.ide.eclipse.adt;
     17 
     18 import java.io.File;
     19 import java.io.StringReader;
     20 
     21 import junit.framework.TestCase;
     22 
     23 public class AdtPluginTest extends TestCase {
     24     public void testReaderContains() throws Exception {
     25         String input = "this is a test";
     26         assertFalse(AdtPlugin.streamContains(new StringReader(input), "hello"));
     27         assertTrue(AdtPlugin.streamContains(new StringReader(input), "this"));
     28         assertFalse(AdtPlugin.streamContains(new StringReader(input), "thiss"));
     29         assertTrue(AdtPlugin.streamContains(new StringReader(input), "is a"));
     30         assertTrue(AdtPlugin.streamContains(new StringReader("ABC ABCDAB ABCDABCDABDE"),
     31                 "ABCDABD"));
     32         assertFalse(AdtPlugin.streamContains(new StringReader("ABC ABCDAB ABCDABCDABDE"),
     33                 "ABCEABD"));
     34     }
     35 
     36     public void testReadStream() throws Exception {
     37         String input = "this is a test";
     38         String contents = AdtPlugin.readFile(new StringReader(input));
     39         assertEquals(input, contents);
     40     }
     41 
     42     public void testReadWriteFile() throws Exception {
     43         File temp = File.createTempFile("test", ".txt");
     44         String myContent = "this is\na test";
     45         AdtPlugin.writeFile(temp, myContent);
     46         String readBack = AdtPlugin.readFile(temp);
     47         assertEquals(myContent, readBack);
     48     }
     49 }
     50