Skip to content
Permalink
Browse files

-adds test for JENKINS-30926

  • Loading branch information...
lordofthejars committed Oct 14, 2015
1 parent 73e81a7 commit 5bb0fe95dea9b255fd82647d3d3519ad32321d82
Showing with 115 additions and 0 deletions.
  1. +5 −0 pom.xml
  2. +110 −0 src/test/java/org/jenkinsci/plugins/plaincredentials/FileCredentialsTest.java
@@ -42,6 +42,11 @@
<artifactId>credentials</artifactId>
<version>1.21</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<plugins>
@@ -0,0 +1,110 @@
package org.jenkinsci.plugins.plaincredentials;

import com.cloudbees.plugins.credentials.CredentialsScope;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemHeaders;
import org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;

public class FileCredentialsTest {

@Test(expected = IllegalArgumentException.class)
public void shouldThrowAnExceptionIfFileNameIsBlank() throws IOException {
FileCredentials fileCredentials = new FileCredentialsImpl(CredentialsScope.GLOBAL, "1", "", new StubFileItem(), "", "");
}

private class StubFileItem implements FileItem {

@Override
public InputStream getInputStream() throws IOException {
return null;
}

@Override
public String getContentType() {
return null;
}

@Override
public String getName() {
return "";
}

@Override
public boolean isInMemory() {
return false;
}

@Override
public long getSize() {
return 0;
}

@Override
public byte[] get() {
return new byte[0];
}

@Override
public String getString(String encoding) throws UnsupportedEncodingException {
return null;
}

@Override
public String getString() {
return null;
}

@Override
public void write(File file) throws Exception {

}

@Override
public void delete() {

}

@Override
public String getFieldName() {
return null;
}

@Override
public void setFieldName(String name) {

}

@Override
public boolean isFormField() {
return false;
}

@Override
public void setFormField(boolean state) {

}

@Override
public OutputStream getOutputStream() throws IOException {
return null;
}

@Override
public FileItemHeaders getHeaders() {
return null;
}

@Override
public void setHeaders(FileItemHeaders headers) {

}
}

}

0 comments on commit 5bb0fe9

Please sign in to comment.
You can’t perform that action at this time.