forked from reficio/p2-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reficio#241: errors in embedded bnd result in an exception
- Loading branch information
Showing
6 changed files
with
167 additions
and
7 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
25 changes: 25 additions & 0 deletions
25
src/main/java/org/reficio/p2/bundler/AquteAnalyzerException.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,25 @@ | ||
/** | ||
* Copyright (c) 2012 Reficio (TM) - Reestablish your software! All Rights Reserved. | ||
* | ||
* 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.reficio.p2.bundler; | ||
|
||
public class AquteAnalyzerException extends RuntimeException { | ||
public AquteAnalyzerException(String message) { | ||
super(message); | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
src/test/java/org/reficio/p2/bundler/impl/AnalyzerStub.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,36 @@ | ||
/** | ||
* Copyright (c) 2012 Reficio (TM) - Reestablish your software! All Rights Reserved. | ||
* | ||
* 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.reficio.p2.bundler.impl; | ||
|
||
import aQute.bnd.osgi.Analyzer; | ||
import aQute.bnd.osgi.Jar; | ||
|
||
import java.util.jar.Manifest; | ||
|
||
class AnalyzerStub extends Analyzer { | ||
@Override | ||
public Manifest calcManifest() throws Exception { | ||
return new Manifest(); | ||
} | ||
|
||
@Override | ||
public Jar getJar() { | ||
return new Jar("fake"); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/test/java/org/reficio/p2/bundler/impl/AquteBundlerTest.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,59 @@ | ||
/** | ||
* Copyright (c) 2012 Reficio (TM) - Reestablish your software! All Rights Reserved. | ||
* | ||
* 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.reficio.p2.bundler.impl; | ||
|
||
|
||
import org.apache.maven.plugin.logging.SystemStreamLog; | ||
import org.assertj.core.api.ThrowableAssert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.mockito.MockedStatic; | ||
import org.reficio.p2.bundler.AquteAnalyzerException; | ||
import org.reficio.p2.bundler.ArtifactBundlerInstructions; | ||
import org.reficio.p2.bundler.ArtifactBundlerRequest; | ||
import org.reficio.p2.logger.Logger; | ||
|
||
import java.io.File; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyBoolean; | ||
import static org.mockito.Mockito.mockStatic; | ||
|
||
public class AquteBundlerTest { | ||
|
||
|
||
@BeforeClass | ||
public static void setUpClass() { | ||
Logger.initialize(new SystemStreamLog()); | ||
} | ||
|
||
@Test | ||
public void bndAnalyzerProduceErrorThenExceptionIsExpected() { | ||
try (MockedStatic<AquteHelper> theMock = mockStatic(AquteHelper.class)) { | ||
theMock.when(() -> AquteHelper.buildAnalyzer(any(ArtifactBundlerRequest.class), any(ArtifactBundlerInstructions.class), anyBoolean())) | ||
.thenReturn(new AnalyzerStub()); | ||
|
||
AquteBundler bundlerUnderTest = new AquteBundler(true, new BundleUtilsStub()); | ||
ThrowableAssert.ThrowingCallable methodUnderTest = () -> bundlerUnderTest.execute(new ArtifactBundlerRequest(new File(""), new File("target/tmp.jar"), null, null, true), ArtifactBundlerInstructions.builder().build()); | ||
|
||
assertThatThrownBy(methodUnderTest).isInstanceOf(RuntimeException.class).hasRootCauseInstanceOf(AquteAnalyzerException.class); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/test/java/org/reficio/p2/bundler/impl/BundleUtilsStub.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,30 @@ | ||
/** | ||
* Copyright (c) 2012 Reficio (TM) - Reestablish your software! All Rights Reserved. | ||
* | ||
* 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.reficio.p2.bundler.impl; | ||
|
||
import aQute.bnd.osgi.Analyzer; | ||
import org.reficio.p2.utils.BundleUtils; | ||
|
||
class BundleUtilsStub extends BundleUtils { | ||
|
||
@Override | ||
public boolean reportErrors(Analyzer analyzer) { | ||
return true; | ||
} | ||
} |