blob: 5bcb5b621b977c2e12eaf5658cf996b4f42324eb [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sling.thumbnails.internal.transformers;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import org.apache.sling.thumbnails.internal.models.TransformationHandlerConfigImpl;
import org.apache.sling.thumbnails.TransformationHandlerConfig;
import org.junit.Before;
import org.junit.Test;
public class GreyscaleHandlerTest {
private ByteArrayOutputStream outputStream;
private InputStream inputStream;
private GreyscaleHandler decolorizer;
@Before
public void init() {
inputStream = getClass().getClassLoader().getResourceAsStream("apache.png");
outputStream = new ByteArrayOutputStream();
decolorizer = new GreyscaleHandler();
}
@Test
public void testResourceType() throws IOException {
assertEquals("sling/thumbnails/transformers/greyscale", decolorizer.getResourceType());
}
@Test
public void testColorize() throws IOException {
TransformationHandlerConfig config = new TransformationHandlerConfigImpl("/conf", Collections.emptyMap());
decolorizer.handle(inputStream, outputStream, config);
assertNotEquals(0, outputStream.toByteArray().length);
}
}