Skip to content

Commit

Permalink
#61 extra test
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed May 29, 2023
1 parent fe1b6a3 commit a235c1e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/jcabi/manifests/Manifests.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@
* <p>If you want to add more manifests to the collection, use
* its static instance:
*
* <pre>Manifests.DEFAULT.append(new FilesMfs(new File("MANIFEST.MF")));</pre>
* <pre>Manifests.singleton().append(new FilesMfs(new File("MANIFEST.MF")));</pre>
*
* <p>You can also modify the map directly:
*
* <pre>Manifests.DEFAULT.put("Hello", "world");</pre>
* <pre>Manifests.singleton().put("Hello", "world");</pre>
*
* <p>The only dependency you need (check the latest version at
* <a href="http://manifests.jcabi.com/">jcabi-manifests</a>):
Expand Down Expand Up @@ -164,7 +164,7 @@ public Manifests(final Map<String, String> attrs) {
* Get the singleton.
*
* @return The singleton
* @since 1.3
* @since 2.0.0
*/
public static MfMap singleton() {
return Manifests.DEFAULT.get();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/manifests/MfMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public interface MfMap {
*
* @param mfs Content to append
* @throws IOException If fails on I/O problem
* @since 1.0
* @since 2.0.0
*/
void append(Mfs mfs) throws IOException;
}
56 changes: 56 additions & 0 deletions src/test/java/com/jcabi/manifests/StringMfsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2012-2022, jcabi.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met: 1) Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer. 2) Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution. 3) Neither the name of the jcabi.com nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jcabi.manifests;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.IOUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;

/**
* Test case for {@link StringMfs}.
*
* @since 2.0.0
*/
final class StringMfsTest {

@Test
void turnsStringIntoMfs() throws IOException {
final InputStream input = new StringMfs("Foo: bar").fetch().iterator().next();
MatcherAssert.assertThat(
IOUtils.toString(input, StandardCharsets.UTF_8),
Matchers.containsString("Foo:")
);
}

}

0 comments on commit a235c1e

Please sign in to comment.