1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */1718package org.apache.any23.mime.purifier;
1920import org.apache.tika.io.IOUtils;
21import org.junit.After;
22import org.junit.Assert;
23import org.junit.Before;
24import org.junit.Test;
2526import java.io.*;
2728/**29 * Reference test case for {@link WhiteSpacesPurifier}.30 *31 * @author Davide Palmisano ( dpalmisano@gmail.com )32 */33publicclassWhiteSpacesPurifierTest {
3435private Purifier purifier;
3637 @Before
38publicvoid setUp() {
39this.purifier = new WhiteSpacesPurifier();
40 }
4142 @After
43publicvoid tearDown() {
44this.purifier = null;
45 }
4647 @Test
48publicvoid testPurification() throws IOException {
49 InputStream inputStream = new BufferedInputStream(
50this.getClass().getResourceAsStream("/application/xhtml/blank-file-header.xhtml"));
51this.purifier.purify(inputStream);
52 Assert.assertNotNull(inputStream);
53 Assert.assertTrue(validatePurification(IOUtils.toString(inputStream)));
5455 }
5657/**58 * Checks if a {@link String} starts with a propert character.59 * 60 * @param string61 * 62 * @return63 */64privateboolean validatePurification(String string) {
65char firstChar = string.charAt(0);
66return (firstChar != '\t') && (firstChar != '\n') && (firstChar != ' ');
67 }
6869 }