1616package org .commonjava .indy .content .browse .ftest ;
1717
1818import org .apache .commons .io .IOUtils ;
19+ import org .commonjava .indy .client .core .IndyClientModule ;
20+ import org .commonjava .indy .content .browse .client .IndyContentBrowseClientModule ;
21+ import org .commonjava .indy .content .browse .model .ContentBrowseResult ;
1922import org .commonjava .indy .ftest .core .AbstractContentManagementTest ;
2023import org .commonjava .indy .model .core .HostedRepository ;
2124import org .commonjava .indy .model .core .StoreKey ;
25+ import org .commonjava .indy .model .core .io .IndyObjectMapper ;
2226import org .commonjava .indy .pkg .maven .model .MavenPackageTypeDescriptor ;
2327import org .commonjava .indy .pkg .npm .model .NPMPackageTypeDescriptor ;
2428import org .junit .Test ;
2529
2630import java .io .ByteArrayInputStream ;
2731import java .io .InputStream ;
2832import java .net .URL ;
33+ import java .util .Collection ;
34+ import java .util .Collections ;
2935
3036import static org .commonjava .indy .model .core .StoreType .hosted ;
3137import static org .hamcrest .CoreMatchers .equalTo ;
@@ -78,12 +84,20 @@ public void run()
7884
7985 final String dirPath = "/@babel/opossum" ;
8086 final String path = dirPath + "/package.json" ;
87+ final String tarPath = dirPath + "/-/opossum-5.0.0.tgz" ;
8188
8289 final StoreKey testKey = hostedRepository .getKey ();
8390
91+ assertThat ( client .content ().exists ( testKey , tarPath ), equalTo ( false ) );
92+
93+ client .content ().store ( testKey , tarPath , stream );
94+
95+ assertThat ( client .content ().exists ( testKey , tarPath ), equalTo ( true ) );
96+
97+ final InputStream stream2 = new ByteArrayInputStream ( content .getBytes () );
8498 assertThat ( client .content ().exists ( testKey , path ), equalTo ( false ) );
8599
86- client .content ().store ( testKey , path , stream );
100+ client .content ().store ( testKey , path , stream2 );
87101
88102 assertThat ( client .content ().exists ( testKey , path ), equalTo ( true ) );
89103
@@ -103,8 +117,29 @@ public void run()
103117 assertThat ( json .contains ( "/@babel/" ), equalTo ( true ) );
104118 }
105119
120+ IndyContentBrowseClientModule browseClientModule = client .module ( IndyContentBrowseClientModule .class );
121+
122+ ContentBrowseResult browseResult = browseClientModule .getContentList (testKey , "/@babel/opossum" );
123+ String browseResultInJson = new IndyObjectMapper (false ).writeValueAsString (browseResult );
124+
125+ assertThat ( browseResultInJson .contains ("/@babel/opossum/-/" ), equalTo (true ) );
126+ assertThat ( "no metadata result" , browseResult , notNullValue () );
127+
128+ try (InputStream jsonIn = client .content ().get ( testKey , "/@babel/opossum" ))
129+ {
130+ assertThat ( jsonIn , notNullValue () );
131+ String json = IOUtils .toString ( jsonIn );
132+ assertEquals (content , json );
133+ }
134+
106135 assertThat ( client .content ()
107136 .exists ( testKey , path ), equalTo ( true ) );
108137
109138 }
139+
140+ @ Override
141+ protected Collection <IndyClientModule > getAdditionalClientModules ()
142+ {
143+ return Collections .singletonList ( new IndyContentBrowseClientModule () );
144+ }
110145}
0 commit comments