This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rhbz1124630 - fix according review comments
- Loading branch information
Patrick Huang
committed
Dec 1, 2014
1 parent
3545941
commit 8eb6170
Showing
20 changed files
with
140 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,4 +225,5 @@ | |
<module>zanata-maven-plugin</module> | ||
<module>zanata-rest-client</module> | ||
</modules> | ||
</project> | ||
</project> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,4 +55,5 @@ public void testPut() throws Exception { | |
|
||
MockServerTestUtil.verifyServerRespondSuccessStatus(); | ||
} | ||
} | ||
} | ||
|
69 changes: 0 additions & 69 deletions
69
zanata-rest-client/src/test/java/org/zanata/rest/client/ApiKeyHeaderDecoratorTest.java
This file was deleted.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
zanata-rest-client/src/test/java/org/zanata/rest/client/ApiKeyHeaderFilterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright 2011, Red Hat, Inc. and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.zanata.rest.client; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.mockito.Mockito.when; | ||
|
||
import javax.ws.rs.core.MultivaluedHashMap; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.zanata.rest.RestConstant; | ||
import com.sun.jersey.api.client.ClientRequest; | ||
import com.sun.jersey.api.client.ClientResponse; | ||
|
||
/** | ||
* @author Sean Flanigan <a | ||
* href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a> | ||
* | ||
*/ | ||
public class ApiKeyHeaderFilterTest { | ||
@Mock | ||
private ClientRequest mockRequest; | ||
@Mock | ||
private ClientResponse response; | ||
|
||
@Before | ||
public void setUp() { | ||
MockitoAnnotations.initMocks(this); | ||
} | ||
|
||
@Test | ||
public void testHeaders() throws Exception { | ||
String username = "username"; | ||
String apiKey = "apiKey"; | ||
String ver = "ver"; | ||
ApiKeyHeaderFilter filter = | ||
new ApiKeyHeaderFilter(username, apiKey, ver) { | ||
@Override | ||
protected ClientResponse handleNext( | ||
ClientRequest cr) { | ||
return response; | ||
} | ||
}; | ||
|
||
MultivaluedHashMap<String, Object> headerMap = | ||
new MultivaluedHashMap<>(); | ||
when(mockRequest.getHeaders()).thenReturn(headerMap); | ||
// | ||
|
||
filter.handle(mockRequest); | ||
|
||
assertThat(headerMap.getFirst(RestConstant.HEADER_USERNAME).toString(), | ||
Matchers.equalTo(username)); | ||
assertThat(headerMap.getFirst(RestConstant.HEADER_API_KEY).toString(), | ||
Matchers.equalTo(apiKey)); | ||
assertThat(headerMap.getFirst(RestConstant.HEADER_VERSION_NO) | ||
.toString(), Matchers.equalTo(ver)); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,4 +167,5 @@ public void testDownloadTranslationFile() { | |
Matchers.hasSize(1)); | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,5 @@ public void testPut() throws Exception { | |
MockServerTestUtil.verifyServerRespondSuccessStatus(); | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,5 @@ public void testSampleConfig() { | |
|
||
assertThat(config, Matchers.containsString("<project>")); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,4 +49,5 @@ public void canGetProjects() { | |
assertThat(projects[0].getId(), Matchers.equalTo("about-fedora")); | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,5 @@ public void testGetVersion() { | |
Matchers.equalTo("3.6.0-SNAPSHOT")); | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,4 +75,5 @@ public void testGetContributorStatistics() { | |
assertThat(statistics, Matchers.hasKey("pahuang")); | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,5 @@ public void testGetTranslations() { | |
assertThat(translations.getTextFlowTargets(), Matchers.hasSize(1)); | ||
} | ||
|
||
} | ||
} | ||
|
We shouldn't need the
skip
any more.